diff --git a/frontend/src/components/TableActionMenu.vue b/frontend/src/components/TableActionMenu.vue index 432eaa6..9e40f53 100644 --- a/frontend/src/components/TableActionMenu.vue +++ b/frontend/src/components/TableActionMenu.vue @@ -1,7 +1,7 @@ diff --git a/frontend/src/components/right/PropertyPanel.vue b/frontend/src/components/right/PropertyPanel.vue index 5384028..4aa3d87 100644 --- a/frontend/src/components/right/PropertyPanel.vue +++ b/frontend/src/components/right/PropertyPanel.vue @@ -40,8 +40,7 @@ import { IActionNode, IActionProperty } from 'src/types/ActionTypes'; }, props: { actionNode:{ - type:Object as PropType, - required:true + type:Object as PropType }, drawerRight:{ type:Boolean, @@ -55,7 +54,7 @@ import { IActionNode, IActionProperty } from 'src/types/ActionTypes'; setup(props,{emit}) { const showPanel =ref(props.drawerRight); - const cloneProps = (actionProps:IActionProperty[]):IActionProperty[]|null=>{ + const cloneProps = (actionProps:IActionProperty[]|undefined):IActionProperty[]|null=>{ if(!actionProps){ return null; } diff --git a/frontend/src/pages/AppManagement.vue b/frontend/src/pages/AppManagement.vue index 0576a4d..cde89a5 100644 --- a/frontend/src/pages/AppManagement.vue +++ b/frontend/src/pages/AppManagement.vue @@ -5,7 +5,7 @@ - + + + \ No newline at end of file diff --git a/frontend/src/router/routes.ts b/frontend/src/router/routes.ts index 1b999ad..3740740 100644 --- a/frontend/src/router/routes.ts +++ b/frontend/src/router/routes.ts @@ -28,6 +28,7 @@ const routes: RouteRecordRaw[] = [ { path: 'userdomain', component: () => import('pages/UserDomain.vue')}, { path: 'user', component: () => import('pages/UserManagement.vue')}, { path: 'app', component: () => import('pages/AppManagement.vue')}, + { path: 'app/version/:id', component: () => import('pages/AppVersionManagement.vue')}, { path: 'condition', component: () => import('pages/conditionPage.vue') } ], }, diff --git a/frontend/src/stores/useAppStore.ts b/frontend/src/stores/useAppStore.ts new file mode 100644 index 0000000..6546521 --- /dev/null +++ b/frontend/src/stores/useAppStore.ts @@ -0,0 +1,106 @@ +import { defineStore } from 'pinia'; +import { api } from 'boot/axios'; +import { IAppDisplay, IAppVersion, IAppVersionDisplay, IManagedApp } from 'src/types/AppTypes'; +import { IUser } from 'src/types/UserTypes'; +import { date, Notify } from 'quasar' + + +export const useAppStore = defineStore('app', { + state: () => ({ + apps: [] as IAppDisplay[], + rowIds: new Set(), + }), + actions: { + async loadApps() { + this.reset(); + try { + const { data } = await api.get('api/apps'); + this.apps = data.data.map((item: IManagedApp) => { + this.rowIds.add(item.appid); + return appToAppDisplay(item) + }).sort((a: IAppDisplay, b: IAppDisplay) => a.sortId - b.sortId); // set default order + } catch (error) { + Notify.create({ + icon: 'error', + color: 'negative', + message: 'アプリ一覧の読み込みに失敗しました' + }) + } + }, + + getAppById(id: string) { + if (!this.rowIds.has(id)) { + return null; + } + return this.apps.find((item: IAppDisplay) => item.id === id); + }, + + async getVersionsByAppId(app: IAppDisplay) { + const { data } = await api.get(`api/appversions/${app.id}`); + return data.data.map((item: IAppVersion) => versionToVersionDisplay(item)); + }, + + async changeVersion(app: IAppDisplay, version: IAppVersionDisplay) { + await api.put(`api/appversions/${app.id}/${version.id}`); + }, + + async deleteApp(app: IAppDisplay) { + try { + await api.delete(`api/apps/${app.id}`); + } catch (error) { + console.error(error); + Notify.create({ + icon: 'error', + color: 'negative', + message: 'アプリの削除に失敗しました' + }); + return false; + } + return true; + }, + + reset() { + this.apps = []; + this.rowIds.clear(); + }, + }, +}); + +function versionToVersionDisplay(item: IAppVersion) { + return { + id: item.version, + version: item.version, + appid: item.appid, + name: item.versionname, + comment: item.comment, + // updater: toUserDisplay(item.updateuser), + // updateTime: formatDate(item.updatetime), + // creator: toUserDisplay(item.createuser), + // createTime: formatDate(item.createtime), + } as IAppVersionDisplay; +} + +function appToAppDisplay(app: IManagedApp) { + return { + id: app.appid, + sortId: parseInt(app.appid, 10), + name: app.appname, + url: `${app.domainurl}/k/${app.appid}`, + version: app.version, + updateTime: date.formatDate(app.update_time, 'YYYY/MM/DD HH:mm'), + updateUser: userToUserDisplay(app.updateuser) + } as IAppDisplay +} + +function userToUserDisplay(user: IUser) { + return { + id: user.id, + firstName: user.first_name, + lastName: user.last_name, + fullNameSearch: (user.last_name + user.first_name).toLowerCase(), + fullName: user.last_name + ' ' + user.first_name, + email: user.email, + isActive: user.is_active, + isSuperuser: user.is_superuser, + } +} \ No newline at end of file diff --git a/frontend/src/stores/useAuthStore.ts b/frontend/src/stores/useAuthStore.ts index 8ce4136..6187b7d 100644 --- a/frontend/src/stores/useAuthStore.ts +++ b/frontend/src/stores/useAuthStore.ts @@ -3,6 +3,8 @@ import { api } from 'boot/axios'; import { router } from 'src/router'; import { IDomainInfo } from '../types/DomainTypes'; import { jwtDecode } from 'jwt-decode'; +import { useAppStore } from './useAppStore'; + interface UserInfo { firstName: string; lastName: string; @@ -87,6 +89,7 @@ export const useAuthStore = defineStore('auth', { logout() { this.token = ''; this.currentDomain = {} as IDomainInfo; // 清空当前域 + useAppStore().reset(); router.push('/login'); }, async setCurrentDomain(domain?: IDomainInfo) { diff --git a/frontend/src/types/AppTypes.ts b/frontend/src/types/AppTypes.ts index 150d06e..0023a31 100644 --- a/frontend/src/types/AppTypes.ts +++ b/frontend/src/types/AppTypes.ts @@ -4,18 +4,7 @@ export interface IManagedApp { appid: string; appname: string; domainurl: string; - version: string; - user: IUser; - updateuser: IUser; - create_time: string; - update_time: string; -} - -export interface IManagedApp { - appid: string; - appname: string; - domainurl: string; - version: string; + version: number; user: IUser; updateuser: IUser; create_time: string; @@ -29,7 +18,7 @@ export interface IAppDisplay{ url:string; updateUser: IUserDisplay; updateTime:string; - version:string; + version:number; } export interface IVersionInfo {