@mixd-id/web-scaffold 0.2.240701 → 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 -10
  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,317 @@
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" />
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" maxlength="50" placeholder="Label" :readonly="readonly" />
29
+ </div>
30
+
31
+ <div v-if="value.props.datasourceUid" class="flex flex-col gap-5">
32
+
33
+ <div class="flex flex-col">
34
+ <div class="flex flex-row items-center gap-3">
35
+ <div class="flex-1">
36
+ <label class="text-primary cursor-pointer"
37
+ ref="xAxis"
38
+ @click="!readonly ? $refs.context1.open($refs.xAxis) : null">
39
+ {{ value.props.xAxeMultiple ? 'X Axes' : 'X Axis' }}
40
+ <svg v-if="!readonly" class="fill-primary inline relative top-[-1px]" width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M310.6 246.6l-127.1 128C176.4 380.9 168.2 384 160 384s-16.38-3.125-22.63-9.375l-127.1-128C.2244 237.5-2.516 223.7 2.438 211.8S19.07 192 32 192h255.1c12.94 0 24.62 7.781 29.58 19.75S319.8 237.5 310.6 246.6z"/></svg>
41
+ </label>
42
+ <ContextMenu ref="context1">
43
+ <div class="flex flex-col min-w-[100px]">
44
+
45
+ <button class="w-full p-3 text-left flex flex-row" :class="appStyle.menuItem"
46
+ @click="value.props.xAxeMultiple = false;$emit('change')">
47
+ Single
48
+ </button>
49
+ <button class="w-full p-3 text-left flex flex-row" :class="appStyle.menuItem"
50
+ @click="value.props.xAxeMultiple = true;$emit('change')">
51
+ Multiple
52
+ </button>
53
+ </div>
54
+ </ContextMenu>
55
+ </div>
56
+ <button v-if="value.props.xAxeMultiple && !readonly" type="button" class="text-primary" @click="xAxes.push({})">
57
+ <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>
58
+ </button>
59
+ </div>
60
+
61
+ <ListItem :items="cXAxes" class="mt-2 bg-transparent" container-class="flex flex-col gap-1"
62
+ @reorder="(from, to) => { cXAxes.splice(to, 0, cXAxes.splice(from, 1)[0]); $emit('change') }">
63
+ <template v-slot="{ item, index }">
64
+ <div class="flex flex-row items-center gap-2">
65
+ <div data-reorder v-if="cXAxes.length > 1 && !readonly">
66
+ <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>
67
+ </div>
68
+ <div class="flex-1 flex flex-row gap-2">
69
+ <Dropdown v-model="item.key" :readonly="readonly" class="flex-1">
70
+ <option v-for="column in selectedDatasourceColumns"
71
+ :value="column.key">
72
+ {{ selectedDatasource.pivot?.enabled ? column.key : column.label }}
73
+ </option>
74
+ </Dropdown>
75
+
76
+ <Dropdown v-if="!value.props.xAxeMultiple" v-model="item.modifier" :readonly="readonly" class="w-[100px]">
77
+ <option value="">-</option>
78
+ <option value="lowercase">Lower</option>
79
+ <option value="capitalize">Capitalize</option>
80
+ <option value="uppercase">Upper</option>
81
+ <option disabled>-----</option>
82
+ <option value="date">Date</option>
83
+ <option value="month">Month</option>
84
+ <option value="year">Year</option>
85
+ <option value="hour">Hour</option>
86
+ <option value="minute">Minute</option>
87
+ <option value="last60Minutes">Last 60 Minutes</option>
88
+ <option value="last12Hours">Last 12 Hours</option>
89
+ <option value="last24Hours">Last 24 Hours</option>
90
+ </Dropdown>
91
+ </div>
92
+ <button v-if="cXAxes.length > 1 && !readonly" type="button" @click="cXAxes.splice(index, 1)">
93
+ <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>
94
+ </button>
95
+ </div>
96
+ </template>
97
+ </ListItem>
98
+ </div>
99
+
100
+ <div class="flex flex-col">
101
+ <div class="flex flex-row items-center gap-3">
102
+ <div class="flex-1">
103
+ <label class="text-primary cursor-pointer"
104
+ ref="yAxis"
105
+ @click="!readonly ? $refs.context2.open($refs.yAxis) : null">
106
+ {{ value.props.yAxeMultiple ? 'Y Axes' : 'Y Axis' }}
107
+ <svg v-if="!readonly" class="fill-primary inline relative top-[-1px]" width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M310.6 246.6l-127.1 128C176.4 380.9 168.2 384 160 384s-16.38-3.125-22.63-9.375l-127.1-128C.2244 237.5-2.516 223.7 2.438 211.8S19.07 192 32 192h255.1c12.94 0 24.62 7.781 29.58 19.75S319.8 237.5 310.6 246.6z"/></svg>
108
+ </label>
109
+ <ContextMenu ref="context2">
110
+ <div class="flex flex-col min-w-[100px]">
111
+
112
+ <button class="w-full p-3 text-left flex flex-row" :class="appStyle.menuItem"
113
+ @click="value.props.yAxeMultiple = false;$emit('change')">
114
+ Single
115
+ </button>
116
+ <button class="w-full p-3 text-left flex flex-row" :class="appStyle.menuItem"
117
+ @click="value.props.yAxeMultiple = true;$emit('change')">
118
+ Multiple
119
+ </button>
120
+ </div>
121
+ </ContextMenu>
122
+ </div>
123
+ <button v-if="false" type="button" class="text-primary" @click="yAxes.push({})">
124
+ <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>
125
+ </button>
126
+ </div>
127
+
128
+ <ListItem :items="cYAxes" class="mt-2 bg-transparent" container-class="flex flex-col gap-1"
129
+ @reorder="(from, to) => { cYAxes.splice(to, 0, cYAxes.splice(from, 1)[0]); $emit('change') }">
130
+ <template v-slot="{ item, index }">
131
+ <div class="flex flex-row items-center gap-2">
132
+ <div data-reorder v-if="cYAxes.length > 1">
133
+ <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>
134
+ </div>
135
+ <div class="flex-1 flex flex-row gap-2">
136
+ <Dropdown v-model="item.key" :readonly="readonly" class="flex-1" @change="clearExcluded">
137
+ <option v-for="column in selectedDatasourceColumns"
138
+ :value="column.key">
139
+ {{ selectedDatasource.pivot?.enabled ? column.key : column.label }}
140
+ </option>
141
+ </Dropdown>
142
+
143
+ <Dropdown v-model="item.modifier" :readonly="readonly" class="w-[100px]">
144
+ <option value="">-</option>
145
+ <option value="count">Count</option>
146
+ <option value="countDistinct">Unique Count</option>
147
+ <option value="sum">Sum</option>
148
+ <option value="avg">Avg</option>
149
+ <option value="min">Min</option>
150
+ <option value="max">Max</option>
151
+ </Dropdown>
152
+ </div>
153
+ <button v-if="cYAxes.length > 1 && !readonly" type="button" @click="cYAxes.splice(index, 1)">
154
+ <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>
155
+ </button>
156
+ </div>
157
+ </template>
158
+ </ListItem>
159
+ </div>
160
+
161
+ <div class="flex justify-center" v-if="!readonly">
162
+ <button type="button" class="text-primary p-3 flex flex-row items-center gap-2"
163
+ @click="swap">
164
+ <svg width="14" height="14" class="fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="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>
165
+ Swap X and Y Axis
166
+ </button>
167
+ </div>
168
+
169
+ <div v-if="value.props.yAxeMultiple" class="flex flex-row items-center gap-2">
170
+ <label class="flex-1">Use Percentage</label>
171
+ <Switch v-model="value.props.usePercentage" :readonly="readonly" />
172
+ </div>
173
+
174
+ <div v-if="value.props.yAxeMultiple" class="flex flex-row items-center gap-2">
175
+ <label class="flex-1">Stacked</label>
176
+ <Switch v-model="value.props.stacked" :readonly="readonly" />
177
+ </div>
178
+
179
+ <div>
180
+ <div class="flex flex-row gap-2">
181
+ <label class="text-text-400 flex-1">Interactions</label>
182
+ <button type="button" class="text-primary" @click="$refs.interactionEdit.create()">
183
+ <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>
184
+ </button>
185
+ </div>
186
+ <div class="mt-1">
187
+ <ListItem :items="interactions"
188
+ class="rounded-xl"
189
+ container-class="flex flex-col divide-y divide-text-50"
190
+ @reorder="(from, to) => { interactions.splice(to, 0, interactions.splice(from, 1)[0]); }">
191
+ <template v-slot="{ item, index }">
192
+ <div class="flex flex-row items-center gap-3 px-3">
193
+ <div data-reorder v-if="interactions.length > 1">
194
+ <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>
195
+ </div>
196
+ <div class="flex-1 p-3 cursor-pointer" @click="$refs.interactionEdit.open(item)">
197
+ {{ item.event }}
198
+ {{ item.eventModifier ? item.eventModifier : '' }}
199
+ </div>
200
+ <button type="button" @click="interactions.splice(index, 1)">
201
+ <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>
202
+ </button>
203
+ </div>
204
+ </template>
205
+ </ListItem>
206
+
207
+ <InteractionEdit ref="interactionEdit" @save="addInteraction" />
208
+ </div>
209
+ </div>
210
+
211
+ </div>
212
+
213
+
214
+ </div>
215
+ </template>
216
+
217
+ <script>
218
+
219
+ import InteractionEdit from "./InteractionEdit.vue";
220
+
221
+ export default{
222
+ components: {InteractionEdit},
223
+
224
+ computed: {
225
+
226
+ interactions(){
227
+ if(!Array.isArray(this.value.props.interactions))
228
+ this.value.props.interactions = []
229
+ return this.value.props.interactions
230
+ },
231
+
232
+ selectedDatasource(){
233
+ return this.datasource.find(d => d.uid === this.value.props.datasourceUid)
234
+ },
235
+
236
+ selectedDatasourceColumns(){
237
+ if(!this.selectedDatasource) return []
238
+
239
+ return this.selectedDatasource.pivot?.enabled ?
240
+ this.selectedDatasource.pivot.columns :
241
+ [
242
+ ...(this.selectedDatasource.computedColumns ?? []),
243
+ ...this.selectedDatasource.columns
244
+ ]
245
+ },
246
+
247
+ xAxes(){
248
+ if(!Array.isArray(this.value.props.xAxes))
249
+ this.value.props.xAxes = [{ key:"" }]
250
+
251
+ return this.value.props.xAxes
252
+ },
253
+
254
+ cXAxes(){
255
+ return this.value.props.xAxeMultiple ? this.xAxes : [this.xAxes[0]]
256
+ },
257
+
258
+ yAxes(){
259
+ if(!Array.isArray(this.value.props.yAxes))
260
+ this.value.props.yAxes = [{ key:"" }]
261
+
262
+ return this.value.props.yAxes
263
+ },
264
+
265
+ cYAxes(){
266
+ return [this.yAxes[0]]
267
+ }
268
+
269
+ },
270
+
271
+ inject: [ 'appStyle', 'previewDatasource' ],
272
+
273
+ methods: {
274
+
275
+ addInteraction(obj){
276
+ this.$util.push(this.interactions, obj)
277
+ },
278
+
279
+ clearExcluded(){
280
+ this.value.props.excluded = []
281
+ },
282
+
283
+ swap(){
284
+ const yAxes = this.value.props.yAxes
285
+ const xAxes = this.value.props.xAxes
286
+
287
+ Object.assign(this.value.props, {
288
+ xAxes: yAxes,
289
+ yAxes: xAxes
290
+ })
291
+
292
+ this.$emit('change')
293
+ }
294
+
295
+ },
296
+
297
+ props: {
298
+
299
+ datasource: Object,
300
+
301
+ readonly: [ Boolean, Number ],
302
+
303
+ value: Object
304
+
305
+ }
306
+
307
+ }
308
+
309
+ </script>
310
+
311
+ <style module>
312
+
313
+ .comp{
314
+
315
+ }
316
+
317
+ </style>
@@ -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>