@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.
Files changed (92) hide show
  1. package/docs/schema/user-action.json +266 -0
  2. package/package.json +6 -2
  3. package/public/assets/dashboard/bar.png +0 -0
  4. package/public/assets/dashboard/doughnut.png +0 -0
  5. package/public/assets/dashboard/metric.png +0 -0
  6. package/public/assets/dashboard/pie.png +0 -0
  7. package/public/assets/dashboard/polar-area.png +0 -0
  8. package/public/assets/dashboard/virtual-table.png +0 -0
  9. package/public/static/dashboard/bar.png +0 -0
  10. package/public/static/dashboard/doughnut.png +0 -0
  11. package/public/static/dashboard/metric.png +0 -0
  12. package/public/static/dashboard/pie.png +0 -0
  13. package/public/static/dashboard/polar-area.png +0 -0
  14. package/public/static/dashboard/virtual-table.png +0 -0
  15. package/src/components/Button.vue +179 -160
  16. package/src/components/Checkbox.vue +0 -1
  17. package/src/components/Datepicker.vue +8 -6
  18. package/src/components/GHeatMaps.vue +317 -0
  19. package/src/components/GmapsDirection.vue +191 -0
  20. package/src/components/Grid.vue +2 -0
  21. package/src/components/HTMLEditor.vue +2 -2
  22. package/src/components/List.vue +384 -308
  23. package/src/components/Modal.vue +2 -3
  24. package/src/components/PresetSelectorFilterItem.vue +15 -2
  25. package/src/components/Switch.vue +3 -0
  26. package/src/components/Tabs.vue +1 -1
  27. package/src/components/TextWithTag.vue +67 -25
  28. package/src/components/Textbox.vue +5 -0
  29. package/src/components/VirtualGrid.vue +224 -228
  30. package/src/components/VirtualTable.vue +46 -28
  31. package/src/configs/dashboard/bar.js +10 -0
  32. package/src/configs/dashboard/collection-1.js +5 -0
  33. package/src/configs/dashboard/doughnut.js +7 -0
  34. package/src/configs/dashboard/gheatmaps.js +9 -0
  35. package/src/configs/dashboard/grid-2.js +34 -0
  36. package/src/configs/dashboard/grid-3.js +34 -0
  37. package/src/configs/dashboard/grid-4.js +34 -0
  38. package/src/configs/dashboard/grid.js +15 -0
  39. package/src/configs/dashboard/metric.js +10 -0
  40. package/src/configs/dashboard/pie.js +7 -0
  41. package/src/configs/dashboard/polar-area.js +7 -0
  42. package/src/configs/dashboard/virtual-table.js +9 -0
  43. package/src/defs/dashboard-preset.js +22 -0
  44. package/src/index.js +35 -23
  45. package/src/mixin/ready-state.js +37 -0
  46. package/src/stores/datasource.js +11 -0
  47. package/src/themes/default/index.js +1 -1
  48. package/src/utils/dashboard.js +1080 -0
  49. package/src/utils/event-bus.js +8 -0
  50. package/src/utils/helpers.js +56 -8
  51. package/src/utils/helpers.mjs +35 -1
  52. package/src/utils/preset-selector.js +5 -2
  53. package/src/utils/preset-selector.mjs +23 -13
  54. package/src/widgets/Dashboard/BarChart.vue +330 -0
  55. package/src/widgets/Dashboard/BarChartSetting.vue +317 -0
  56. package/src/widgets/Dashboard/DatasourceFilterSharing.vue +93 -0
  57. package/src/widgets/Dashboard/DatasourcePreview.vue +93 -0
  58. package/src/widgets/Dashboard/DatasourceSelector.vue +122 -0
  59. package/src/widgets/Dashboard/Doughnut.vue +157 -0
  60. package/src/widgets/Dashboard/DoughnutSetting.vue +196 -0
  61. package/src/widgets/Dashboard/GHeatMapsSetting.vue +108 -0
  62. package/src/widgets/Dashboard/InteractionEdit.vue +228 -0
  63. package/src/widgets/Dashboard/Metric.vue +76 -0
  64. package/src/widgets/Dashboard/MetricSetting.vue +174 -0
  65. package/src/widgets/Dashboard/Pie.vue +139 -0
  66. package/src/widgets/Dashboard/PieSetting.vue +247 -0
  67. package/src/widgets/Dashboard/PolarArea.vue +159 -0
  68. package/src/widgets/Dashboard/PolarAreaSetting.vue +195 -0
  69. package/src/widgets/Dashboard/SharingModal.vue +116 -0
  70. package/src/widgets/Dashboard/ViewSelector.vue +183 -0
  71. package/src/widgets/Dashboard/VirtualColumnEdit.vue +97 -0
  72. package/src/widgets/Dashboard/VirtualTableSetting.vue +234 -0
  73. package/src/widgets/Dashboard.vue +1773 -0
  74. package/src/widgets/PresetBar.vue +136 -175
  75. package/src/widgets/PresetBarPivot.vue +186 -0
  76. package/src/widgets/UserActionBuilder/UserActionCondition.vue +97 -0
  77. package/src/widgets/UserActionBuilder/UserActionConsole.vue +77 -0
  78. package/src/widgets/UserActionBuilder/UserActionItem.vue +163 -58
  79. package/src/widgets/UserActionBuilder/UserActionOutput.vue +35 -9
  80. package/src/widgets/UserActionBuilder/UserActionOutputDelay.vue +27 -0
  81. package/src/widgets/UserActionBuilder/UserActionOutputLog.vue +28 -0
  82. package/src/widgets/UserActionBuilder/UserActionOutputReply.vue +135 -0
  83. package/src/widgets/UserActionBuilder/UserActionProps.vue +211 -0
  84. package/src/widgets/UserActionBuilder.vue +68 -199
  85. package/src/widgets/WebPageBuilder4/GridSetting.vue +123 -73
  86. package/src/widgets/WebPageBuilder4/HeightSetting.vue +14 -11
  87. package/src/widgets/WebPageBuilder4/MarginSetting.vue +4 -1
  88. package/src/widgets/WebPageBuilder4/MultiValueSetting.vue +12 -4
  89. package/src/widgets/WebPageBuilder4/PaddingSetting.vue +4 -0
  90. package/src/widgets/WebPageBuilder4/TreeView.vue +6 -3
  91. package/src/widgets/WebPageBuilder4/TreeViewItem.vue +32 -58
  92. package/tailwind.config.js +2 -2
