@hostlink/nuxt-light 1.20.6 → 1.21.1

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.
@@ -53,7 +53,7 @@ const passwordExpiredProcess = (username: string, password: string) => {
53
53
  color: "positive",
54
54
  icon: "sym_o_check",
55
55
  });
56
- } catch (e) {
56
+ } catch (e: any) {
57
57
  $q.notify({
58
58
  message: e.message,
59
59
  color: "negative",
@@ -205,7 +205,7 @@ const bioLogin = async () => {
205
205
  }
206
206
  const handleGoogleCredentialResponse = async (response) => {
207
207
  try {
208
- await api.auth.googleLogin(response.credential);
208
+ await api.auth.google.login(response.credential);
209
209
  window.self.location.reload();
210
210
  } catch (e: any) {
211
211
  $q.notify({
@@ -255,7 +255,7 @@ onMounted(() => {
255
255
 
256
256
  const microsoftLogin = async (resp) => {
257
257
  try {
258
- await api.auth.microsoftLogin(resp.accessToken);
258
+ await api.auth.microsoft.login(resp.accessToken);
259
259
  emits("login");
260
260
  } catch (e) {
261
261
  $q.notify({
@@ -268,7 +268,7 @@ const microsoftLogin = async (resp) => {
268
268
  }
269
269
 
270
270
  const facebookLogin = (accessToken) => {
271
- m("facebookLogin", { access_token: accessToken }).then(() => {
271
+ api.auth.facebook.login(accessToken).then(() => {
272
272
  emits("login");
273
273
  }).catch((e) => {
274
274
  $q.notify({
@@ -1,79 +1,48 @@
1
1
  <script setup lang="ts">
2
2
 
3
- import { model } from "#imports";
4
- const props = defineProps(['id']);
5
-
6
- const obj = await model('User').get({ user_id: props.id }, ["user_id", "username", "first_name", "last_name", "email", "phone", "roles", 'status', 'join_date'])
3
+ import { collect, model } from "#imports";
4
+ const props = defineProps({
5
+ id: {
6
+ type: String,
7
+ required: true
8
+ }
9
+ });
10
+
11
+ const obj = await collect("User", {
12
+ user_id: true,
13
+ username: true,
14
+ first_name: true,
15
+ last_name: true,
16
+ email: true,
17
+ phone: true,
18
+ roles: true,
19
+ status: true,
20
+ join_date: true
21
+ }).where("user_id", props.id).first()
7
22
 
8
23
  </script>
9
24
  <template>
10
- <l-card class="q-mb-md">
25
+ <l-card>
11
26
  <q-card-section>
12
27
  <l-row>
13
- <l-col md="5">
28
+ <l-col md="6">
14
29
  <q-list dense separator>
15
- <q-item>
16
- <q-item-section>
17
- <q-item-label>{{ $t('Username') }}</q-item-label>
18
- </q-item-section>
19
- <q-item-section>{{ obj.username }}</q-item-section>
20
- </q-item>
21
- <q-item>
22
- <q-item-section>
23
- <q-item-label>{{ $t('First name') }}</q-item-label>
24
- </q-item-section>
25
- <q-item-section>{{ obj.first_name }}</q-item-section>
26
- </q-item>
27
- <q-item>
28
- <q-item-section>
29
- <q-item-label>{{ $t('Last name') }}</q-item-label>
30
- </q-item-section>
31
- <q-item-section>{{ obj.last_name }}</q-item-section>
32
- </q-item>
33
- <q-item>
34
- <q-item-section>
35
- <q-item-label>{{ $t('Email') }}</q-item-label>
36
- </q-item-section>
37
- <q-item-section>{{ obj.email }}</q-item-section>
38
- </q-item>
39
- <q-item>
40
- <q-item-section>
41
- <q-item-label>{{ $t('Phone') }}</q-item-label>
42
- </q-item-section>
43
- <q-item-section>{{ obj.phone }}</q-item-section>
44
- </q-item>
45
-
46
- <q-item>
47
- <q-item-section>
48
- <q-item-label>{{ $t('Roles') }}</q-item-label>
49
- </q-item-section>
50
- <q-item-section>
51
- <div class="q-gutter-xs float-left">
52
- <q-badge v-for="role in obj.roles" :key="role" :color="$light.color">{{ role }}</q-badge>
53
- </div>
54
- </q-item-section>
55
- </q-item>
56
-
57
- <q-item>
58
- <q-item-section>
59
- <q-item-label>{{ $t('Status') }}</q-item-label>
60
- </q-item-section>
61
- <q-item-section>{{ model('User').columns(["status"])[0].format(obj.status) }}</q-item-section>
62
- </q-item>
63
-
64
- <q-item>
65
- <q-item-section>
66
- <q-item-label>{{ $t('Join date') }}</q-item-label>
67
- </q-item-section>
68
- <q-item-section>{{ obj.join_date }}</q-item-section>
69
- </q-item>
30
+ <l-item label="Username">{{ obj.username }}</l-item>
31
+ <l-item label="First name">{{ obj.first_name }}</l-item>
32
+ <l-item label="Last name">{{ obj.last_name }}</l-item>
33
+ <l-item label="Email">{{ obj.email }}</l-item>
34
+ <l-item label="Phone">{{ obj.phone }}</l-item>
35
+ <l-item label="Roles">
36
+ <div class="q-gutter-xs float-left">
37
+ <q-badge v-for="role in obj.roles" :key="role" :color="$light.color">{{ role
38
+ }}</q-badge>
39
+ </div>
40
+ </l-item>
41
+ <l-item label="Status">{{ model('User').columns(["status"])[0].format(obj.status) }}</l-item>
42
+ <l-item label="Join date">{{ obj.join_date }}</l-item>
70
43
  </q-list>
71
-
72
-
73
44
  </l-col>
74
45
  </l-row>
75
-
76
46
  </q-card-section>
77
-
78
47
  </l-card>
79
48
  </template>
@@ -1,2 +1,3 @@
1
- declare const _default: () => Promise<any>;
1
+ import type { UserFields } from "@hostlink/light";
2
+ declare const _default: (fields?: UserFields) => Promise<any>;
2
3
  export default _default;
@@ -1,9 +1,16 @@
1
- import q from "./q.js";
2
- export default async () => {
1
+ import { default as api } from "./api.js";
2
+ export default async (fields = {
3
+ username: true,
4
+ first_name: true,
5
+ last_name: true,
6
+ roles: true
7
+ }) => {
3
8
  try {
4
- return await q("my", ["username", "first_name", "last_name", "roles"]);
9
+ const { my } = await api.query({
10
+ my: fields
11
+ });
12
+ return my;
5
13
  } catch (e) {
6
14
  return null;
7
15
  }
8
- return null;
9
16
  };
@@ -1,6 +1,7 @@
1
+ import { toQuery } from "@hostlink/light";
1
2
  import { useRoute } from "vue-router";
2
- import loadObject from "./loadObject.js";
3
3
  import { default as getModelField } from "./getModelField.js";
4
+ import { collect } from "#imports";
4
5
  export default async function(fields = []) {
5
6
  let route = useRoute();
6
7
  if (!route.name) {
@@ -8,8 +9,6 @@ export default async function(fields = []) {
8
9
  }
9
10
  const [module, id_name] = route.name.split("-");
10
11
  const id = parseInt(route.params[id_name]);
11
- const filters = {};
12
- filters[id_name] = id;
13
12
  if (fields instanceof Object && !(fields instanceof Array)) {
14
13
  fields = [fields];
15
14
  }
@@ -25,5 +24,5 @@ export default async function(fields = []) {
25
24
  }
26
25
  return field;
27
26
  });
28
- return await loadObject(module, filters, fs);
27
+ return await collect(module, toQuery(fs)).where(id_name, id).first();
29
28
  }
@@ -7,8 +7,6 @@ export { default as list } from "./list.js";
7
7
  export { default as m } from "./m.js";
8
8
  export { default as q } from "./q.js";
9
9
  export { default as t } from "./t.js";
10
- export { default as listObject } from "./listObject.js";
11
- export { default as loadObject } from "./loadObject.js";
12
10
  export { default as isGranted } from "./isGranted.js";
13
11
  export { default as GQLFieldBuilder } from "./GQLFieldBuilder.js";
14
12
  export { default as getModelField } from "./getModelField.js";
@@ -9,8 +9,6 @@ export { default as list } from "./list.js";
9
9
  export { default as m } from "./m.js";
10
10
  export { default as q } from "./q.js";
11
11
  export { default as t } from "./t.js";
12
- export { default as listObject } from "./listObject.js";
13
- export { default as loadObject } from "./loadObject.js";
14
12
  export { default as isGranted } from "./isGranted.js";
15
13
  export { default as GQLFieldBuilder } from "./GQLFieldBuilder.js";
16
14
  export { default as getModelField } from "./getModelField.js";
@@ -1,4 +1,13 @@
1
+ import { default as api } from "./api.js";
1
2
  export default async function isGranted(right) {
2
- const my = await q("my", [f("granted", { right }, [])]);
3
+ const { my } = await api.query({
4
+ my: {
5
+ granted: {
6
+ __args: {
7
+ right
8
+ }
9
+ }
10
+ }
11
+ });
3
12
  return my.granted;
4
13
  }
@@ -1,18 +1,9 @@
1
1
  <script setup>
2
- import { model, collect, api } from "#imports"
3
- import { ref } from 'vue'
2
+ import { model } from "#imports"
4
3
  const columns = model("MailLog").columns(["maillog_id", "from", "to", "subject", "created_time"])
5
4
  </script>
6
-
7
5
  <template>
8
6
  <l-page>
9
- <q-dialog v-model="show" full-width>
10
- <l-card title="Mail content">
11
- <q-card-section>
12
- <iframe width="100%" height="500px" :srcdoc="content" frameborder="0"></iframe>
13
- </q-card-section>
14
- </l-card>
15
- </q-dialog>
16
7
  <l-table row-key="maillog_id" @request-data="$event.loadObjects('MailLog', {}, ['body'])" :columns="columns"
17
8
  sort-by="maillog_id:desc">
18
9
 
@@ -4,16 +4,18 @@ import { m, api } from '#imports'
4
4
  import { useI18n } from 'vue-i18n';
5
5
  const { t } = useI18n();
6
6
 
7
- const { app, listRole: roles } = await api.query({
7
+ const { app } = await api.query({
8
8
  app: {
9
- permissions: true
10
- },
11
- listRole: {
12
- name: true,
13
- permissions: true
9
+ permissions: true,
10
+ roles: {
11
+ name: true,
12
+ permissions: true
13
+ }
14
14
  }
15
15
  })
16
16
 
17
+ const roles = app.roles;
18
+
17
19
  const columns = [{
18
20
  label: t("Permission"),
19
21
  field: "permission",
@@ -6,18 +6,17 @@ const obj = reactive({
6
6
  roles: []
7
7
  });
8
8
 
9
- const { app, listRole } = await api.query({
9
+ const { app } = await api.query({
10
10
  app: {
11
- permissions: true
12
- },
13
- listRole: {
14
- name: true,
15
- permissions: true
11
+ permissions: true,
12
+ roles: {
13
+ name: true,
14
+ permissions: true
15
+ }
16
16
  }
17
-
18
17
  })
19
18
 
20
- let roles = listRole.map((role) => {
19
+ let roles = app.roles.map((role) => {
21
20
  return {
22
21
  label: role.name,
23
22
  value: role.name,
@@ -27,7 +26,7 @@ let roles = listRole.map((role) => {
27
26
  const submit = () => {
28
27
 
29
28
  //filter roles
30
- let e = listRole.filter((role) => {
29
+ let e = app.roles.filter((role) => {
31
30
  return obj.roles.indexOf(role.name) != -1;
32
31
  });
33
32
 
@@ -14,6 +14,7 @@ const columns = [
14
14
  }
15
15
  ]
16
16
 
17
+
17
18
  </script>
18
19
  <template>
19
20
  <l-page>
@@ -1,7 +1,13 @@
1
1
  <script setup>
2
2
  import { ref } from 'vue';
3
3
  import { m, q } from "#imports"
4
- const { listFileSystem } = await q({ listFileSystem: true });
4
+ const { app, listFileSystem } = await q({
5
+ app: {
6
+ driveTypes: true
7
+ },
8
+ listFileSystem: true
9
+ });
10
+
5
11
  const items = ref(listFileSystem)
6
12
  const dialog = ref(false)
7
13
  const value = ref({})
@@ -58,10 +64,12 @@ const columns = [
58
64
  ]
59
65
  </script>
60
66
  <template>
67
+
61
68
  <l-page gutter="xs">
62
69
  <template #header>
63
70
  <l-btn label="Add" icon="sym_o_add" @click="dialog = true"></l-btn>
64
71
  </template>
72
+
65
73
  <q-dialog v-model="dialog" persistent>
66
74
  <q-card style="width: 500px;">
67
75
 
@@ -74,18 +82,23 @@ const columns = [
74
82
  <FormKit type="l-form" :value="value" @submit="onSubmit" #default="{ value }">
75
83
  <FormKit type="l-input" label="Name" name="name" validation="required"></FormKit>
76
84
  <FormKit type="l-select" label="Type" name="type" validation="required" :options="[
77
- { label: 'Local', value: 'local' },
78
- { label: 'S3', value: 'S3' },
79
- { label: 'HostLink storage', value: 'hostlink' },
80
- { label: 'Aliyun OSS', value: 'aliyun-oss' }
85
+ { label: 'Local', value: 'local', disable: !app.driveTypes.includes('local') },
86
+ { label: 'S3', value: 's3', disable: !app.driveTypes.includes('s3') },
87
+ { label: 'HostLink storage', value: 'hostlink', disable: !app.driveTypes.includes('hostlink') },
88
+ { label: 'Aliyun OSS', value: 'aliyun-oss', disable: !app.driveTypes.includes('aliyun-oss') },
81
89
  ]"></FormKit>
82
90
 
83
91
  <FormKit type="group" name="data">
92
+ <FormKit type="l-input" label="Url" name="url"
93
+ hint="URL is used to generate the full URL of the file.">
94
+ </FormKit>
95
+
84
96
  <template v-if="value.type == 'local'">
85
- <FormKit type="l-input" label="Location" name="location" validation="required"></FormKit>
97
+ <FormKit type="l-input" label="Location" name="location" validation="required"
98
+ hint="Location is the path to the directory where the files are stored."></FormKit>
86
99
  </template>
87
100
 
88
- <template v-if="value.type == 'S3'">
101
+ <template v-if="value.type == 's3'">
89
102
  <FormKit type="l-input" label="Bucket" name="bucket" validation="required"></FormKit>
90
103
  <FormKit type="l-input" label="Access Key" name="accessKey" validation="required"></FormKit>
91
104
  <FormKit type="l-input" label="Secret Key" name="secretKey" validation="required"></FormKit>
@@ -1,21 +1,22 @@
1
1
  <script setup>
2
2
  import { useQuasar } from "quasar";
3
- import { ref, reactive } from "vue"
4
- import { refreshNuxtData } from "#imports";
3
+ import { reactive } from "vue"
4
+
5
5
  import { q, m, getCurrentUser, api } from '#imports'
6
- const { app, listWebAuthn: data } = reactive(await q({
6
+ const { app, my: { webAuthn } } = reactive(await q({
7
7
  app: {
8
8
  hasBioAuth: true
9
9
  },
10
- listWebAuthn: {
11
- uuid: true,
12
- ip: true,
13
- user_agent: true,
14
- createdTime: true
10
+ my: {
11
+ webAuthn: {
12
+ uuid: true,
13
+ ip: true,
14
+ user_agent: true,
15
+ createdTime: true
16
+ }
15
17
  }
16
18
  }));
17
19
 
18
-
19
20
  const quasar = useQuasar();
20
21
 
21
22
  const register = async () => {
@@ -25,19 +26,21 @@ const register = async () => {
25
26
  localStorage.setItem("username", user.username);
26
27
 
27
28
  //refresh data
28
- const { listWebAuthn: d } = await q({
29
- listWebAuthn: {
30
- uuid: true,
31
- ip: true,
32
- user_agent: true,
33
- createdTime: true
29
+ const { my } = await q({
30
+ my: {
31
+ webAuthn: {
32
+ uuid: true,
33
+ ip: true,
34
+ user_agent: true,
35
+ createdTime: true
36
+ }
34
37
  }
35
38
  });
36
39
 
37
40
  //clear data
38
- data.splice(0, data.length);
41
+ webAuthn.splice(0, webAuthn.length);
39
42
 
40
- data.push(...d);
43
+ webAuthn.push(...my.webAuthn);
41
44
 
42
45
  } catch (e) {
43
46
  quasar.dialog({
@@ -83,7 +86,7 @@ const deleteItem = async (uuid) => {
83
86
  }).onOk(async () => {
84
87
  await m("deleteWebAuthn", { uuid });
85
88
  //remove from data
86
- data.splice(data.findIndex(item => item.uuid === uuid), 1);
89
+ webAuthn.splice(webAuthn.findIndex(item => item.uuid === uuid), 1);
87
90
  })
88
91
  }
89
92
 
@@ -100,7 +103,7 @@ const deleteItem = async (uuid) => {
100
103
  <l-btn label="Register" @click="register" icon="sym_o_add"></l-btn>
101
104
  </q-toolbar>
102
105
 
103
- <q-table :rows="data" :columns="columns" dense :rows-per-page-options="[0]">
106
+ <q-table :rows="webAuthn" :columns="columns" dense :rows-per-page-options="[0]">
104
107
  <template #body-cell-action="props">
105
108
  <q-td :props="props" auto-width>
106
109
  <q-btn @click="deleteItem(props.row.uuid)" icon="sym_o_delete" round flat dense></q-btn>
@@ -1,7 +1,7 @@
1
1
  <script setup>
2
2
  import { reactive, onMounted, nextTick } from "vue"
3
3
  import { useQuasar } from "quasar";
4
- import { q, m, useLight } from '#imports'
4
+ import { q, m, useLight, api } from '#imports'
5
5
  import { useI18n } from 'vue-i18n'
6
6
 
7
7
  const light = useLight()
@@ -20,13 +20,13 @@ let { app, my } = await q({
20
20
  }
21
21
  })
22
22
 
23
+
23
24
  const $q = useQuasar();
24
25
  my = reactive(my);
25
26
 
26
27
  const handleGoogleCredentialResponse = async (response) => {
27
28
  try {
28
- await m("googleRegister", { credential: response.credential })
29
-
29
+ await api.auth.google.register(response.credential);
30
30
  const resp = await q("my", ["gmail"]);
31
31
  my.google = resp.google;
32
32
 
@@ -91,14 +91,12 @@ const onUnlink = async () => {
91
91
  ok: "Yes",
92
92
  cancel: "No",
93
93
  }).onOk(async () => {
94
- await m("unlinkGoogle");
94
+ await api.auth.google.unlink();
95
95
  my.gmail = null;
96
96
  window.location.reload();
97
97
  })
98
98
  }
99
99
 
100
- const ms = reactive({});
101
-
102
100
  const onUnlinkMicrosoft = async () => {
103
101
  //confirm
104
102
  light.dialog({
@@ -108,7 +106,7 @@ const onUnlinkMicrosoft = async () => {
108
106
  ok: "Yes",
109
107
  cancel: "No",
110
108
  }).onOk(async () => {
111
- await m("unlinkMicrosoft");
109
+ await api.auth.microsoft.unlink();
112
110
  my.microsoft = null;
113
111
  window.location.reload();
114
112
  })
@@ -116,7 +114,7 @@ const onUnlinkMicrosoft = async () => {
116
114
 
117
115
  const onLinkMicrosoft = async (resp) => {
118
116
  try {
119
- await m("microsoftRegister", { account_id: resp.account.localAccountId });
117
+ await api.auth.microsoft.register(resp.account.localAccountId);
120
118
  light.notify({
121
119
  message: "Microsoft account linked",
122
120
  color: "positive",
@@ -131,9 +129,9 @@ const onLinkMicrosoft = async (resp) => {
131
129
  }
132
130
  }
133
131
 
134
- const onLinkFacebook = (accessToken) => {
132
+ const onLinkFacebook = async (accessToken) => {
135
133
  try {
136
- m("facebookRegister", { access_token: accessToken })
134
+ await api.auth.facebook.register(accessToken);
137
135
  light.notify({
138
136
  message: "Facebook account linked",
139
137
  color: "positive",
@@ -156,7 +154,7 @@ const onUnlinkFacebook = async () => {
156
154
  ok: "Yes",
157
155
  cancel: "No",
158
156
  }).onOk(async () => {
159
- await m("unlinkFacebook");
157
+ await api.auth.facebook.unlink();
160
158
  my.facebook = null;
161
159
  window.location.reload();
162
160
  })
@@ -25,8 +25,12 @@ export default defineNuxtPlugin((nuxtApp) => {
25
25
  api.models.create("SystemValue", TypeSystemValue);
26
26
  api.models.create("MailLog", TypeMailLog);
27
27
  api.models.create("EventLog", TypeEventLog);
28
- api.model("MailLog").setDataPath("app.mailLogs");
29
- api.model("EventLog").setDataPath("app.eventLogs");
28
+ api.model("MailLog").setDataPath("app.listMailLog");
29
+ api.model("EventLog").setDataPath("app.listEventLog");
30
+ api.model("User").setDataPath("app.listUser");
31
+ api.model("UserLog").setDataPath("app.listUserLog");
32
+ api.model("SystemValue").setDataPath("app.listSystemValue");
33
+ api.model("Permission").setDataPath("app.listPermission");
30
34
  nuxtApp.vueApp.config.errorHandler = (err, instance, info) => {
31
35
  console.log(err);
32
36
  const light = useLight();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.20.6",
3
+ "version": "1.21.1",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "@azure/msal-browser": "^3.26.1",
36
36
  "@formkit/drag-and-drop": "^0.1.6",
37
- "@hostlink/light": "^2.3.7",
37
+ "@hostlink/light": "^2.5.2",
38
38
  "@nuxt/kit": "^3.7.4",
39
39
  "@nuxt/module-builder": "^0.8.3",
40
40
  "@quasar/extras": "^1.16.11",
@@ -1,2 +0,0 @@
1
- import type { Fields } from "@hostlink/light";
2
- export default function listObject(name: string, filters: {} | undefined, sort: string, offset: number, limit: number, fields?: Fields): Promise<any>;
@@ -1,10 +0,0 @@
1
- import list from "./list.js";
2
- export default async function listObject(name, filters = {}, sort, offset, limit, fields = []) {
3
- const resp = await list(name, {
4
- filters,
5
- sort,
6
- offset,
7
- limit
8
- }, fields);
9
- return resp.data;
10
- }
@@ -1 +0,0 @@
1
- export default function (module: string, filters: Object, fields?: Array<string | Object>): Promise<any>;
@@ -1,10 +0,0 @@
1
- import list from "./list.js";
2
- export default async function(module, filters, fields = []) {
3
- let { data } = await list(module, {
4
- filters
5
- }, fields);
6
- if (data.length > 0) {
7
- return data[0];
8
- }
9
- return null;
10
- }