@hostlink/nuxt-light 0.0.3
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/README.md +106 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.ts +7 -0
- package/dist/module.json +5 -0
- package/dist/module.mjs +51 -0
- package/dist/runtime/assets/element.css +15925 -0
- package/dist/runtime/assets/element.css.map +1 -0
- package/dist/runtime/assets/main.css +13 -0
- package/dist/runtime/components/l-add-btn.vue +22 -0
- package/dist/runtime/components/l-app-main.vue +214 -0
- package/dist/runtime/components/l-app.vue +17 -0
- package/dist/runtime/components/l-back-btn.vue +7 -0
- package/dist/runtime/components/l-btn.vue +19 -0
- package/dist/runtime/components/l-card.vue +19 -0
- package/dist/runtime/components/l-checkbox.vue +6 -0
- package/dist/runtime/components/l-col.vue +14 -0
- package/dist/runtime/components/l-customizer.vue +102 -0
- package/dist/runtime/components/l-date-picker.vue +78 -0
- package/dist/runtime/components/l-delete-btn.vue +23 -0
- package/dist/runtime/components/l-edit-btn.vue +3 -0
- package/dist/runtime/components/l-file-manager-labels.vue +55 -0
- package/dist/runtime/components/l-file-manager-move.vue +185 -0
- package/dist/runtime/components/l-file-manager-preview.vue +59 -0
- package/dist/runtime/components/l-file-manager.vue +618 -0
- package/dist/runtime/components/l-file.vue +33 -0
- package/dist/runtime/components/l-form.vue +73 -0
- package/dist/runtime/components/l-input.vue +48 -0
- package/dist/runtime/components/l-item.vue +14 -0
- package/dist/runtime/components/l-link.vue +24 -0
- package/dist/runtime/components/l-list.vue +5 -0
- package/dist/runtime/components/l-login.vue +128 -0
- package/dist/runtime/components/l-menu.vue +37 -0
- package/dist/runtime/components/l-page.vue +94 -0
- package/dist/runtime/components/l-row.vue +5 -0
- package/dist/runtime/components/l-save-btn.vue +3 -0
- package/dist/runtime/components/l-select.vue +77 -0
- package/dist/runtime/components/l-table.vue +333 -0
- package/dist/runtime/components/l-tabs.vue +5 -0
- package/dist/runtime/components/l-time-picker.vue +28 -0
- package/dist/runtime/components/l-view-btn.vue +3 -0
- package/dist/runtime/composables/addObject.d.ts +2 -0
- package/dist/runtime/composables/addObject.mjs +6 -0
- package/dist/runtime/composables/f.d.ts +1 -0
- package/dist/runtime/composables/f.mjs +27 -0
- package/dist/runtime/composables/getApiUrl.d.ts +1 -0
- package/dist/runtime/composables/getApiUrl.mjs +4 -0
- package/dist/runtime/composables/getCurrentUser.d.ts +2 -0
- package/dist/runtime/composables/getCurrentUser.mjs +8 -0
- package/dist/runtime/composables/getObject.d.ts +1 -0
- package/dist/runtime/composables/getObject.mjs +20 -0
- package/dist/runtime/composables/id.d.ts +2 -0
- package/dist/runtime/composables/id.mjs +12 -0
- package/dist/runtime/composables/list.d.ts +1 -0
- package/dist/runtime/composables/list.mjs +33 -0
- package/dist/runtime/composables/listData.d.ts +1 -0
- package/dist/runtime/composables/listData.mjs +30 -0
- package/dist/runtime/composables/login.d.ts +2 -0
- package/dist/runtime/composables/login.mjs +17 -0
- package/dist/runtime/composables/m.d.ts +1 -0
- package/dist/runtime/composables/m.mjs +73 -0
- package/dist/runtime/composables/mutation.d.ts +1 -0
- package/dist/runtime/composables/mutation.mjs +23 -0
- package/dist/runtime/composables/q.d.ts +1 -0
- package/dist/runtime/composables/q.mjs +18 -0
- package/dist/runtime/composables/removeObject.d.ts +1 -0
- package/dist/runtime/composables/removeObject.mjs +15 -0
- package/dist/runtime/composables/t.d.ts +1 -0
- package/dist/runtime/composables/t.mjs +8 -0
- package/dist/runtime/composables/updateObject.d.ts +2 -0
- package/dist/runtime/composables/updateObject.mjs +10 -0
- package/dist/runtime/composables/useLight.d.ts +7 -0
- package/dist/runtime/composables/useLight.mjs +17 -0
- package/dist/runtime/composables/viewAs.d.ts +1 -0
- package/dist/runtime/composables/viewAs.mjs +15 -0
- package/dist/runtime/locales/en.json +14 -0
- package/dist/runtime/locales/zh-hk.json +140 -0
- package/dist/runtime/pages/EventLog/_eventlog_id/view.vue +21 -0
- package/dist/runtime/pages/EventLog/index.vue +56 -0
- package/dist/runtime/pages/FileManager/index.vue +5 -0
- package/dist/runtime/pages/MailLog/index.vue +48 -0
- package/dist/runtime/pages/Permission/add.vue +47 -0
- package/dist/runtime/pages/Permission/all.vue +85 -0
- package/dist/runtime/pages/Permission/index.vue +26 -0
- package/dist/runtime/pages/Role/add.vue +28 -0
- package/dist/runtime/pages/Role/index.vue +51 -0
- package/dist/runtime/pages/System/database/backup.vue +5 -0
- package/dist/runtime/pages/System/database/table.vue +19 -0
- package/dist/runtime/pages/System/index.vue +8 -0
- package/dist/runtime/pages/System/mailtest.vue +22 -0
- package/dist/runtime/pages/System/package.vue +8 -0
- package/dist/runtime/pages/System/phpinfo.vue +8 -0
- package/dist/runtime/pages/System/setting.vue +68 -0
- package/dist/runtime/pages/System/view_as.vue +56 -0
- package/dist/runtime/pages/User/_user_id/change-password.vue +49 -0
- package/dist/runtime/pages/User/_user_id/edit.vue +49 -0
- package/dist/runtime/pages/User/_user_id/view.vue +21 -0
- package/dist/runtime/pages/User/add.vue +64 -0
- package/dist/runtime/pages/User/index.vue +47 -0
- package/dist/runtime/pages/User/profile.vue +25 -0
- package/dist/runtime/pages/User/update-password.vue +45 -0
- package/dist/runtime/pages/UserLog/index.vue +53 -0
- package/dist/runtime/pages/index.vue +9 -0
- package/dist/runtime/pages/logout.vue +10 -0
- package/dist/runtime/plugin.d.ts +4 -0
- package/dist/runtime/plugin.mjs +58 -0
- package/dist/runtime/routes.d.ts +7 -0
- package/dist/runtime/routes.mjs +261 -0
- package/dist/runtime/system_menus.d.ts +10 -0
- package/dist/runtime/system_menus.mjs +37 -0
- package/dist/types.d.ts +15 -0
- package/package.json +57 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useQuasar } from 'quasar';
|
|
3
|
+
const route = useRoute();
|
|
4
|
+
const module = route.path.split("/")[1];
|
|
5
|
+
const errors = ref([]);
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
columns: {
|
|
11
|
+
type: Array,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
showActions: {
|
|
15
|
+
type: [Boolean, Array],
|
|
16
|
+
default: false
|
|
17
|
+
},
|
|
18
|
+
selection: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: "none"
|
|
21
|
+
},
|
|
22
|
+
sortBy: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: null
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
//apply all aligns to the columns
|
|
29
|
+
props.columns.forEach((col) => {
|
|
30
|
+
if (!col.align) {
|
|
31
|
+
col.align = "left";
|
|
32
|
+
}
|
|
33
|
+
if (!col.field && col.name) {
|
|
34
|
+
col.field = col.name
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
col.label = t(col.label)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const renderColumns = computed(() => {
|
|
41
|
+
let cols = [];
|
|
42
|
+
if (props.showActions) {
|
|
43
|
+
cols = [
|
|
44
|
+
{
|
|
45
|
+
name: "_actions",
|
|
46
|
+
align: "left"
|
|
47
|
+
},
|
|
48
|
+
...props.columns
|
|
49
|
+
]
|
|
50
|
+
} else {
|
|
51
|
+
cols = props.columns;
|
|
52
|
+
}
|
|
53
|
+
return cols;
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const emits = defineEmits(["request"])
|
|
57
|
+
|
|
58
|
+
const loading = ref(false);
|
|
59
|
+
|
|
60
|
+
let activeEdit = false;
|
|
61
|
+
let actionView = false;
|
|
62
|
+
let actionDelete = false;
|
|
63
|
+
if (props.showActions && props.showActions instanceof Array) {
|
|
64
|
+
actionView = props.showActions.includes("view");
|
|
65
|
+
activeEdit = props.showActions.includes("edit");
|
|
66
|
+
actionDelete = props.showActions.includes("delete");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const pagination = ref({
|
|
71
|
+
sortBy: null,
|
|
72
|
+
descending: true,
|
|
73
|
+
page: 1,
|
|
74
|
+
rowsPerPage: 10,
|
|
75
|
+
rowsNumber: 0
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
if (props.sortBy) {
|
|
79
|
+
let [sortBy, descending] = props.sortBy.split(":");
|
|
80
|
+
pagination.value.sortBy = sortBy;
|
|
81
|
+
pagination.value.descending = descending == "desc";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const hasSearch = computed(() => {
|
|
85
|
+
return props.columns.some((col) => {
|
|
86
|
+
return col.searchable;
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const table = ref(null);
|
|
91
|
+
|
|
92
|
+
const filters = ref({});
|
|
93
|
+
const rows = ref([]);
|
|
94
|
+
|
|
95
|
+
onMounted(() => {
|
|
96
|
+
table.value.requestServerInteraction();
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
let primaryKey = ref("");
|
|
100
|
+
const recordName = ref("");
|
|
101
|
+
const onRequest = async (p) => {
|
|
102
|
+
|
|
103
|
+
p.fields = [];
|
|
104
|
+
props.columns.forEach((col) => {
|
|
105
|
+
if (col.name.startsWith("_")) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (p.fields.includes(col.name)) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
p.fields.push(col.name);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if (actionDelete) {
|
|
116
|
+
p.fields.push("canDelete");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
p.filters = getFilterValue();
|
|
120
|
+
|
|
121
|
+
loading.value = true;
|
|
122
|
+
p.done = (data) => {
|
|
123
|
+
loading.value = false;
|
|
124
|
+
rows.value = data.rows;
|
|
125
|
+
pagination.value.rowsPerPage = p.pagination.rowsPerPage;
|
|
126
|
+
pagination.value.page = p.pagination.page;
|
|
127
|
+
pagination.value.sortBy = p.pagination.sortBy;
|
|
128
|
+
pagination.value.descending = p.pagination.descending;
|
|
129
|
+
|
|
130
|
+
pagination.value = Object.assign(pagination.value, data.pagination);
|
|
131
|
+
|
|
132
|
+
pagination.value.rowsNumber = data.total;
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
primaryKey.value = data.key;
|
|
136
|
+
recordName.value = data.name;
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
if (props.showActions) {
|
|
140
|
+
if (props.showActions.includes("edit")) {
|
|
141
|
+
if (rows.value.length > 0) {
|
|
142
|
+
//get first row
|
|
143
|
+
let row = rows.value[0];
|
|
144
|
+
//check has primary key
|
|
145
|
+
|
|
146
|
+
if (!row[primaryKey.value]) {
|
|
147
|
+
errors.value.push("[edit] Primary key not found in the data");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (props.showActions.includes("delete")) {
|
|
153
|
+
if (rows.value.length > 0) {
|
|
154
|
+
//get first row
|
|
155
|
+
let row = rows.value[0];
|
|
156
|
+
//check has primary key
|
|
157
|
+
|
|
158
|
+
if (!row[primaryKey.value]) {
|
|
159
|
+
errors.value.push("[delete] Primary key not found in the data");
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (p.pagination.sortBy) {
|
|
170
|
+
p.sort = p.pagination.sortBy + ":" + (p.pagination.descending ? "desc" : "asc")
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
p.limit = p.pagination.rowsPerPage;
|
|
174
|
+
p.offset = (p.pagination.page - 1) * p.pagination.rowsPerPage;
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
emits("request", p);
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const getFilterValue = () => {
|
|
183
|
+
let f = {};
|
|
184
|
+
|
|
185
|
+
props.columns.forEach((col) => {
|
|
186
|
+
if (col.searchable) {
|
|
187
|
+
if (filters.value[col.name]) {
|
|
188
|
+
|
|
189
|
+
if (col.searchType == "date") {
|
|
190
|
+
if (filters.value[col.name].from) {
|
|
191
|
+
f[col.name] = {
|
|
192
|
+
between: [filters.value[col.name].from, filters.value[col.name].to]
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
f[col.name] = {
|
|
197
|
+
contains: filters.value[col.name]
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});/*
|
|
204
|
+
Object.entries(filters.value).forEach(([key, value]) => {
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
f[key] = {
|
|
208
|
+
contains: value
|
|
209
|
+
}
|
|
210
|
+
}) */
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
return f;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
const onFilters = () => {
|
|
218
|
+
//clone the filters
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
onRequest({
|
|
222
|
+
pagination: {
|
|
223
|
+
page: 1,
|
|
224
|
+
rowsPerPage: pagination.value.rowsPerPage,
|
|
225
|
+
sortBy: pagination.value.sortBy,
|
|
226
|
+
descending: pagination.value.descending
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const slots = useSlots();
|
|
232
|
+
|
|
233
|
+
const ss = Object.entries(slots).map(([key, value]) => {
|
|
234
|
+
return key;
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
/*
|
|
239
|
+
let MyComp = h("div", null, ["abc"])
|
|
240
|
+
|
|
241
|
+
console.log(MyComp)
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
const qua = useQuasar();
|
|
249
|
+
const onDelete = async (id) => {
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
await removeObject(recordName.value, id)
|
|
253
|
+
} catch (e) {
|
|
254
|
+
|
|
255
|
+
qua.notify({
|
|
256
|
+
message: e.message,
|
|
257
|
+
color: "negative",
|
|
258
|
+
icon: "report_problem"
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
return;
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
// refresh the table
|
|
268
|
+
table.value.requestServerInteraction();
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
</script>
|
|
274
|
+
<template>
|
|
275
|
+
<template v-if="errors.length > 0">
|
|
276
|
+
<div class="text-white bg-negative">
|
|
277
|
+
<ul>
|
|
278
|
+
<li v-for="e in errors">{{ e }}</li>
|
|
279
|
+
</ul>
|
|
280
|
+
</div>
|
|
281
|
+
</template>
|
|
282
|
+
|
|
283
|
+
<q-table flat bordered :columns="renderColumns" v-model:pagination="pagination" ref="table" :loading="loading"
|
|
284
|
+
@request="onRequest" :selection="selection" :rows="rows">
|
|
285
|
+
|
|
286
|
+
<template v-for="s in ss" v-slot:[s]="props">
|
|
287
|
+
<slot :name="s" v-bind="props"></slot>
|
|
288
|
+
</template>
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
<template #body-cell-_actions="props">
|
|
292
|
+
<q-td :props="props" auto-width>
|
|
293
|
+
<div class="text-grey-8">
|
|
294
|
+
|
|
295
|
+
<l-view-btn :to="`/${recordName}/${props.row[primaryKey]}/view`" v-if="actionView"></l-view-btn>
|
|
296
|
+
|
|
297
|
+
<l-edit-btn :to="`/${recordName}/${props.row[primaryKey]}/edit`" v-if="activeEdit"></l-edit-btn>
|
|
298
|
+
|
|
299
|
+
<l-delete-btn v-if="actionDelete && props.row.canDelete"
|
|
300
|
+
@submit="onDelete(props.row[primaryKey])"></l-delete-btn>
|
|
301
|
+
|
|
302
|
+
<slot name="actions" v-bind="props"></slot>
|
|
303
|
+
</div>
|
|
304
|
+
</q-td>
|
|
305
|
+
</template>
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
<template #top-row="props" v-if="hasSearch">
|
|
310
|
+
<q-tr>
|
|
311
|
+
<q-td v-if="selection != 'none'" auto-width>
|
|
312
|
+
|
|
313
|
+
</q-td>
|
|
314
|
+
<q-td v-for="col in props.cols">
|
|
315
|
+
<template v-if="col.searchable">
|
|
316
|
+
<template v-if="col.searchType == 'date'">
|
|
317
|
+
<l-date-picker hide-bottom-space v-model="filters[col.name]" dense
|
|
318
|
+
@update:model-value="onFilters" clearable range @clear="onFilters" />
|
|
319
|
+
</template>
|
|
320
|
+
|
|
321
|
+
<template v-else>
|
|
322
|
+
<q-input dense clearable v-model="filters[col.name]" @keydown.enter.prevent="onFilters"
|
|
323
|
+
@clear="onFilters"></q-input>
|
|
324
|
+
|
|
325
|
+
</template>
|
|
326
|
+
|
|
327
|
+
</template>
|
|
328
|
+
</q-td>
|
|
329
|
+
</q-tr>
|
|
330
|
+
</template>
|
|
331
|
+
|
|
332
|
+
</q-table>
|
|
333
|
+
</template>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
const props = defineProps(["modelValue"]);
|
|
3
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
4
|
+
const popup = ref(null);
|
|
5
|
+
const localValue = computed({
|
|
6
|
+
get: () => props.modelValue,
|
|
7
|
+
set: (value) => {
|
|
8
|
+
// popup.value.hide();
|
|
9
|
+
emit('update:modelValue', value)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
<template>
|
|
15
|
+
<q-input v-model="localValue" mask="time" :rules="['time']">
|
|
16
|
+
<template v-slot:prepend>
|
|
17
|
+
<q-icon name="access_time" class="cursor-pointer">
|
|
18
|
+
<q-popup-proxy cover transition-show="scale" transition-hide="scale" ref="popup">
|
|
19
|
+
<q-time v-model="localValue" format24h>
|
|
20
|
+
<div class="row items-center justify-end">
|
|
21
|
+
<q-btn v-close-popup label="Close" color="primary" flat />
|
|
22
|
+
</div>
|
|
23
|
+
</q-time>
|
|
24
|
+
</q-popup-proxy>
|
|
25
|
+
</q-icon>
|
|
26
|
+
</template>
|
|
27
|
+
</q-input>
|
|
28
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (operation: string, args: any, fields?: any): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsonToGraphQLQuery } from "json-to-graphql-query";
|
|
2
|
+
export default function(operation, args, fields = []) {
|
|
3
|
+
if (arguments.length === 2) {
|
|
4
|
+
fields = args;
|
|
5
|
+
args = {};
|
|
6
|
+
}
|
|
7
|
+
let query = {};
|
|
8
|
+
query[operation] = {};
|
|
9
|
+
if (args) {
|
|
10
|
+
query[operation] = {
|
|
11
|
+
__args: args
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
fields.forEach(async (field) => {
|
|
15
|
+
if (typeof field === "string") {
|
|
16
|
+
query[operation][field] = true;
|
|
17
|
+
} else if (typeof field === "object") {
|
|
18
|
+
Object.entries(field).forEach(([key, value]) => {
|
|
19
|
+
query[operation][key] = {};
|
|
20
|
+
value.forEach((subField) => {
|
|
21
|
+
query[operation][key][subField] = true;
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return jsonToGraphQLQuery(query);
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getApiUrl(url: String, params: any): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (fields?: Array<string>): Promise<any>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default async function(fields = []) {
|
|
2
|
+
let route = useRoute();
|
|
3
|
+
if (!route.name) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const [module, id_name] = route.name.split("-");
|
|
7
|
+
const id = parseInt(route.params[id_name]);
|
|
8
|
+
const filters = {};
|
|
9
|
+
filters[id_name] = id;
|
|
10
|
+
if (fields.length == 0) {
|
|
11
|
+
fields.push(id_name);
|
|
12
|
+
}
|
|
13
|
+
let { data } = await listData(module, {
|
|
14
|
+
filters
|
|
15
|
+
}, fields);
|
|
16
|
+
if (data.length > 0) {
|
|
17
|
+
return data[0];
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const route = useRoute();
|
|
2
|
+
export default () => {
|
|
3
|
+
let route2 = useRoute();
|
|
4
|
+
let name = route2.name?.toString();
|
|
5
|
+
if (name == void 0)
|
|
6
|
+
return 0;
|
|
7
|
+
let parts = name.split("-");
|
|
8
|
+
const module = parts[0];
|
|
9
|
+
const moduleLower = module.charAt(0).toLowerCase() + module.slice(1);
|
|
10
|
+
const keyname = parts[1];
|
|
11
|
+
return parseInt(route2.params[keyname]);
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function listData(name: string, props?: any, fields?: Array<string>): Promise<any>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export default async function listData(name, props = {}, fields = []) {
|
|
2
|
+
let v = {};
|
|
3
|
+
if (props.sort) {
|
|
4
|
+
v.sort = props.sort;
|
|
5
|
+
}
|
|
6
|
+
if (props.filters) {
|
|
7
|
+
v.filters = {
|
|
8
|
+
value: props.filters,
|
|
9
|
+
type: "mixed"
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
let offset_limit = {};
|
|
13
|
+
if (props.offset) {
|
|
14
|
+
offset_limit.offset = props.offset;
|
|
15
|
+
}
|
|
16
|
+
if (props.limit) {
|
|
17
|
+
offset_limit.limit = props.limit;
|
|
18
|
+
}
|
|
19
|
+
const fs = fields;
|
|
20
|
+
if (props.fields) {
|
|
21
|
+
fs.push(...props.fields);
|
|
22
|
+
}
|
|
23
|
+
let data = await q(`list${name}`, v, [f("data", offset_limit, fs), f("meta", ["total", "key", "name"])]);
|
|
24
|
+
if (props.done) {
|
|
25
|
+
props.done({
|
|
26
|
+
rows: data[`list${name}`].data,
|
|
27
|
+
total: data[`list${name}`].meta.total,
|
|
28
|
+
key: data[`list${name}`].meta.key,
|
|
29
|
+
name: data[`list${name}`].meta.name
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return data[`list${name}`][`data`];
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function listData(name: string, props?: any, fields?: Array<string>): Promise<any>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default async function listData(name, props = {}, fields = []) {
|
|
2
|
+
let v = {};
|
|
3
|
+
if (props.sort) {
|
|
4
|
+
v.sort = props.sort;
|
|
5
|
+
}
|
|
6
|
+
if (props.filters) {
|
|
7
|
+
v.filters = props.filters;
|
|
8
|
+
}
|
|
9
|
+
let offset_limit = {};
|
|
10
|
+
if (props.offset) {
|
|
11
|
+
offset_limit.offset = props.offset;
|
|
12
|
+
}
|
|
13
|
+
if (props.limit) {
|
|
14
|
+
offset_limit.limit = props.limit;
|
|
15
|
+
}
|
|
16
|
+
const fs = fields;
|
|
17
|
+
if (props.fields) {
|
|
18
|
+
fs.push(...props.fields);
|
|
19
|
+
}
|
|
20
|
+
let data = await q(`list${name}`, v, [f("data", offset_limit, fs), f("meta", ["total", "key", "name"])]);
|
|
21
|
+
if (props.done) {
|
|
22
|
+
props.done({
|
|
23
|
+
rows: data.data,
|
|
24
|
+
total: data.meta.total,
|
|
25
|
+
key: data.meta.key,
|
|
26
|
+
name: data.meta.name
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import mutation from "./mutation.mjs";
|
|
2
|
+
export default async (username, password) => {
|
|
3
|
+
await mutation({
|
|
4
|
+
operation: "login",
|
|
5
|
+
variables: {
|
|
6
|
+
username: {
|
|
7
|
+
value: username,
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
password: {
|
|
11
|
+
value: password,
|
|
12
|
+
required: true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return true;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function _default(operation: any, args: any, fields?: any[]): Promise<any>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
//import { mutation } from 'gql-query-builder';
|
|
3
|
+
import { jsonToGraphQLQuery } from 'json-to-graphql-query';
|
|
4
|
+
|
|
5
|
+
export default async function (operation, args, fields = []) {
|
|
6
|
+
|
|
7
|
+
const mutation = {
|
|
8
|
+
mutation: {
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
mutation.mutation[operation] = {};
|
|
15
|
+
if (args) {
|
|
16
|
+
mutation.mutation[operation].__args = args;
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
let map = {};
|
|
22
|
+
let map_values = [];
|
|
23
|
+
|
|
24
|
+
fields.forEach(field => {
|
|
25
|
+
|
|
26
|
+
if (typeof field === 'string') {
|
|
27
|
+
mutation.mutation[operation][field] = true;
|
|
28
|
+
} else {
|
|
29
|
+
mutation.mutation.__variables = mutation.mutation.__variables || {};
|
|
30
|
+
|
|
31
|
+
let i = 0;
|
|
32
|
+
Object.entries(field.__variables).forEach(([key, value]) => {
|
|
33
|
+
mutation.mutation.__variables[key] = value.type;
|
|
34
|
+
map[i] = ["variables." + key];
|
|
35
|
+
map_values.push(value.value);
|
|
36
|
+
i++;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const graphql_query = jsonToGraphQLQuery(mutation);
|
|
43
|
+
let service = axios.create({
|
|
44
|
+
withCredentials: true
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
let data = null;
|
|
48
|
+
if (map_values.length) {
|
|
49
|
+
const fd = new FormData;
|
|
50
|
+
|
|
51
|
+
fd.append("operations", JSON.stringify({
|
|
52
|
+
query: graphql_query
|
|
53
|
+
}));
|
|
54
|
+
fd.append("map", JSON.stringify(map));
|
|
55
|
+
for (let i = 0; i < map_values.length; i++) {
|
|
56
|
+
fd.append(i, map_values[i]);
|
|
57
|
+
}
|
|
58
|
+
data = (await service.post("/api/", fd)).data;
|
|
59
|
+
|
|
60
|
+
} else {
|
|
61
|
+
data = (await service.post("/api/", {
|
|
62
|
+
query: graphql_query
|
|
63
|
+
})).data;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (data.errors) {
|
|
67
|
+
throw new Error(data.errors[0].message);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return data.data[operation];
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function _default(options: any): Promise<any>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { mutation } from 'gql-query-builder';
|
|
3
|
+
|
|
4
|
+
export default async function (options) {
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
let service = axios.create({
|
|
8
|
+
withCredentials: true
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const data = (await service.post("/api/", mutation(options))).data;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
if (data.errors) {
|
|
17
|
+
throw new Error(data.errors[0].message);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return data;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (operation: string, args: any, fields?: Array<any>): Promise<any>;
|