Some ts interface fix
This commit is contained in:
@@ -27,15 +27,19 @@
|
|||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts" >
|
<script setup lang="ts" >
|
||||||
import { IDomainInfo } from 'src/types/ActionTypes';
|
import { IDomainInfo } from 'src/types/DomainTypes';
|
||||||
import { useAuthStore,IUserState } from 'stores/useAuthStore';
|
import { useAuthStore } from 'stores/useAuthStore';
|
||||||
import { ref, computed } from 'vue';
|
import { useDomainStore } from 'src/stores/useDomainStore';
|
||||||
|
import { computed } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
const userStore = useAuthStore();
|
const userStore = useAuthStore();
|
||||||
|
const domainStore = useDomainStore();
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const domains = ref<IDomainInfo[]>([]);
|
const domains = computed(() => domainStore.userDomains);
|
||||||
|
|
||||||
(async ()=>{
|
(async ()=>{
|
||||||
domains.value = await userStore.getUserDomains();
|
await domainStore.loadUserDomains();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const isUnclickable = computed(()=>{
|
const isUnclickable = computed(()=>{
|
||||||
|
|||||||
@@ -18,10 +18,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:body-cell-name="p">
|
<template v-slot:body-cell-name="p">
|
||||||
<q-td :props="p">
|
<q-td class="flex justify-between items-center" :props="p">
|
||||||
{{ p.row.name }}
|
{{ p.row.name }}
|
||||||
<q-badge v-if="!p.row.domainActive" color="grey">未启用</q-badge>
|
<q-badge v-if="!p.row.domainActive" color="grey">未启用</q-badge>
|
||||||
<q-badge v-if="p.row.id == tenantid" color="primary">現在</q-badge>
|
<q-badge v-if="p.row.id == currendDomainId" color="primary">現在</q-badge>
|
||||||
</q-td>
|
</q-td>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -129,34 +129,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, reactive } 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';
|
||||||
type IManagedDomain = {
|
import { IDomain, IDomainDisplay, IDomainSubmit } from '../types/DomainTypes';
|
||||||
id: number;
|
|
||||||
tenantid: string;
|
|
||||||
name: string;
|
|
||||||
url: string;
|
|
||||||
kintoneuser: string,
|
|
||||||
kintonepwd: string,
|
|
||||||
create_time: string;
|
|
||||||
update_time: string;
|
|
||||||
is_active: boolean;
|
|
||||||
owner: object
|
|
||||||
}
|
|
||||||
|
|
||||||
type IDomainDisplay = {
|
|
||||||
id: number;
|
|
||||||
tenantid: string;
|
|
||||||
name: string;
|
|
||||||
url: string;
|
|
||||||
user: string;
|
|
||||||
password: string;
|
|
||||||
domainActive: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
|
const domainStore = useDomainStore();
|
||||||
const inactiveRowClass = (row: IDomainDisplay) => row.domainActive ? '' : 'inactive-row';
|
const inactiveRowClass = (row: IDomainDisplay) => row.domainActive ? '' : 'inactive-row';
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
@@ -185,6 +165,7 @@ const show = ref(false);
|
|||||||
const confirm = ref(false);
|
const confirm = ref(false);
|
||||||
const resetPsw = ref(false);
|
const resetPsw = ref(false);
|
||||||
|
|
||||||
|
const currendDomainId = computed(() => authStore.currentDomain.id);
|
||||||
const tenantid = ref(authStore.currentDomain.id);
|
const tenantid = ref(authStore.currentDomain.id);
|
||||||
const name = ref('');
|
const name = ref('');
|
||||||
const url = ref('');
|
const url = ref('');
|
||||||
@@ -195,11 +176,12 @@ const kintonepwdBK = ref('');
|
|||||||
const domainActive = ref(true);
|
const domainActive = ref(true);
|
||||||
const isCreate = ref(true);
|
const isCreate = ref(true);
|
||||||
let editId = ref(0);
|
let editId = ref(0);
|
||||||
|
let ownerid = ref('');
|
||||||
|
|
||||||
const getDomain = async () => {
|
const getDomain = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const userId = authStore.userId;
|
const userId = authStore.userId;
|
||||||
const result = await api.get<IManagedDomain[]>(`api/domain?userId=${userId}`);
|
const result = await api.get<IDomain[]>(`api/domain?userId=${userId}`);
|
||||||
rows.value = result.data.map((item) => {
|
rows.value = result.data.map((item) => {
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
@@ -208,7 +190,7 @@ const getDomain = async () => {
|
|||||||
name: item.name,
|
name: item.name,
|
||||||
url: item.url,
|
url: item.url,
|
||||||
user: item.kintoneuser,
|
user: item.kintoneuser,
|
||||||
password: item.kintonepwd
|
password: item.kintonepwd,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
@@ -266,39 +248,23 @@ const closeDg = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
if (!isCreate.value && editId.value !== 0) {
|
const method = editId.value !== 0 ? 'put' : 'post';
|
||||||
api.put(`api/domain`, {
|
const param: IDomainSubmit = {
|
||||||
'id': editId.value,
|
'id': editId.value,
|
||||||
'tenantid': tenantid.value,
|
'tenantid': tenantid.value,
|
||||||
'name': name.value,
|
'name': name.value,
|
||||||
'url': url.value,
|
'url': url.value,
|
||||||
'kintoneuser': kintoneuser.value,
|
'kintoneuser': kintoneuser.value,
|
||||||
'kintonepwd': isCreate.value || resetPsw.value ? kintonepwd.value : '',
|
'kintonepwd': ((isCreate.value && editId.value == 0) || resetPsw.value) ? kintonepwd.value : '',
|
||||||
'is_active': domainActive.value,
|
'is_active': domainActive.value,
|
||||||
'ownerid': authStore.userId,
|
'ownerid': authStore.userId || ''
|
||||||
}).then(() => {
|
}
|
||||||
|
api[method].apply(api, [`api/domain`, param]).then(() => {
|
||||||
getDomain();
|
getDomain();
|
||||||
|
domainStore.loadUserDomains();
|
||||||
closeDg();
|
closeDg();
|
||||||
onReset();
|
onReset();
|
||||||
})
|
})
|
||||||
}
|
|
||||||
else {
|
|
||||||
api.post(`api/domain`, {
|
|
||||||
'id': 0,
|
|
||||||
'tenantid': tenantid.value,
|
|
||||||
'name': name.value,
|
|
||||||
'url': url.value,
|
|
||||||
'kintoneuser': kintoneuser.value,
|
|
||||||
'kintonepwd': kintonepwd.value,
|
|
||||||
'is_active': domainActive.value,
|
|
||||||
'ownerid': authStore.userId,
|
|
||||||
}).then(() => {
|
|
||||||
getDomain();
|
|
||||||
closeDg();
|
|
||||||
onReset();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onReset = () => {
|
const onReset = () => {
|
||||||
@@ -308,6 +274,7 @@ const onReset = () => {
|
|||||||
kintonepwd.value = '';
|
kintonepwd.value = '';
|
||||||
isPwd.value = true;
|
isPwd.value = true;
|
||||||
editId.value = 0;
|
editId.value = 0;
|
||||||
|
ownerid.value = '';
|
||||||
isCreate.value = true;
|
isCreate.value = true;
|
||||||
domainActive.value = true;
|
domainActive.value = true;
|
||||||
resetPsw.value = false
|
resetPsw.value = false
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { api } from 'boot/axios';
|
import { api } from 'boot/axios';
|
||||||
import { router } from 'src/router';
|
import { router } from 'src/router';
|
||||||
import { IDomainInfo } from '../types/ActionTypes';
|
import { IDomainInfo } from '../types/DomainTypes';
|
||||||
import { jwtDecode } from 'jwt-decode';
|
import { jwtDecode } from 'jwt-decode';
|
||||||
interface UserInfo {
|
interface UserInfo {
|
||||||
firstName: string;
|
firstName: string;
|
||||||
|
|||||||
23
frontend/src/stores/useDomainStore.ts
Normal file
23
frontend/src/stores/useDomainStore.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { defineStore } from 'pinia';
|
||||||
|
import { api } from 'boot/axios';
|
||||||
|
import { IDomainInfo, IDomain } from '../types/DomainTypes';
|
||||||
|
|
||||||
|
export const useDomainStore = defineStore('domain', {
|
||||||
|
state: () => ({
|
||||||
|
userDomains: [] as IDomainInfo[],
|
||||||
|
}),
|
||||||
|
actions: {
|
||||||
|
async loadUserDomains(): Promise<IDomainInfo[]> {
|
||||||
|
const resp = await api.get(`api/domain`);
|
||||||
|
const domains = resp.data as IDomain[];
|
||||||
|
this.userDomains = domains
|
||||||
|
.filter(data => data.is_active)
|
||||||
|
.map((data) => ({
|
||||||
|
id: data.id,
|
||||||
|
domainName: data.name,
|
||||||
|
kintoneUrl: data.url,
|
||||||
|
}));
|
||||||
|
return this.userDomains;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
export interface IDomainInfo{
|
|
||||||
id:number;
|
|
||||||
domainName:string;
|
|
||||||
kintoneUrl:string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* アプリ情報
|
* アプリ情報
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
interface IUser {
|
import { IUser } from './UserTypes';
|
||||||
first_name: string;
|
|
||||||
last_name: string;
|
|
||||||
email: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IManagedApp {
|
export interface IManagedApp {
|
||||||
appid: string;
|
appid: string;
|
||||||
|
|||||||
35
frontend/src/types/DomainTypes.ts
Normal file
35
frontend/src/types/DomainTypes.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { IDomain } from './ActionTypes';
|
||||||
|
import { IUser } from './UserTypes';
|
||||||
|
|
||||||
|
export interface IDomainInfo {
|
||||||
|
id: number;
|
||||||
|
domainName: string;
|
||||||
|
kintoneUrl: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IDomain {
|
||||||
|
id: number;
|
||||||
|
tenantid: string;
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
kintoneuser: string,
|
||||||
|
kintonepwd: string,
|
||||||
|
create_time: string;
|
||||||
|
update_time: string;
|
||||||
|
is_active: boolean;
|
||||||
|
owner: IUser
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IDomainSubmit extends Omit<IDomain, 'create_time' | 'update_time' | 'owner'> {
|
||||||
|
ownerid: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IDomainDisplay {
|
||||||
|
id: number;
|
||||||
|
tenantid: string;
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
user: string;
|
||||||
|
password: string;
|
||||||
|
domainActive: boolean;
|
||||||
|
}
|
||||||
8
frontend/src/types/UserTypes.ts
Normal file
8
frontend/src/types/UserTypes.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export interface IUser {
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
email: string;
|
||||||
|
is_active: boolean,
|
||||||
|
is_superuser: boolean,
|
||||||
|
roles: string[]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user