diff --git a/frontend/quasar.config.js b/frontend/quasar.config.js index 449fef0..40530ff 100644 --- a/frontend/quasar.config.js +++ b/frontend/quasar.config.js @@ -115,7 +115,8 @@ module.exports = configure(function (/* ctx */) { // Quasar plugins plugins: [ - 'Notify' + 'Notify', + 'Dialog' ] }, diff --git a/frontend/src/components/DomainSelect.vue b/frontend/src/components/DomainSelect.vue index c6fa61c..65759f1 100644 --- a/frontend/src/components/DomainSelect.vue +++ b/frontend/src/components/DomainSelect.vue @@ -16,19 +16,19 @@ export default { type: Function, }, }, - setup() { - const columns = [ - { name: 'id'}, - { name: 'tenantid', required: true,label: 'テナント',align: 'left',field: 'tenantid',sortable: true}, - { name: 'name', align: 'center', label: 'ドメイン', field: 'name', sortable: true }, - { name: 'url', label: 'URL', field: 'url', sortable: true }, - { name: 'kintoneuser', label: 'アカウント', field: 'kintoneuser' } - ] - const rows = reactive([]) - onMounted( () => { + setup(props) { + const columns = [ + { name: 'id'}, + { name: 'tenantid', required: true,label: 'テナント',align: 'left',field: 'tenantid',sortable: true}, + { name: 'name', align: 'center', label: 'ドメイン', field: 'name', sortable: true }, + { name: 'url', label: 'URL', field: 'url', sortable: true }, + { name: 'kintoneuser', label: 'アカウント', field: 'kintoneuser' } + ] + const rows = reactive([]); + + onMounted(() => { api.get(`api/domains`).then(res =>{ - res.data.data.forEach((item) => - { + res.data.data.forEach((item) => { if (props.filterInitRowsFunc && !props.filterInitRowsFunc(item)) { return; } @@ -36,7 +36,7 @@ export default { } ) }); - }); + }); return { columns, rows, diff --git a/frontend/src/components/EssentialLink.vue b/frontend/src/components/EssentialLink.vue index c736344..3a677c5 100644 --- a/frontend/src/components/EssentialLink.vue +++ b/frontend/src/components/EssentialLink.vue @@ -4,6 +4,7 @@ tag="a" :target="target?target:'_blank'" :href="link" + :disable="disable" v-if="!isSeparator" > (), { caption: '', diff --git a/frontend/src/layouts/MainLayout.vue b/frontend/src/layouts/MainLayout.vue index e699cf4..32e3f9c 100644 --- a/frontend/src/layouts/MainLayout.vue +++ b/frontend/src/layouts/MainLayout.vue @@ -47,7 +47,8 @@ const essentialLinks: EssentialLinkProps[] = [ caption: '設計書から導入する', icon: 'home', link: '/', - target: '_self' + target: '_self', + disable: !authStore.hasDomain }, // { // title: 'フローエディター', @@ -61,7 +62,8 @@ const essentialLinks: EssentialLinkProps[] = [ caption: 'アプリを管理する', icon: 'widgets', link: '/#/app', - target: '_self' + target: '_self', + disable: !authStore.hasDomain }, // { // title: '条件エディター', diff --git a/frontend/src/pages/UserDomain.vue b/frontend/src/pages/UserDomain.vue index faaefdb..653b25f 100644 --- a/frontend/src/pages/UserDomain.vue +++ b/frontend/src/pages/UserDomain.vue @@ -123,12 +123,14 @@ import { ref, onMounted, computed } from 'vue' import { api } from 'boot/axios'; import { useAuthStore } from 'stores/useAuthStore'; +import { useDomainStore } from 'stores/useDomainStore'; import ShowDialog from 'components/ShowDialog.vue'; import DomainSelect from 'components/DomainSelect.vue'; import UserList from 'components/UserList.vue'; const authStore = useAuthStore(); +const domainStore = useDomainStore(); const pagination = ref({ sortBy: 'id', rowsPerPage: 0 }); const rows = ref([] as any[]); const rowIds = new Set(); @@ -166,7 +168,18 @@ const addUserDomainFinished = (val: string) => { const selected = addDomainRef.value.selected; if (val == 'OK' && selected.length > 0) { 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) => { loading.value = true; 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; const domainResult = userId ? await api.get(`api/domain?userId=${userId}`) : await api.get(`api/domain`); const domains = domainResult.data as any[]; diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index db72a87..44ed7db 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -5,6 +5,7 @@ import { createWebHashHistory, createWebHistory, } from 'vue-router'; +import { Dialog } from 'quasar' import routes from './routes'; import { useAuthStore } from 'stores/useAuthStore'; @@ -47,6 +48,20 @@ export default route(function (/* { store, ssrContext } */) { authStore.returnUrl = to.fullPath; 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: '既定/利用可能なドメインはありません。
ドメイン管理ページに遷移して処理します。', + html: true, + persistent: true, + }).onDismiss(() => { + console.log('Dialog dismissed. You can do some clean up here') + }) + return '/domain'; + } }); return routerInstance; }); diff --git a/frontend/src/stores/useAuthStore.ts b/frontend/src/stores/useAuthStore.ts index d27817f..6770efa 100644 --- a/frontend/src/stores/useAuthStore.ts +++ b/frontend/src/stores/useAuthStore.ts @@ -35,6 +35,9 @@ export const useAuthStore = defineStore('auth', { toggleLeftDrawer(): boolean { return this.LeftDrawer; }, + hasDomain(): boolean { + return !!this.currentDomain.id; + } }, actions: { setLeftMenu(value:boolean){ @@ -84,6 +87,7 @@ export const useAuthStore = defineStore('auth', { logout() { this.token = ''; this.currentDomain = {} as IDomainInfo; // 清空当前域 + this.returnUrl = ''; router.push('/login'); }, async setCurrentDomain(domain: IDomainInfo) {