@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.
Files changed (95) 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 +37 -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/BotEditor/BotEditorActions.vue +162 -0
  55. package/src/widgets/BotEditor.vue +228 -0
  56. package/src/widgets/Dashboard/BarChart.vue +330 -0
  57. package/src/widgets/Dashboard/BarChartSetting.vue +317 -0
  58. package/src/widgets/Dashboard/DatasourceFilterSharing.vue +93 -0
  59. package/src/widgets/Dashboard/DatasourcePreview.vue +93 -0
  60. package/src/widgets/Dashboard/DatasourceSelector.vue +122 -0
  61. package/src/widgets/Dashboard/Doughnut.vue +157 -0
  62. package/src/widgets/Dashboard/DoughnutSetting.vue +196 -0
  63. package/src/widgets/Dashboard/GHeatMapsSetting.vue +108 -0
  64. package/src/widgets/Dashboard/InteractionEdit.vue +228 -0
  65. package/src/widgets/Dashboard/Metric.vue +76 -0
  66. package/src/widgets/Dashboard/MetricSetting.vue +174 -0
  67. package/src/widgets/Dashboard/Pie.vue +139 -0
  68. package/src/widgets/Dashboard/PieSetting.vue +247 -0
  69. package/src/widgets/Dashboard/PolarArea.vue +159 -0
  70. package/src/widgets/Dashboard/PolarAreaSetting.vue +195 -0
  71. package/src/widgets/Dashboard/SharingModal.vue +116 -0
  72. package/src/widgets/Dashboard/ViewSelector.vue +183 -0
  73. package/src/widgets/Dashboard/VirtualColumnEdit.vue +97 -0
  74. package/src/widgets/Dashboard/VirtualTableSetting.vue +234 -0
  75. package/src/widgets/Dashboard.vue +1773 -0
  76. package/src/widgets/PresetBar.vue +136 -175
  77. package/src/widgets/PresetBarPivot.vue +186 -0
  78. package/src/widgets/PresetSelector.vue +2 -2
  79. package/src/widgets/UserActionBuilder/UserActionCondition.vue +99 -0
  80. package/src/widgets/UserActionBuilder/UserActionConsole.vue +77 -0
  81. package/src/widgets/UserActionBuilder/UserActionItem.vue +166 -58
  82. package/src/widgets/UserActionBuilder/UserActionOutput.vue +35 -9
  83. package/src/widgets/UserActionBuilder/UserActionOutputDelay.vue +27 -0
  84. package/src/widgets/UserActionBuilder/UserActionOutputLog.vue +28 -0
  85. package/src/widgets/UserActionBuilder/UserActionOutputReply.vue +135 -0
  86. package/src/widgets/UserActionBuilder/UserActionProps.vue +213 -0
  87. package/src/widgets/UserActionBuilder.vue +68 -199
  88. package/src/widgets/WebPageBuilder4/GridSetting.vue +123 -73
  89. package/src/widgets/WebPageBuilder4/HeightSetting.vue +14 -11
  90. package/src/widgets/WebPageBuilder4/MarginSetting.vue +4 -1
  91. package/src/widgets/WebPageBuilder4/MultiValueSetting.vue +12 -4
  92. package/src/widgets/WebPageBuilder4/PaddingSetting.vue +4 -0
  93. package/src/widgets/WebPageBuilder4/TreeView.vue +6 -3
  94. package/src/widgets/WebPageBuilder4/TreeViewItem.vue +32 -58
  95. package/tailwind.config.js +2 -2
