@hostlink/nuxt-light 0.0.11 → 0.0.13

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 (34) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/l-add-btn.vue +1 -1
  3. package/dist/runtime/components/l-date-picker.vue +1 -0
  4. package/dist/runtime/components/l-file-manager.vue +2 -1
  5. package/dist/runtime/components/l-input.vue +1 -0
  6. package/dist/runtime/components/l-select.vue +3 -2
  7. package/dist/runtime/lib/list.d.ts +1 -1
  8. package/dist/runtime/lib/list.mjs +6 -6
  9. package/dist/runtime/lib/q.d.ts +1 -1
  10. package/dist/runtime/lib/q.mjs +29 -6
  11. package/dist/runtime/pages/EventLog/_eventlog_id/view.vue +1 -2
  12. package/dist/runtime/pages/EventLog/index.vue +3 -1
  13. package/dist/runtime/pages/MailLog/index.vue +1 -0
  14. package/dist/runtime/pages/Permission/add.vue +3 -0
  15. package/dist/runtime/pages/Permission/all.vue +2 -0
  16. package/dist/runtime/pages/Permission/index.vue +1 -0
  17. package/dist/runtime/pages/Role/add.vue +2 -0
  18. package/dist/runtime/pages/Role/index.vue +3 -0
  19. package/dist/runtime/pages/System/database/table.vue +4 -3
  20. package/dist/runtime/pages/System/index.vue +1 -0
  21. package/dist/runtime/pages/System/mailtest.vue +2 -0
  22. package/dist/runtime/pages/System/package.vue +2 -1
  23. package/dist/runtime/pages/System/phpinfo.vue +3 -2
  24. package/dist/runtime/pages/System/setting.vue +8 -2
  25. package/dist/runtime/pages/System/view_as.vue +6 -1
  26. package/dist/runtime/pages/User/_user_id/change-password.vue +3 -0
  27. package/dist/runtime/pages/User/_user_id/edit.vue +1 -0
  28. package/dist/runtime/pages/User/_user_id/view.vue +2 -1
  29. package/dist/runtime/pages/User/add.vue +2 -0
  30. package/dist/runtime/pages/User/profile.vue +1 -0
  31. package/dist/runtime/pages/User/update-password.vue +3 -0
  32. package/dist/runtime/pages/UserLog/index.vue +1 -0
  33. package/dist/runtime/pages/logout.vue +2 -5
  34. package/package.json +2 -2
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "0.0.11"
4
+ "version": "0.0.13"
5
5
  }
@@ -16,7 +16,7 @@ const to = props.to ?? relativePath + "/add";
16
16
 
17
17
  </script>
18
18
  <template>
19
- <q-btn rounded outline color="primary" icon="sym_o_add" :to="to">{{ label }}
19
+ <q-btn rounded outline color="primary" icon="sym_o_add" :to="to" :label="label">
20
20
  <q-tooltip>
21
21
  {{ label }}
22
22
  </q-tooltip>
@@ -1,5 +1,6 @@
1
1
  <script setup>
2
2
  import { ref, computed } from "vue";
