@mixd-id/web-scaffold 0.2.240702 → 0.2.240704
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 +37 -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/BotEditor/BotEditorActions.vue +162 -0
- package/src/widgets/BotEditor.vue +228 -0
- 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/PresetSelector.vue +2 -2
- package/src/widgets/UserActionBuilder/UserActionCondition.vue +99 -0
- package/src/widgets/UserActionBuilder/UserActionConsole.vue +77 -0
- package/src/widgets/UserActionBuilder/UserActionItem.vue +166 -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 +213 -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,108 @@
|
|
|
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">Value</label>
|
|
30
|
+
<div class="flex flex-row gap-2">
|
|
31
|
+
<Dropdown class="flex-1"
|
|
32
|
+
v-model="value.props.column"
|
|
33
|
+
:readonly="readonly"
|
|
34
|
+
@change="onColumnChanged">
|
|
35
|
+
<option v-for="column in selectedDatasource?.columns"
|
|
36
|
+
:value="column.key">
|
|
37
|
+
{{ column.label }}
|
|
38
|
+
</option>
|
|
39
|
+
</Dropdown>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script>
|
|
49
|
+
|
|
50
|
+
import InteractionEdit from "./InteractionEdit.vue";
|
|
51
|
+
|
|
52
|
+
export default{
|
|
53
|
+
components: {InteractionEdit},
|
|
54
|
+
|
|
55
|
+
computed: {
|
|
56
|
+
|
|
57
|
+
interactions(){
|
|
58
|
+
if(!Array.isArray(this.value.props.interactions))
|
|
59
|
+
this.value.props.interactions = []
|
|
60
|
+
return this.value.props.interactions
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
selectedDatasource(){
|
|
64
|
+
return this.datasource.find(d => d.uid === this.value.props.datasourceUid)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
emits: [ 'change' ],
|
|
70
|
+
|
|
71
|
+
mounted() {
|
|
72
|
+
this.applyDefault()
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
props: {
|
|
76
|
+
|
|
77
|
+
datasource: Object,
|
|
78
|
+
|
|
79
|
+
readonly: [ Boolean, Number ],
|
|
80
|
+
|
|
81
|
+
value: Object
|
|
82
|
+
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
methods: {
|
|
86
|
+
|
|
87
|
+
addInteraction(obj){
|
|
88
|
+
this.$util.push(this.interactions, obj)
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
applyDefault(){
|
|
92
|
+
if(!this.value.props.datasourceUid && this.datasource?.length === 1){
|
|
93
|
+
this.value.props.datasourceUid = this.datasource[0].uid
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
onColumnChanged(){
|
|
98
|
+
if(!this.value.props.label)
|
|
99
|
+
this.value.props.label = this.value.props.column
|
|
100
|
+
|
|
101
|
+
this.$emit('change')
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
</script>
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Modal :state="state"
|
|
3
|
+
:hash="hash"
|
|
4
|
+
ref="modal"
|
|
5
|
+
width="400"
|
|
6
|
+
height="480">
|
|
7
|
+
<template v-slot:head>
|
|
8
|
+
<div class="relative p-6">
|
|
9
|
+
<h3>Add Interaction</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
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
<template v-slot:foot>
|
|
20
|
+
<div class="p-6">
|
|
21
|
+
<Button class="w-[80px]" :state="canSave ? 1 : -1" @click="save">Save</Button>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
<div class="flex-1 p-6 flex flex-col gap-6">
|
|
25
|
+
|
|
26
|
+
<div>
|
|
27
|
+
<div class="flex flex-row gap-4">
|
|
28
|
+
<div class="flex-1">
|
|
29
|
+
<label class="text-text-400">Event</label>
|
|
30
|
+
<Dropdown v-model="instance.event">
|
|
31
|
+
<option value="click">Click</option>
|
|
32
|
+
</Dropdown>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div class="w-[100px]">
|
|
36
|
+
<label class="text-text-400">Modifier</label>
|
|
37
|
+
<Dropdown v-model="instance.eventModifier">
|
|
38
|
+
<option value="">None</option>
|
|
39
|
+
<option value="alt">Alt</option>
|
|
40
|
+
<option value="shift">Shift</option>
|
|
41
|
+
<option value="meta">Meta</option>
|
|
42
|
+
</Dropdown>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<div>
|
|
48
|
+
<label class="text-text-400">Action</label>
|
|
49
|
+
<div>
|
|
50
|
+
<Dropdown v-model="instance.action">
|
|
51
|
+
<option disabled selected value="">Select Action</option>
|
|
52
|
+
<option value="openDashboardPreset">Open Preset</option>
|
|
53
|
+
</Dropdown>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<div v-if="instance.action === 'openDashboardPreset'" class="flex flex-col gap-6">
|
|
58
|
+
|
|
59
|
+
<div>
|
|
60
|
+
<label class="text-text-400">Preset Name</label>
|
|
61
|
+
<Dropdown v-model="instance.presetUid">
|
|
62
|
+
<option disabled selected value="">Select Preset</option>
|
|
63
|
+
<option v-for="preset in presets" :value="preset.uid">{{ preset.name }}</option>
|
|
64
|
+
</Dropdown>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div>
|
|
68
|
+
<div class="flex flex-row items-center gap-2 mb-1">
|
|
69
|
+
<label class="text-text-400 flex-1">Filters</label>
|
|
70
|
+
<button type="button" @click="addFilter">
|
|
71
|
+
<svg width="16" height="16" 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 256C432 269.3 421.3 280 408 280h-160v160c0 13.25-10.75 24.01-24 24.01S200 453.3 200 440v-160h-160c-13.25 0-24-10.74-24-23.99C16 242.8 26.75 232 40 232h160v-160c0-13.25 10.75-23.99 24-23.99S248 58.75 248 72v160h160C421.3 232 432 242.8 432 256z"/></svg>
|
|
72
|
+
</button>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<ListItem :items="filters"
|
|
76
|
+
class="bg-transparent"
|
|
77
|
+
@reorder="(from, to) => { filters.splice(to, 0, filters.splice(from, 1)[0]);}">
|
|
78
|
+
<template v-slot="{ item, index }">
|
|
79
|
+
<div class="flex flex-row items-start gap-3">
|
|
80
|
+
<button type="button" @click="filters.splice(index, 1)" class="py-3">
|
|
81
|
+
<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>
|
|
82
|
+
</button>
|
|
83
|
+
<div class="flex-1 flex flex-col gap-2">
|
|
84
|
+
<div class="flex flex-row gap-2">
|
|
85
|
+
<Dropdown v-model="item.datasourceUid" class="w-[120px]">
|
|
86
|
+
<option disabled selected>Select Datasource</option>
|
|
87
|
+
<option v-for="datasource in selectedPreset.datasource" :value="datasource.uid">
|
|
88
|
+
{{ datasource.name }}
|
|
89
|
+
</option>
|
|
90
|
+
</Dropdown>
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<div class="flex flex-row gap-2" v-if="!!(item.datasource = getDatasource(item.datasourceUid))">
|
|
94
|
+
|
|
95
|
+
<Dropdown v-if="item.datasource.pivot?.enabled" v-model="item.key" class="w-[100px]">
|
|
96
|
+
<option disabled selected>Select Key</option>
|
|
97
|
+
<option v-for="column in item.datasource.pivot.columns" :value="column.key">{{ column.label }}</option>
|
|
98
|
+
</Dropdown>
|
|
99
|
+
<Dropdown v-else v-model="item.key" class="w-[100px]">
|
|
100
|
+
<option disabled selected>Select Key</option>
|
|
101
|
+
<option v-for="column in item.datasource.columns" :value="column.key">{{ column.label }}</option>
|
|
102
|
+
</Dropdown>
|
|
103
|
+
|
|
104
|
+
<div class="flex-1 flex flex-row gap-2">
|
|
105
|
+
<Dropdown v-model="item.operator"
|
|
106
|
+
class="w-[80px]">
|
|
107
|
+
<option value="eq">Equal</option>
|
|
108
|
+
<option value="not">Not Equal</option>
|
|
109
|
+
<option value="startsWith">Starts With</option>
|
|
110
|
+
<option value="endsWith">Ends With</option>
|
|
111
|
+
<option value="contains">Contains</option>
|
|
112
|
+
<option value="notContains">Not Contains</option>
|
|
113
|
+
<option value="in">Multiple with comma</option>
|
|
114
|
+
<option value="notIn">Except with comma</option>
|
|
115
|
+
<option value="regex">Regex</option>
|
|
116
|
+
</Dropdown>
|
|
117
|
+
|
|
118
|
+
<TextWithTag :items="tags" v-model="item.value" class="flex-1" variant="minimal" />
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
</template>
|
|
125
|
+
</ListItem>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
</div>
|
|
131
|
+
</Modal>
|
|
132
|
+
</template>
|
|
133
|
+
|
|
134
|
+
<script>
|
|
135
|
+
|
|
136
|
+
import md5 from "md5";
|
|
137
|
+
|
|
138
|
+
export default{
|
|
139
|
+
|
|
140
|
+
emits: [ 'save' ],
|
|
141
|
+
|
|
142
|
+
inject: [ 'getPresets', 'socket' ],
|
|
143
|
+
|
|
144
|
+
computed: {
|
|
145
|
+
|
|
146
|
+
canSave(){
|
|
147
|
+
return this.instance.event && this.instance.action
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
filters(){
|
|
151
|
+
if(!Array.isArray(this.instance.filters))
|
|
152
|
+
this.instance.filters = []
|
|
153
|
+
return this.instance.filters
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
presets(){
|
|
157
|
+
return this.getPresets()
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
selectedPreset(){
|
|
161
|
+
return this.presets.find(p => p.uid === this.instance.presetUid)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
props: {
|
|
167
|
+
state: Boolean,
|
|
168
|
+
hash: String
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
data(){
|
|
172
|
+
return {
|
|
173
|
+
instance: null,
|
|
174
|
+
tags: [
|
|
175
|
+
{ text:"Segment", value:"{segment}" },
|
|
176
|
+
{ text:"Key", value:"{key}" },
|
|
177
|
+
{ text:"Value", value:"{value}" },
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
methods: {
|
|
183
|
+
|
|
184
|
+
addFilter(){
|
|
185
|
+
const newFilter = {
|
|
186
|
+
uid: md5('filter-' + new Date().getTime()),
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
this.filters.push(newFilter)
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
create(obj){
|
|
193
|
+
this.instance = obj ?? {}
|
|
194
|
+
this.instance.uid = md5('interaction-' + new Date().getTime())
|
|
195
|
+
this.$refs.modal.open()
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
getDatasource(uid){
|
|
199
|
+
return this.selectedPreset.datasource.find(d => d.uid === uid)
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
open(instance){
|
|
203
|
+
this.instance = instance
|
|
204
|
+
this.$refs.modal.open()
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
close(){
|
|
208
|
+
this.$refs.modal.close()
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
save(){
|
|
212
|
+
this.$emit('save', this.instance)
|
|
213
|
+
this.close()
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
</script>
|
|
221
|
+
|
|
222
|
+
<style module>
|
|
223
|
+
|
|
224
|
+
.comp{
|
|
225
|
+
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
</style>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="$style.comp">
|
|
3
|
+
<label class="text-text-400 text-ellipsis overflow-hidden whitespace-nowrap">{{ label }}</label>
|
|
4
|
+
<div class="flex flex-row gap-2">
|
|
5
|
+
<h1 v-if="readyState === 1" class="text-ellipsis overflow-hidden whitespace-nowrap" :class="column2Enabled ? '' : 'text-green-600'">
|
|
6
|
+
{{ cValue }}
|
|
7
|
+
</h1>
|
|
8
|
+
<h1 v-else class="text-ellipsis overflow-hidden whitespace-nowrap text-text-300">
|
|
9
|
+
Loading...
|
|
10
|
+
</h1>
|
|
11
|
+
|
|
12
|
+
<div class="flex flex-col" v-if="column2Enabled && readyState === 1">
|
|
13
|
+
<div class="text-sm text-ellipsis whitespace-nowrap overflow-hidden" :class="value?.comparedPercent <= 50 ? 'text-red-600' : 'text-green-600'">{{ value?.comparedPercent }}%</div>
|
|
14
|
+
<div class="text-sm text-ellipsis whitespace-nowrap overflow-hidden">{{ ccValue }}</div>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
|
|
22
|
+
import {readyStateMixin} from "../../mixin/ready-state";
|
|
23
|
+
|
|
24
|
+
export default{
|
|
25
|
+
|
|
26
|
+
computed: {
|
|
27
|
+
|
|
28
|
+
cValue(){
|
|
29
|
+
let value = parseFloat(this.value?.value)
|
|
30
|
+
if(isNaN(value)) return 'N/A'
|
|
31
|
+
return value.toLocaleString()
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
ccValue(){
|
|
35
|
+
if(!this.column2Enabled) return
|
|
36
|
+
|
|
37
|
+
let value = parseFloat(this.value?.comparedValue)
|
|
38
|
+
if(isNaN(value)) return 'N/A'
|
|
39
|
+
return value.toLocaleString()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
mixins: [ readyStateMixin ],
|
|
45
|
+
|
|
46
|
+
props: {
|
|
47
|
+
|
|
48
|
+
column: String,
|
|
49
|
+
columnModifier: String,
|
|
50
|
+
|
|
51
|
+
column2: String,
|
|
52
|
+
column2Enabled: [ Boolean, Number ],
|
|
53
|
+
column2Modifier: String,
|
|
54
|
+
|
|
55
|
+
datasourceUid: String,
|
|
56
|
+
|
|
57
|
+
label: String,
|
|
58
|
+
|
|
59
|
+
value: Object,
|
|
60
|
+
|
|
61
|
+
uid: String,
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<style module>
|
|
70
|
+
|
|
71
|
+
.comp{
|
|
72
|
+
@apply border-[1px] border-text-50 bg-base-500 rounded-xl overflow-hidden;
|
|
73
|
+
@apply p-3 flex flex-col gap-1;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
</style>
|
|
@@ -0,0 +1,174 @@
|
|
|
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 class="flex flex-col gap-1">
|
|
10
|
+
<div class="flex flex-row gap-2">
|
|
11
|
+
<label class="flex-1">Datasource</label>
|
|
12
|
+
<button type="button" class="text-primary"
|
|
13
|
+
@click="previewDatasource(selectedDatasource)">Preview</button>
|
|
14
|
+
</div>
|
|
15
|
+
<Dropdown class="min-w-[150px]"
|
|
16
|
+
:readonly="readonly"
|
|
17
|
+
v-model="value.props.datasourceUid"
|
|
18
|
+
@change="delete value.props.columns">
|
|
19
|
+
<option v-for="obj in datasource"
|
|
20
|
+
:value="obj.uid">
|
|
21
|
+
{{ obj.name }}
|
|
22
|
+
</option>
|
|
23
|
+
</Dropdown>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div class="flex flex-col gap-1">
|
|
27
|
+
<label class="flex-1">Label</label>
|
|
28
|
+
<Textbox v-model="value.props.label"
|
|
29
|
+
maxlength="30"
|
|
30
|
+
placeholder="Label"
|
|
31
|
+
:readonly="readonly"
|
|
32
|
+
@keyup.enter="$emit('change')"
|
|
33
|
+
@blur="$emit('change')" />
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<div v-if="value.props.datasourceUid" class="flex flex-col gap-5">
|
|
37
|
+
<div class="flex flex-col gap-1">
|
|
38
|
+
<label class="flex-1">Column</label>
|
|
39
|
+
<div class="flex flex-row gap-2">
|
|
40
|
+
<Dropdown class="min-w-[150px] flex-1"
|
|
41
|
+
:readonly="readonly"
|
|
42
|
+
v-model="value.props.column"
|
|
43
|
+
@change="$emit('change')">
|
|
44
|
+
<option v-for="column in selectedDatasourceColumns"
|
|
45
|
+
:value="column.key">
|
|
46
|
+
{{ selectedDatasource.pivot?.enabled ? column.key : column.label }}
|
|
47
|
+
</option>
|
|
48
|
+
</Dropdown>
|
|
49
|
+
|
|
50
|
+
<Dropdown class="w-[125px]"
|
|
51
|
+
:readonly="readonly"
|
|
52
|
+
v-model="value.props.columnModifier"
|
|
53
|
+
@change="$emit('change')">
|
|
54
|
+
<option value="count">Count</option>
|
|
55
|
+
<option value="countDistinct">Unique Count</option>
|
|
56
|
+
<option value="sum">Sum</option>
|
|
57
|
+
<option value="avg">Avg</option>
|
|
58
|
+
<option value="min">Min</option>
|
|
59
|
+
<option value="max">Max</option>
|
|
60
|
+
<option value="first">First</option>
|
|
61
|
+
<option value="last">Last</option>
|
|
62
|
+
</Dropdown>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div class="flex flex-col gap-2">
|
|
67
|
+
<div>
|
|
68
|
+
<Checkbox v-model="value.props.column2Enabled" :disabled="readonly">
|
|
69
|
+
Compare to
|
|
70
|
+
</Checkbox>
|
|
71
|
+
</div>
|
|
72
|
+
<div class="flex flex-row gap-2">
|
|
73
|
+
<Dropdown class="min-w-[150px] flex-1"
|
|
74
|
+
:readonly="readonly || !value.props.column2Enabled"
|
|
75
|
+
v-model="value.props.column2"
|
|
76
|
+
@change="$emit('change')">
|
|
77
|
+
<option v-for="column in selectedDatasourceColumns"
|
|
78
|
+
:value="column.key">
|
|
79
|
+
{{ selectedDatasource.pivot?.enabled ? column.key : column.label }}
|
|
80
|
+
</option>
|
|
81
|
+
</Dropdown>
|
|
82
|
+
|
|
83
|
+
<Dropdown class="w-[125px]"
|
|
84
|
+
:readonly="readonly || !value.props.column2Enabled"
|
|
85
|
+
v-model="value.props.column2Modifier"
|
|
86
|
+
@change="$emit('change')">
|
|
87
|
+
<option value="count">Count</option>
|
|
88
|
+
<option value="countDistinct">Unique Count</option>
|
|
89
|
+
<option value="sum">Sum</option>
|
|
90
|
+
<option value="avg">Avg</option>
|
|
91
|
+
<option value="min">Min</option>
|
|
92
|
+
<option value="max">Max</option>
|
|
93
|
+
<option value="first">First</option>
|
|
94
|
+
<option value="last">Last</option>
|
|
95
|
+
</Dropdown>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div v-if="value.props.column2Enabled && !readonly" class="flex justify-center p-3">
|
|
100
|
+
<button type="button" class="text-primary" @click="swap">
|
|
101
|
+
<svg width="14" height="14" class="fill-primary inline" 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="M449.9 39.96l-48.5 48.53C362.5 53.19 311.4 32 256 32C161.5 32 78.59 92.34 49.58 182.2c-5.438 16.81 3.797 34.88 20.61 40.28c16.97 5.5 34.86-3.812 40.3-20.59C130.9 138.5 189.4 96 256 96c37.96 0 73 14.18 100.2 37.8L311.1 178C295.1 194.8 306.8 223.4 330.4 224h146.9C487.7 223.7 496 215.3 496 204.9V59.04C496 34.99 466.9 22.95 449.9 39.96zM441.8 289.6c-16.94-5.438-34.88 3.812-40.3 20.59C381.1 373.5 322.6 416 256 416c-37.96 0-73-14.18-100.2-37.8L200 334C216.9 317.2 205.2 288.6 181.6 288H34.66C24.32 288.3 16 296.7 16 307.1v145.9c0 24.04 29.07 36.08 46.07 19.07l48.5-48.53C149.5 458.8 200.6 480 255.1 480c94.45 0 177.4-60.34 206.4-150.2C467.9 313 458.6 294.1 441.8 289.6z"/></svg>
|
|
102
|
+
Swap
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
</div>
|
|
108
|
+
</template>
|
|
109
|
+
|
|
110
|
+
<script>
|
|
111
|
+
|
|
112
|
+
export default{
|
|
113
|
+
|
|
114
|
+
computed: {
|
|
115
|
+
|
|
116
|
+
selectedDatasource(){
|
|
117
|
+
return this.datasource.find(d => d.uid === this.value.props.datasourceUid)
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
selectedDatasourceColumns(){
|
|
121
|
+
if(!this.selectedDatasource) return []
|
|
122
|
+
|
|
123
|
+
return this.selectedDatasource.pivot?.enabled ?
|
|
124
|
+
this.selectedDatasource.pivot.columns :
|
|
125
|
+
[
|
|
126
|
+
...(this.selectedDatasource.computedColumns ?? []),
|
|
127
|
+
...this.selectedDatasource.columns
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
emits: [ 'change' ],
|
|
134
|
+
|
|
135
|
+
inject: [ 'previewDatasource' ],
|
|
136
|
+
|
|
137
|
+
methods: {
|
|
138
|
+
|
|
139
|
+
swap(){
|
|
140
|
+
const props = {
|
|
141
|
+
column: this.value.props.column2,
|
|
142
|
+
columnModifier: this.value.props.column2Modifier,
|
|
143
|
+
column2: this.value.props.column,
|
|
144
|
+
column2Modifier: this.value.props.columnModifier,
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
Object.assign(this.value.props, props)
|
|
148
|
+
|
|
149
|
+
this.$emit('change')
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
props: {
|
|
155
|
+
|
|
156
|
+
datasource: Object,
|
|
157
|
+
|
|
158
|
+
readonly: [ Boolean, Number ],
|
|
159
|
+
|
|
160
|
+
value: Object
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
</script>
|
|
167
|
+
|
|
168
|
+
<style module>
|
|
169
|
+
|
|
170
|
+
.comp{
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
</style>
|