@simitgroup/simpleapp-generator 1.0.54 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simitgroup/simpleapp-generator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.55",
|
|
4
4
|
"description": "frontend nuxtjs and backend nests code generator using jsonschema",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@apidevtools/json-schema-ref-parser": "^10.1.0",
|
|
23
|
-
"@simitgroup/simpleapp-generator": "^1.0.
|
|
23
|
+
"@simitgroup/simpleapp-generator": "^1.0.54",
|
|
24
24
|
"@simitgroup/simpleapp-vue-component": "^1.0.65",
|
|
25
25
|
"ajv": "^8.12.0",
|
|
26
26
|
"ajv-formats": "^2.1.1",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* author: Ks Tan
|
|
8
8
|
*/
|
|
9
9
|
<% let skipcolumns = ['_id','createdby','created','updatedby','updated','orgId','branchId','tenantId','doctype'] %>
|
|
10
|
-
import {InputTableColumnType,InputTableColumn} from "~/components/type";
|
|
10
|
+
//import {InputTableColumnType,InputTableColumn} from "~/components/type";
|
|
11
11
|
import Column from "primevue/column";
|
|
12
12
|
const {$<%= it.typename %>Doc } = useNuxtApp();
|
|
13
13
|
const doc = $<%= it.typename %>Doc()
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import Menu from "primevue/menu";
|
|
3
|
-
import Dialog from "primevue/dialog";
|
|
4
|
-
import _ from "lodash";
|
|
5
|
-
import Panel from "primevue/panel";
|
|
6
|
-
import { ref } from "vue";
|
|
7
|
-
import {
|
|
8
|
-
UserListItem,
|
|
9
|
-
BranchListItem,
|
|
10
|
-
OrgListItem,
|
|
11
|
-
InvitationListItem,
|
|
12
|
-
PermissionListItem,
|
|
13
|
-
} from "../../../types";
|
|
14
|
-
import SelectButton from "primevue/selectbutton";
|
|
15
|
-
import Button from "primevue/button";
|
|
16
|
-
import InputText from "primevue/inputtext";
|
|
17
|
-
|
|
18
|
-
import TabView from "primevue/tabview";
|
|
19
|
-
import TabPanel from "primevue/tabpanel";
|
|
20
|
-
import { Permission } from "../../../simpleapp/generate/openapi/api";
|
|
21
|
-
//initialize api
|
|
22
|
-
const { $PermissionDoc, $OrganizationDoc, $BranchDoc, $InvitationDoc } =
|
|
23
|
-
useNuxtApp();
|
|
24
|
-
const doc = $PermissionDoc();
|
|
25
|
-
const orgdoc = $OrganizationDoc();
|
|
26
|
-
const branchdoc = $BranchDoc();
|
|
27
|
-
const invitedoc = $InvitationDoc();
|
|
28
|
-
|
|
29
|
-
//initialize require list in UI
|
|
30
|
-
const permlist = ref<PermissionListItem[]>([]);
|
|
31
|
-
const userlist = ref<PermissionListItem[]>([]);
|
|
32
|
-
const invitationlist = ref<InvitationListItem[]>([]);
|
|
33
|
-
const orglist = ref<OrgListItem[]>([]);
|
|
34
|
-
const branchlist = ref<BranchListItem[]>([]);
|
|
35
|
-
const currentpermissions = ref<Permission[]>([]);
|
|
36
|
-
const grouplist = getAllGroups().map((item) => {
|
|
37
|
-
return { value: item, label: _.capitalize(item) };
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
//initialize some runtime variable
|
|
41
|
-
const inviteemail = ref("");
|
|
42
|
-
const selected = ref("");
|
|
43
|
-
const activeuser = ref("");
|
|
44
|
-
const showpermissioninfo = ref(false);
|
|
45
|
-
const permissionselected = ref();
|
|
46
|
-
const permissiontitle = "Permission Information";
|
|
47
|
-
|
|
48
|
-
//initialize UI methods
|
|
49
|
-
const getPermssionData = (uid: string, branchId: number) => {
|
|
50
|
-
const result = permlist.value.find(
|
|
51
|
-
(el) => el.uid == uid && el.branchId == branchId,
|
|
52
|
-
);
|
|
53
|
-
let pm: Permission = {
|
|
54
|
-
_id: result?._id ?? "",
|
|
55
|
-
orgId: result?.orgId ?? 0,
|
|
56
|
-
tenantId: result?.tenantId ?? 0,
|
|
57
|
-
branchId: branchId,
|
|
58
|
-
uid: uid,
|
|
59
|
-
group: result?.group ?? "",
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return pm;
|
|
63
|
-
};
|
|
64
|
-
const onSelectUser = async (item: any) => {
|
|
65
|
-
orglist.value = await orgdoc.list();
|
|
66
|
-
branchlist.value = await branchdoc.list();
|
|
67
|
-
selected.value = item.uid;
|
|
68
|
-
activeuser.value = item.fullName;
|
|
69
|
-
const uid = item.uid;
|
|
70
|
-
currentpermissions.value = [];
|
|
71
|
-
for (let i = 0; i < branchlist.value.length; i++) {
|
|
72
|
-
const b = branchlist.value[i];
|
|
73
|
-
const permdata = getPermssionData(uid, b.branchId);
|
|
74
|
-
const tmp: Permission = {
|
|
75
|
-
_id: permdata?._id,
|
|
76
|
-
uid: uid,
|
|
77
|
-
tenantId: b.tenantId,
|
|
78
|
-
orgId: b.orgId,
|
|
79
|
-
branchId: b.branchId,
|
|
80
|
-
group: permdata.group,
|
|
81
|
-
};
|
|
82
|
-
currentpermissions.value.push(tmp);
|
|
83
|
-
}
|
|
84
|
-
console.log("currentpermissions", currentpermissions.value);
|
|
85
|
-
};
|
|
86
|
-
const refreshList = async (resetpage:boolean=true) => {
|
|
87
|
-
const items: any[] = [];
|
|
88
|
-
permlist.value = await doc.listUser();
|
|
89
|
-
userlist.value = _.uniqBy(permlist.value, "uid");
|
|
90
|
-
if(resetpage){
|
|
91
|
-
selected.value=''
|
|
92
|
-
activeuser.value=''
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
console.log(permlist.value);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const refreshInvitation = async () => {
|
|
100
|
-
inviteemail.value = "";
|
|
101
|
-
invitationlist.value = await invitedoc.list();
|
|
102
|
-
};
|
|
103
|
-
const checkBranchInOrg = (org: OrgListItem, branch: BranchListItem) => {
|
|
104
|
-
return org.orgId === branch.orgId;
|
|
105
|
-
};
|
|
106
|
-
const previewPermission = () => {
|
|
107
|
-
showpermissioninfo.value = true;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
/***** send or remove invitation ******/
|
|
111
|
-
const invite = async () => {
|
|
112
|
-
const result = await sendInvitation(inviteemail.value);
|
|
113
|
-
refreshInvitation();
|
|
114
|
-
};
|
|
115
|
-
const deleteInvitation = async (recordId: string) => {
|
|
116
|
-
await cancelInvitation(recordId);
|
|
117
|
-
refreshInvitation();
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**********applPermission ******/
|
|
121
|
-
/**
|
|
122
|
-
* apply permission:
|
|
123
|
-
* _id:'', group:'' => skip
|
|
124
|
-
* _id: '', group:'something' => create
|
|
125
|
-
* _id:'something', 'group':'something' => update
|
|
126
|
-
* _id:'something', group:'' => remove
|
|
127
|
-
*/
|
|
128
|
-
const applPermission = async (d: Permission) => {
|
|
129
|
-
let result;
|
|
130
|
-
|
|
131
|
-
d._id = String(d._id ?? "");
|
|
132
|
-
d.group = String(d.group ?? "");
|
|
133
|
-
const data = doc.getReactiveData();
|
|
134
|
-
data.value = d;
|
|
135
|
-
console.log("apply permission", data.value)
|
|
136
|
-
if (!d._id && !d.group) {
|
|
137
|
-
//no changes
|
|
138
|
-
} else if (!d._id && d.group) {
|
|
139
|
-
result = await doc.create();
|
|
140
|
-
} else if (d._id && d.group) {
|
|
141
|
-
data.value = d;
|
|
142
|
-
result = await doc.update();
|
|
143
|
-
} else if (d._id && !d.group) {
|
|
144
|
-
d.group = "";
|
|
145
|
-
data.value = d;
|
|
146
|
-
result = await doc.delete(d._id);
|
|
147
|
-
} else {
|
|
148
|
-
console.warn("unknown apply permission", result);
|
|
149
|
-
}
|
|
150
|
-
refreshList(false)
|
|
151
|
-
};
|
|
152
|
-
//init ui
|
|
153
|
-
onMounted(() => {
|
|
154
|
-
refreshList();
|
|
155
|
-
refreshInvitation();
|
|
156
|
-
});
|
|
157
|
-
</script>
|
|
158
|
-
<template>
|
|
159
|
-
<Button @click="refreshList()" class="pi pi-refresh"></Button>
|
|
160
|
-
<Dialog
|
|
161
|
-
v-model:visible="showpermissioninfo"
|
|
162
|
-
modal
|
|
163
|
-
:header="permissiontitle"
|
|
164
|
-
:autoZIndex="false"
|
|
165
|
-
:style="{ zIndex: 100, width: '80vw' }"
|
|
166
|
-
>
|
|
167
|
-
<PermissionInfo></PermissionInfo>
|
|
168
|
-
</Dialog>
|
|
169
|
-
|
|
170
|
-
<div class="grid grid-cols-3">
|
|
171
|
-
<div v-if="userlist">
|
|
172
|
-
<TabView>
|
|
173
|
-
<TabPanel header="Active">
|
|
174
|
-
<Menu
|
|
175
|
-
:model="userlist"
|
|
176
|
-
class="w w-auto border border-solid border-1"
|
|
177
|
-
:pt="{ root: { class: 'w-auto ' } }"
|
|
178
|
-
>
|
|
179
|
-
<template #start>
|
|
180
|
-
<div class="flex flex-column align">
|
|
181
|
-
<h1>Users</h1>
|
|
182
|
-
</div>
|
|
183
|
-
</template>
|
|
184
|
-
<template #item="{ item, label, props }">
|
|
185
|
-
<a
|
|
186
|
-
class="flex m-2 p-2 flex-col border border-b-2 cursor cursor-pointer"
|
|
187
|
-
@click="onSelectUser(item)"
|
|
188
|
-
>
|
|
189
|
-
<div class="text text-left text-base text-black">
|
|
190
|
-
{{ item.fullName }}
|
|
191
|
-
</div>
|
|
192
|
-
<div class="text text-sm text-right">{{ item.email }}</div>
|
|
193
|
-
</a>
|
|
194
|
-
</template>
|
|
195
|
-
</Menu>
|
|
196
|
-
</TabPanel>
|
|
197
|
-
<TabPanel header="Invite">
|
|
198
|
-
<div class="padding p-2">
|
|
199
|
-
<form @submit.prevent="true" class="w-full">
|
|
200
|
-
<div class="p-inputgroup flex-1">
|
|
201
|
-
|
|
202
|
-
<InputText
|
|
203
|
-
type="email"
|
|
204
|
-
placeholder="email"
|
|
205
|
-
v-model="inviteemail"
|
|
206
|
-
/>
|
|
207
|
-
<Button label="Search" class=" btn-primary" @click="invite"
|
|
208
|
-
>Invite</Button
|
|
209
|
-
>
|
|
210
|
-
|
|
211
|
-
</div>
|
|
212
|
-
</form>
|
|
213
|
-
</div>
|
|
214
|
-
<div class="flex flex-col">
|
|
215
|
-
<div
|
|
216
|
-
v-for="(invitation, index) in invitationlist"
|
|
217
|
-
class="grid grid-cols-4"
|
|
218
|
-
>
|
|
219
|
-
<div class="text text-base m-2">{{ index + 1 }}</div>
|
|
220
|
-
<div class="col-span-2 text text-base m-2">
|
|
221
|
-
{{ invitation.email }}
|
|
222
|
-
</div>
|
|
223
|
-
<div>
|
|
224
|
-
<Button
|
|
225
|
-
class="btn-danger pi pi-times"
|
|
226
|
-
@click="deleteInvitation(invitation._id)"
|
|
227
|
-
></Button>
|
|
228
|
-
</div>
|
|
229
|
-
</div>
|
|
230
|
-
</div>
|
|
231
|
-
</TabPanel>
|
|
232
|
-
</TabView>
|
|
233
|
-
</div>
|
|
234
|
-
<div class="col-span-2" v-if="selected">
|
|
235
|
-
<div class="flex flex-row w w-full">
|
|
236
|
-
<div class="text text-xl p p-2 text-left flex-1">{{ activeuser }}</div>
|
|
237
|
-
<div class="text-right m mr-2">
|
|
238
|
-
<Button
|
|
239
|
-
class="btn-primary pi pi-question"
|
|
240
|
-
@click="previewPermission"
|
|
241
|
-
></Button>
|
|
242
|
-
</div>
|
|
243
|
-
</div>
|
|
244
|
-
|
|
245
|
-
<Panel v-for="o in orglist" :header="o.orgName" class="m-2">
|
|
246
|
-
<table class="w w-full">
|
|
247
|
-
<thead class="">
|
|
248
|
-
<tr>
|
|
249
|
-
<th>Branch Code</th>
|
|
250
|
-
<th>Branch Name</th>
|
|
251
|
-
<th>Access Right</th>
|
|
252
|
-
</tr>
|
|
253
|
-
</thead>
|
|
254
|
-
<tr v-for="(b, index) in branchlist">
|
|
255
|
-
<td v-if="checkBranchInOrg(o, b)">{{ b.branchCode }}</td>
|
|
256
|
-
<td v-if="checkBranchInOrg(o, b)">{{ b.branchName }}</td>
|
|
257
|
-
<td v-if="checkBranchInOrg(o, b)" clas="flex flex-row">
|
|
258
|
-
<div class="grid gap-4 grid-cols-5">
|
|
259
|
-
<div class="col-span-4">
|
|
260
|
-
<SelectButton
|
|
261
|
-
v-model="currentpermissions[index].group"
|
|
262
|
-
:options="grouplist"
|
|
263
|
-
option-label="label"
|
|
264
|
-
option-value="value"
|
|
265
|
-
@change="applPermission(currentpermissions[index])"
|
|
266
|
-
></SelectButton>
|
|
267
|
-
</div>
|
|
268
|
-
</div>
|
|
269
|
-
</td>
|
|
270
|
-
</tr>
|
|
271
|
-
</table>
|
|
272
|
-
</Panel>
|
|
273
|
-
</div>
|
|
274
|
-
</div>
|
|
275
|
-
</template>
|
|
276
|
-
<style scoped>
|
|
277
|
-
td {
|
|
278
|
-
text-align: center;
|
|
279
|
-
}
|
|
280
|
-
</style>
|