@hostlink/nuxt-light 0.0.77 → 0.0.79

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.
Files changed (39) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +3 -1
  3. package/dist/runtime/components/l-app-main.vue +6 -6
  4. package/dist/runtime/components/l-audit-card.vue +1 -1
  5. package/dist/runtime/components/l-card.vue +6 -4
  6. package/dist/runtime/components/l-form.vue +5 -1
  7. package/dist/runtime/components/l-table.vue +44 -22
  8. package/dist/runtime/lib/GQLFieldBuilder.d.ts +5 -0
  9. package/dist/runtime/lib/GQLFieldBuilder.mjs +35 -0
  10. package/dist/runtime/lib/defineType.d.ts +3 -0
  11. package/dist/runtime/lib/defineType.mjs +5 -0
  12. package/dist/runtime/lib/getTypeColumns.d.ts +2 -0
  13. package/dist/runtime/lib/getTypeColumns.mjs +19 -0
  14. package/dist/runtime/lib/index.d.ts +3 -1
  15. package/dist/runtime/lib/index.mjs +5 -1
  16. package/dist/runtime/lib/q.mjs +2 -2
  17. package/dist/runtime/lib/sv.d.ts +2 -0
  18. package/dist/runtime/lib/sv.mjs +11 -0
  19. package/dist/runtime/pages/MailLog/index.vue +1 -4
  20. package/dist/runtime/pages/Permission/all.vue +12 -12
  21. package/dist/runtime/pages/Permission/export.vue +13 -5
  22. package/dist/runtime/pages/Permission/index.vue +2 -5
  23. package/dist/runtime/pages/System/database/backup.vue +1 -0
  24. package/dist/runtime/pages/System/database/table.vue +11 -2
  25. package/dist/runtime/pages/System/setting.vue +0 -2
  26. package/dist/runtime/pages/SystemValue/_systemvalue_id/edit.vue +15 -0
  27. package/dist/runtime/pages/SystemValue/add.vue +15 -0
  28. package/dist/runtime/pages/SystemValue/index.vue +12 -0
  29. package/dist/runtime/pages/User/index.vue +5 -48
  30. package/dist/runtime/pages/UserLog/index.vue +2 -49
  31. package/dist/runtime/plugin.mjs +7 -1
  32. package/dist/runtime/routes.mjs +30 -0
  33. package/dist/runtime/types/SystemValue.d.ts +11 -0
  34. package/dist/runtime/types/SystemValue.mjs +10 -0
  35. package/dist/runtime/types/User.d.ts +34 -0
  36. package/dist/runtime/types/User.mjs +33 -0
  37. package/dist/runtime/types/UserLog.d.ts +39 -0
  38. package/dist/runtime/types/UserLog.mjs +44 -0
  39. package/package.json +1 -1
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "0.0.77"
4
+ "version": "0.0.79"
5
5
  }
package/dist/module.mjs CHANGED
@@ -52,7 +52,9 @@ const module = defineNuxtModule({
52
52
  { name: "updateObject", from },
53
53
  { name: "listObject", from },
54
54
  { name: "useLight", from: index },
55
- { name: "isGranted", from }
55
+ { name: "isGranted", from },
56
+ { name: "getTypeColumns", from },
57
+ { name: "defineType", from }
56
58
  ]);
