[UI] dialog and redirect for no active domain
This commit is contained in:
@@ -115,7 +115,8 @@ module.exports = configure(function (/* ctx */) {
|
|||||||
|
|
||||||
// Quasar plugins
|
// Quasar plugins
|
||||||
plugins: [
|
plugins: [
|
||||||
'Notify'
|
'Notify',
|
||||||
|
'Dialog'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -16,19 +16,19 @@ export default {
|
|||||||
type: Function,
|
type: Function,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup() {
|
setup(props) {
|
||||||
const columns = [
|
const columns = [
|
||||||
{ name: 'id'},
|
{ name: 'id'},
|
||||||
{ name: 'tenantid', required: true,label: 'テナント',align: 'left',field: 'tenantid',sortable: true},
|
{ name: 'tenantid', required: true,label: 'テナント',align: 'left',field: 'tenantid',sortable: true},
|
||||||
{ name: 'name', align: 'center', label: 'ドメイン', field: 'name', sortable: true },
|
{ name: 'name', align: 'center', label: 'ドメイン', field: 'name', sortable: true },
|
||||||
{ name: 'url', label: 'URL', field: 'url', sortable: true },
|
{ name: 'url', label: 'URL', field: 'url', sortable: true },
|
||||||
{ name: 'kintoneuser', label: 'アカウント', field: 'kintoneuser' }
|
{ name: 'kintoneuser', label: 'アカウント', field: 'kintoneuser' }
|
||||||
]
|
]
|
||||||
const rows = reactive([])
|
const rows = reactive([]);
|
||||||
onMounted( () => {
|
|
||||||
|
onMounted(() => {
|
||||||
api.get(`api/domains`).then(res =>{
|
api.get(`api/domains`).then(res =>{
|
||||||
res.data.data.forEach((item) =>
|
res.data.data.forEach((item) => {
|
||||||
{
|
|
||||||
if (props.filterInitRowsFunc && !props.filterInitRowsFunc(item)) {
|
if (props.filterInitRowsFunc && !props.filterInitRowsFunc(item)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ export default {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
columns,
|
columns,
|
||||||
rows,
|
rows,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
tag="a"
|
tag="a"
|
||||||
:target="target?target:'_blank'"
|
:target="target?target:'_blank'"
|
||||||
:href="link"
|
:href="link"
|
||||||
|
:disable="disable"
|
||||||
v-if="!isSeparator"
|
v-if="!isSeparator"
|
||||||
>
|
>
|
||||||
<q-item-section
|
<q-item-section
|
||||||
@@ -33,6 +34,7 @@ export interface EssentialLinkProps {
|
|||||||
icon?: string;
|
icon?: string;
|
||||||
isSeparator?: boolean;
|
isSeparator?: boolean;
|
||||||
target?:string;
|
target?:string;
|
||||||
|
disable?:boolean;
|
||||||
}
|
}
|
||||||
withDefaults(defineProps<EssentialLinkProps>(), {
|
withDefaults(defineProps<EssentialLinkProps>(), {
|
||||||
caption: '',
|
caption: '',
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ const essentialLinks: EssentialLinkProps[] = [
|
|||||||
caption: '設計書から導入する',
|
caption: '設計書から導入する',
|
||||||
icon: 'home',
|
icon: 'home',
|
||||||
link: '/',
|
link: '/',
|
||||||
target: '_self'
|
target: '_self',
|
||||||
|
disable: !authStore.hasDomain
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// title: 'フローエディター',
|
// title: 'フローエディター',
|
||||||
@@ -61,7 +62,8 @@ const essentialLinks: EssentialLinkProps[] = [
|
|||||||
caption: 'アプリを管理する',
|
caption: 'アプリを管理する',
|
||||||
icon: 'widgets',
|
icon: 'widgets',
|
||||||
link: '/#/app',
|
link: '/#/app',
|
||||||
target: '_self'
|
target: '_self',
|
||||||
|
disable: !authStore.hasDomain
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// title: '条件エディター',
|
// title: '条件エディター',
|
||||||
|
|||||||
@@ -123,12 +123,14 @@
|
|||||||
import { ref, onMounted, computed } from 'vue'
|
import { ref, onMounted, computed } from 'vue'
|
||||||
import { api } from 'boot/axios';
|
import { api } from 'boot/axios';
|
||||||
import { useAuthStore } from 'stores/useAuthStore';
|
import { useAuthStore } from 'stores/useAuthStore';
|
||||||
|
import { useDomainStore } from 'stores/useDomainStore';
|
||||||
|
|
||||||
import ShowDialog from 'components/ShowDialog.vue';
|
import ShowDialog from 'components/ShowDialog.vue';
|
||||||
import DomainSelect from 'components/DomainSelect.vue';
|
import DomainSelect from 'components/DomainSelect.vue';
|
||||||
import UserList from 'components/UserList.vue';
|
import UserList from 'components/UserList.vue';
|
||||||
|
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
|
const domainStore = useDomainStore();
|
||||||
const pagination = ref({ sortBy: 'id', rowsPerPage: 0 });
|
const pagination = ref({ sortBy: 'id', rowsPerPage: 0 });
|
||||||
const rows = ref([] as any[]);
|
const rows = ref([] as any[]);
|
||||||
const rowIds = new Set<string>();
|
const rowIds = new Set<string>();
|
||||||
@@ -166,7 +168,18 @@ const addUserDomainFinished = (val: string) => {
|
|||||||
const selected = addDomainRef.value.selected;
|
const selected = addDomainRef.value.selected;
|
||||||
if (val == 'OK' && selected.length > 0) {
|
if (val == 'OK' && selected.length > 0) {
|
||||||
api.post(`api/domain/${useOtherUser.value ? otherUserId.value : authStore.userId}?domainid=${selected[0].id}`)
|
api.post(`api/domain/${useOtherUser.value ? otherUserId.value : authStore.userId}?domainid=${selected[0].id}`)
|
||||||
.then(() => { getDomain(useOtherUser.value ? otherUserId.value : undefined); });
|
.then(({ data }) => {
|
||||||
|
if (rows.value.length === 0 && data.data) {
|
||||||
|
const domain = data.data;
|
||||||
|
authStore.setCurrentDomain({
|
||||||
|
id: domain.id,
|
||||||
|
kintoneUrl: domain.url,
|
||||||
|
domainName: domain.name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
domainStore.loadUserDomains();
|
||||||
|
getDomain(useOtherUser.value ? otherUserId.value : undefined);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -223,7 +236,11 @@ const switchUserFinished = async (val: string) => {
|
|||||||
const getDomain = async (userId? : string) => {
|
const getDomain = async (userId? : string) => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
rowIds.clear();
|
rowIds.clear();
|
||||||
const resp = await api.get(`api/activedomain${useOtherUser.value ? `?userId=${otherUserId.value}` : ''}`);
|
if (useOtherUser.value) {
|
||||||
|
// TODO
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const resp = await api.get(`api/activedomain`);
|
||||||
activeDomainId.value = resp?.data?.data?.id;
|
activeDomainId.value = resp?.data?.data?.id;
|
||||||
const domainResult = userId ? await api.get(`api/domain?userId=${userId}`) : await api.get(`api/domain`);
|
const domainResult = userId ? await api.get(`api/domain?userId=${userId}`) : await api.get(`api/domain`);
|
||||||
const domains = domainResult.data as any[];
|
const domains = domainResult.data as any[];
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
createWebHashHistory,
|
createWebHashHistory,
|
||||||
createWebHistory,
|
createWebHistory,
|
||||||
} from 'vue-router';
|
} from 'vue-router';
|
||||||
|
import { Dialog } from 'quasar'
|
||||||
|
|
||||||
import routes from './routes';
|
import routes from './routes';
|
||||||
import { useAuthStore } from 'stores/useAuthStore';
|
import { useAuthStore } from 'stores/useAuthStore';
|
||||||
@@ -47,6 +48,20 @@ export default route(function (/* { store, ssrContext } */) {
|
|||||||
authStore.returnUrl = to.fullPath;
|
authStore.returnUrl = to.fullPath;
|
||||||
return '/login';
|
return '/login';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// redirect to domain setting page if no domain exist
|
||||||
|
const domainPages = [...publicPages, '/domain', '/userDomain', '/user'];
|
||||||
|
if (!authStore.hasDomain && !domainPages.includes(to.path)) {
|
||||||
|
Dialog.create({
|
||||||
|
title: '注意',
|
||||||
|
message: '既定/利用可能なドメインはありません。<br>ドメイン管理ページに遷移して処理します。',
|
||||||
|
html: true,
|
||||||
|
persistent: true,
|
||||||
|
}).onDismiss(() => {
|
||||||
|
console.log('Dialog dismissed. You can do some clean up here')
|
||||||
|
})
|
||||||
|
return '/domain';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return routerInstance;
|
return routerInstance;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ export const useAuthStore = defineStore('auth', {
|
|||||||
toggleLeftDrawer(): boolean {
|
toggleLeftDrawer(): boolean {
|
||||||
return this.LeftDrawer;
|
return this.LeftDrawer;
|
||||||
},
|
},
|
||||||
|
hasDomain(): boolean {
|
||||||
|
return !!this.currentDomain.id;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setLeftMenu(value:boolean){
|
setLeftMenu(value:boolean){
|
||||||
@@ -84,6 +87,7 @@ export const useAuthStore = defineStore('auth', {
|
|||||||
logout() {
|
logout() {
|
||||||
this.token = '';
|
this.token = '';
|
||||||
this.currentDomain = {} as IDomainInfo; // 清空当前域
|
this.currentDomain = {} as IDomainInfo; // 清空当前域
|
||||||
|
this.returnUrl = '';
|
||||||
router.push('/login');
|
router.push('/login');
|
||||||
},
|
},
|
||||||
async setCurrentDomain(domain: IDomainInfo) {
|
async setCurrentDomain(domain: IDomainInfo) {
|
||||||
|
|||||||
Reference in New Issue
Block a user