@mixd-id/web-scaffold 0.2.240702 → 0.2.240703
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/schema/user-action.json +266 -0
- package/package.json +6 -2
- package/public/assets/dashboard/bar.png +0 -0
- package/public/assets/dashboard/doughnut.png +0 -0
- package/public/assets/dashboard/metric.png +0 -0
- package/public/assets/dashboard/pie.png +0 -0
- package/public/assets/dashboard/polar-area.png +0 -0
- package/public/assets/dashboard/virtual-table.png +0 -0
- package/public/static/dashboard/bar.png +0 -0
- package/public/static/dashboard/doughnut.png +0 -0
- package/public/static/dashboard/metric.png +0 -0
- package/public/static/dashboard/pie.png +0 -0
- package/public/static/dashboard/polar-area.png +0 -0
- package/public/static/dashboard/virtual-table.png +0 -0
- package/src/components/Button.vue +179 -160
- package/src/components/Checkbox.vue +0 -1
- package/src/components/Datepicker.vue +8 -6
- package/src/components/GHeatMaps.vue +317 -0
- package/src/components/GmapsDirection.vue +191 -0
- package/src/components/Grid.vue +2 -0
- package/src/components/HTMLEditor.vue +2 -2
- package/src/components/List.vue +384 -308
- package/src/components/Modal.vue +2 -3
- package/src/components/PresetSelectorFilterItem.vue +15 -2
- package/src/components/Switch.vue +3 -0
- package/src/components/Tabs.vue +1 -1
- package/src/components/TextWithTag.vue +67 -25
- package/src/components/Textbox.vue +5 -0
- package/src/components/VirtualGrid.vue +224 -228
- package/src/components/VirtualTable.vue +46 -28
- package/src/configs/dashboard/bar.js +10 -0
- package/src/configs/dashboard/collection-1.js +5 -0
- package/src/configs/dashboard/doughnut.js +7 -0
- package/src/configs/dashboard/gheatmaps.js +9 -0
- package/src/configs/dashboard/grid-2.js +34 -0
- package/src/configs/dashboard/grid-3.js +34 -0
- package/src/configs/dashboard/grid-4.js +34 -0
- package/src/configs/dashboard/grid.js +15 -0
- package/src/configs/dashboard/metric.js +10 -0
- package/src/configs/dashboard/pie.js +7 -0
- package/src/configs/dashboard/polar-area.js +7 -0
- package/src/configs/dashboard/virtual-table.js +9 -0
- package/src/defs/dashboard-preset.js +22 -0
- package/src/index.js +35 -23
- package/src/mixin/ready-state.js +37 -0
- package/src/stores/datasource.js +11 -0
- package/src/themes/default/index.js +1 -1
- package/src/utils/dashboard.js +1080 -0
- package/src/utils/event-bus.js +8 -0
- package/src/utils/helpers.js +56 -8
- package/src/utils/helpers.mjs +35 -1
- package/src/utils/preset-selector.js +5 -2
- package/src/utils/preset-selector.mjs +23 -13
- package/src/widgets/Dashboard/BarChart.vue +330 -0
- package/src/widgets/Dashboard/BarChartSetting.vue +317 -0
- package/src/widgets/Dashboard/DatasourceFilterSharing.vue +93 -0
- package/src/widgets/Dashboard/DatasourcePreview.vue +93 -0
- package/src/widgets/Dashboard/DatasourceSelector.vue +122 -0
- package/src/widgets/Dashboard/Doughnut.vue +157 -0
- package/src/widgets/Dashboard/DoughnutSetting.vue +196 -0
- package/src/widgets/Dashboard/GHeatMapsSetting.vue +108 -0
- package/src/widgets/Dashboard/InteractionEdit.vue +228 -0
- package/src/widgets/Dashboard/Metric.vue +76 -0
- package/src/widgets/Dashboard/MetricSetting.vue +174 -0
- package/src/widgets/Dashboard/Pie.vue +139 -0
- package/src/widgets/Dashboard/PieSetting.vue +247 -0
- package/src/widgets/Dashboard/PolarArea.vue +159 -0
- package/src/widgets/Dashboard/PolarAreaSetting.vue +195 -0
- package/src/widgets/Dashboard/SharingModal.vue +116 -0
- package/src/widgets/Dashboard/ViewSelector.vue +183 -0
- package/src/widgets/Dashboard/VirtualColumnEdit.vue +97 -0
- package/src/widgets/Dashboard/VirtualTableSetting.vue +234 -0
- package/src/widgets/Dashboard.vue +1773 -0
- package/src/widgets/PresetBar.vue +136 -175
- package/src/widgets/PresetBarPivot.vue +186 -0
- package/src/widgets/UserActionBuilder/UserActionCondition.vue +97 -0
- package/src/widgets/UserActionBuilder/UserActionConsole.vue +77 -0
- package/src/widgets/UserActionBuilder/UserActionItem.vue +163 -58
- package/src/widgets/UserActionBuilder/UserActionOutput.vue +35 -9
- package/src/widgets/UserActionBuilder/UserActionOutputDelay.vue +27 -0
- package/src/widgets/UserActionBuilder/UserActionOutputLog.vue +28 -0
- package/src/widgets/UserActionBuilder/UserActionOutputReply.vue +135 -0
- package/src/widgets/UserActionBuilder/UserActionProps.vue +211 -0
- package/src/widgets/UserActionBuilder.vue +68 -199
- package/src/widgets/WebPageBuilder4/GridSetting.vue +123 -73
- package/src/widgets/WebPageBuilder4/HeightSetting.vue +14 -11
- package/src/widgets/WebPageBuilder4/MarginSetting.vue +4 -1
- package/src/widgets/WebPageBuilder4/MultiValueSetting.vue +12 -4
- package/src/widgets/WebPageBuilder4/PaddingSetting.vue +4 -0
- package/src/widgets/WebPageBuilder4/TreeView.vue +6 -3
- package/src/widgets/WebPageBuilder4/TreeViewItem.vue +32 -58
- package/tailwind.config.js +2 -2
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="readyState === 1" class="flex flex-col gap-2">
|
|
3
|
+
<PolarArea class="aspect-square"
|
|
4
|
+
:options="chartOptions"
|
|
5
|
+
:data="chartData" />
|
|
6
|
+
|
|
7
|
+
<div class="px-3 text-center text-ellipsis overflow-hidden whitespace-nowrap capitalize">
|
|
8
|
+
{{ label }}
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<div v-else-if="readyState === 2" class="aspect-square flex items-center justify-center">
|
|
13
|
+
<label class="text-text-300">Loading...</label>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
|
|
19
|
+
import {PolarArea} from 'vue-chartjs'
|
|
20
|
+
import {color} from 'chart.js/helpers'
|
|
21
|
+
import {strVars} from "../../utils/helpers.mjs";
|
|
22
|
+
import {readyStateMixin} from "../../mixin/ready-state";
|
|
23
|
+
|
|
24
|
+
export default{
|
|
25
|
+
|
|
26
|
+
components: {
|
|
27
|
+
PolarArea
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
computed: {
|
|
31
|
+
|
|
32
|
+
chartData(){
|
|
33
|
+
if(!this.value?.datasets)
|
|
34
|
+
return { labels:[], datasets:[] }
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
labels: this.value?.labels ?? [],
|
|
38
|
+
datasets: this.value.datasets.map(_ => {
|
|
39
|
+
return {
|
|
40
|
+
..._,
|
|
41
|
+
borderWidth: 1,
|
|
42
|
+
borderColor: function(context, options) {
|
|
43
|
+
const hex = options.color;
|
|
44
|
+
return color(hex).darken(0.5).rgbString()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
chartOptions(){
|
|
52
|
+
return {
|
|
53
|
+
responsive: true,
|
|
54
|
+
maintainAspectRatio: true,
|
|
55
|
+
plugins: {
|
|
56
|
+
legend: {
|
|
57
|
+
display: false
|
|
58
|
+
},
|
|
59
|
+
tooltip: {
|
|
60
|
+
callbacks: {
|
|
61
|
+
title: function(tooltipItems) {
|
|
62
|
+
return `${tooltipItems[0].label}`;
|
|
63
|
+
},
|
|
64
|
+
label: (tooltipItem) => {
|
|
65
|
+
const total = tooltipItem.dataset.data.reduce((a, b) => a + b, 0)
|
|
66
|
+
const percentage = ((tooltipItem.raw / total) * 100).toFixed(1)
|
|
67
|
+
|
|
68
|
+
return `${tooltipItem.dataset.label}: ${tooltipItem.raw} (${percentage}%)`;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
scales: {
|
|
74
|
+
r: {
|
|
75
|
+
display: false
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
onClick: this.onClick
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
data(){
|
|
85
|
+
return {
|
|
86
|
+
backgroundColors: [
|
|
87
|
+
'#5D9CEC',
|
|
88
|
+
'#A0D468',
|
|
89
|
+
'#FFCE54',
|
|
90
|
+
'#FC6E51',
|
|
91
|
+
'#48CFAD',
|
|
92
|
+
'#AC92EC',
|
|
93
|
+
'#4FC1E9',
|
|
94
|
+
'#FFCE54',
|
|
95
|
+
'#ED5565',
|
|
96
|
+
'#EC87C0'
|
|
97
|
+
],
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
inject: [ 'selectPreset' ],
|
|
102
|
+
|
|
103
|
+
methods: {
|
|
104
|
+
|
|
105
|
+
onClick(e, segments){
|
|
106
|
+
|
|
107
|
+
const clickInteractions = (this.interactions ?? []).filter(_ => _.event === 'click')
|
|
108
|
+
const segment = segments[0]
|
|
109
|
+
if(!segment) return
|
|
110
|
+
|
|
111
|
+
const dataset = this.value.datasets[segment.datasetIndex]
|
|
112
|
+
const obj = {
|
|
113
|
+
segment: this.value.labels[segment.index],
|
|
114
|
+
key: dataset.label,
|
|
115
|
+
value: dataset.data[segment.index]
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
for(let click of clickInteractions){
|
|
119
|
+
const { action, presetUid, filters } = click
|
|
120
|
+
|
|
121
|
+
const params = filters.reduce((res, cur) => {
|
|
122
|
+
res[cur.datasourceUid + '.filters.' + cur.key + '.' + cur.operator] = strVars(cur.value, obj)
|
|
123
|
+
return res
|
|
124
|
+
}, {})
|
|
125
|
+
|
|
126
|
+
switch(action){
|
|
127
|
+
|
|
128
|
+
case 'openDashboardPreset':
|
|
129
|
+
if(typeof this.selectPreset === 'function')
|
|
130
|
+
this.selectPreset(presetUid, params)
|
|
131
|
+
break
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
mixins: [ readyStateMixin ],
|
|
140
|
+
|
|
141
|
+
props: {
|
|
142
|
+
|
|
143
|
+
label: String,
|
|
144
|
+
|
|
145
|
+
value: Object,
|
|
146
|
+
|
|
147
|
+
column: String,
|
|
148
|
+
|
|
149
|
+
datasourceUid: String,
|
|
150
|
+
|
|
151
|
+
interactions: Array,
|
|
152
|
+
|
|
153
|
+
uid: String,
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
</script>
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex flex-col gap-5 p-6">
|
|
3
|
+
|
|
4
|
+
<div class="flex flex-row items-center">
|
|
5
|
+
<label class="flex-1">Active</label>
|
|
6
|
+
<Switch v-model="value.props.enabled" :readonly="readonly" @change="$emit('change')" />
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<div>
|
|
10
|
+
<label class="text-text-400">Datasource</label>
|
|
11
|
+
<Dropdown class="min-w-[150px]"
|
|
12
|
+
:readonly="readonly"
|
|
13
|
+
v-model="value.props.datasourceUid"
|
|
14
|
+
@change="delete value.props.columns">
|
|
15
|
+
<option v-for="obj in datasource"
|
|
16
|
+
:value="obj.uid">
|
|
17
|
+
{{ obj.name }}
|
|
18
|
+
</option>
|
|
19
|
+
</Dropdown>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div>
|
|
23
|
+
<label class="text-text-400">Label</label>
|
|
24
|
+
<Textbox v-model="value.props.label" maxlength="50" placeholder="Label" :readonly="readonly" />
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div v-if="value.props.datasourceUid" class="flex flex-col gap-5">
|
|
28
|
+
<div>
|
|
29
|
+
<label class="text-text-400">Segment</label>
|
|
30
|
+
<div class="flex flex-row gap-2">
|
|
31
|
+
<Dropdown class="min-w-[150px]"
|
|
32
|
+
v-model="value.props.rows"
|
|
33
|
+
:readonly="readonly"
|
|
34
|
+
@change="$emit('change')">
|
|
35
|
+
<option v-for="column in selectedDatasourceColumns"
|
|
36
|
+
:value="column.key">
|
|
37
|
+
{{ column.label }}
|
|
38
|
+
</option>
|
|
39
|
+
</Dropdown>
|
|
40
|
+
|
|
41
|
+
<Dropdown v-model="value.props.rowsModifier"
|
|
42
|
+
:readonly="readonly"
|
|
43
|
+
class="w-[125px]"
|
|
44
|
+
@change="$emit('change')">
|
|
45
|
+
<option value="">-</option>
|
|
46
|
+
<option value="lowercase">Lower</option>
|
|
47
|
+
<option value="capitalize">Capitalize</option>
|
|
48
|
+
<option value="uppercase">Upper</option>
|
|
49
|
+
<option disabled>-----</option>
|
|
50
|
+
<option value="date">Date</option>
|
|
51
|
+
<option value="month">Month</option>
|
|
52
|
+
<option value="year">Year</option>
|
|
53
|
+
<option value="hour">Hour</option>
|
|
54
|
+
<option value="minute">Minute</option>
|
|
55
|
+
</Dropdown>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<div>
|
|
60
|
+
<label class="text-text-400">Value</label>
|
|
61
|
+
<div class="flex flex-row gap-2">
|
|
62
|
+
<Dropdown class="min-w-[150px]"
|
|
63
|
+
v-model="value.props.column"
|
|
64
|
+
:readonly="readonly"
|
|
65
|
+
@change="onColumnChanged">
|
|
66
|
+
<option v-for="column in selectedDatasourceColumns"
|
|
67
|
+
:value="column.key">
|
|
68
|
+
{{ column.label }}
|
|
69
|
+
</option>
|
|
70
|
+
</Dropdown>
|
|
71
|
+
|
|
72
|
+
<Dropdown v-model="value.props.columnModifier"
|
|
73
|
+
:readonly="readonly"
|
|
74
|
+
class="w-[125px]"
|
|
75
|
+
@change="$emit('change')">
|
|
76
|
+
<option value="">-</option>
|
|
77
|
+
<option value="count">Count</option>
|
|
78
|
+
<option value="countDistinct">Unique Count</option>
|
|
79
|
+
<option value="sum">Sum</option>
|
|
80
|
+
<option value="avg">Avg</option>
|
|
81
|
+
<option value="min">Min</option>
|
|
82
|
+
<option value="max">Max</option>
|
|
83
|
+
</Dropdown>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div>
|
|
88
|
+
<div class="flex flex-row gap-2">
|
|
89
|
+
<label class="text-text-400 flex-1">Interactions</label>
|
|
90
|
+
<button type="button" class="text-primary" @click="$refs.interactionEdit.create()">
|
|
91
|
+
<svg width="14" height="14" class="fill-primary" 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 256c0 17.69-14.33 32.01-32 32.01H256v144c0 17.69-14.33 31.99-32 31.99s-32-14.3-32-31.99v-144H48c-17.67 0-32-14.32-32-32.01s14.33-31.99 32-31.99H192v-144c0-17.69 14.33-32.01 32-32.01s32 14.32 32 32.01v144h144C417.7 224 432 238.3 432 256z"/></svg>
|
|
92
|
+
</button>
|
|
93
|
+
</div>
|
|
94
|
+
<div class="mt-1">
|
|
95
|
+
<ListItem :items="interactions"
|
|
96
|
+
class="rounded-xl"
|
|
97
|
+
container-class="flex flex-col divide-y divide-text-50"
|
|
98
|
+
@reorder="(from, to) => { interactions.splice(to, 0, interactions.splice(from, 1)[0]); }">
|
|
99
|
+
<template v-slot="{ item, index }">
|
|
100
|
+
<div class="flex flex-row items-center gap-3 px-3">
|
|
101
|
+
<div data-reorder v-if="interactions.length > 1">
|
|
102
|
+
<svg width="14" height="14" class="fill-text-300" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M496 288H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-128H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16z"/></svg>
|
|
103
|
+
</div>
|
|
104
|
+
<div class="flex-1 p-3 cursor-pointer" @click="$refs.interactionEdit.open(item)">
|
|
105
|
+
{{ item.event }}
|
|
106
|
+
{{ item.eventModifier ? item.eventModifier : '' }}
|
|
107
|
+
</div>
|
|
108
|
+
<button type="button" @click="interactions.splice(index, 1)">
|
|
109
|
+
<svg width="16" height="16" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"/></svg>
|
|
110
|
+
</button>
|
|
111
|
+
</div>
|
|
112
|
+
</template>
|
|
113
|
+
</ListItem>
|
|
114
|
+
|
|
115
|
+
<InteractionEdit ref="interactionEdit" @save="addInteraction" />
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
</div>
|
|
122
|
+
</template>
|
|
123
|
+
|
|
124
|
+
<script>
|
|
125
|
+
|
|
126
|
+
import InteractionEdit from "./InteractionEdit.vue";
|
|
127
|
+
|
|
128
|
+
export default{
|
|
129
|
+
components: {InteractionEdit},
|
|
130
|
+
|
|
131
|
+
computed: {
|
|
132
|
+
|
|
133
|
+
interactions(){
|
|
134
|
+
if(!Array.isArray(this.value.props.interactions))
|
|
135
|
+
this.value.props.interactions = []
|
|
136
|
+
return this.value.props.interactions
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
selectedDatasource(){
|
|
140
|
+
return this.datasource.find(d => d.uid === this.value.props.datasourceUid)
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
selectedDatasourceColumns(){
|
|
144
|
+
if(!this.selectedDatasource) return []
|
|
145
|
+
|
|
146
|
+
return this.selectedDatasource.pivot?.enabled ?
|
|
147
|
+
this.selectedDatasource.pivot.columns :
|
|
148
|
+
[
|
|
149
|
+
...(this.selectedDatasource.computedColumns ?? []),
|
|
150
|
+
...this.selectedDatasource.columns
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
emits: [ 'change' ],
|
|
157
|
+
|
|
158
|
+
methods: {
|
|
159
|
+
|
|
160
|
+
addInteraction(obj){
|
|
161
|
+
this.$util.push(this.interactions, obj)
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
applyDefault(){
|
|
165
|
+
if(!this.value.props.datasourceUid && this.datasource?.length === 1){
|
|
166
|
+
this.value.props.datasourceUid = this.datasource[0].uid
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
onColumnChanged(){
|
|
171
|
+
if(!this.value.props.label)
|
|
172
|
+
this.value.props.label = this.value.props.column
|
|
173
|
+
|
|
174
|
+
this.$emit('change')
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
mounted() {
|
|
180
|
+
this.applyDefault()
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
props: {
|
|
184
|
+
|
|
185
|
+
datasource: Object,
|
|
186
|
+
|
|
187
|
+
readonly: [ Boolean, Number ],
|
|
188
|
+
|
|
189
|
+
value: Object
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
</script>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Modal ref="modal"
|
|
3
|
+
width="360"
|
|
4
|
+
height="480" @show="$refs.search.select()">
|
|
5
|
+
<template v-slot:head>
|
|
6
|
+
<div class="relative p-6 flex flex-col gap-4">
|
|
7
|
+
<h3>Sharing</h3>
|
|
8
|
+
<div class="absolute top-0 right-0 p-2">
|
|
9
|
+
<button type="button" class="p-2" @click="close">
|
|
10
|
+
<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">
|
|
11
|
+
<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"/>
|
|
12
|
+
</svg>
|
|
13
|
+
</button>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div>
|
|
17
|
+
<Textbox @keyup.enter="load"
|
|
18
|
+
ref="search"
|
|
19
|
+
v-model="search"
|
|
20
|
+
placeholder="Search..."
|
|
21
|
+
:clearable="true"
|
|
22
|
+
@clear="load(search = '')">
|
|
23
|
+
<template #start>
|
|
24
|
+
<div class="pl-3">
|
|
25
|
+
<svg width="14" height="14" class="fill-text-200" 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="M500.3 443.7l-119.7-119.7c27.22-40.41 40.65-90.9 33.46-144.7C401.8 87.79 326.8 13.32 235.2 1.723C99.01-15.51-15.51 99.01 1.724 235.2c11.6 91.64 86.08 166.7 177.6 178.9c53.8 7.189 104.3-6.236 144.7-33.46l119.7 119.7c15.62 15.62 40.95 15.62 56.57 0C515.9 484.7 515.9 459.3 500.3 443.7zM79.1 208c0-70.58 57.42-128 128-128s128 57.42 128 128c0 70.58-57.42 128-128 128S79.1 278.6 79.1 208z"/></svg>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
</Textbox>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
<div class="flex-1 p-6 flex flex-col">
|
|
33
|
+
|
|
34
|
+
<div v-if="items?.length > 0">
|
|
35
|
+
<div v-for="item in items" :class="$style.button" @click="select(item)">
|
|
36
|
+
<slot name="item" :item="item">
|
|
37
|
+
<div>{{ item.name }}</div>
|
|
38
|
+
</slot>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div v-else class="flex-1 flex items-center justify-center">
|
|
43
|
+
<label class="text-text-300">
|
|
44
|
+
{{ search ? 'No result found' : 'Enter search keyword above' }}
|
|
45
|
+
</label>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
</div>
|
|
49
|
+
</Modal>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
|
|
54
|
+
export default{
|
|
55
|
+
|
|
56
|
+
emits: [ 'select' ],
|
|
57
|
+
|
|
58
|
+
inject: [ 'socket', 'toast' ],
|
|
59
|
+
|
|
60
|
+
name: 'SharingModal',
|
|
61
|
+
|
|
62
|
+
props: {
|
|
63
|
+
src: String
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
data(){
|
|
67
|
+
return {
|
|
68
|
+
items: null,
|
|
69
|
+
selectedIds: null,
|
|
70
|
+
callback: null,
|
|
71
|
+
search: '',
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
methods: {
|
|
76
|
+
|
|
77
|
+
close(){
|
|
78
|
+
this.$refs.modal.close()
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
load(){
|
|
82
|
+
this.socket.send(this.src, { search:this.search })
|
|
83
|
+
.then(res => {
|
|
84
|
+
this.items = res.items
|
|
85
|
+
})
|
|
86
|
+
.catch(err => this.toast(err))
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
open(selectedIds, opt){
|
|
90
|
+
this.selectedIds = selectedIds
|
|
91
|
+
this.callback = opt?.callback
|
|
92
|
+
this.load()
|
|
93
|
+
this.$refs.modal.open()
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
select(item){
|
|
97
|
+
if(typeof this.callback === 'function')
|
|
98
|
+
this.callback(item)
|
|
99
|
+
this.$emit('select', item)
|
|
100
|
+
this.close()
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<style module>
|
|
110
|
+
|
|
111
|
+
.button{
|
|
112
|
+
@apply text-left p-3 border-[1px] border-transparent rounded-lg cursor-pointer;
|
|
113
|
+
@apply hover:border-primary-300 hover:bg-primary-100;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
</style>
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Modal ref="modal"
|
|
3
|
+
width="600"
|
|
4
|
+
height="600"
|
|
5
|
+
:dismissable="true"
|
|
6
|
+
@dismiss="close">
|
|
7
|
+
<template v-slot:head>
|
|
8
|
+
<div class="relative p-6 flex flex-col gap-3">
|
|
9
|
+
<h3>{{ $t('Select View') }}</h3>
|
|
10
|
+
<div class="absolute top-0 right-0 p-2">
|
|
11
|
+
<button type="button" class="p-2" @click="close">
|
|
12
|
+
<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">
|
|
13
|
+
<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"/>
|
|
14
|
+
</svg>
|
|
15
|
+
</button>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div class="flex justify-center">
|
|
19
|
+
<Tabs :items="tabItems" v-model="tabIndex" />
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
<div class="flex-1 p-6">
|
|
24
|
+
|
|
25
|
+
<div v-if="tabIndex === 1">
|
|
26
|
+
<button v-for="component in collections"
|
|
27
|
+
type="button"
|
|
28
|
+
:class="$style.button"
|
|
29
|
+
:disabled="isDisabled"
|
|
30
|
+
@click="add(component)">
|
|
31
|
+
<Image class="w-[125px] aspect-square rounded-xl"
|
|
32
|
+
item-class="object-center object-contain"
|
|
33
|
+
:src="component.thumbnailUrl" />
|
|
34
|
+
<label>{{ component.name ?? component.text }}</label>
|
|
35
|
+
</button>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<div v-if="tabIndex === 2" class="grid grid-cols-3 gap-3">
|
|
39
|
+
<button v-for="component in layouts"
|
|
40
|
+
type="button"
|
|
41
|
+
:class="$style.button"
|
|
42
|
+
:disabled="isDisabled"
|
|
43
|
+
@click="add(component)">
|
|
44
|
+
<Image class="w-[125px] aspect-square rounded-xl"
|
|
45
|
+
item-class="object-center object-contain"
|
|
46
|
+
:src="component.thumbnailUrl" />
|
|
47
|
+
<label>{{ component.name ?? component.text }}</label>
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<div v-if="tabIndex === 3" class="grid grid-cols-3 gap-6">
|
|
52
|
+
<button v-for="component in components"
|
|
53
|
+
type="button"
|
|
54
|
+
:class="$style.button"
|
|
55
|
+
:disabled="isDisabled"
|
|
56
|
+
@click="add(component)">
|
|
57
|
+
<Image class="w-[125px] aspect-square rounded-xl"
|
|
58
|
+
item-class="object-center object-contain"
|
|
59
|
+
:src="component.thumbnailUrl" />
|
|
60
|
+
<label>{{ component.name ?? component.text }}</label>
|
|
61
|
+
</button>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
</div>
|
|
65
|
+
</Modal>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script>
|
|
69
|
+
|
|
70
|
+
import Modal from "../../components/Modal.vue"
|
|
71
|
+
import md5 from "md5";
|
|
72
|
+
|
|
73
|
+
export default{
|
|
74
|
+
|
|
75
|
+
components: { Modal },
|
|
76
|
+
|
|
77
|
+
computed: {
|
|
78
|
+
|
|
79
|
+
components(){
|
|
80
|
+
return this.allComponents.filter(_ => _.group === 'components')
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
collections(){
|
|
84
|
+
return this.allComponents.filter(_ => _.group === 'collections')
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
layouts(){
|
|
88
|
+
return this.allComponents.filter(_ => _.group === 'layouts')
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
data(){
|
|
94
|
+
return {
|
|
95
|
+
allComponents: [
|
|
96
|
+
{ type:'Grid', name:'Grid 2 Columns', group:"layouts", import: () => import('../../configs/dashboard/grid-2.js'), thumbnailUrl:"/static/dashboard/grid-2.png" },
|
|
97
|
+
{ type:'Grid', name:'Grid 3 Columns', group:"layouts", import: () => import('../../configs/dashboard/grid-3.js'), thumbnailUrl:"/static/dashboard/grid-3.png" },
|
|
98
|
+
{ type:'Grid', name:'Grid 4 Columns', group:"layouts", import: () => import('../../configs/dashboard/grid-4.js'), thumbnailUrl:"/static/dashboard/grid-4.png" },
|
|
99
|
+
{ type:'Grid', name:'Grid 5 Columns', group:"layouts", import: () => import('../../configs/dashboard/grid.js'), thumbnailUrl:"/static/dashboard/grid-5.png" },
|
|
100
|
+
|
|
101
|
+
{ type:"Pie", name:"Pie", group:"components", import: () => import('../../configs/dashboard/pie.js'), thumbnailUrl:"/static/dashboard/pie.png" },
|
|
102
|
+
{ type:"Doughnut", name:"Doughnut", group:"components", import: () => import('../../configs/dashboard/doughnut.js'), thumbnailUrl:"/static/dashboard/doughnut.png" },
|
|
103
|
+
{ type:"PolarArea", name:"Polar Area", group:"components", import: () => import('../../configs/dashboard/polar-area.js'), thumbnailUrl:"/static/dashboard/polar-area.png" },
|
|
104
|
+
{ type:"VirtualTable", name:"Table", group:"components", import: () => import('../../configs/dashboard/virtual-table.js'), thumbnailUrl:"/static/dashboard/virtual-table.png" },
|
|
105
|
+
{ type:"Metric", name:"Metric", group:"components", import: () => import('../../configs/dashboard/metric.js'), thumbnailUrl:"/static/dashboard/metric.png" },
|
|
106
|
+
{ type:"BarChart", name:"Bar Chart", group:"components", import: () => import('../../configs/dashboard/bar.js'), thumbnailUrl:"/static/dashboard/bar.png" },
|
|
107
|
+
{ type:"GHeatMaps", name:"Heat Map", group:"components", import: () => import('../../configs/dashboard/gheatmaps.js'), thumbnailUrl:"/static/dashboard/gheatmaps.png" },
|
|
108
|
+
],
|
|
109
|
+
|
|
110
|
+
callback: null,
|
|
111
|
+
instance: null,
|
|
112
|
+
|
|
113
|
+
isDisabled: false,
|
|
114
|
+
|
|
115
|
+
tabIndex: 3,
|
|
116
|
+
tabItems: [
|
|
117
|
+
//{ text:'Collection', value:1 },
|
|
118
|
+
{ text:'Layouts', value:2 },
|
|
119
|
+
{ text:'Components', value:3 },
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
emits: [ 'add' ],
|
|
125
|
+
|
|
126
|
+
inject: [ 'dashboardStyle', 'socketEmit2' ],
|
|
127
|
+
|
|
128
|
+
methods: {
|
|
129
|
+
|
|
130
|
+
async add(component){
|
|
131
|
+
this.isDisabled = true
|
|
132
|
+
|
|
133
|
+
if(component.import){
|
|
134
|
+
component = (await component.import()).component
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const newComponent = JSON.parse(JSON.stringify(component))
|
|
138
|
+
newComponent.uid = md5(newComponent.type + Date.now())
|
|
139
|
+
newComponent.name = newComponent.type
|
|
140
|
+
|
|
141
|
+
if(!newComponent.props)
|
|
142
|
+
newComponent.props = {}
|
|
143
|
+
|
|
144
|
+
newComponent.props.enabled = true
|
|
145
|
+
|
|
146
|
+
if(component.isContainer && !Array.isArray(newComponent).items)
|
|
147
|
+
newComponent.items = []
|
|
148
|
+
|
|
149
|
+
if(typeof this.callback === 'function')
|
|
150
|
+
this.callback(newComponent)
|
|
151
|
+
|
|
152
|
+
this.$emit('add', newComponent)
|
|
153
|
+
this.close()
|
|
154
|
+
this.isDisabled = false
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
open(callback){
|
|
158
|
+
this.callback = callback
|
|
159
|
+
this.$refs.modal.open()
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
close(){
|
|
163
|
+
this.$refs.modal.close()
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
props: {
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
</script>
|
|
174
|
+
|
|
175
|
+
<style module>
|
|
176
|
+
|
|
177
|
+
.button{
|
|
178
|
+
@apply flex flex-col gap-2 items-center rounded-xl p-3;
|
|
179
|
+
@apply hover:bg-text-50 border-[1px] border-transparent hover:border-text-200;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
</style>
|