@@ -0,0 +1,93 @@
1
+ <template>
2
+ <Modal ref="modal"
3
+ width="330"
4
+ height="360">
5
+ <template v-slot:head>
6
+ <div class="relative p-6">
7
+ <h3>Assign This Filter For</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
+ </div>
16
+ </template>
17
+ <template v-slot:foot>
18
+ <div class="p-6" v-if="items?.length > 0 && !readonly">
19
+ <Button class="w-[80px]" @click="apply">OK</Button>
20
+ </div>
21
+ </template>
22
+ <div class="flex-1 p-6 flex">
23
+
24
+ <div v-if="items?.length > 0" class="flex flex-col gap-3">
25
+ <div v-for="item in items">
26
+ <Checkbox v-model="instance" :value="item.id" :disabled="readonly">
27
+ {{ item.name }}
28
+ </Checkbox>
29
+ </div>
30
+ </div>
31
+
32
+ <div v-else class="flex-1 flex items-center justify-center">
33
+ <label class="text-text-300">No users shared</label>
34
+ </div>
35
+
36
+ </div>
37
+ </Modal>
38
+ </template>
39
+
40
+ <script>
41
+
42
+ export default{
43
+
44
+ inject: [ 'socketEmit2' ],
45
+
46
+ props: {
47
+ items: Array,
48
+ readonly: [ Number, Boolean ],
49
+ },
50
+
51
+ computed: {
52
+
53
+
54
+ },
55
+
56
+ data(){
57
+ return {
58
+ instance: null,
59
+ callback: null
60
+ }
61
+ },
62
+
63
+ methods: {
64
+
65
+ apply(){
66
+ const instance = this.instance.map(_ => this.items.find(__ => __.id === _))
67
+ this.callback(instance)
68
+ this.close()
69
+ },
70
+
71
+ open(instance = [], callback){
72
+ this.instance = instance.map(_ => _.id)
73
+ this.callback = callback
74
+ this.$refs.modal.open()
75
+ },
76
+
77
+ close(){
78
+ this.$refs.modal.close()
79
+ }
80
+
81
+ }
82
+
83
+ }
84
+
85
+ </script>
86
+
87
+ <style module>
88
+
89
+ .comp{
90
+
91
+ }
92
+
93
+ </style>
@@ -0,0 +1,93 @@
1
+ <template>
2
+ <Modal ref="modal"
3
+ dismissable="true"
4
+ width="480"
5
+ height="600"
6
+ @dismiss="close">
7
+ <template v-slot:head>
8
+ <div class="relative p-6">
9
+ <h3>Data Preview</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
+ <div class="flex-1 p-6 flex flex-col">
20
+
21
+ <VirtualTable class="flex-1" :columns="columns" :items="items" />
22
+
23
+ </div>
24
+ </Modal>
25
+ </template>
26
+
27
+ <script>
28
+
29
+ export default{
30
+
31
+ inject: [ 'alert', 'preview', 'socket' ],
32
+
33
+ props: {
34
+ src: String
35
+ },
36
+
37
+ computed: {
38
+
39
+ items(){
40
+ if(!this.res?.items || this.res.items.length < 1) return []
41
+
42
+ return Object.keys(this.res.items[0]).map(key => {
43
+ return {
44
+ key,
45
+ value: this.res.items[0][key]
46
+ }
47
+ })
48
+ },
49
+
50
+ },
51
+
52
+ data(){
53
+ return {
54
+ datasource: null,
55
+ res: null,
56
+ columns: [
57
+ { key:"key", label:"Column", width:150 },
58
+ { key:"value", label:"Sample", width:300 },
59
+ ]
60
+ }
61
+ },
62
+
63
+ methods: {
64
+
65
+ close(){
66
+ this.$refs.modal.close()
67
+ },
68
+
69
+ load(){
70
+ this.preview(this.datasource)
71
+ .then(res => this.res = res)
72
+ .catch(err => this.alert(err))
73
+ },
74
+
75
+ open(datasource){
76
+ this.datasource = datasource
77
+ this.$refs.modal.open()
78
+ this.load()
79
+ },
80
+
81
+ }
82
+
83
+ }
84
+
85
+ </script>
86
+
87
+ <style module>
88
+
89
+ .comp{
90
+
91
+ }
92
+
93
+ </style>
@@ -0,0 +1,122 @@
1
+ <template>
2
+ <Modal ref="modal"
3
+ width="360"
4
+ height="420">
5
+ <template v-slot:head>
6
+ <div class="relative p-6 pb-0">
7
+ <h3>{{ $t('Select Datasource') }}</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
+ </div>
16
+ </template>
17
+ <template v-slot:foot>
18
+ <div class="p-6 flex justify-center border-t-[1px] border-text-50">
19
+ <router-link :to="listSrc" target="_blank" class="text-primary flex flex-row items-center">
20
+ Datasource Manager
21
+ <svg class="inline ml-2 fill-primary" width="11" height="11" 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="M392 320c-13.25 0-24 10.75-24 24v112c0 4.406-3.594 8-8 8h-304c-4.406 0-8-3.594-8-8v-304c0-4.406 3.594-8 8-8h112C181.3 144 192 133.3 192 120S181.3 96 168 96h-112C25.13 96 0 121.1 0 152v304C0 486.9 25.13 512 56 512h304c30.88 0 56-25.12 56-56v-112C416 330.8 405.3 320 392 320zM488 0H320c-13.25 0-24 10.75-24 24S306.8 48 320 48h110.1L183 295c-9.375 9.375-9.375 24.56 0 33.94C187.7 333.7 193.8 336 200 336s12.28-2.344 16.97-7.031L464 81.94V192c0 13.25 10.75 24 24 24S512 205.3 512 192V24C512 10.75 501.3 0 488 0z"/></svg>
22
+ </router-link>
23
+ </div>
24
+ </template>
25
+ <div class="flex-1 p-6 flex">
26
+
27
+ <div v-if="datasources?.length > 0" class="flex-1 flex flex-col">
28
+ <div v-for="(datasource, idx) in sortedDatasource"
29
+ type="button"
30
+ :class="dashboardStyle.button"
31
+ class="flex flex-row items-start gap-2">
32
+ <button type="button" class="flex-1 text-left" @click="add(datasource)">{{ datasource.name }}</button>
33
+ </div>
34
+ </div>
35
+
36
+ <div v-else class="flex-1 flex items-center justify-center">
37
+ <div>
38
+ <label class="text-text-300">No datasource</label>
39
+ </div>
40
+ </div>
41
+
42
+ </div>
43
+ </Modal>
44
+ </template>
45
+
46
+ <script>
47
+
48
+ import Modal from "../../components/Modal.vue"
49
+
50
+ export default{
51
+
52
+ components: { Modal },
53
+
54
+ emits: [ 'add' ],
55
+
56
+ inject: [ 'alert', 'appStyle', 'confirm', 'dashboardStyle', 'socket' ],
57
+
58
+ props: {
59
+
60
+ listSrc: String,
61
+
62
+ src: String,
63
+
64
+ },
65
+
66
+ computed: {
67
+
68
+ sortedDatasource(){
69
+ return (this.datasources ?? []).sort((a, b) => a.name.localeCompare(b.name))
70
+ }
71
+
72
+ },
73
+
74
+ data(){
75
+ return {
76
+ instance: null,
77
+ datasources: null,
78
+ }
79
+ },
80
+
81
+ methods: {
82
+
83
+ add(item){
84
+ const newItem = JSON.parse(JSON.stringify(item))
85
+ this.close()
86
+ this.$emit('add', newItem)
87
+ },
88
+
89
+ load(){
90
+ this.socket.send(this.src, {})
91
+ .then(res => this.datasources = res.items)
92
+ .catch(err => this.alert(err))
93
+ },
94
+
95
+ open(){
96
+ this.load()
97
+ this.$refs.modal.open()
98
+ },
99
+
100
+ remove(datasource){
101
+ this.confirm(this.$t('Are you sure you want to remove this datasource?'), () => {
102
+ this.socket.send(this.removeSrc, { id: datasource.id })
103
+ .then(() => {
104
+ this.datasources = this.datasources.filter(item => item.id !== datasource.id)
105
+ })
106
+ .catch(err => this.alert(err))
107
+ })
108
+ },
109
+
110
+ close(){
111
+ this.$refs.modal.close()
112
+ }
113
+
114
+ }
115
+
116
+ }
117
+
118
+ </script>
119
+
120
+ <style module>
121
+
122
+ </style>
@@ -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>