@hostlink/nuxt-light 0.0.51 → 0.0.53

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/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "0.0.51"
4
+ "version": "0.0.53"
5
5
  }
@@ -19,6 +19,8 @@ const tt = await q({
19
19
  my: ["styles", "language", f('granted_storage:granted', { right: "system.storage" }, [])],
20
20
  })
21
21
 
22
+ const allTranslate = ref(await q("allTranslate", []))
23
+
22
24
  let app = tt.app
23
25
  let my = tt.my
24
26
  let system = null
@@ -33,6 +35,15 @@ const menus = ref(app.menus)
33
35
  const i18n = useI18n();
34
36
  i18n.locale = my.language || 'en';
35
37
 
38
+ const messages = i18n.messages.value[i18n.locale];
39
+
40
+ for (const translate of allTranslate.value) {
41
+ messages[translate.name] = translate[my.language]
42
+ }
43
+
44
+ i18n.setLocaleMessage(i18n.locale, messages);
45
+
46
+
36
47
  const user = ref(await getCurrentUser());
37
48
 
38
49
  const leftDrawerOpen = ref(false)
@@ -7,4 +7,4 @@ interface Light {
7
7
  getVersion(): string;
8
8
  }
9
9
  export declare function useLight(): Light;
10
- export { notify, addObject, f, getApiUrl, getCurrentUser, getObject, id, list, listData, login, m, mutation, q, removeObject, t, updateObject, getID, deleteObject, listObject } from "./lib";
10
+ export { notify, addObject, f, getApiUrl, getCurrentUser, getObject, id, list, listData, login, m, mutation, q, removeObject, t, updateObject, getID, deleteObject, listObject, getApiBase } from "./lib";
@@ -48,5 +48,6 @@ export {
48
48
  updateObject,
49
49
  getID,
50
50
  deleteObject,
51
- listObject
51
+ listObject,
52
+ getApiBase
52
53
  } from "./lib/index.mjs";
@@ -1,4 +1,5 @@
1
+ import { getApiBase } from "./index.mjs";
1
2
  export default function getApiUrl(url, params) {
2
3
  const urlParams = new URLSearchParams(params).toString();
3
- return `/api/${url}?${urlParams}`;
4
+ return getApiBase() + `${url}?${urlParams}`;
4
5
  }
@@ -18,4 +18,5 @@ import listObject from "./listObject";
18
18
  import isGranted from "./isGranted";
19
19
  declare const notify: (message: string, color?: string) => void;
20
20
  import getID from "./getID";
21
- export { addObject, f, getApiUrl, getCurrentUser, getObject, id, list, listData, login, m, mutation, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted };
21
+ declare const getApiBase: () => {};
22
+ export { addObject, f, getApiUrl, getCurrentUser, getObject, id, list, listData, login, m, mutation, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted, getApiBase };
@@ -1,3 +1,4 @@
1
+ import { useRuntimeConfig } from "nuxt/app";
1
2
  import { Notify } from "quasar";
2
3
  import addObject from "./addObject.mjs";
3
4
  import f from "./f.mjs";
@@ -25,6 +26,10 @@ const notify = function(message, color = "green") {
25
26
  });
26
27
  };
27
28
  import getID from "./getID.mjs";