3
+ import { t } from "../light";
3
4
  const props = defineProps({
4
5
  modelValue: {
5
6
  type: [String, Object],
@@ -1,8 +1,9 @@
1
1
  <script setup>
2
2
  import { VariableType } from "json-to-graphql-query";
3
3
  import { useI18n } from "vue-i18n";
4
- import { ref } from 'vue';
4
+ import { ref, watch, computed } from 'vue';
5
5
  import { useQuasar } from 'quasar';
6
+ import { q } from "../light";
6
7
 
7
8
  const quasar = useQuasar();
8
9
  const emit = defineEmits(["input", "close"]);
@@ -1,5 +1,6 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
+ import { t } from "../light";
3
4
 
4
5
  const props = defineProps({
5
6
  modelValue: {
@@ -1,5 +1,6 @@
1
1
  <script setup>
2
2
  import { computed, ref } from "vue";
3
+ import { t } from "../light"
3
4
  const props = defineProps({
4
5
 
5
6
  rules: {
@@ -28,10 +29,10 @@ const props = defineProps({
28
29
 
29
30
  if (props.required) {
30
31
  props.rules.push((val) => {
31
- if(isNumber(val)){
32
+ if (isNumber(val)) {
32
33
  return;
33
34
  }
34
-
35
+
35
36
  return !!val || 'Required.'
36
37
  });
37
38
  }
@@ -1 +1 @@
1
- export default function listData(name: string, props?: any, fields?: Array<string>): Promise<any>;
1
+ export default function list(name: string, props?: any, fields?: Array<string>): Promise<any>;
@@ -1,6 +1,6 @@
1
1
  import q from "./q.mjs";
2
2
  import f from "./f.mjs";
3
- export default async function listData(name, props = {}, fields = []) {
3
+ export default async function list(name, props = {}, fields = []) {
4
4
  let v = {};
5
5
  if (props.sort) {
6
6
  v.sort = props.sort;
@@ -25,11 +25,11 @@ export default async function listData(name, props = {}, fields = []) {
25
25
  let data = await q(`list${name}`, v, [f("data", offset_limit, fs), f("meta", ["total", "key", "name"])]);
26
26
  if (props.done) {
27
27
  props.done({
28
- rows: data[`list${name}`].data,
29
- total: data[`list${name}`].meta.total,
30
- key: data[`list${name}`].meta.key,
31
- name: data[`list${name}`].meta.name
28
+ rows: data.data,
29
+ total: data.meta.total,
30
+ key: data.meta.key,
31
+ name: data.meta.name
32
32
  });
33
33
  }
34
- return data[`list${name}`][`data`];
34
+ return data.data;
35
35
  }
@@ -1 +1 @@
1
- export default function (operation: string, args: any, fields?: Array<any>): Promise<any>;
1
+ export default function (operation: string | object, args: any, fields?: Array<any>): Promise<any>;
@@ -1,19 +1,42 @@
1
1
  import axios from "axios";
2
2
  import f from "./f.mjs";
3
+ import { jsonToGraphQLQuery } from "json-to-graphql-query";
4
+ const mapping = function(obj) {
5
+ let q = {};
6
+ Object.entries(obj).forEach(([key, value]) => {
7
+ if (value instanceof Array) {
8
+ q[key] = {};
9
+ value.forEach((subField) => {
10
+ q[key][subField] = true;
11
+ });
12
+ } else {
13
+ q[key] = mapping(value);
14
+ }
15
+ });
16
+ return q;
17
+ };
3
18
  export default async function(operation, args, fields = []) {
4
- if (arguments.length === 2) {
5
- fields = args;
6
- args = {};
7
- }
8
- let service = axios.create({
19
+ const service = axios.create({
9
20
  withCredentials: true
10
21
  });
11
- const query = f(operation, args, fields);
22
+ let query;
23
+ if (operation instanceof Object) {
24
+ query = jsonToGraphQLQuery(mapping(operation));
25
+ } else {
26
+ if (arguments.length === 2) {
27
+ fields = args;
28
+ args = {};
29
+ }
30
+ query = f(operation, args, fields);
31
+ }
12
32
  const resp = (await service.post("/api/", {
13
33
  query: `{ ${query} }`
14
34
  })).data;
15
35
  if (resp.errors) {
16
36
  throw resp.errors[0].message;
17
37
  }
38
+ if (operation instanceof Object) {
39
+ return resp.data;
40
+ }
18
41
  return resp.data[operation];
19
42
  }
@@ -1,7 +1,6 @@
1
1
  <script setup>
2
+ import { getObject } from "../../light"
2
3
  const obj = await getObject(["eventlog_id", "class", "id", "action", "created_time", "username"]);
3
-
4
-
5
4
  </script>
6
5
  <template>
7
6
  <l-page>
@@ -1,4 +1,6 @@
1
1
  <script setup>
2
+ import { listData } from "../../light"
3
+
2
4
  const onRequest = async (params) => {
3
5
  listData("EventLog", params, ["canRead"]);
4
6
  };
@@ -50,7 +52,7 @@ const columns = [
50
52
  <template>
51
53
  <l-page>
52
54
  <l-table @request="onRequest" :columns="columns" sort-by="eventlog_id:desc" :show-actions="['view']">
53
-
55
+
54
56
  </l-table>
55
57
  </l-page>
56
58
  </template>
@@ -1,4 +1,5 @@
1
1
  <script setup>
2
+ import { listData } from "../../light"
2
3
  const onRequest = async (params) => {
3
4
  listData("MailLog", params, ["body"]);
4
5
  };
@@ -1,4 +1,7 @@
1
1
  <script setup>
2
+ import { reactive } from 'vue'
3
+ import { q } from "../../light"
4
+ import { useRouter } from "vue-router"
2
5
  const obj = reactive({
3
6
  roles: []
4
7
  });
@@ -1,4 +1,6 @@
1
1
  <script setup>
2
+ import { reactive } from 'vue'
3
+ import { q, m } from "../../light"
2
4
  const app = await q("app", ["permissions"])
3
5
 
4
6
  const roles = await q("listRole", ["name", "permissions"])
@@ -1,4 +1,5 @@
1
1
  <script setup>
2
+ import { listData } from "../../light";
2
3
  const onRequest = async (params) => {
3
4
  listData("Permission", params, ["permission_id"]);
4
5
  };
@@ -1,4 +1,6 @@
1
1
  <script setup>
2
+ import { reactive } from 'vue'
3
+ import { q } from "../../light"
2
4
  const obj = reactive({
3
5
  childs: ["Users"],
4
6
  })
@@ -1,4 +1,7 @@
1
1
  <script setup>
2
+ import { useQuasar } from 'quasar'
3
+ import { q, m } from "../../light"
4
+ import { ref } from "vue"
2
5
 
3
6
  const qua = useQuasar();
4
7
 
@@ -1,15 +1,16 @@
1
1
  <script setup>
2
- const { database } = await q("system", [f("database", ["table"])])
2
+ import { q } from "../../../light"
3
+ const { system: { database } } = await q({ system: { database: ["table"] } })
3
4
  </script>
4
5
  <template>
5
6
  <l-page>
6
7
  <q-card flat bordered>
7
- <q-list bordered class="rounded-borders" separator >
8
+ <q-list bordered class="rounded-borders" separator>
8
9
  <q-expansion-item :label="table.name" v-for="table in database.table" expand-separator>
9
10
  <div class=" q-ma-sm">
10
11
  <q-table :rows="table.columns" :rows-per-page-options="[0]" hide-pagination flat bordered></q-table>
11
12
  </div>
12
-
13
+
13
14
  </q-expansion-item>
14
15
  </q-list>
15
16
  </q-card>
@@ -1,4 +1,5 @@
1
1
  <script setup>
2
+ import { q } from "../../light"
2
3
  const system = await q("system", ["server"])
3
4
  </script>
4
5
  <template>
@@ -1,4 +1,6 @@
1
1
  <script setup>
2
+ import { reactive } from 'vue'
3
+ import { m } from "../../light"
2
4
  const obj = reactive({})
3
5
 
4
6
  const onSave = async () => {
@@ -1,5 +1,6 @@
1
1
  <script setup>
2
- const system = await q("system", ["package"])
2
+ import { q } from "../../light"
3
+ const { system } = await q({ system: ["package"] })
3
4
  </script>
4
5
  <template>
5
6
  <l-page>
@@ -1,8 +1,9 @@
1
1
  <script setup>
2
- const app = await q("system", ["phpInfo"])
2
+ import { q } from "../../light"
3
+ const { system } = await q({ system: ["phpInfo"] })
3
4
  </script>
4
5
  <template>
5
6
  <l-page>
6
- <iframe :srcdoc="app.phpInfo" style="height: 700px;" class="full-width no-border"></iframe>
7
+ <iframe :srcdoc="system.phpInfo" style="height: 700px;" class="full-width no-border"></iframe>
7
8
  </l-page>
8
9
  </template>
@@ -1,8 +1,13 @@
1
1
  <script setup>
2
+ import { useQuasar } from 'quasar'
3
+ import { useRouter } from 'vue-router'
4
+ import { reactive } from "vue"
5
+ import { q, m } from "../../light"
6
+
2
7
  const router = useRouter()
3
8
  const que = useQuasar()
4
9
 
5
- const app = await q("app", [f("config", ["name", "value"])])
10
+ const { app } = await q({ app: { config: ["name", "value"] } })
6
11
 
7
12
  //const system = await q("system", ["passwordPolicy"])
8
13
 
@@ -49,6 +54,7 @@ const onSave = async () => {
49
54
  <template>
50
55
  <l-page>
51
56
 
57
+ {{ test }}
52
58
  <l-form @save="onSave">
53
59
  <l-input label="Company" v-model="obj.company"></l-input>
54
60
  <l-input label="Company logo" v-model="obj.company_logo"></l-input>
@@ -63,6 +69,6 @@ const onSave = async () => {
63
69
  false-value="0"></q-checkbox>
64
70
  </q-field>
65
71
 
66
- </l-form>
72
+ </l-form>
67
73
  </l-page>
68
74
  </template>
@@ -1,4 +1,7 @@
1
1
  <script setup>
2
+ import { list } from "../../light"
3
+ import { useRouter } from "vue-router"
4
+
2
5
  let users = await list("User", {
3
6
  fields: [
4
7
  "user_id", "username", "name", "roles"
@@ -41,10 +44,12 @@ const onCickView = async (id) => {
41
44
  </script>
42
45
  <template>
43
46
  <l-page>
47
+
44
48
  <q-table flat :columns="columns" :rows="users">
45
49
  <template #body-cell-view="props">
46
50
  <q-td :props="props">
47
- <q-btn rounded outline color="primary" @click="onCickView(props.row.user_id)">view</q-btn>
51
+ <q-btn rounded outline color="primary" @click="onCickView(props.row.user_id)" label="view"
52
+ icon="sym_o_search"></q-btn>
48
53
  </q-td>
49
54
 
50
55
  </template>
@@ -1,4 +1,7 @@
1
1
  <script setup>
2
+ import { q } from "../../../light"
3
+ import { useRouter, useRoute } from "vue-router"
4
+ import { reactive } from "vue"
2
5
  const system = await q("system", ["passwordPolicy"]);
3
6
  const rules = system.passwordPolicy.map((rule) => {
4
7
  let s = rule.split(":");
@@ -1,4 +1,5 @@
1
1
  <script setup>
2
+ import { reacttive } from 'vue'
2
3
  const obj = reactive(await getObject(["first_name", "last_name", "email", "phone",
3
4
  "addr1", "addr2", "addr3", "join_date", "expiry_date", "status", "language", "default_page"
4
5
  ]))
@@ -1,4 +1,5 @@
1
1
  <script setup>
2
+ import { getObject } from "../../../light";
2
3
  const obj = await getObject(["username", "first_name", "last_name", "email", "phone"]);
3
4
 
4
5
  </script>
@@ -6,7 +7,7 @@ const obj = await getObject(["username", "first_name", "last_name", "email", "ph
6
7
  <template>
7
8
  <l-page>
8
9
  <template #header>
9
- <l-btn to="change-password" icon="sym_o_key" permission="user.changePassword">Change password</l-btn>
10
+ <l-btn to="change-password" icon="sym_o_key" permission="user.changePassword" label="Change password"></l-btn>
10
11
  </template>
11
12
  <l-card>
12
13
  <l-list>
@@ -1,4 +1,6 @@
1
1
  <script setup>
2
+ import { reactive } from "vue"
3
+ import { q } from "../../light"
2
4
  const obj = reactive({
3
5
  roles: ['Users'],
4
6
  status: 'Active',
@@ -1,4 +1,5 @@
1
1
  <script setup>
2
+ import { q } from "../../light"
2
3
  const my = await q("my", ["username", "first_name", "last_name", "email", "phone", "roles", "addr1", "addr2", "addr3", "join_date"])
3
4
 
4
5
  </script>
@@ -1,4 +1,7 @@
1
1
  <script setup>
2
+ import { useQuasar } from 'quasar';
3
+ import { useRouter } from 'vue-router';
4
+ import { router } from "vue-router"
2
5
 
3
6
  const obj = reactive({
4
7
  old_password: "",
@@ -1,4 +1,5 @@
1
1
  <script setup>
2
+ import { listData } from "../../light";
2
3
  const onRequest = async (params) => {
3
4
  listData("UserLog", params);
4
5
  };
@@ -1,9 +1,6 @@
1
1
  <script setup>
2
-
3
- await mutation({
4
- operation: "logout"
5
- });
6
-
2
+ import { m } from "../light";
3
+ await m("logout");
7
4
  window.self.location = "/";
8
5
 
9
6
  </script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.11",
4
- "description": "My new Nuxt module",
3
+ "version": "0.0.13",
4
+ "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",
7
7
  "type": "module",