@hostlink/nuxt-light 0.0.12 → 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.
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "0.0.12"
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 +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,6 +1,6 @@
1
1
  <script setup>
2
2
  import { q } from "../../../light"
3
- const { database } = await q("system", [f("database", ["table"])])
3
+ const { system: { database } } = await q({ system: { database: ["table"] } })
4
4
  </script>
5
5
  <template>
6
6
  <l-page>
@@ -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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",