@mixd-id/web-scaffold 0.1.240411062 → 0.1.240411064
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/docs/components/Dashboard.md +56 -0
- package/package.json +1 -1
- package/src/components/Alert.vue +1 -1
- package/src/components/Button.vue +1 -1
- package/src/components/Checkout.vue +1 -1
- package/src/components/Confirm.vue +5 -5
- package/src/components/ContextMenu.vue +3 -3
- package/src/components/Dashboard.vue +243 -0
- package/src/components/DashboardComponentSelector.vue +96 -0
- package/src/components/DashboardConfigs.vue +202 -0
- package/src/components/Dropdown.vue +1 -1
- package/src/components/HTMLEditor.vue +5 -4
- package/src/components/List.vue +35 -30
- package/src/components/ListPage1.vue +4 -4
- package/src/components/MarkdownEdit.vue +128 -0
- package/src/components/MarkdownPreview.vue +102 -0
- package/src/components/Modal.vue +37 -16
- package/src/components/MultilineText.vue +1 -4
- package/src/components/OTPField.vue +3 -3
- package/src/components/Switch.vue +1 -1
- package/src/components/TextEditor.vue +2 -2
- package/src/components/TextWithTag.vue +24 -5
- package/src/components/Textarea.vue +0 -3
- package/src/components/Textbox.vue +1 -0
- package/src/components/TreeMenu.vue +2 -2
- package/src/components/TreeView2.vue +5 -3
- package/src/components/TreeViewItem2.vue +14 -7
- package/src/components/VirtualTable.vue +10 -13
- package/src/index.js +4 -1
- package/src/themes/default/index.js +23 -31
- package/src/utils/helpers.mjs +4 -10
- package/src/utils/wss.mjs +0 -2
- package/src/widgets/ComponentSetting2.vue +1 -11
- package/src/widgets/Dashboard/DataTableSetting.vue +0 -4
- package/src/widgets/Dashboard/VirtualTableSetting.vue +121 -184
- package/src/widgets/{Dashboard.vue → Dashboard0.vue} +0 -4
- package/src/widgets/GridSetting.vue +0 -18
- package/src/widgets/PresetBar.vue +18 -10
- package/src/widgets/PresetBarPivot.vue +0 -4
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Dashboard
|
|
2
|
+
Dashboard components
|
|
3
|
+
|
|
4
|
+
## Configs
|
|
5
|
+
| Property | Type | Default | Description |
|
|
6
|
+
|----------|------|---------|-------------|
|
|
7
|
+
| params | Object | {} | | Dashboard parameters |
|
|
8
|
+
| params.presetUid | String | "" | | Preset unique identifier |
|
|
9
|
+
|
|
10
|
+
## Samples
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"params": {
|
|
14
|
+
"presetUid": "abc",
|
|
15
|
+
"viewUid": "def"
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
"presets": [
|
|
19
|
+
|
|
20
|
+
{
|
|
21
|
+
"name": "Preset Name",
|
|
22
|
+
|
|
23
|
+
"views": [
|
|
24
|
+
{
|
|
25
|
+
"type": "Grid",
|
|
26
|
+
"uid": ":uid"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
"datasource": {
|
|
31
|
+
|
|
32
|
+
":uid": {
|
|
33
|
+
"uid": ":uid",
|
|
34
|
+
"datasourceUid": "234",
|
|
35
|
+
"filters": [],
|
|
36
|
+
"sorts": [],
|
|
37
|
+
"groups": [],
|
|
38
|
+
"pivot": []
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## Sub Components
|
|
51
|
+
|
|
52
|
+
### Dashboard Configs
|
|
53
|
+
Dashboard configuration panel
|
|
54
|
+
|
|
55
|
+
### Dashboard Component Selector
|
|
56
|
+
Component selector for adding component to preset views
|
package/package.json
CHANGED
package/src/components/Alert.vue
CHANGED
|
@@ -204,7 +204,7 @@ export default{
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
.alert>*{
|
|
207
|
-
@apply max-h-[60vh] overflow-y-auto bg-base-
|
|
207
|
+
@apply max-h-[60vh] overflow-y-auto bg-base-400 dark:bg-base-300 rounded-xl;
|
|
208
208
|
@apply border-[1px] border-text-50;
|
|
209
209
|
@apply min-w-[280px] max-w-[80vw] md:max-w-[480px];
|
|
210
210
|
}
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
|
|
67
67
|
<div class="mt-1 p-5 bg-base-300 flex flex-col gap-3">
|
|
68
68
|
<div v-for="item in order.items" class="flex flex-row gap-3">
|
|
69
|
-
<Image :src="item.imageSrc" class="w-[60px] aspect-square rounded-lg bg-base-
|
|
69
|
+
<Image :src="item.imageSrc" class="w-[60px] aspect-square rounded-lg bg-base-300" />
|
|
70
70
|
<div class="flex-1 flex flex-col gap1">
|
|
71
71
|
<small>{{ item.code }}</small>
|
|
72
72
|
<strong>{{ item.name }}</strong>
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
</div>
|
|
19
19
|
|
|
20
20
|
<div class="mt-4 flex flex-row gap-2">
|
|
21
|
-
<Button ref="btnOK" @click="onConfirm" class="min-w-[88px]" tabindex="0">
|
|
21
|
+
<Button ref="btnOK" @click="onConfirm" class="min-w-[88px] text-lg" tabindex="0">
|
|
22
22
|
<strong class="px-4">
|
|
23
23
|
{{ buttonText[0] }}
|
|
24
24
|
</strong>
|
|
25
25
|
</Button>
|
|
26
|
-
<Button variant="minimal" @click="onDismiss" class="min-w-[88px] px-4 hover:text-primary">
|
|
26
|
+
<Button variant="minimal" @click="onDismiss" class="min-w-[88px] px-4 hover:text-primary text-lg">
|
|
27
27
|
{{ buttonText[1] }}
|
|
28
28
|
</Button>
|
|
29
29
|
</div>
|
|
@@ -122,7 +122,7 @@ export default{
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
.confirm>*{
|
|
125
|
-
@apply max-h-[60vh] overflow-y-auto bg-base-
|
|
125
|
+
@apply max-h-[60vh] overflow-y-auto bg-base-400 dark:bg-base-300 rounded-xl;
|
|
126
126
|
@apply border-[1px] border-text-50;
|
|
127
127
|
@apply min-w-[280px] max-w-[80vw] md:max-w-[480px];
|
|
128
128
|
}
|
|
@@ -132,7 +132,7 @@ export default{
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
.cont2{
|
|
135
|
-
@apply my-4 text-center flex-1 overflow-y-auto;
|
|
135
|
+
@apply my-4 text-center flex-1 overflow-y-auto px-6;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
.title{
|
|
@@ -140,7 +140,7 @@ export default{
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
.description{
|
|
143
|
-
@apply overflow-y-auto whitespace-pre-line text-center;
|
|
143
|
+
@apply overflow-y-auto whitespace-pre-line text-center text-lg;
|
|
144
144
|
overflow-wrap: break-word;
|
|
145
145
|
word-wrap: break-word;
|
|
146
146
|
-ms-word-break: break-all;
|
|
@@ -241,15 +241,15 @@ export default {
|
|
|
241
241
|
<style module>
|
|
242
242
|
|
|
243
243
|
.contextMenu{
|
|
244
|
-
@apply fixed bg-base-300 min-w-[150px] overflow-y-auto rounded-
|
|
245
|
-
@apply whitespace-nowrap shadow-2xl border-[1px] border-text-
|
|
244
|
+
@apply fixed bg-base-400 dark:bg-base-300 min-w-[150px] overflow-y-auto rounded-lg;
|
|
245
|
+
@apply whitespace-nowrap shadow-2xl border-[1px] border-text-50 mt-[1px];
|
|
246
246
|
z-index: 180;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
@media screen and (min-width: 640px){
|
|
250
250
|
|
|
251
251
|
.contextMenu{
|
|
252
|
-
@apply fixed min-w-[150px] overflow-y-auto
|
|
252
|
+
@apply fixed min-w-[150px] overflow-y-auto;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="$style.comp">
|
|
3
|
+
|
|
4
|
+
<div v-if="config.params.openSidebar" :style="leftStyle" class="relative flex flex-col bg-base-300 border-l-[1px] border-text-50">
|
|
5
|
+
<DashboardConfigs :config="config" class="flex-1" />
|
|
6
|
+
|
|
7
|
+
<div :class="$style.resize1" @mousedown="(e) => $util.dragResize(e, resize1)"></div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div class="flex-1 flex flex-col gap-4 py-4">
|
|
11
|
+
|
|
12
|
+
<div class="px-8 flex flex-row gap-8 items-center">
|
|
13
|
+
<button type="button" class="p-3" @click="config.params.openSidebar = !config.params.openSidebar">
|
|
14
|
+
<svg width="16" height="16" class="hover:fill-primary" :class="config.params.openSidebar ? 'fill-primary' : 'fill-text'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M448 32H64C28.65 32 0 60.65 0 96v320c0 35.35 28.65 64 64 64h384c35.35 0 64-28.65 64-64V96C512 60.65 483.3 32 448 32zM136 336h-48C74.75 336 64 325.3 64 312C64 298.7 74.75 288 88 288h48C149.3 288 160 298.7 160 312C160 325.3 149.3 336 136 336zM136 240h-48C74.75 240 64 229.3 64 216C64 202.7 74.75 192 88 192h48C149.3 192 160 202.7 160 216C160 229.3 149.3 240 136 240zM136 144h-48C74.75 144 64 133.3 64 120C64 106.7 74.75 96 88 96h48C149.3 96 160 106.7 160 120C160 133.3 149.3 144 136 144zM464 416c0 8.822-7.176 16-16 16H224v-352h224c8.824 0 16 7.178 16 16V416z"/></svg>
|
|
15
|
+
</button>
|
|
16
|
+
<button type="button" class="flex flex-row gap-2 items-center">
|
|
17
|
+
<h5>{{ preset?.name }}</h5>
|
|
18
|
+
<svg width="14" height="14" class="fill-text" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M432.6 209.3l-191.1 183.1C235.1 397.8 229.1 400 224 400s-11.97-2.219-16.59-6.688L15.41 209.3C5.814 200.2 5.502 184.1 14.69 175.4c9.125-9.625 24.38-9.938 33.91-.7187L224 342.8l175.4-168c9.5-9.219 24.78-8.906 33.91 .7187C442.5 184.1 442.2 200.2 432.6 209.3z"/></svg>
|
|
19
|
+
<button type="button" class="p-3" @click="load">
|
|
20
|
+
<svg width="14" height="14" class="fill-text hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M468.9 32.11c13.87 0 27.18 10.77 27.18 27.04v145.9c0 10.59-8.584 19.17-19.17 19.17h-145.7c-16.28 0-27.06-13.32-27.06-27.2c0-6.634 2.461-13.4 7.96-18.9l45.12-45.14c-28.22-23.14-63.85-36.64-101.3-36.64c-88.09 0-159.8 71.69-159.8 159.8S167.8 415.9 255.9 415.9c73.14 0 89.44-38.31 115.1-38.31c18.48 0 31.97 15.04 31.97 31.96c0 35.04-81.59 70.41-147 70.41c-123.4 0-223.9-100.5-223.9-223.9S132.6 32.44 256 32.44c54.6 0 106.2 20.39 146.4 55.26l47.6-47.63C455.5 34.57 462.3 32.11 468.9 32.11z"/></svg>
|
|
21
|
+
</button>
|
|
22
|
+
</button>
|
|
23
|
+
<div class="flex-1"></div>
|
|
24
|
+
|
|
25
|
+
<button type="button" class="p-3" @click="config.params.openRightbar = !config.params.openRightbar">
|
|
26
|
+
<svg width="16" height="16" class="fill-text hover:fill-primary" :class="config.params.openRightbar ? 'fill-primary' : 'fill-text'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M324.4 103.1L384 128l24.88 59.63C410.2 190.3 413 192 416 192s5.75-1.75 7.125-4.375L448 128l59.63-24.88C510.3 101.8 512 99 512 96s-1.75-5.75-4.375-7.125L448 64l-24.88-59.62C421.8 1.75 419 0 416 0s-5.75 1.75-7.125 4.375L384 64l-59.63 24.88C321.8 90.25 320 93 320 96S321.8 101.8 324.4 103.1zM507.6 408.9L448 384l-24.88-59.63C421.8 321.8 419 320 416 320s-5.75 1.75-7.125 4.375L384 384l-59.63 24.88C321.8 410.2 320 413 320 416s1.75 5.75 4.375 7.125L384 448l24.88 59.63C410.2 510.2 413 512 416 512s5.75-1.75 7.125-4.375L448 448l59.63-24.88C510.3 421.8 512 419 512 416S510.3 410.2 507.6 408.9zM384 255.6c0-6-3.375-11.62-8.875-14.38l-112.5-56.31L206.3 72.19c-5.375-10.88-23.13-10.88-28.5 0L121.4 184.9L8.875 241.2C3.375 244 0 249.6 0 255.6c0 6.125 3.375 11.62 8.875 14.38l112.5 56.37l56.38 112.7C180.4 444.4 185.1 447.9 192 447.9c5.999 0 11.62-3.512 14.25-8.887l56.38-112.7l112.5-56.37C380.6 267.2 384 261.8 384 255.6z"/></svg>
|
|
27
|
+
</button>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<div class="flex-1 overflow-y-auto px-8">
|
|
31
|
+
<component :is="component.type"
|
|
32
|
+
v-for="component in components"
|
|
33
|
+
:="component" />
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<div v-if="config.params.openRightbar" class="w-[320px] bg-base-300 flex flex-col">
|
|
39
|
+
|
|
40
|
+
<div class="flex-1"></div>
|
|
41
|
+
|
|
42
|
+
<div class="p-3">
|
|
43
|
+
<Textarea placeholder="Ask anything...">
|
|
44
|
+
<template #end>
|
|
45
|
+
<div class="p-1">
|
|
46
|
+
<button class="p-2">
|
|
47
|
+
<svg width="14" height="14" class="fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M511.1 255.1c0 12.8-7.625 24.38-19.41 29.41L44.6 477.4c-4.062 1.75-8.344 2.594-12.59 2.594c-8.625 0-17.09-3.5-23.28-10.05c-9.219-9.766-11.34-24.25-5.344-36.27l73.66-147.3l242.1-30.37L77.03 225.6l-73.66-147.3C-2.623 66.3-.4982 51.81 8.72 42.05c9.25-9.766 23.56-12.75 35.87-7.453L492.6 226.6C504.4 231.6 511.1 243.2 511.1 255.1z"/></svg>
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
</Textarea>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
</div>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<script setup>
|
|
60
|
+
|
|
61
|
+
import {computed, inject, onMounted, ref, watch} from "vue";
|
|
62
|
+
import DashboardConfigs from "./DashboardConfigs.vue";
|
|
63
|
+
|
|
64
|
+
const { controller, presetKey } = defineProps({
|
|
65
|
+
|
|
66
|
+
controller: {
|
|
67
|
+
type: String,
|
|
68
|
+
required: true
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
presetKey: { type: String },
|
|
72
|
+
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const alert = inject('alert')
|
|
76
|
+
const loadConfig = inject('loadConfig')
|
|
77
|
+
const saveConfig = inject('saveConfig')
|
|
78
|
+
const useSocket = inject('useSocket')
|
|
79
|
+
const socket = useSocket()
|
|
80
|
+
|
|
81
|
+
const config = ref(Object.assign({
|
|
82
|
+
params: {},
|
|
83
|
+
presets: []
|
|
84
|
+
}, presetKey ? await loadConfig(presetKey, {}) : {}))
|
|
85
|
+
|
|
86
|
+
const data = ref({})
|
|
87
|
+
|
|
88
|
+
const leftStyle = computed(() => {
|
|
89
|
+
if(!config.value.params.leftWidth)
|
|
90
|
+
config.value.params.leftWidth = 300
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
width: `${config.value.params.leftWidth}px`
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
function load(){
|
|
98
|
+
if(!preset.value) return
|
|
99
|
+
|
|
100
|
+
socket.send(`${controller}.load`, preset.value.datasource)
|
|
101
|
+
.then(res => Object.assign(data.value, res))
|
|
102
|
+
.catch(err => alert(err))
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function resize1(w){
|
|
106
|
+
if(config.value.params.leftWidth + w >= 100 && config.value.params.leftWidth + w <= 600){
|
|
107
|
+
config.value.params.leftWidth += w
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const preset = computed(() => {
|
|
112
|
+
return (config.value.presets ?? []).find(_ => _.uid === config.value.params.presetUid)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
const selectedPreset = computed(() => {
|
|
116
|
+
return (config.value.presets ?? []).find(_ => _.uid === config.value.params.selectedUid)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
const compClasses = [
|
|
120
|
+
'aspectRatio', 'position', 'left', 'top', 'right', 'bottom',
|
|
121
|
+
|
|
122
|
+
'bdSize', 'bdColor', 'bdRadius', 'bdStyle',
|
|
123
|
+
'divideSize', 'divideColor', 'divideStyle',
|
|
124
|
+
'outlineWidth', 'outlineColor', 'outlineStyle',
|
|
125
|
+
'bgColors', 'bgSize', 'bgPosition', 'bgRepeat',
|
|
126
|
+
'textAlign', 'verticalAlign',
|
|
127
|
+
'gap',
|
|
128
|
+
'padding', 'margin',
|
|
129
|
+
'direction', 'columns', 'rows', 'display', 'wrap',
|
|
130
|
+
'width', 'minWidth', 'maxWidth',
|
|
131
|
+
'height', 'minHeight', 'maxHeight',
|
|
132
|
+
'fontFamily', 'fontSize', 'fontWeight', 'textColor', 'lineHeight', 'overflow',
|
|
133
|
+
'textTransform', 'whitespace', 'textOverflow', 'textDecoration',
|
|
134
|
+
'boxShadow', 'opacity',
|
|
135
|
+
'colSpan', 'rowSpan',
|
|
136
|
+
'flex', 'flexAlign', 'flexJustify', 'flexBasis', 'flexColumns', 'flexWrap',
|
|
137
|
+
'flexDirection',
|
|
138
|
+
'zIndex',
|
|
139
|
+
|
|
140
|
+
'autoFlow', 'alignItems', 'justifyContent',
|
|
141
|
+
'letterSpacing', 'lineClamp',
|
|
142
|
+
|
|
143
|
+
'animate',
|
|
144
|
+
|
|
145
|
+
'blur', 'grayscale',
|
|
146
|
+
]
|
|
147
|
+
const containerClasses = [
|
|
148
|
+
'containerVariant', 'containerGridColumn', 'containerGap'
|
|
149
|
+
]
|
|
150
|
+
const itemClasses = [
|
|
151
|
+
'itemMinWidth', 'itemRatio', 'itemVariant'
|
|
152
|
+
]
|
|
153
|
+
|
|
154
|
+
const components = computed(() => {
|
|
155
|
+
if(!selectedPreset.value) return
|
|
156
|
+
|
|
157
|
+
const getComponent = (component) => {
|
|
158
|
+
if (!component.uid) return
|
|
159
|
+
if (!component.props.enabled) return
|
|
160
|
+
|
|
161
|
+
const compUid = '_' + component.uid.substring(0, 4) + ' '
|
|
162
|
+
|
|
163
|
+
const instance = {
|
|
164
|
+
type: component.type,
|
|
165
|
+
uid: component.uid,
|
|
166
|
+
|
|
167
|
+
class: compUid + compClasses.map(key => {
|
|
168
|
+
return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
|
|
169
|
+
})
|
|
170
|
+
.filter(_ => _)
|
|
171
|
+
.join(' '),
|
|
172
|
+
|
|
173
|
+
containerClass: containerClasses.map(key => {
|
|
174
|
+
return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
|
|
175
|
+
})
|
|
176
|
+
.filter(_ => _)
|
|
177
|
+
.join(' '),
|
|
178
|
+
|
|
179
|
+
itemClass: itemClasses.map(key => {
|
|
180
|
+
return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
|
|
181
|
+
})
|
|
182
|
+
.filter(_ => _)
|
|
183
|
+
.join(' ')
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
for (let key in component.props) {
|
|
187
|
+
if (!compClasses.includes(key) &&
|
|
188
|
+
!containerClasses.includes(key) &&
|
|
189
|
+
!itemClasses.includes(key) &&
|
|
190
|
+
!['enabled'].includes(key)) {
|
|
191
|
+
instance[key] = component.props[key]
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const whitelistProps = [
|
|
196
|
+
'column', 'datasourceUid', 'rows', 'columns'
|
|
197
|
+
]
|
|
198
|
+
whitelistProps.forEach((key) => {
|
|
199
|
+
if (component.props[key]) {
|
|
200
|
+
instance[key] = component.props[key]
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
if(data.value[component.uid]){
|
|
205
|
+
instance.items = data.value[component.uid].items
|
|
206
|
+
}
|
|
207
|
+
else if(Array.isArray(component.items)) {
|
|
208
|
+
instance.items = component.items.map((_) => getComponent(_)).filter(_ => _)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return instance
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return selectedPreset.value.views.map(view => {
|
|
215
|
+
return getComponent(view)
|
|
216
|
+
})
|
|
217
|
+
.filter(_ => _)
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
if(presetKey){
|
|
221
|
+
console.log('Watch config changes')
|
|
222
|
+
watch(() => config, _ => saveConfig(presetKey, config.value), {
|
|
223
|
+
deep: true
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
onMounted(() => {
|
|
228
|
+
load()
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
</script>
|
|
232
|
+
|
|
233
|
+
<style module>
|
|
234
|
+
|
|
235
|
+
.comp {
|
|
236
|
+
@apply flex flex-row;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.resize1{
|
|
240
|
+
@apply w-[3px] cursor-ew-resize absolute top-0 right-0 bottom-0;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
</style>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Modal ref="modal" width="360" height="480">
|
|
3
|
+
<template v-slot:head>
|
|
4
|
+
<div class="relative p-5">
|
|
5
|
+
<h3>Select Component</h3>
|
|
6
|
+
<div class="absolute top-0 right-0 p-2">
|
|
7
|
+
<button type="button" class="p-2" @click="$refs.modal.close()">
|
|
8
|
+
<svg width="24" height="24" viewBox="0 0 24 24" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg">
|
|
9
|
+
<path d="M6.53034 5.46965C6.23745 5.17676 5.76257 5.17676 5.46968 5.46965C5.17679 5.76255 5.17679 6.23742 5.46968 6.53031L10.9393 12L5.46967 17.4697C5.17678 17.7626 5.17678 18.2374 5.46967 18.5303C5.76256 18.8232 6.23744 18.8232 6.53033 18.5303L12 13.0606L17.4697 18.5303C17.7626 18.8232 18.2375 18.8232 18.5303 18.5303C18.8232 18.2374 18.8232 17.7626 18.5303 17.4697L13.0607 12L18.5303 6.53032C18.8232 6.23743 18.8232 5.76256 18.5303 5.46966C18.2374 5.17677 17.7626 5.17677 17.4697 5.46966L12 10.9393L6.53034 5.46965Z"/>
|
|
10
|
+
</svg>
|
|
11
|
+
</button>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
<template v-slot:foot>
|
|
16
|
+
<div class="p-5">
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
<div class="flex-1 divide-y divide-text-50">
|
|
21
|
+
|
|
22
|
+
<div class="flex flex-col">
|
|
23
|
+
<button v-for="component of components"
|
|
24
|
+
class="p-3 px-6 text-left"
|
|
25
|
+
@click="add(component)">
|
|
26
|
+
{{ component.type }}
|
|
27
|
+
</button>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
</div>
|
|
32
|
+
</Modal>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup>
|
|
36
|
+
|
|
37
|
+
import {ref, useTemplateRef} from "vue";
|
|
38
|
+
import md5 from "md5";
|
|
39
|
+
|
|
40
|
+
const modal = useTemplateRef('modal')
|
|
41
|
+
const callback = ref(null)
|
|
42
|
+
|
|
43
|
+
function open(_, cb){
|
|
44
|
+
callback.value = cb
|
|
45
|
+
modal.value.open()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function add(component){
|
|
49
|
+
if(typeof callback.value === 'function'){
|
|
50
|
+
const newComponent = JSON.parse(JSON.stringify(component))
|
|
51
|
+
newComponent.uid = md5(new Date().toString())
|
|
52
|
+
callback.value(newComponent)
|
|
53
|
+
}
|
|
54
|
+
modal.value.close()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const components = ref([
|
|
58
|
+
{
|
|
59
|
+
type: "Grid",
|
|
60
|
+
name: "Grid",
|
|
61
|
+
props: {
|
|
62
|
+
enabled: true
|
|
63
|
+
},
|
|
64
|
+
items: []
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: "VirtualTable",
|
|
68
|
+
name: "Virtual Table",
|
|
69
|
+
props: {
|
|
70
|
+
enabled: true,
|
|
71
|
+
class: "bg-base-500 max-h-[80vh]"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: "Metric",
|
|
76
|
+
name: "Metric",
|
|
77
|
+
props: {
|
|
78
|
+
enabled: true,
|
|
79
|
+
class: "bg-base-500"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
])
|
|
83
|
+
|
|
84
|
+
defineExpose({
|
|
85
|
+
open
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<style module>
|
|
91
|
+
|
|
92
|
+
.comp{
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
</style>
|