57
59
  addPlugin({
58
60
  src: resolver.resolve("./runtime/plugin"),
@@ -312,12 +312,12 @@ const storageUsagePercent = computed(() => {
312
312
 
313
313
  <q-page-container class="bg-grey-2" style="color:#1f1f1f">
314
314
  <!-- Error message -->
315
- <q-card v-for="error in errors" flat class="q-ma-md" bordered style="border-color: var(--q-negative)">
316
- <q-card-section>
317
- <q-btn dense flat round icon="close" class="q-mr-sm" @click="light.removeError(error)"></q-btn>{{
318
- error }}
319
- </q-card-section>
320
- </q-card>
315
+ <q-banner dense inline-actions class="bg-grey-4 q-ma-md" v-for="error in errors" rounded>
316
+ {{ error }}
317
+ <template v-slot:action>
318
+ <q-btn flat icon="sym_o_close" round dense @click="light.removeError(error)" />
319
+ </template>
320
+ </q-banner>
321
321
 
322
322
  <router-view v-slot="{ Component }">
323
323
  <template v-if="Component">
@@ -9,7 +9,7 @@ defineProps({
9
9
 
10
10
  </script>
11
11
  <template>
12
- <l-card>
12
+ <l-card title="Audit info">
13
13
  <l-list>
14
14
  <l-item label="Created time">{{ modelValue.createdTime }}</l-item>
15
15
  <l-item label="Created by">{{ modelValue.createdBy }}</l-item>
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import { useLight } from '../'
3
- import { useAttrs, ref } from 'vue'
3
+ import { useAttrs, ref, computed } from 'vue'
4
4
 
5
5
  defineProps({
6
6
  loading: Boolean,
@@ -22,16 +22,18 @@ const color = light.getStyle("color", 'primary');
22
22
 
23
23
  const cl = ["text-white", `bg-${color}`];
24
24
 
25
- const minimize = ref(true);
25
+ const minimize = ref(false);
26
+
27
+ const icon = computed(() => minimize.value ? "sym_o_add" : "sym_o_remove");
26
28
  </script>
27
29
  <template>
28
30
  <q-card v-bind="attrs">
29
31
  <q-bar :class="cl" v-if="title">
30
32
  <div>{{ title }}</div>
31
33
  <q-space />
32
- <q-btn dense flat icon="sym_o_remove" @click="minimize = !minimize" />
34
+ <q-btn dense flat :icon="icon" @click="minimize = !minimize" />
33
35
  </q-bar>
34
- <template v-if="minimize">
36
+ <template v-if="!minimize">
35
37
  <slot></slot>
36
38
  </template>
37
39
 
@@ -30,6 +30,8 @@ const props = defineProps({
30
30
  }
31
31
  });
32
32
 
33
+ const loading = ref(false)
34
+
33
35
  const que = useQuasar();
34
36
  const emit = defineEmits(["save", "submit"]);
35
37
  const save = async () => {
@@ -37,6 +39,7 @@ const save = async () => {
37
39
  let valid = await form.value.validate();
38
40
  if (!valid) return;
39
41
  if (valid) {
42
+ loading.value = true;
40
43
  emit("save");
41
44
  emit('submit');
42
45
  }
@@ -72,6 +75,7 @@ const save = async () => {
72
75
  }
73
76
  }
74
77
  }
78
+ loading.value = false
75
79
  }
76
80
  const onSubmit = (e) => {
77
81
  e.preventDefault();
@@ -90,7 +94,7 @@ const onSubmit = (e) => {
90
94
  </q-card-section>
91
95
 
92
96
  <q-card-actions align="right">
93
- <l-btn color="primary" :icon="submitIcon" :label="submitLabel" @click="save" />
97
+ <l-btn color="primary" :icon="submitIcon" :label="submitLabel" @click="save" :loading="loading" />
94
98
  </q-card-actions>
95
99
  </l-card>
96
100
  </q-form>
@@ -1,7 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import { useQuasar, QTable } from 'quasar';
3
3
  import { ref, computed, onMounted, useSlots, reactive, useAttrs } from "vue";
4
- import { t, deleteObject, q, f, useLight } from '../';
4
+ import { t, deleteObject, q, f, useLight, GQLFieldBuilder } from '../';
5
+ import { toQuery } from '@hostlink/light'
5
6
 
6
7
  const errors = ref<InstanceType<any>>([]);
7
8
 
@@ -21,6 +22,7 @@ const props = defineProps({
21
22
  searchType?: string,
22
23
  searchOptions?: Array<any>,
23
24
  field?: string | Object,
25
+ gqlField?: string | Array<string> | Object,
24
26
  }>
25
27
  },
26
28
  actions: {
@@ -166,7 +168,7 @@ const validateData = () => {
166
168
  let row = rows.value[0];
167
169
  //check has primary key
168
170
 
169
- if (!primaryKey.value) {
171
+ if (!row[primaryKey.value]) {
170
172
  errors.value.push("[edit] Primary key not found in the data");
171
173
  }
172
174
  }
@@ -194,6 +196,15 @@ const getData = async (
194
196
  limit: number,
195
197
  fields: Array<string> = []) => {
196
198
 
199
+ const query: any = {};
200
+ query[operation] = {
201
+ meta: {
202
+ total: true,
203
+ key: true,
204
+ name: true
205
+ }
206
+ }
207
+
197
208
  let offset_limit: any = {}
198
209
  if (offset) {
199
210
  offset_limit.offset = offset;
@@ -203,6 +214,12 @@ const getData = async (
203
214
  offset_limit.limit = limit;
204
215
  }
205
216
 
217
+ if (offset_limit) {
218
+ query[operation].data = {
219
+ __args: offset_limit
220
+ };
221
+ }
222
+
206
223
  let params: any = {}
207
224
  if (sort) {
208
225
  params.sort = sort;
@@ -212,7 +229,13 @@ const getData = async (
212
229
  params.filters = filters
213
230
  }
214
231
 
215
- return await q(operation, params, [f("data", offset_limit, fields), f("meta", ["total", "key", "name"])]);
232
+ query[operation].__args = params;
233
+
234
+ query[operation].data = query[operation].data || {};
235
+ Object.assign(query[operation].data, fields);
236
+
237
+ const resp = await q(query);
238
+ return resp[operation];
216
239
 
217
240
  }
218
241
 
@@ -226,41 +249,43 @@ const onRequest = async (p: any) => {
226
249
  },
227
250
  async loadData(operation: string, filters: any = null, fields: Array<any> = []) {
228
251
 
252
+
253
+ const builder = GQLFieldBuilder();
254
+
229
255
  //
230
- let localFields: Array<any> = [];
231
256
 
232
257
  if (props.rowKey) {
233
- localFields.push(props.rowKey);
258
+ builder.add(props.rowKey);
234
259
  }
235
260
 
236
261
  fields.forEach((f) => {
237
- localFields.push(f);
262
+ builder.add(f);
238
263
  });
239
264
 
240
265
  props.columns?.forEach((col) => {
241
- if (col.name.startsWith("_")) {
242
- return;
266
+ if (col.gqlField) {
267
+ builder.add(col.gqlField);
243
268
  }
244
- if (localFields.includes(col.name)) {
269
+
270
+ if (col.name.startsWith("_")) {
245
271
  return;
246
272
  }
247
- localFields.push(col.name);
273
+ builder.add(col.name);
274
+
248
275
  });
249
276
 
250
277
  if (actionView) {
251
- localFields.push("canView");
278
+ builder.add("canView");
252
279
  }
253
280
 
254
281
  if (actionDelete) {
255
- localFields.push("canDelete");
282
+ builder.add("canDelete");
256
283
  }
257
284
 
258
285
  if (activeEdit) {
259
- localFields.push("canUpdate");
286
+ builder.add("canUpdate");
260
287
  }
261
288
 
262
-
263
-
264
289
  let localFilters = getFilterValue();
265
290
  //merge the filters
266
291
  if (filters) {
@@ -280,7 +305,7 @@ const onRequest = async (p: any) => {
280
305
  loading.value = true;
281
306
  const offset = (p.pagination.page - 1) * p.pagination.rowsPerPage;
282
307
  const limit = p.pagination.rowsPerPage;
283
- const allData = await getData(operation, localFilters, sort, offset, limit, localFields);
308
+ const allData = await getData(operation, localFilters, sort, offset, limit, builder.get());
284
309
 
285
310
  rows.value = allData.data;
286
311
 
@@ -384,10 +409,8 @@ const filter = ref('');
384
409
  </script>
385
410
  <template>
386
411
  <template v-if="errors.length > 0">
387
- <div class="text-white bg-negative">
388
- <ul>
389
- <li v-for="e in errors">{{ e }}</li>
390
- </ul>
412
+ <div class="q-gutter-sm">
413
+ <q-banner inline-actions v-for="e in errors" rounded class="bg-negative text-white">{{ e }}</q-banner>
391
414
  </div>
392
415
  </template>
393
416
 
@@ -407,8 +430,7 @@ const filter = ref('');
407
430
 
408
431
  <q-table v-bind="attrs" :row-key="rowKey" :loading="loading" :rows="rows" ref="table" @request="onRequest"
409
432
  :rows-per-page-label="$t(props.rowsPerPageLabel)" :columns="renderColumns"
410
- :rows-per-page-options="rowsPerPageOptions" :selection="selection" v-model:pagination="pagination"
411
- :filter="filter">
433
+ :rows-per-page-options="rowsPerPageOptions" :selection="selection" v-model:pagination="pagination" :filter="filter">
412
434
 
413
435
  <template #top-right="props" v-if="fullscreen || searchable">
414
436
  <q-input v-if="searchable" outlined dense debounce="300" v-model="filter" placeholder="Search">
@@ -0,0 +1,5 @@
1
+ export default function (): {
2
+ merge: (obj1: any, obj2: any) => any;
3
+ add: (f: any) => void;
4
+ get(): any;
5
+ };
@@ -0,0 +1,35 @@
1
+ import { toQuery } from "@hostlink/light";
2
+ export default function() {
3
+ const merge = (obj1, obj2) => {
4
+ for (let key in obj2) {
5
+ if (obj2.hasOwnProperty(key)) {
6
+ obj1[key] = obj1[key] && obj1[key].toString() === "[object Object]" ? merge(obj1[key], obj2[key]) : obj1[key] = obj2[key];
7
+ }
8
+ }
9
+ return obj1;
10
+ };
11
+ let fields = {};
12
+ return {
13
+ //deep merge
14
+ merge,
15
+ add: (f) => {
16
+ if (typeof f === "string") {
17
+ fields[f] = true;
18
+ return;
19
+ }
20
+ if (Array.isArray(f)) {
21
+ f.forEach((item) => {
22
+ fields[item] = true;
23
+ });
24
+ return;
25
+ }
26
+ if (typeof f === "object") {
27
+ fields = merge(fields, toQuery(f));
28
+ return;
29
+ }
30
+ },
31
+ get() {
32
+ return fields;
33
+ }
34
+ };
35
+ }
@@ -0,0 +1,3 @@
1
+ declare const _default: (type: string, fields: Object) => void;
2
+ export default _default;
3
+ export declare const getData: () => any;
@@ -0,0 +1,5 @@
1
+ let data = {};
2
+ export default (type, fields) => {
3
+ data[type] = fields;
4
+ };
5
+ export const getData = () => data;
@@ -0,0 +1,2 @@
1
+ declare const _default: (type: string, names: string[]) => any;
2
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import { getData } from "./defineType.mjs";
2
+ export default (type, names) => {
3
+ let data = getData();
4
+ let columns = [];
5
+ for (let name of names) {
6
+ if (!data[type])
7
+ continue;
8
+ if (!data[type][name])
9
+ continue;
10
+ let options = data[type][name];
11
+ if (!options)
12
+ continue;
13
+ if (!options.name) {
14
+ options.name = name;
15
+ }
16
+ columns.push(options);
17
+ }
18
+ return columns;
19
+ };
@@ -14,7 +14,9 @@ import updateObject from "./updateObject";
14
14
  import listObject from "./listObject";
15
15
  import loadObject from "./loadObject";
16
16
  import isGranted from "./isGranted";
17
+ import GQLFieldBuilder from "./GQLFieldBuilder";
17
18
  declare const notify: (message: string, color?: string) => void;
18
19
  import getID from "./getID";
19
20
  declare const getApiBase: () => {};
20
- export { addObject, f, getApiUrl, getCurrentUser, getObject, list, listData, m, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted, getApiBase, loadObject };
21
+ import defineType from './defineType';
22
+ export { addObject, f, getApiUrl, getCurrentUser, getObject, list, listData, m, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted, getApiBase, loadObject, GQLFieldBuilder, defineType };
@@ -16,6 +16,7 @@ import updateObject from "./updateObject.mjs";
16
16
  import listObject from "./listObject.mjs";
17
17
  import loadObject from "./loadObject.mjs";
18
18
  import isGranted from "./isGranted.mjs";
19
+ import GQLFieldBuilder from "./GQLFieldBuilder.mjs";
19
20
  const notify = function(message, color = "green") {
20
21
  Notify.create({
21
22
  message,
@@ -28,6 +29,7 @@ const getApiBase = () => {
28
29
  const config = useRuntimeConfig();
29
30
  return config?.public?.apiBase ?? "/api/";
30
31
  };
32
+ import defineType from "./defineType.mjs";
31
33
  export {
32
34
  addObject,
33
35
  f,
@@ -47,5 +49,7 @@ export {
47
49
  listObject,
48
50
  isGranted,
49
51
  getApiBase,
50
- loadObject
52
+ loadObject,
53
+ GQLFieldBuilder,
54
+ defineType
51
55
  };
@@ -2,14 +2,14 @@ import axios from "axios";
2
2
  import f from "./f.mjs";
3
3
  import { jsonToGraphQLQuery } from "json-to-graphql-query";
4
4
  import { getApiBase } from "./index.mjs";
5
- import toJson from "./toJson.mjs";
5
+ import { toQuery } from "@hostlink/light";
6
6
  export default async function(operation, args = null, fields = []) {
7
7
  const service = axios.create({
8
8
  withCredentials: true
9
9
  });
10
10
  let query;
11
11
  if (operation instanceof Object) {
12
- query = jsonToGraphQLQuery(toJson(operation));
12
+ query = jsonToGraphQLQuery(toQuery(operation));
13
13
  } else {
14
14
  if (arguments.length === 2) {
15
15
  fields = args;
@@ -0,0 +1,2 @@
1
+ declare const _default: (name: string) => Promise<any>;
2
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { query } from "@hostlink/light";
2
+ export default async (name) => {
3
+ const resp = await query({
4
+ systemValue: {
5
+ __args: {
6
+ name
7
+ }
8
+ }
9
+ });
10
+ return resp.systemValue;
11
+ };
@@ -35,9 +35,6 @@ const columns = [
35
35
 
36
36
  <template>
37
37
  <l-page>
38
- <l-table @request="$event.loadObjects('MailLog', null, ['body'])" :columns="columns" sort-by="maillog_id:desc">
39
-
40
-
41
- </l-table>
38
+ <l-table @request="$event.loadObjects('MailLog')" :columns="columns" sort-by="maillog_id:desc" />
42
39
  </l-page>
43
40
  </template>
@@ -1,9 +1,18 @@
1
1
  <script setup>
2
2
  import { reactive } from 'vue'
3
- import { q, m } from '../../'
4
- const app = await q("app", ["permissions"])
3
+ import { m } from '../../'
5
4
 
6
- const roles = await q("listRole", ["name", "permissions"])
5
+ import { query } from '@hostlink/light';
6
+
7
+ const { app, listRole: roles } = await query({
8
+ app: {
9
+ permissions: true
10
+ },
11
+ listRole: {
12
+ name: true,
13
+ permissions: true
14
+ }
15
+ })
7
16
 
8
17
  const columns = [{
9
18
  label: "Permission",
@@ -41,13 +50,6 @@ app.permissions.forEach(permission => {
41
50
  });
42
51
 
43
52
  const onUpdate = (value, role, permission) => {
44
- /* if (value) {
45
- app.permissions.push(role);
46
- } else {
47
- app.permissions.splice(app.permissions.indexOf(role), 1);
48
- }
49
- app.save(); */
50
-
51
53
  if (value) {
52
54
  m("addPermission", { value: permission, role })
53
55
  } else {
@@ -60,8 +62,6 @@ const onUpdate = (value, role, permission) => {
60
62
  row[role] = value;
61
63
  }
62
64
  });
63
-
64
-
65
65
  }
66
66
 
67
67
  </script>
@@ -1,15 +1,23 @@
1
1
  <script setup>
2
2
  import { reactive } from 'vue'
3
3
  import { utils, writeFileXLSX } from 'xlsx';
4
- import { q } from '../../'
4
+ import { query } from '@hostlink/light';
5
5
  const obj = reactive({
6
6
  roles: []
7
7
  });
8
8
 
9
- const app = await q("app", ["permissions"])
10
- let allData = await q("listRole", ["name", "permissions"]);
9
+ const { app, listRole } = await query({
10
+ app: {
11
+ permissions: true
12
+ },
13
+ listRole: {
14
+ name: true,
15
+ permissions: true
16
+ }
11
17
 
12
- let roles = allData.map((role) => {
18
+ })
19
+
20
+ let roles = listRole.map((role) => {
13
21
  return {
14
22
  label: role.name,
15
23
  value: role.name,
@@ -19,7 +27,7 @@ let roles = allData.map((role) => {
19
27
  const submit = () => {
20
28
 
21
29
  //filter roles
22
- let e = allData.filter((role) => {
30
+ let e = listRole.filter((role) => {
23
31
  return obj.roles.indexOf(role.name) != -1;
24
32
  });
25
33
 
@@ -1,8 +1,4 @@
1
1
  <script setup>
2
- const onRequest = async (request) => {
3
- request.loadObjects("Permission", null, ["permission_id"])
4
- };
5
-
6
2
  const columns = [
7
3
  {
8
4
  label: "Role",
@@ -21,6 +17,7 @@ const columns = [
21
17
  </script>
22
18
  <template>
23
19
  <l-page>
24
- <l-table @request="onRequest" :columns="columns" :actions="['delete']"></l-table>
20
+ <l-table row-key="permission_id" @request="$event.loadObjects('Permission')" :columns="columns"
21
+ :actions="['delete']"></l-table>
25
22
  </l-page>
26
23
  </template>
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <l-page>
3
+ comming soon
3
4
 
4
5
  </l-page>
5
6
  </template>
@@ -1,6 +1,15 @@
1
1
  <script setup>
2
- import { q } from '../../../'
3
- const { system: { database } } = await q({ system: { database: ["table"] } })
2
+ import { query } from '@hostlink/light';
3
+
4
+ const { system: { database } } = await query({
5
+ system: {
6
+ database: {
7
+ table: true
8
+ }
9
+ }
10
+ })
11
+
12
+
4
13
  </script>
5
14
  <template>
6
15
  <l-page>
@@ -49,8 +49,6 @@ const onSave = async () => {
49
49
  </script>
50
50
  <template>
51
51
  <l-page>
52
-
53
- {{ test }}
54
52
  <l-form @save="onSave">
55
53
  <l-input label="Company" v-model="obj.company"></l-input>
56
54
  <l-input label="Company logo" v-model="obj.company_logo"></l-input>
@@ -0,0 +1,15 @@
1
+ <script setup>
2
+ import { reactive } from 'vue'
3
+ import { getObject } from '../../../'
4
+ const obj = reactive(await getObject(["name", "value"]))
5
+ </script>
6
+
7
+ <template>
8
+ <l-page>
9
+ <l-form v-model="obj">
10
+ <l-input label="Name" v-model="obj.name" required />
11
+ <l-input label="Value" v-model="obj.value" required type="textarea" />
12
+ </l-form>
13
+
14
+ </l-page>
15
+ </template>
@@ -0,0 +1,15 @@
1
+ <script setup>
2
+ import { reactive } from 'vue'
3
+
4
+ const obj = reactive({})
5
+ </script>
6
+
7
+ <template>
8
+ <l-page>
9
+ <l-form v-model="obj">
10
+ <l-input label="Name" v-model="obj.name" required />
11
+ <l-input label="Value" v-model="obj.value" required type="textarea" />
12
+ </l-form>
13
+
14
+ </l-page>
15
+ </template>
@@ -0,0 +1,12 @@
1
+ <script setup>
2
+ import { ref } from 'vue'
3
+ import getTypeColumns from "../../lib/getTypeColumns";
4
+ import sv from "../../lib/sv";
5
+ const columns = getTypeColumns("SystemValue", ["name", "value"]);
6
+ </script>
7
+ <template>
8
+ <l-page>
9
+ <l-table row-key="systemvalue_id" :columns="columns" @request="$event.loadObjects('SystemValue')"
10
+ :actions="['edit', 'delete']"></l-table>
11
+ </l-page>
12
+ </template>
@@ -1,67 +1,24 @@
1
1
  <script setup>
2
2
  import { ref } from 'vue'
3
+ import getTypeColumns from "../../lib/getTypeColumns";
3
4
  const onRequest = async (request) => {
4
- //listData("User", params, ["canDelete", "canUpdate", "canRead", "user_id"]);
5
-
6
- request.loadObjects("User", {
7
- status: status.value
8
- }, ["user_id"]);
5
+ request.loadObjects("User", { status: status.value });
9
6
  };
10
-
11
- const columns = [
12
- {
13
- label: "Username",
14
- name: "username",
15
- sortable: true,
16
- searchable: true,
17
- },
18
- {
19
- label: "First name",
20
- name: "first_name",
21
- sortable: true,
22
- searchable: true,
23
- }, {
24
-
25
- label: "Last name",
26
- name: "last_name",
27
- sortable: true,
28
- searchable: true,
29
- }, {
30
- label: "Email",
31
- name: "email",
32
- sortable: true,
33
- searchable: true,
34
- }, {
35
- label: "Phone",
36
- name: "phone",
37
- sortable: true,
38
- searchable: true,
39
- }, {
40
- label: "Join date",
41
- name: "join_date",
42
- sortable: true,
43
- searchable: true,
44
- searchType: "date"
45
- }
46
- ]
7
+ const columns = getTypeColumns("User", ["username", "first_name", "label_name", "email", "phone", "join_date"]);
47
8
  const status = ref("0");
48
9
  </script>
49
10
 
50
11
  <template>
51
12
  <l-page>
52
-
53
13
  <l-tabs v-model="status">
54
14
  <l-tab label="Active" name="0">
55
- <l-table
56
-
57
- @request="onRequest" :columns="columns" :actions="['view', 'edit', 'delete']">
15
+ <l-table row-key="user_id" @request="onRequest" :columns="columns" :actions="['view', 'edit', 'delete']">
58
16
  </l-table>
59
17
  </l-tab>
60
18
  <l-tab label="Inactive" name="1">
61
- <l-table @request="onRequest" :columns="columns" :actions="['view', 'edit', 'delete']">
19
+ <l-table row-key="user_id" @request="onRequest" :columns="columns" :actions="['view', 'edit', 'delete']">
62
20
  </l-table>
63
21
  </l-tab>
64
22
  </l-tabs>
65
-
66
23
  </l-page>
67
24
  </template>
@@ -1,53 +1,6 @@
1
1
  <script setup>
2
- const columns = [
3
- {
4
- label: "ID",
5
- name: "userlog_id",
6
- sortable: true,
7
- searchable: true,
8
- },
9
- {
10
- label: "User",
11
- name: "username",
12
- sortable: true,
13
- searchable: true,
14
- },
15
- {
16
- label: "Login time",
17
- name: "login_dt",
18
- sortable: true,
19
- searchable: true,
20
- searchType: "date",
21
- }, {
22
- label: "Logout time",
23
- name: "logout_dt",
24
- sortable: true,
25
- searchable: true,
26
- },
27
- {
28
- label: "Result",
29
- name: "result",
30
- sortable: true,
31
- searchable: true,
32
- searchType: "select",
33
- searchOptions: [
34
- {
35
- label: "SUCCESS",
36
- value: "SUCCESS"
37
- },
38
- {
39
- label: "FAIL",
40
- value: "FAIL"
41
- }
42
- ]
43
- }, {
44
- label: "User agent",
45
- name: "user_agent",
46
- sortable: true,
47
- searchable: true,
48
- },
49
- ]
50
-
2
+ import getTypeColumns from "../../lib/getTypeColumns";
3
+ const columns = getTypeColumns("UserLog", ["userlog_id", "username", "login_dt", "logout_dt", "result", "user_agent"]);
51
4
  </script>
52
5
  <template>
53
6
  <l-page>
@@ -7,8 +7,14 @@ import message_en from "./locales/en.json";
7
7
  import message_zh from "./locales/zh-hk.json";
8
8
  import routes from "./routes.mjs";
9
9
  localStorage.getItem("locale") || localStorage.setItem("locale", "en");
10
- import { useLight } from "./index.mjs";
10
+ import { useLight, defineType } from "./index.mjs";
11
+ import TypeUser from "./types/User.mjs";
12
+ import TypeUserLog from "./types/UserLog.mjs";
13
+ import TypeSystemValue from "./types/SystemValue.mjs";
11
14
  export default defineNuxtPlugin((nuxtApp) => {
15
+ defineType("User", TypeUser);
16
+ defineType("UserLog", TypeUserLog);
17
+ defineType("SystemValue", TypeSystemValue);
12
18
  nuxtApp.vueApp.config.errorHandler = (error) => {
13
19
  console.log(error);
14
20
  const light = useLight();
@@ -29,6 +29,11 @@ function System_index() {
29
29
  /* webpackChunkName: "System-index" */ './pages/System/index.vue'
30
30
  )
31
31
  }
32
+ function SystemValue_index() {
33
+ return import(
34
+ /* webpackChunkName: "SystemValue-index" */ './pages/SystemValue/index.vue'
35
+ )
36
+ }
32
37
  function Translate_index() {
33
38
  return import(
34
39
  /* webpackChunkName: "Translate-index" */ './pages/Translate/index.vue'
@@ -93,6 +98,11 @@ function System_menu_index() {
93
98
  /* webpackChunkName: "System-menu-index" */ './pages/System/menu/index.vue'
94
99
  )
95
100
  }
101
+ function SystemValue_add() {
102
+ return import(
103
+ /* webpackChunkName: "SystemValue-add" */ './pages/SystemValue/add.vue'
104
+ )
105
+ }
96
106
  function User_add() {
97
107
  return import(/* webpackChunkName: "User-add" */ './pages/User/add.vue')
98
108
  }
@@ -166,6 +176,11 @@ function Role__name_update_child() {
166
176
  /* webpackChunkName: "Role-name-update-child" */ './pages/Role/_name/update-child.vue'
167
177
  )
168
178
  }
179
+ function SystemValue__systemvalue_id_edit() {
180
+ return import(
181
+ /* webpackChunkName: "SystemValue-systemvalue_id-edit" */ './pages/SystemValue/_systemvalue_id/edit.vue'
182
+ )
183
+ }
169
184
  function User__user_id_change_password() {
170
185
  return import(
171
186
  /* webpackChunkName: "User-user_id-change-password" */ './pages/User/_user_id/change-password.vue'
@@ -223,6 +238,11 @@ export default [
223
238
  path: '/System',
224
239
  component: System_index,
225
240
  },
241
+ {
242
+ name: 'SystemValue',
243
+ path: '/SystemValue',
244
+ component: SystemValue_index,
245
+ },
226
246
  {
227
247
  name: 'Translate',
228
248
  path: '/Translate',
@@ -293,6 +313,11 @@ export default [
293
313
  path: '/System/menu',
294
314
  component: System_menu_index,
295
315
  },
316
+ {
317
+ name: 'SystemValue-add',
318
+ path: '/SystemValue/add',
319
+ component: SystemValue_add,
320
+ },
296
321
  {
297
322
  name: 'User-add',
298
323
  path: '/User/add',
@@ -369,6 +394,11 @@ export default [
369
394
  path: '/Role/:name/update-child',
370
395
  component: Role__name_update_child,
371
396
  },
397
+ {
398
+ name: 'SystemValue-systemvalue_id-edit',
399
+ path: '/SystemValue/:systemvalue_id/edit',
400
+ component: SystemValue__systemvalue_id_edit,
401
+ },
372
402
  {
373
403
  name: 'User-user_id-change-password',
374
404
  path: '/User/:user_id/change-password',
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ name: {
3
+ label: string;
4
+ sortable: boolean;
5
+ searchable: boolean;
6
+ };
7
+ value: {
8
+ label: string;
9
+ };
10
+ };
11
+ export default _default;
@@ -0,0 +1,10 @@
1
+ export default {
2
+ name: {
3
+ label: "Name",
4
+ sortable: true,
5
+ searchable: true
6
+ },
7
+ value: {
8
+ label: "Value"
9
+ }
10
+ };
@@ -0,0 +1,34 @@
1
+ declare const _default: {
2
+ username: {
3
+ label: string;
4
+ sortable: boolean;
5
+ searchable: boolean;
6
+ };
7
+ first_name: {
8
+ label: string;
9
+ sortable: boolean;
10
+ searchable: boolean;
11
+ };
12
+ last_name: {
13
+ label: string;
14
+ sortable: boolean;
15
+ searchable: boolean;
16
+ };
17
+ email: {
18
+ label: string;
19
+ sortable: boolean;
20
+ searchable: boolean;
21
+ };
22
+ phone: {
23
+ label: string;
24
+ sortable: boolean;
25
+ searchable: boolean;
26
+ };
27
+ join_date: {
28
+ label: string;
29
+ sortable: boolean;
30
+ searchable: boolean;
31
+ searchType: string;
32
+ };
33
+ };
34
+ export default _default;
@@ -0,0 +1,33 @@
1
+ export default {
2
+ username: {
3
+ label: "Username",
4
+ sortable: true,
5
+ searchable: true
6
+ },
7
+ first_name: {
8
+ label: "First Name",
9
+ sortable: true,
10
+ searchable: true
11
+ },
12
+ last_name: {
13
+ label: "Last Name",
14
+ sortable: true,
15
+ searchable: true
16
+ },
17
+ email: {
18
+ label: "Email",
19
+ sortable: true,
20
+ searchable: true
21
+ },
22
+ phone: {
23
+ label: "Phone",
24
+ sortable: true,
25
+ searchable: true
26
+ },
27
+ join_date: {
28
+ label: "Join Date",
29
+ sortable: true,
30
+ searchable: true,
31
+ searchType: "date"
32
+ }
33
+ };
@@ -0,0 +1,39 @@
1
+ declare const _default: {
2
+ userlog_id: {
3
+ label: string;
4
+ sortable: boolean;
5
+ searchable: boolean;
6
+ };
7
+ username: {
8
+ label: string;
9
+ sortable: boolean;
10
+ searchable: boolean;
11
+ };
12
+ login_dt: {
13
+ label: string;
14
+ sortable: boolean;
15
+ searchable: boolean;
16
+ searchType: string;
17
+ };
18
+ logout_dt: {
19
+ label: string;
20
+ sortable: boolean;
21
+ searchable: boolean;
22
+ };
23
+ result: {
24
+ label: string;
25
+ sortable: boolean;
26
+ searchable: boolean;
27
+ searchType: string;
28
+ searchOptions: {
29
+ label: string;
30
+ value: string;
31
+ }[];
32
+ };
33
+ user_agent: {
34
+ label: string;
35
+ sortable: boolean;
36
+ searchable: boolean;
37
+ };
38
+ };
39
+ export default _default;
@@ -0,0 +1,44 @@
1
+ export default {
2
+ userlog_id: {
3
+ label: "ID",
4
+ sortable: true,
5
+ searchable: true
6
+ },
7
+ username: {
8
+ label: "User",
9
+ sortable: true,
10
+ searchable: true
11
+ },
12
+ login_dt: {
13
+ label: "Login time",
14
+ sortable: true,
15
+ searchable: true,
16
+ searchType: "date"
17
+ },
18
+ logout_dt: {
19
+ label: "Logout time",
20
+ sortable: true,
21
+ searchable: true
22
+ },
23
+ result: {
24
+ label: "Result",
25
+ sortable: true,
26
+ searchable: true,
27
+ searchType: "select",
28
+ searchOptions: [
29
+ {
30
+ label: "SUCCESS",
31
+ value: "SUCCESS"
32
+ },
33
+ {
34
+ label: "FAIL",
35
+ value: "FAIL"
36
+ }
37
+ ]
38
+ },
39
+ user_agent: {
40
+ label: "User agent",
41
+ sortable: true,
42
+ searchable: true
43
+ }
44
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.77",
3
+ "version": "0.0.79",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",