29
+ const getApiBase = () => {
30
+ const config = useRuntimeConfig();
31
+ return config?.public?.apiBase ?? "/api/";
32
+ };
28
33
  export {
29
34
  addObject,
30
35
  f,
@@ -45,5 +50,6 @@ export {
45
50
  getID,
46
51
  deleteObject,
47
52
  listObject,
48
- isGranted
53
+ isGranted,
54
+ getApiBase
49
55
  };
@@ -1,6 +1,9 @@
1
1
  import axios from "axios";
2
2
  import { jsonToGraphQLQuery } from "json-to-graphql-query";
3
+ import { useRuntimeConfig } from "nuxt/app";
4
+ import { getApiBase } from "./index.mjs";
3
5
  export default async function(operation, args, fields = []) {
6
+ const config = useRuntimeConfig();
4
7
  const mutation = {
5
8
  mutation: {}
6
9
  };
@@ -42,9 +45,9 @@ export default async function(operation, args, fields = []) {
42
45
  for (let i = 0; i < map_values.length; i++) {
43
46
  fd.append(i.toString(), map_values[i]);
44
47
  }
45
- data = (await service.post("/api/", fd)).data;
48
+ data = (await service.post(getApiBase(), fd)).data;
46
49
  } else {
47
- data = (await service.post("/api/", {
50
+ data = (await service.post(getApiBase(), {
48
51
  query: graphql_query
49
52
  })).data;
50
53
  }
@@ -1,6 +1,8 @@
1
1
  import axios from "axios";
2
2
  import f from "./f.mjs";
3
3
  import { jsonToGraphQLQuery } from "json-to-graphql-query";
4
+ import { useRuntimeConfig } from "nuxt/app";
5
+ import { getApiBase } from "./index.mjs";
4
6
  const mapping = function(obj) {
5
7
  let q = {};
6
8
  Object.entries(obj).forEach(([key, value]) => {
@@ -16,6 +18,7 @@ const mapping = function(obj) {
16
18
  return q;
17
19
  };
18
20
  export default async function(operation, args, fields = []) {
21
+ const config = useRuntimeConfig();
19
22
  const service = axios.create({
20
23
  withCredentials: true
21
24
  });
@@ -29,7 +32,7 @@ export default async function(operation, args, fields = []) {
29
32
  }
30
33
  query = f(operation, args, fields);
31
34
  }
32
- const resp = (await service.post("/api/", {
35
+ const resp = (await service.post(getApiBase(), {
33
36
  query: `{ ${query} }`
34
37
  })).data;
35
38
  if (resp.errors) {
@@ -1,9 +1,12 @@
1
1
  <script setup>
2
2
  import { ref, computed, inject, reactive } from 'vue';
3
3
  import { m, q } from '../../'
4
+ import { Notify } from 'quasar';
4
5
  const app = await q("app", ["languages"])
5
6
 
6
- const splitterModel = ref(38)
7
+ const splitterModel = ref(62)
8
+
9
+ const all = ref(await q("allTranslate", []))
7
10
 
8
11
  const obj = reactive({
9
12
  name: ""
@@ -23,6 +26,63 @@ const onSave = async () => {
23
26
 
24
27
  }
25
28
  })
29
+ //reload
30
+ all.value = await q("allTranslate", [])
31
+ }
32
+
33
+
34
+ const columns = [
35
+ {
36
+ label: "",
37
+ name: "_delete"
38
+ },
39
+ {
40
+ label: "Name",
41
+ name: "name",
42
+ field: "name",
43
+ align: "left"
44
+ }];
45
+
46
+ for (const language of app.languages) {
47
+ columns.push({
48
+ label: language.name,
49
+ name: language.value,
50
+ align: "left",
51
+ })
52
+ }
53
+
54
+
55
+ const onUpdateTranslate = async (value, language, name) => {
56
+
57
+ if (await m("updateTranslate", {
58
+ name: name,
59
+ language: language,
60
+ value: value
61
+ })) {
62
+ Notify.create({
63
+ message: "Update success",
64
+ color: "positive",
65
+ icon: "check"
66
+ })
67
+
68
+ }
69
+ }
70
+
71
+ const onDelete = async (name) => {
72
+
73
+ if (await m("deleteTranslate", {
74
+ name: name
75
+ })) {
76
+ Notify.create({
77
+ message: "Delete success",
78
+ color: "positive",
79
+ icon: "check"
80
+ })
81
+
82
+ //reload
83
+ all.value = await q("allTranslate", [])
84
+ }
85
+
26
86
  }
27
87
  </script>
28
88
  <template>
@@ -30,13 +90,31 @@ const onSave = async () => {
30
90
  <l-card>
31
91
  <q-splitter v-model="splitterModel" style="height:680px">
32
92
  <template #before>
33
- <q-card-section>
34
- comming soon
35
- </q-card-section>
93
+ <q-table :rows="all" flat hide-bottom :rows-per-page-options="[0]" :columns="columns">
94
+ <template #body="props">
95
+ <q-tr :props="props">
96
+ <q-td key="_delete" auto-width>
97
+ <q-btn dense flat round icon="sym_o_delete" @click="onDelete(props.row.name)"></q-btn>
98
+ </q-td>
99
+ <q-td key="name">
100
+ {{ props.row.name }}
101
+ </q-td>
102
+ <q-td :key="language.value" v-for="language in app.languages" :props="props">
103
+ <div class="text-pre-wrap">{{ props.row[language.value] }}</div>
104
+ <q-popup-edit v-model="props.row[language.value]" v-slot="scope" buttons
105
+ :title="language.name"
106
+ @save="onUpdateTranslate($event, language.value, props.row.name)">
107
+ <q-input v-model="scope.value" dense autofocus @keyup.enter="scope.set" />
108
+ </q-popup-edit>
109
+ </q-td>
110
+ </q-tr>
111
+ </template>
112
+ </q-table>
113
+
36
114
  </template>
37
115
  <template #after>
38
116
  <l-form :bordered="false" @save="onSave">
39
- <l-input label="Name" required v-model="obj.name"></l-input>
117
+ <l-input label="Name" required v-model.trim="obj.name"></l-input>
40
118
  <l-input v-for="language in app.languages" :label="language.name"
41
119
  v-model="obj[language.value]"></l-input>
42
120
  </l-form>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",