@@ -0,0 +1,157 @@
1
+ <template>
2
+ <div v-if="readyState === 1" class="flex flex-col gap-2">
3
+
4
+ <Doughnut class="aspect-square"
5
+ :options="chartOptions"
6
+ :data="chartData" />
7
+
8
+ <div class="px-3 text-center text-ellipsis overflow-hidden whitespace-nowrap capitalize">
9
+ {{ label }}
10
+ </div>
11
+
12
+ </div>
13
+
14
+ <div v-else-if="readyState === 2" class="aspect-square flex items-center justify-center">
15
+ <label class="text-text-300">Loading...</label>
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+
21
+ import {Doughnut} from 'vue-chartjs'
22
+ import {color} from "chart.js/helpers";
23
+ import {strVars} from "../../utils/helpers.mjs";
24
+ import {readyStateMixin} from "../../mixin/ready-state";
25
+
26
+ export default{
27
+
28
+ components: {
29
+ Doughnut
30
+ },
31
+
32
+ computed: {
33
+
34
+ chartData(){
35
+ if(!this.value?.datasets)
36
+ return { labels:[], datasets:[] }
37
+
38
+ return {
39
+ labels: this.value?.labels ?? [],
40
+ datasets: this.value.datasets.map(_ => {
41
+ return {
42
+ ..._,
43
+ borderWidth: 1,
44
+ borderColor: function(context, options) {
45
+ const hex = options.color;
46
+ return color(hex).darken(0.5).rgbString()
47
+ }
48
+ }
49
+ })
50
+ }
51
+ },
52
+
53
+ chartOptions(){
54
+ return {
55
+ responsive: true,
56
+ maintainAspectRatio: true,
57
+ /*animation: false,*/
58
+ plugins: {
59
+ legend: {
60
+ display: false
61
+ },
62
+ tooltip: {
63
+ callbacks: {
64
+ title: function(tooltipItems) {
65
+ return `${tooltipItems[0].label}`;
66
+ },
67
+ label: (tooltipItem) => {
68
+ const total = tooltipItem.dataset.data.reduce((a, b) => a + b, 0)
69
+ const percentage = ((tooltipItem.raw / total) * 100).toFixed(1)
70
+
71
+ return `${tooltipItem.dataset.label}: ${tooltipItem.raw} (${percentage}%)`;
72
+ }
73
+ },
74
+ },
75
+ },
76
+ onClick: this.onClick
77
+ }
78
+ },
79
+
80
+ },
81
+
82
+ data(){
83
+ return {
84
+ backgroundColors: [
85
+ '#5D9CEC',
86
+ '#A0D468',
87
+ '#FFCE54',
88
+ '#FC6E51',
89
+ '#48CFAD',
90
+ '#AC92EC',
91
+ '#4FC1E9',
92
+ '#FFCE54',
93
+ '#ED5565',
94
+ '#EC87C0'
95
+ ]
96
+ }
97
+ },
98
+
99
+ inject: [ 'selectPreset' ],
100
+
101
+ methods: {
102
+
103
+ onClick(e, segments){
104
+
105
+ const clickInteractions = (this.interactions ?? []).filter(_ => _.event === 'click')
106
+ const segment = segments[0]
107
+ if(!segment) return
108
+
109
+ const dataset = this.value.datasets[segment.datasetIndex]
110
+ const obj = {
111
+ segment: this.value.labels[segment.index],
112
+ key: dataset.label,
113
+ value: dataset.data[segment.index]
114
+ }
115
+
116
+ for(let click of clickInteractions){
117
+ const { action, presetUid, filters } = click
118
+
119
+ const params = filters.reduce((res, cur) => {
120
+ res[cur.datasourceUid + '.filters.' + cur.key + '.' + cur.operator] = strVars(cur.value, obj)
121
+ return res
122
+ }, {})
123
+
124
+ switch(action){
125
+
126
+ case 'openDashboardPreset':
127
+ if(typeof this.selectPreset === 'function')
128
+ this.selectPreset(presetUid, params)
129
+ break
130
+ }
131
+ }
132
+
133
+ }
134
+
135
+ },
136
+
137
+ mixins: [ readyStateMixin ],
138
+
139
+ props: {
140
+
141
+ label: String,
142
+
143
+ value: Object,
144
+
145
+ column: String,
146
+
147
+ datasourceUid: String,
148
+
149
+ interactions: Array,
150
+
151
+ uid: String,
152
+
153
+ },
154
+
155
+ }
156
+
157
+ </script>
@@ -0,0 +1,196 @@
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 disabled selected>Select Datasource</option>
16
+ <option v-for="obj in datasource"
17
+ :value="obj.uid">
18
+ {{ obj.name }}
19
+ </option>
20
+ </Dropdown>
21
+ </div>
22
+
23
+ <div>
24
+ <label class="text-text-400">Label</label>
25
+ <Textbox v-model="value.props.label" maxlength="50" placeholder="Label" :readonly="readonly" />
26
+ </div>
27
+
28
+ <div v-if="value.props.datasourceUid" class="flex flex-col gap-5">
29
+ <div>
30
+ <label class="text-text-400">Segment</label>
31
+ <div class="flex flex-row gap-2">
32
+ <Dropdown class="min-w-[150px]"
33
+ v-model="value.props.rows"
34
+ :readonly="readonly"
35
+ @change="$emit('change')">
36
+ <option v-for="column in selectedDatasourceColumns"
37
+ :value="column.key">
38
+ {{ column.label }}
39
+ </option>
40
+ </Dropdown>
41
+
42
+ <Dropdown v-model="value.props.rowsModifier"
43
+ :readonly="readonly"
44
+ :class="!value.props.rowsModifier ? 'w-[80px]' : 'w-[150px]'"
45
+ @change="$emit('change')">
46
+ <option value="">-</option>
47
+ <option value="lowercase">Lower</option>
48
+ <option value="capitalize">Capitalize</option>
49
+ <option value="uppercase">Upper</option>
50
+ <option disabled>-----</option>
51
+ <option value="date">Date</option>
52
+ <option value="month">Month</option>
53
+ <option value="year">Year</option>
54
+ <option value="hour">Hour</option>
55
+ <option value="minute">Minute</option>
56
+ </Dropdown>
57
+ </div>
58
+ </div>
59
+
60
+ <div>
61
+ <label class="text-text-400">Value</label>
62
+ <div class="flex flex-row gap-2">
63
+ <Dropdown class="min-w-[150px]"
64
+ v-model="value.props.column"
65
+ :readonly="readonly"
66
+ @change="onColumnChanged">
67
+ <option v-for="column in selectedDatasourceColumns"
68
+ :value="column.key">
69
+ {{ column.label }}
70
+ </option>
71
+ </Dropdown>
72
+
73
+ <Dropdown v-model="value.props.columnModifier"
74
+ :readonly="readonly"
75
+ :class="!value.props.columnModifier ? 'w-[80px]' : 'w-[150px]'"
76
+ @change="$emit('change')">
77
+ <option value="">-</option>
78
+ <option value="count">Count</option>
79
+ <option value="countDistinct">Unique Count</option>
80
+ <option value="sum">Sum</option>
81
+ <option value="avg">Avg</option>
82
+ <option value="min">Min</option>
83
+ <option value="max">Max</option>
84
+ </Dropdown>
85
+ </div>
86
+ </div>
87
+
88
+ <div>
89
+ <div class="flex flex-row gap-2">
90
+ <label class="text-text-400 flex-1">Interactions</label>
91
+ <button type="button" class="text-primary" @click="$refs.interactionEdit.create()">
92
+ <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>
93
+ </button>
94
+ </div>
95
+ <div class="mt-1">
96
+ <ListItem :items="interactions"
97
+ class="rounded-xl"
98
+ container-class="flex flex-col divide-y divide-text-50"
99
+ @reorder="(from, to) => { interactions.splice(to, 0, interactions.splice(from, 1)[0]); }">
100
+ <template v-slot="{ item, index }">
101
+ <div class="flex flex-row items-center gap-3 px-3">
102
+ <div data-reorder v-if="interactions.length > 1">
103
+ <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>
104
+ </div>
105
+ <div class="flex-1 p-3 cursor-pointer" @click="$refs.interactionEdit.open(item)">
106
+ {{ item.event }}
107
+ {{ item.eventModifier ? item.eventModifier : '' }}
108
+ </div>
109
+ <button type="button" @click="interactions.splice(index, 1)">
110
+ <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>
111
+ </button>
112
+ </div>
113
+ </template>
114
+ </ListItem>
115
+
116
+ <InteractionEdit ref="interactionEdit" @save="addInteraction" />
117
+ </div>
118
+ </div>
119
+ </div>
120
+
121
+
122
+ </div>
123
+ </template>
124
+
125
+ <script>
126
+
127
+ import InteractionEdit from "./InteractionEdit.vue";
128
+
129
+ export default{
130
+ components: {InteractionEdit},
131
+
132
+ computed: {
133
+
134
+ interactions(){
135
+ if(!Array.isArray(this.value.props.interactions))
136
+ this.value.props.interactions = []
137
+ return this.value.props.interactions
138
+ },
139
+
140
+ selectedDatasource(){
141
+ return this.datasource.find(d => d.uid === this.value.props.datasourceUid)
142
+ },
143
+
144
+ selectedDatasourceColumns(){
145
+ if(!this.selectedDatasource) return []
146
+
147
+ return this.selectedDatasource.pivot?.enabled ?
148
+ this.selectedDatasource.pivot.columns :
149
+ [
150
+ ...(this.selectedDatasource.computedColumns ?? []),
151
+ ...this.selectedDatasource.columns
152
+ ]
153
+ },
154
+
155
+ },
156
+
157
+ emits: [ 'change' ],
158
+
159
+ mounted() {
160
+ this.applyDefault()
161
+ },
162
+
163
+ props: {
164
+
165
+ datasource: Object,
166
+
167
+ readonly: [ Boolean, Number ],
168
+
169
+ value: Object
170
+
171
+ },
172
+
173
+ methods: {
174
+
175
+ addInteraction(obj){
176
+ this.$util.push(this.interactions, obj)
177
+ },
178
+
179
+ applyDefault(){
180
+ if(!this.value.props.datasourceUid && this.datasource?.length === 1){
181
+ this.value.props.datasourceUid = this.datasource[0].uid
182
+ }
183
+ },
184
+
185
+ onColumnChanged(){
186
+ if(!this.value.props.label)
187
+ this.value.props.label = this.value.props.column
188
+
189
+ this.$emit('change')
190
+ }
191
+
192
+ }
193
+
194
+ }
195
+
196
+ </script>
@@ -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>