diff --git a/frontend/src/components/ShowDialog.vue b/frontend/src/components/ShowDialog.vue index 50641db..5f6098e 100644 --- a/frontend/src/components/ShowDialog.vue +++ b/frontend/src/components/ShowDialog.vue @@ -13,7 +13,7 @@ - + diff --git a/frontend/src/components/main/domainTable.vue b/frontend/src/components/main/domainTable.vue new file mode 100644 index 0000000..23bf91d --- /dev/null +++ b/frontend/src/components/main/domainTable.vue @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + {{ p.row.name }} + 未启用 + 現在 + + + + + + + + + + + + + + + diff --git a/frontend/src/pages/UserDomain.vue b/frontend/src/pages/UserDomain.vue index 08942f3..e4ba99c 100644 --- a/frontend/src/pages/UserDomain.vue +++ b/frontend/src/pages/UserDomain.vue @@ -6,23 +6,14 @@ - + - - - - @@ -38,69 +29,47 @@ - + - - Domain - {{ props.row.name }} + + + {{ props.row.name }} + {{ props.row.url }} + + + + - - URL - {{ props.row.url }} - - - Account - {{ props.row.kintoneuser }} + + + + + アカウント + {{ props.row.kintoneuser }} + + + 所有者 + {{ props.row.owner }} + - - - {{ - isActive(props.row.id)?'既定':'' }} - - 既定にする - 削除 - - - + + 既定 + + 既定にする + 削除 - + - - - - - - - - - - - - 他のユーザーを選択する - - - - - - - - - - - - @@ -123,32 +92,27 @@ 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(); -const loading = ref(true); +const initLoading = ref(true); +const addUserDomainLoading = ref(false); +const activeDomainLoadingId = ref(undefined); +const deleteDomainLoadingId = ref(undefined); const columns = [ { name: 'id' }, { name: 'name', required: true, label: 'Name', align: 'left', field: 'name', sortable: true }, { name: 'url', align: 'center', label: 'Domain', field: 'url', sortable: true }, { name: 'kintoneuser', label: 'User', field: 'kintoneuser', sortable: true }, - { name: 'kintonepwd' }, ]; const userDomainTableFilter = ref(); -const currentUserName = ref(''); -const useOtherUser = ref(false); -const otherUserId = ref(''); - let editId = ref(0); const showAddDomainDg = ref(false); @@ -163,21 +127,23 @@ const clickAddDomain = () => { showAddDomainDg.value = true; }; -const addUserDomainFinished = (val: string) => { +const addUserDomainFinished = async (val: string) => { + showAddDomainDg.value = true; + addUserDomainLoading.value = true; 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(async ({ data }) => { - if (rows.value.length === 0 && data.data) { - const domain = data.data; - await authStore.setCurrentDomain({ - id: domain.id, - kintoneUrl: domain.url, - domainName: domain.name - }); - } - getDomain(useOtherUser.value ? otherUserId.value : undefined); + const { data } = await api.post(`api/domain/${authStore.userId}?domainid=${selected[0].id}`) + if (rows.value.length === 0 && data.data) { + const domain = data.data; + await authStore.setCurrentDomain({ + id: domain.id, + kintoneUrl: domain.url, + domainName: domain.name }); + } + await getDomain(); + addUserDomainLoading.value = false; + showAddDomainDg.value = false; } }; @@ -189,26 +155,25 @@ const clickDeleteConfirm = (row: any) => { }; const deleteDomainFinished = async () => { - await api.delete(`api/domain/${editId.value}/${useOtherUser.value ? otherUserId.value : authStore.userId}`).then(({ data }) => { - if (data.msg == 'OK' && authStore.currentDomain.id === editId.value) { - authStore.setCurrentDomain(); - } - getDomain(useOtherUser.value ? otherUserId.value : undefined); - }) + deleteDomainLoadingId.value = editId.value; + const { data } = await api.delete(`api/domain/${editId.value}/${authStore.userId}`) + if (data.msg == 'OK' && authStore.currentDomain.id === editId.value) { + authStore.setCurrentDomain(); + } editId.value = 0; + await getDomain(); + deleteDomainLoadingId.value = undefined; }; const activeDomain = async (domain: any) => { - if (useOtherUser.value) { - // TODO - return; - } + activeDomainLoadingId.value = domain.id; await authStore.setCurrentDomain({ id: domain.id, kintoneUrl: domain.url, domainName: domain.name }); - getDomain(); + await getDomain(); + activeDomainLoadingId.value = undefined; }; let activeDomainId = ref(0); @@ -217,52 +182,43 @@ const isActive = computed(() => (id: number) => { return id == activeDomainId.value; }); - -const showSwitchUserDd = ref(false); -const switchUserRef = ref(); -const switchUserFilter = ref('') - -const clickSwitchUser = () => { - showSwitchUserDd.value = true; - useOtherUser.value = false; -}; - -const switchUserFinished = async (val: string) => { - if (val == 'OK') { - if (useOtherUser.value) { - const user = switchUserRef.value.selected[0] - currentUserName.value = user.email; - otherUserId.value = user.id - await getDomain(user.id) - } else { - currentUserName.value = authStore.userInfo.email - await getDomain(); - } - - } -}; +const isNotOwner = computed(() => (ownerId: string) => { + return ownerId == authStore.userId; +}); const getDomain = async (userId? : string) => { - loading.value = true; rowIds.clear(); - if (useOtherUser.value) { - // TODO - return; - } const resp = await api.get(`api/defaultdomain`); 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[]; rows.value = domains.map((item) => { rowIds.add(item.id); - return { id: item.id, name: item.name, url: item.url, kintoneuser: item.kintoneuser, kintonepwd: item.kintonepwd } + return { + id: item.id, + name: item.name, + url: item.url, + kintoneuser: item.kintoneuser, + ownerEmail: item.owner.email, + owner: item.owner.first_name + ' ' + item.owner.last_name, + } }); - loading.value = false; } onMounted(async () => { - currentUserName.value = authStore.userInfo.email + initLoading.value = true; await getDomain(); + initLoading.value = false; }) + \ No newline at end of file