@mixd-id/web-scaffold 0.2.250801010 → 0.2.250801012

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 (398) hide show
  1. package/docs/components/AccountIcon.md +16 -0
  2. package/docs/components/Ahref.md +35 -0
  3. package/docs/components/Alert.md +72 -0
  4. package/docs/components/ArrayList.md +39 -0
  5. package/docs/components/Article.md +28 -0
  6. package/docs/components/BarChart.md +81 -0
  7. package/docs/components/Block.md +23 -0
  8. package/docs/components/Box.md +15 -0
  9. package/docs/components/Button.md +68 -0
  10. package/docs/components/Card.md +67 -0
  11. package/docs/components/Carousel.md +70 -0
  12. package/docs/components/Cart.md +20 -0
  13. package/docs/components/CartIcon.md +29 -0
  14. package/docs/components/Chart.md +53 -0
  15. package/docs/components/ChartBar.md +34 -0
  16. package/docs/components/ChatTyping.md +21 -0
  17. package/docs/components/Checkbox.md +63 -0
  18. package/docs/components/CodeEditor.md +25 -0
  19. package/docs/components/CollapsiblePanel.md +41 -0
  20. package/docs/components/ColorPicker.md +52 -0
  21. package/docs/components/Confirm.md +62 -0
  22. package/docs/components/ContextMenu.md +76 -0
  23. package/docs/components/ContextMenuItem.md +29 -0
  24. package/docs/components/CopyToClipboard.md +43 -0
  25. package/docs/components/Countdown.md +47 -0
  26. package/docs/components/Datepicker.md +61 -0
  27. package/docs/components/Datetimepicker.md +57 -0
  28. package/docs/components/DayTimeRange.md +20 -0
  29. package/docs/components/Dropdown.md +65 -0
  30. package/docs/components/ErrorText.md +15 -0
  31. package/docs/components/FBLogin.md +21 -0
  32. package/docs/components/Flex.md +44 -0
  33. package/docs/components/GHeatMaps.md +16 -0
  34. package/docs/components/GSignIn.md +21 -0
  35. package/docs/components/Gmaps.md +16 -0
  36. package/docs/components/GmapsDirection.md +20 -0
  37. package/docs/components/Grid.md +36 -0
  38. package/docs/components/HTMLEditor.md +26 -0
  39. package/docs/components/IconMenu.md +20 -0
  40. package/docs/components/Image.md +78 -0
  41. package/docs/components/Link.md +33 -0
  42. package/docs/components/MultiDropdown.md +46 -0
  43. package/docs/components/Radio.md +55 -0
  44. package/docs/components/Slider.md +47 -0
  45. package/docs/components/Switch.md +43 -0
  46. package/docs/components/Table.md +31 -0
  47. package/docs/components/Tabs.md +65 -0
  48. package/docs/components/Text.md +30 -0
  49. package/docs/components/Textarea.md +66 -0
  50. package/docs/components/Textbox.md +97 -0
  51. package/docs/components/Timepicker.md +62 -0
  52. package/docs/components/Toast.md +59 -0
  53. package/docs/components/Uploader.md +51 -0
  54. package/docs/components/Video.md +54 -0
  55. package/package.json +65 -2
  56. package/docs/components/Dashboard.md +0 -56
  57. package/docs/components/Header2.md +0 -16
  58. package/log.txt +0 -7
  59. package/public/assets/dashboard/bar.png +0 -0
  60. package/public/assets/dashboard/doughnut.png +0 -0
  61. package/public/assets/dashboard/metric.png +0 -0
  62. package/public/assets/dashboard/pie.png +0 -0
  63. package/public/assets/dashboard/polar-area.png +0 -0
  64. package/public/assets/dashboard/virtual-table.png +0 -0
  65. package/public/static/dashboard/bar.png +0 -0
  66. package/public/static/dashboard/doughnut.png +0 -0
  67. package/public/static/dashboard/metric.png +0 -0
  68. package/public/static/dashboard/pie.png +0 -0
  69. package/public/static/dashboard/polar-area.png +0 -0
  70. package/public/static/dashboard/virtual-table.png +0 -0
  71. package/src/components/404.vue +0 -61
  72. package/src/components/AccountIcon.vue +0 -19
  73. package/src/components/Ahref.vue +0 -200
  74. package/src/components/Alert.vue +0 -257
  75. package/src/components/ArrayList.vue +0 -49
  76. package/src/components/Article.vue +0 -387
  77. package/src/components/Block.vue +0 -31
  78. package/src/components/Box.vue +0 -34
  79. package/src/components/Button.vue +0 -258
  80. package/src/components/Card.vue +0 -257
  81. package/src/components/Carousel.vue +0 -364
  82. package/src/components/Cart.vue +0 -192
  83. package/src/components/CartIcon.vue +0 -89
  84. package/src/components/Chart.vue +0 -485
  85. package/src/components/ChartBar.vue +0 -192
  86. package/src/components/ChatTyping.vue +0 -69
  87. package/src/components/Checkbox.vue +0 -200
  88. package/src/components/Checkout.vue +0 -373
  89. package/src/components/CheckoutDelivery.vue +0 -267
  90. package/src/components/CodeEditor.vue +0 -50
  91. package/src/components/CollapsiblePanel.vue +0 -70
  92. package/src/components/ColorPicker.vue +0 -165
  93. package/src/components/ColorPicker2.vue +0 -186
  94. package/src/components/ColorPicker3.vue +0 -100
  95. package/src/components/Confirm.vue +0 -180
  96. package/src/components/ContextMenu.vue +0 -265
  97. package/src/components/ContextMenuItem.vue +0 -53
  98. package/src/components/ConversationBuilder.vue +0 -161
  99. package/src/components/CopyToClipboard.vue +0 -34
  100. package/src/components/Countdown.vue +0 -264
  101. package/src/components/DGrid.vue +0 -21
  102. package/src/components/DGridItem.vue +0 -263
  103. package/src/components/Dashboard.vue +0 -243
  104. package/src/components/Dashboard2.vue +0 -118
  105. package/src/components/DashboardComponentSelector.vue +0 -96
  106. package/src/components/DashboardConfigs.vue +0 -202
  107. package/src/components/DataList.vue +0 -92
  108. package/src/components/Datepicker.vue +0 -399
  109. package/src/components/DayTimeRange.vue +0 -126
  110. package/src/components/Dropdown.vue +0 -224
  111. package/src/components/ErrorText.vue +0 -57
  112. package/src/components/FBLogin.vue +0 -194
  113. package/src/components/Feed.vue +0 -118
  114. package/src/components/Flex.vue +0 -44
  115. package/src/components/GHeatMaps.vue +0 -317
  116. package/src/components/GSignIn.vue +0 -166
  117. package/src/components/Gmaps.vue +0 -251
  118. package/src/components/GmapsDirection.vue +0 -191
  119. package/src/components/Grid.vue +0 -35
  120. package/src/components/HTMLEditor.vue +0 -588
  121. package/src/components/IconMenu.vue +0 -95
  122. package/src/components/IconMenu2.vue +0 -89
  123. package/src/components/IconPlus.vue +0 -89
  124. package/src/components/Image.vue +0 -263
  125. package/src/components/Image360.vue +0 -140
  126. package/src/components/ImageFullScreen.vue +0 -101
  127. package/src/components/ImagePreview.vue +0 -93
  128. package/src/components/ImageUploader.vue +0 -114
  129. package/src/components/ImportModal.vue +0 -260
  130. package/src/components/Link.vue +0 -95
  131. package/src/components/List.vue +0 -1381
  132. package/src/components/ListContextMenu.vue +0 -88
  133. package/src/components/ListItem.vue +0 -160
  134. package/src/components/ListPage1.vue +0 -1401
  135. package/src/components/ListPage1Filter.vue +0 -170
  136. package/src/components/ListView.vue +0 -961
  137. package/src/components/ListViewBarSummary.vue +0 -81
  138. package/src/components/ListViewLineSummary.vue +0 -75
  139. package/src/components/ListViewLiveBarSummary.vue +0 -52
  140. package/src/components/ListViewMapSummary.vue +0 -56
  141. package/src/components/ListViewSettings.vue +0 -514
  142. package/src/components/ListViewTableSummary.vue +0 -77
  143. package/src/components/LogViewerItem.vue +0 -116
  144. package/src/components/MarkdownEdit.vue +0 -128
  145. package/src/components/MarkdownPreview.vue +0 -102
  146. package/src/components/MenuItem1.vue +0 -36
  147. package/src/components/Modal.vue +0 -456
  148. package/src/components/MultiDropdown.vue +0 -124
  149. package/src/components/MultilineText.vue +0 -174
  150. package/src/components/OTPField.vue +0 -139
  151. package/src/components/ObjectTree.vue +0 -105
  152. package/src/components/PageBuilder.vue +0 -449
  153. package/src/components/Paragraph.vue +0 -40
  154. package/src/components/PresetSelectorFilterItem.vue +0 -203
  155. package/src/components/Radio.vue +0 -109
  156. package/src/components/SearchModal.vue +0 -153
  157. package/src/components/Slider.vue +0 -317
  158. package/src/components/SplitPane.vue +0 -129
  159. package/src/components/Svg.vue +0 -33
  160. package/src/components/SvgEditor.vue +0 -173
  161. package/src/components/Switch.vue +0 -101
  162. package/src/components/TabView.vue +0 -105
  163. package/src/components/Table.vue +0 -56
  164. package/src/components/TableView.vue +0 -200
  165. package/src/components/TableViewHead.vue +0 -159
  166. package/src/components/Tabs.vue +0 -131
  167. package/src/components/Test.vue +0 -23
  168. package/src/components/Testimonial.vue +0 -86
  169. package/src/components/Text.vue +0 -34
  170. package/src/components/TextBlock.vue +0 -50
  171. package/src/components/TextEditor.vue +0 -85
  172. package/src/components/TextWithTag.vue +0 -298
  173. package/src/components/Textarea.vue +0 -184
  174. package/src/components/Textbox.vue +0 -216
  175. package/src/components/Thumbnail.vue +0 -27
  176. package/src/components/Timepicker.vue +0 -125
  177. package/src/components/Toast.vue +0 -117
  178. package/src/components/TreeMenu.vue +0 -122
  179. package/src/components/TreeView.vue +0 -106
  180. package/src/components/TreeView2.vue +0 -38
  181. package/src/components/TreeViewItem.vue +0 -453
  182. package/src/components/TreeViewItem1.vue +0 -282
  183. package/src/components/TreeViewItem2.vue +0 -55
  184. package/src/components/Uploader.vue +0 -45
  185. package/src/components/Video.vue +0 -119
  186. package/src/components/VirtualGrid.vue +0 -297
  187. package/src/components/VirtualScroll.vue +0 -282
  188. package/src/components/VirtualTable.vue +0 -956
  189. package/src/components/YoutubeVideo.vue +0 -196
  190. package/src/configs/dashboard/bar.js +0 -10
  191. package/src/configs/dashboard/collection-1.js +0 -5
  192. package/src/configs/dashboard/data-table.js +0 -9
  193. package/src/configs/dashboard/doughnut.js +0 -7
  194. package/src/configs/dashboard/gheatmaps.js +0 -9
  195. package/src/configs/dashboard/grid-2.js +0 -34
  196. package/src/configs/dashboard/grid-3.js +0 -34
  197. package/src/configs/dashboard/grid-4.js +0 -34
  198. package/src/configs/dashboard/grid.js +0 -15
  199. package/src/configs/dashboard/metric.js +0 -10
  200. package/src/configs/dashboard/pie.js +0 -7
  201. package/src/configs/dashboard/polar-area.js +0 -7
  202. package/src/configs/dashboard/virtual-table.js +0 -9
  203. package/src/configs/icons-fa.json +0 -12
  204. package/src/configs/web-page-builder.js +0 -118
  205. package/src/defs/dashboard-preset.js +0 -22
  206. package/src/directives/intersect.js +0 -26
  207. package/src/hooks/device.js +0 -14
  208. package/src/index.css +0 -3
  209. package/src/index.js +0 -648
  210. package/src/middleware/http/trim-string.js +0 -20
  211. package/src/mixin/component.js +0 -306
  212. package/src/mixin/ready-state.js +0 -37
  213. package/src/stores/components.js +0 -36
  214. package/src/stores/datasource.js +0 -11
  215. package/src/themes/default/index.js +0 -303
  216. package/src/utils/dashboard.js +0 -140
  217. package/src/utils/event-bus.js +0 -8
  218. package/src/utils/helpers.cjs +0 -635
  219. package/src/utils/helpers.js +0 -635
  220. package/src/utils/helpers.mjs +0 -722
  221. package/src/utils/importer.js +0 -209
  222. package/src/utils/list.mjs +0 -1509
  223. package/src/utils/listpage1.js +0 -1507
  224. package/src/utils/listview.js +0 -1287
  225. package/src/utils/preset-selector.cjs +0 -1455
  226. package/src/utils/preset-selector.js +0 -1452
  227. package/src/utils/preset-selector.mjs +0 -234
  228. package/src/utils/queue.js +0 -63
  229. package/src/utils/selection.js +0 -43
  230. package/src/utils/web.js +0 -50
  231. package/src/utils/web.mjs +0 -120
  232. package/src/utils/wss.js +0 -296
  233. package/src/utils/wss.mjs +0 -285
  234. package/src/widgets/AhrefSetting.vue +0 -97
  235. package/src/widgets/ArticleSetting.vue +0 -457
  236. package/src/widgets/BackgroundColorSetting.vue +0 -153
  237. package/src/widgets/BackgroundSetting.vue +0 -132
  238. package/src/widgets/BlockSetting.vue +0 -49
  239. package/src/widgets/BorderColorSetting.vue +0 -57
  240. package/src/widgets/BorderSetting.vue +0 -201
  241. package/src/widgets/BotEditor/BotEditorActions.vue +0 -163
  242. package/src/widgets/BotEditor/BotEditorSettings.vue +0 -21
  243. package/src/widgets/BotEditor.vue +0 -248
  244. package/src/widgets/BoxSetting.vue +0 -53
  245. package/src/widgets/ButtonSetting.vue +0 -113
  246. package/src/widgets/CarouselSetting.vue +0 -181
  247. package/src/widgets/CartSetting.vue +0 -46
  248. package/src/widgets/CheckoutSetting.vue +0 -46
  249. package/src/widgets/CollapsiblePanelSetting.vue +0 -46
  250. package/src/widgets/ColumnSelector.vue +0 -104
  251. package/src/widgets/ComponentPropertyLabel.vue +0 -35
  252. package/src/widgets/ComponentPropertySelector.vue +0 -115
  253. package/src/widgets/ComponentSetting.vue +0 -2220
  254. package/src/widgets/ComponentSetting2.vue +0 -927
  255. package/src/widgets/ComponentSetting3.vue +0 -231
  256. package/src/widgets/ContactForm.vue +0 -193
  257. package/src/widgets/ContactFormSetting.vue +0 -395
  258. package/src/widgets/CountdownSetting.vue +0 -76
  259. package/src/widgets/Dashboard/BarChart.vue +0 -366
  260. package/src/widgets/Dashboard/BarChartSetting.vue +0 -317
  261. package/src/widgets/Dashboard/DataTable.vue +0 -125
  262. package/src/widgets/Dashboard/DataTableSetting.vue +0 -243
  263. package/src/widgets/Dashboard/DatasourceFilterSharing.vue +0 -93
  264. package/src/widgets/Dashboard/DatasourcePreview.vue +0 -93
  265. package/src/widgets/Dashboard/DatasourceSelector.vue +0 -122
  266. package/src/widgets/Dashboard/Doughnut.vue +0 -199
  267. package/src/widgets/Dashboard/DoughnutSetting.vue +0 -196
  268. package/src/widgets/Dashboard/GHeatMapsSetting.vue +0 -108
  269. package/src/widgets/Dashboard/InteractionEdit.vue +0 -228
  270. package/src/widgets/Dashboard/Metric.vue +0 -135
  271. package/src/widgets/Dashboard/MetricSetting.vue +0 -227
  272. package/src/widgets/Dashboard/Pie.vue +0 -188
  273. package/src/widgets/Dashboard/PieSetting.vue +0 -247
  274. package/src/widgets/Dashboard/PolarArea.vue +0 -201
  275. package/src/widgets/Dashboard/PolarAreaSetting.vue +0 -195
  276. package/src/widgets/Dashboard/SharingModal.vue +0 -115
  277. package/src/widgets/Dashboard/ViewSelector.vue +0 -183
  278. package/src/widgets/Dashboard/VirtualColumnEdit.vue +0 -97
  279. package/src/widgets/Dashboard/VirtualTableSetting.vue +0 -171
  280. package/src/widgets/Dashboard0.vue +0 -1856
  281. package/src/widgets/DataListSetting.vue +0 -102
  282. package/src/widgets/EffectSetting.vue +0 -94
  283. package/src/widgets/EmbeddedVideo.vue +0 -60
  284. package/src/widgets/EmbeddedVideoSetting.vue +0 -50
  285. package/src/widgets/FAQ.vue +0 -98
  286. package/src/widgets/FAQSetting.vue +0 -94
  287. package/src/widgets/FeatureList.vue +0 -131
  288. package/src/widgets/FeatureListSetting.vue +0 -233
  289. package/src/widgets/FiltersSetting.vue +0 -88
  290. package/src/widgets/FlexSetting.vue +0 -174
  291. package/src/widgets/GridSetting.vue +0 -165
  292. package/src/widgets/Header.vue +0 -15
  293. package/src/widgets/Header0.vue +0 -41
  294. package/src/widgets/Header0Setting.vue +0 -75
  295. package/src/widgets/Header2.vue +0 -65
  296. package/src/widgets/Header2Setting.vue +0 -193
  297. package/src/widgets/HeaderSetting.vue +0 -102
  298. package/src/widgets/IconList.vue +0 -51
  299. package/src/widgets/IconListSetting.vue +0 -188
  300. package/src/widgets/ImageSetting.vue +0 -119
  301. package/src/widgets/LayoutSetting.vue +0 -251
  302. package/src/widgets/LinkSetting.vue +0 -209
  303. package/src/widgets/LinkSettingModal.vue +0 -173
  304. package/src/widgets/LogViewer.vue +0 -85
  305. package/src/widgets/MarginPaddingSetting.vue +0 -58
  306. package/src/widgets/MarginSetting.vue +0 -142
  307. package/src/widgets/MenuEditor.vue +0 -256
  308. package/src/widgets/MenuItem1Setting.vue +0 -78
  309. package/src/widgets/ModalSetting.vue +0 -94
  310. package/src/widgets/MultiValueSetting.vue +0 -121
  311. package/src/widgets/MultiValueSetting2.vue +0 -147
  312. package/src/widgets/OGSettingModal.vue +0 -103
  313. package/src/widgets/PaddingSetting.vue +0 -142
  314. package/src/widgets/ParagraphSetting.vue +0 -89
  315. package/src/widgets/PositionSetting.vue +0 -209
  316. package/src/widgets/PresetBar.vue +0 -990
  317. package/src/widgets/PresetBarPivot.vue +0 -198
  318. package/src/widgets/PresetBarPivotColumnEdit.vue +0 -197
  319. package/src/widgets/PresetSelector.vue +0 -685
  320. package/src/widgets/Review.vue +0 -131
  321. package/src/widgets/ReviewSetting.vue +0 -201
  322. package/src/widgets/SearchModalSetting.vue +0 -70
  323. package/src/widgets/Share.vue +0 -164
  324. package/src/widgets/ShareSetting.vue +0 -99
  325. package/src/widgets/SizingSetting.vue +0 -306
  326. package/src/widgets/SpacingSetting.vue +0 -77
  327. package/src/widgets/StyleSetting.vue +0 -543
  328. package/src/widgets/StyleSetting2.vue +0 -90
  329. package/src/widgets/SvgSetting.vue +0 -133
  330. package/src/widgets/TableSetting.vue +0 -172
  331. package/src/widgets/TestimonialSetting.vue +0 -161
  332. package/src/widgets/TextBlockSetting.vue +0 -81
  333. package/src/widgets/ThumbnailSetting.vue +0 -49
  334. package/src/widgets/TransitionSetting.vue +0 -64
  335. package/src/widgets/TypographySetting.vue +0 -334
  336. package/src/widgets/UserActionBuilder/UserActionCondition.vue +0 -99
  337. package/src/widgets/UserActionBuilder/UserActionConsole.vue +0 -97
  338. package/src/widgets/UserActionBuilder/UserActionItem.vue +0 -273
  339. package/src/widgets/UserActionBuilder/UserActionOutput.vue +0 -152
  340. package/src/widgets/UserActionBuilder/UserActionOutputDelay.vue +0 -27
  341. package/src/widgets/UserActionBuilder/UserActionOutputLog.vue +0 -28
  342. package/src/widgets/UserActionBuilder/UserActionOutputReply.vue +0 -112
  343. package/src/widgets/UserActionBuilder/UserActionProps.vue +0 -213
  344. package/src/widgets/UserActionBuilder.vue +0 -314
  345. package/src/widgets/WebComponentSelector.vue +0 -205
  346. package/src/widgets/WebDatasourceSelector.vue +0 -153
  347. package/src/widgets/WebLayoutSelector.vue +0 -147
  348. package/src/widgets/WebPageBuilder.vue +0 -2161
  349. package/src/widgets/WebPageBuilder2.vue +0 -1091
  350. package/src/widgets/WebPageBuilder3.vue +0 -411
  351. package/src/widgets/WebPageBuilder4/BackgroundColorSetting.vue +0 -54
  352. package/src/widgets/WebPageBuilder4/BackgroundPositionSetting.vue +0 -75
  353. package/src/widgets/WebPageBuilder4/BackgroundRepeatSetting.vue +0 -72
  354. package/src/widgets/WebPageBuilder4/BackgroundSizeSetting.vue +0 -72
  355. package/src/widgets/WebPageBuilder4/BlurSetting.vue +0 -72
  356. package/src/widgets/WebPageBuilder4/BorderColorSetting.vue +0 -64
  357. package/src/widgets/WebPageBuilder4/BorderRadiusSetting.vue +0 -75
  358. package/src/widgets/WebPageBuilder4/BorderSizeSetting.vue +0 -69
  359. package/src/widgets/WebPageBuilder4/BorderStyleSetting.vue +0 -72
  360. package/src/widgets/WebPageBuilder4/BoxShadowSetting.vue +0 -73
  361. package/src/widgets/WebPageBuilder4/ButtonSetting.vue +0 -65
  362. package/src/widgets/WebPageBuilder4/CarouselSetting.vue +0 -178
  363. package/src/widgets/WebPageBuilder4/DisplaySetting.vue +0 -76
  364. package/src/widgets/WebPageBuilder4/FlexAlignSetting.vue +0 -71
  365. package/src/widgets/WebPageBuilder4/FlexDirectionSetting.vue +0 -70
  366. package/src/widgets/WebPageBuilder4/FlexJustifySetting.vue +0 -74
  367. package/src/widgets/WebPageBuilder4/FlexPropertySetting.vue +0 -71
  368. package/src/widgets/WebPageBuilder4/FlexSetting.vue +0 -96
  369. package/src/widgets/WebPageBuilder4/FlexWrapSetting.vue +0 -69
  370. package/src/widgets/WebPageBuilder4/GapSetting.vue +0 -75
  371. package/src/widgets/WebPageBuilder4/GrayscaleSetting.vue +0 -68
  372. package/src/widgets/WebPageBuilder4/GridSetting.vue +0 -216
  373. package/src/widgets/WebPageBuilder4/HeightSetting.vue +0 -98
  374. package/src/widgets/WebPageBuilder4/ImageSetting.vue +0 -102
  375. package/src/widgets/WebPageBuilder4/MarginSetting.vue +0 -73
  376. package/src/widgets/WebPageBuilder4/MaxHeightSetting.vue +0 -82
  377. package/src/widgets/WebPageBuilder4/MaxWidthSetting.vue +0 -90
  378. package/src/widgets/WebPageBuilder4/MinHeightSetting.vue +0 -81
  379. package/src/widgets/WebPageBuilder4/MinWidthSetting.vue +0 -101
  380. package/src/widgets/WebPageBuilder4/MultiValueSetting.vue +0 -163
  381. package/src/widgets/WebPageBuilder4/OpacitySetting.vue +0 -77
  382. package/src/widgets/WebPageBuilder4/OverflowSetting.vue +0 -81
  383. package/src/widgets/WebPageBuilder4/PaddingSetting.vue +0 -57
  384. package/src/widgets/WebPageBuilder4/PositionSetting.vue +0 -191
  385. package/src/widgets/WebPageBuilder4/PropertySetting.vue +0 -176
  386. package/src/widgets/WebPageBuilder4/TextSetting.vue +0 -72
  387. package/src/widgets/WebPageBuilder4/TreeView.vue +0 -46
  388. package/src/widgets/WebPageBuilder4/TreeViewItem.vue +0 -303
  389. package/src/widgets/WebPageBuilder4/WebPageComponentSelector.vue +0 -141
  390. package/src/widgets/WebPageBuilder4/WebPagePropertySelector.vue +0 -172
  391. package/src/widgets/WebPageBuilder4/WidthSetting.vue +0 -105
  392. package/src/widgets/WebPageBuilder4/ZIndexSetting.vue +0 -72
  393. package/src/widgets/WebPageBuilder4.vue +0 -798
  394. package/src/widgets/WebPagePreview.vue +0 -295
  395. package/src/widgets/WebPageSelector.vue +0 -173
  396. package/src/widgets/WebTemplateCreator.vue +0 -156
  397. package/src/widgets/YoutubeVideoSetting.vue +0 -68
  398. package/tailwind.config.js +0 -481
@@ -1,1507 +0,0 @@
1
- const { Op } = require('sequelize')
2
- const Sequelize = require('sequelize')
3
- const dayjs = require("dayjs")
4
- const Exceljs = require("exceljs")
5
- const { getPresetSortWhereParams } = require("./helpers")
6
-
7
- let ListPage1 = {
8
-
9
- presetName: 'listpage1',
10
- itemsPerPage: 24,
11
- model: '',
12
- channel: '',
13
-
14
- async patch(params, socket){
15
-
16
- const { reset } = params
17
-
18
- let currentPreset
19
- const preset = this['loadPreset'] && !reset ? await this.loadPreset() : undefined
20
- if(preset){
21
- currentPreset = {
22
- ...this.getDefaultPresets(),
23
- ...preset
24
- }
25
- }
26
- else{
27
- currentPreset = {
28
- ...this.getDefaultPresets()
29
- }
30
- }
31
-
32
- for(let i = 0 ; i < currentPreset.presets.length ; i++){
33
-
34
- Object.assign({
35
- name: 'Default',
36
- columns: [],
37
- sorts: [],
38
- filters: [],
39
- summaries: [],
40
- },
41
- currentPreset.presets[i])
42
-
43
- if(currentPreset.presets[i].summaries){
44
- for(let j = 0 ; j < currentPreset.presets[i].summaries.length ; j++){
45
-
46
- Object.assign({
47
- map: {
48
- mapRadius: 16,
49
- mapType: "heatmap",
50
- zoom: 7
51
- }
52
- },
53
- currentPreset.presets[i].summaries[j])
54
- }
55
- }
56
- }
57
-
58
- /*if(this.user && this.socket && this.socket.auth){
59
- const { userId } = this.socket.auth
60
- const user = await this.user.withId(userId)
61
- const preset = await user.loadPreset(this.presetName)
62
-
63
- }
64
- else{
65
-
66
- }*/
67
-
68
- const data = await this.load({ preset:currentPreset.presets[currentPreset.presetIdx] })
69
-
70
- if(this.channel && this.socket){
71
- if(this.socket.joinWithArgs){
72
- this.socket.joinWithArgs(this.channel, { preset:currentPreset.presets[currentPreset.presetIdx] })
73
- }
74
- else{
75
- this.socket.join(this.channel)
76
- }
77
- }
78
-
79
- const mapApiKey = this.getMapApiKey ? this.getMapApiKey() : undefined
80
-
81
- let extra = this.patchExtra ? await this.patchExtra() : {}
82
-
83
- return {
84
- configs: currentPreset,
85
- mapApiKey,
86
- ...data,
87
- extra
88
- }
89
- },
90
-
91
- async load(params){
92
-
93
- const { items, hasNext, count } = await this._load(params)
94
-
95
- if(this.name){
96
- if(!this.socket.loadParams){
97
- this.socket.loadParams = {}
98
- }
99
-
100
- this.socket.loadParams[this.name] = params
101
- }
102
-
103
- return {
104
- items,
105
- hasNext,
106
- count
107
- }
108
- },
109
-
110
- async loadSummary(params){
111
-
112
- if(!this.conn){
113
- console.error('Unable to load summary, connection not found')
114
- return
115
- }
116
-
117
- const { preset = {} } = params
118
- const summary = preset.summaries.filter((_) => _.enabled).pop()
119
-
120
- if(!summary) return
121
-
122
- const { derivedSql, where, replacements } = await this._load(params)
123
-
124
- switch(summary.mode){
125
-
126
- case 'bar':
127
- return await this.loadBarSummary(summary, derivedSql)
128
-
129
- case 'line':
130
- return await this.loadLineSummary(summary, derivedSql)
131
-
132
- case 'table':
133
- return await this.loadTableSummary(summary, derivedSql)
134
-
135
- case 'map':
136
- if(this.loadMapSummary){
137
- return await this.loadMapSummary(preset, {
138
- derivedSql,
139
- where,
140
- replacements
141
- })
142
- }
143
- break
144
-
145
- }
146
-
147
- return
148
-
149
-
150
-
151
- /*const attributes = []
152
- const group = []
153
- const summaryColumns = [
154
- /!*{ key:"dfDate", label:"Date", width:"200px", visible:true },
155
- { key:"type-1", label:"Type 1", type:"number", visible:true },
156
- { key:"type-2", label:"Type 2", type:"number", visible:true },
157
- { key:"type-3", label:"Type 3", type:"number", visible:true },
158
- { key:"type-4", label:"Type 4", type:"number", visible:true },
159
- { key:"type-8", label:"Type 8", type:"number", visible:true },*!/
160
- ]
161
-
162
- const row = rows[0]
163
- const rowKey = row.key
164
- const rowLabel = this.columns[row.key].label
165
- switch(row.format){
166
- case 'date':
167
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y-%m-%d') as dfDate`)
168
- group.push(`DATE_FORMAT(${rowKey}, '%Y-%m-%d')`)
169
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"D MMM" })
170
- break
171
-
172
- case 'month':
173
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y-%m') as dfDate`)
174
- group.push(`DATE_FORMAT(${rowKey}, '%Y-%m')`)
175
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"MMM YYYY" })
176
- break
177
-
178
- case 'quarter':
179
- attributes.push(`CONCAT(YEAR(${rowKey}), ' Q', QUARTER(${rowKey})) as dfDate`)
180
- group.push(`CONCAT(YEAR(${rowKey}), ' Q', QUARTER(${rowKey}))`)
181
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"MMM YYYY" })
182
- break
183
-
184
- case 'year':
185
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y') as dfDate`)
186
- group.push(`DATE_FORMAT(${rowKey}, '%Y')`)
187
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"YYYY" })
188
- break
189
-
190
- default:
191
- attributes.push(`${rowKey} as dfDate`)
192
- group.push(`${rowKey}`)
193
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true })
194
- break
195
- }
196
-
197
- const value = values[0]
198
- if(columnValues.length > 0){
199
- columnValues.forEach((obj) => {
200
- const columnValue = obj.cols
201
-
202
- let columnLabel = (columnValue ?? '').toString()
203
- const baseColumn = this.columns[colKey]
204
- switch(baseColumn.type){
205
-
206
- case 'enum':
207
- const enumValue = baseColumn.typeParams.filter((_) => _.value === columnValue).pop()
208
- if(enumValue) columnLabel = enumValue.text
209
- break
210
- }
211
-
212
- switch(value.aggregrate){
213
- case 'count':
214
- const fn = columnValue === null ? `${colKey} is null` : `${colKey} = '${columnValue}'`
215
- attributes.push(`SUM(IF(${fn}, 1, 0)) as \`${colKey}-${columnValue}\``)
216
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
217
- break
218
-
219
- case 'min':
220
- attributes.push(`MIN(${colKey}) as \`${colKey}-${columnValue}\``)
221
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
222
- break
223
-
224
- case 'max':
225
- attributes.push(`MAX(${colKey}) as \`${colKey}-${columnValue}\``)
226
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
227
- break
228
-
229
- case 'avg':
230
- attributes.push(`AVG(${colKey}) as \`${colKey}-${columnValue}\``)
231
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
232
- break
233
- }
234
- })
235
- }
236
- else{
237
- switch(value.aggregrate) {
238
- case 'count':
239
- default:
240
- attributes.push(`COUNT(*) as \`Count\``)
241
- summaryColumns.push({ key:'Count', label:'Count', type:"number", visible:true, aggregrate:"count" })
242
- }
243
- }
244
-
245
- //console.log(attributes)
246
-
247
- let [ summaryItems ] = await this.conn.query(`
248
- SELECT
249
- ${attributes.join(', ')}
250
- FROM (
251
- ${derivedSql}
252
- ) as t1
253
- GROUP BY ${group[0]}
254
- ORDER BY dfDate ASC
255
- `)
256
-
257
- if(this.columns[rowKey] && this.columns[rowKey].type === 'enum'){
258
- summaryItems = summaryItems.map((_) => {
259
-
260
- const typeParam = this.columns[rowKey].typeParams.filter((__) => __.value === _.dfDate).pop()
261
- if(typeParam){
262
- _.dfDate = typeParam.text
263
- }
264
-
265
- return _
266
- })
267
- }
268
-
269
- const summary = {
270
- type: "table",
271
- columns: summaryColumns,
272
- items: summaryItems
273
- /!*items: [
274
- { date:"21 Jan 23", "type-1":12, "type-2":11, "type-3":16, "type-4":2, "type-8":8 },
275
- { date:"22 Jan 23", "type-1":51, "type-2":87, "type-3":86, "type-4":3, "type-8":9 },
276
- { date:"23 Jan 23", "type-1":14, "type-2":66, "type-3":77, "type-4":4, "type-8":18 },
277
- { date:"24 Jan 23", "type-1":7, "type-2":3, "type-3":63, "type-4":5, "type-8":28 },
278
- { date:"25 Jan 23", "type-1":88, "type-2":55, "type-3":68, "type-4":6, "type-8":38 },
279
- { date:"26 Jan 23", "type-1":172, "type-2":13, "type-3":6, "type-4":7, "type-8":48 }
280
- ]*!/
281
- }
282
-
283
- return summary*/
284
- },
285
-
286
- async subscribe(params, socket){
287
- const { name } = params
288
- if(name){
289
- socket.join(this.name)
290
- }
291
- },
292
-
293
- async unsubscribe(params, socket){
294
- const { name } = params
295
- if(name){
296
- socket.leave(this.name)
297
- }
298
- },
299
-
300
- async downloadRows(params, socket){
301
-
302
- const { preset } = params
303
-
304
- const columns = []
305
- preset.columns.forEach((column) => {
306
- if(column.visible){
307
- columns.push({ header: column.label, key: column.key, width: 15 })
308
- }
309
- })
310
-
311
- const workbook = new Exceljs.Workbook();
312
- const sheet = workbook.addWorksheet('Export ' + this.name);
313
- sheet.columns = columns
314
-
315
- let where = {}
316
- let replacements = []
317
- let order = [
318
- [ 'updatedAt', 'desc' ],
319
- [ 'id', 'desc' ],
320
- ]
321
-
322
- let attributeIncludes
323
- if(this.getAttributeIncludes){
324
- attributeIncludes = this.getAttributeIncludes(preset)
325
- }
326
-
327
- let attributes = { id:1, updatedAt:1 }
328
- if(preset.columns){
329
- let modelAttributes = this.model.getAttributes();
330
- preset.columns.forEach((column) => {
331
- if(column.visible && modelAttributes[column.key]){
332
- attributes[column.key] = 1
333
- }
334
- else if(column.virtual){
335
- switch(column.virtual.type){
336
-
337
- case 'sql':
338
- if(!Array.isArray(attributeIncludes)){
339
- attributeIncludes = []
340
- }
341
-
342
- attributeIncludes.push([
343
- Sequelize.literal(`(${column.virtual.value})`), column.key
344
- ])
345
- break
346
- }
347
- }
348
- })
349
- }
350
- attributes = Object.keys(attributes)
351
-
352
- if(preset.filters){
353
- const { where:presetWhere } = this.getPresetFilterParams(preset)
354
- where = {
355
- ...where,
356
- ...presetWhere
357
- }
358
- }
359
-
360
- if(preset.sorts){
361
- const { order:presetOrder } = this.getPresetSortParams(preset)
362
- if(presetOrder){
363
- order = presetOrder
364
- }
365
- }
366
-
367
- if(preset.search){
368
- const tableName = this.model.name
369
- where = {
370
- ...where,
371
- [Op.and]: Sequelize.literal(`MATCH(\`${tableName}\`.tag) AGAINST (? IN BOOLEAN MODE)`)
372
- }
373
- replacements.push(preset.search)
374
- }
375
-
376
- if(this.downloadFilters){
377
- await this.downloadFilters(params, where)
378
- }
379
-
380
- const rows = await this.model.findAll({
381
- where,
382
- attributes: {
383
- ...attributes,
384
- include: attributeIncludes
385
- },
386
- order,
387
- replacements,
388
- include: this.getModelIncludes ? this.getModelIncludes(preset) : undefined
389
- })
390
-
391
- rows.forEach((row) => {
392
-
393
- const obj = {}
394
- preset.columns.forEach((column) => {
395
- if(column.visible){
396
- switch(column.type){
397
-
398
- case 'enum':
399
- const enumValue = row[column.key]
400
- const enumObj = column.typeParams.filter((_) => _.value === enumValue).pop()
401
- const enumText = (enumObj ?? {}).text ?? enumValue
402
- obj[column.key] = enumText
403
- break
404
-
405
- default:
406
- obj[column.key] = row[column.key]
407
- break
408
- }
409
- }
410
- })
411
- sheet.addRow(obj)
412
- })
413
-
414
- const filename = 'data-konsumen-' + dayjs().format('YYYYMMDDHHmm') + '.xlsx'
415
- await workbook.xlsx.writeFile(process.env.ROOT_PATH + '/storage/files/downloads/' + filename);
416
- return {
417
- url: '/downloads/' + filename
418
- }
419
- },
420
-
421
-
422
-
423
- async _load(params){
424
-
425
- /*const listAcl = socket.auth.user.getAclv('customer', 'list')
426
- if(listAcl === false){
427
- throw new Error('Insufficient privilege')
428
- }
429
- else if(Array.isArray(listAcl.filters) && listAcl.filters.includes('user-customers')){
430
- where = {
431
- ...where,
432
- referralType: {
433
- [Op.in]: [ "App\\Models\\User", "user" ]
434
- },
435
- referralId: socket.auth.userId
436
- }
437
- }*/
438
-
439
- const { afterItem, itemsPerPage = this.itemsPerPage ?? 24 } = params
440
- const { preset = {} } = params
441
- let where = {}
442
- let replacements = []
443
- let order = [
444
- [ 'updatedAt', 'desc' ],
445
- [ 'id', 'desc' ],
446
- ]
447
-
448
- let attributeIncludes
449
- if(this.getAttributeIncludes){
450
- attributeIncludes = this.getAttributeIncludes(preset)
451
- }
452
-
453
- let includes
454
- if(this.getModelIncludes){
455
- includes = await this.getModelIncludes(preset)
456
- }
457
-
458
- let attributes = { id:1, updatedAt:1 }
459
- if(preset.columns){
460
- let modelAttributes = this.model.getAttributes();
461
- preset.columns.forEach((column) => {
462
- if(column.visible && modelAttributes[column.key]){
463
- attributes[column.key] = 1
464
- }
465
- else if(column.virtual){
466
- switch(column.virtual.type){
467
-
468
- case 'sql':
469
- if(!Array.isArray(attributeIncludes)){
470
- attributeIncludes = []
471
- }
472
-
473
- attributeIncludes.push([
474
- Sequelize.literal(`(${column.virtual.value})`), column.key
475
- ])
476
- break
477
- }
478
- }
479
- })
480
- }
481
- if(typeof this.extraAttributes === 'function'){
482
- attributes = {
483
- ...attributes,
484
- ...((await this.extraAttributes(preset)) ?? {})
485
- }
486
- }
487
- attributes = Object.keys(attributes)
488
-
489
- if(preset.filters){
490
- const { where:presetWhere } = this.getPresetFilterParams(preset, includes)
491
- where = {
492
- ...where,
493
- ...presetWhere
494
- }
495
- }
496
-
497
- if(typeof this['loadFilters'] === 'function'){
498
- where = {
499
- ...where,
500
- ...(await this['loadFilters'](params) ?? {})
501
- }
502
- }
503
-
504
- if(preset.sorts){
505
- const { order:presetOrder } = this.getPresetSortParams(preset, includes)
506
- if(presetOrder){
507
- order = presetOrder
508
- }
509
- }
510
-
511
- if(preset.search){
512
- const tableName = this.model.name
513
- where = {
514
- ...where,
515
- [Op.and]: Sequelize.literal(`MATCH(\`${tableName}\`.tag) AGAINST (? IN BOOLEAN MODE)`)
516
- }
517
- replacements.push(preset.search)
518
- }
519
-
520
- if(afterItem){
521
- const sortWhere = getPresetSortWhereParams(order, afterItem)
522
- where = {
523
- ...where,
524
- ...sortWhere
525
- }
526
- }
527
-
528
- let derivedSql
529
- let { rows:items, count } = await this.model.findAndCountAll({
530
- where,
531
- attributes: {
532
- ...attributes,
533
- include: attributeIncludes
534
- },
535
- order,
536
- limit: itemsPerPage + 1,
537
- replacements,
538
- include: includes,
539
- logging: (sql, queryObject, p) => {
540
- derivedSql = sql
541
- }
542
- })
543
- derivedSql = derivedSql.replace('Executing (default): ', '').replace('LIMIT ' + (this.itemsPerPage + 1), '').slice(0, -1)
544
-
545
- const hasNext = items.length > itemsPerPage
546
- if(hasNext){
547
- items.splice(items.length - 1, 1)
548
- }
549
-
550
- /*let summary
551
- if(!afterItem && preset.summary && preset.summary.enabled){
552
- if(preset.summary.mode === 'map' && this.loadMapSummary){
553
- summary = await this.loadMapSummary(preset, {
554
- where,
555
- replacements
556
- })
557
- }
558
- else{
559
- derivedSql = derivedSql.replace('Executing (default): ', '').replace('LIMIT ' + (this.itemsPerPage + 1), '').slice(0, -1)
560
- summary = await this.loadSummary(preset, {
561
- where,
562
- replacements
563
- }, derivedSql)
564
- }
565
- }*/
566
-
567
- if(this.postLoadItems){
568
- const postLoadItems = await this.postLoadItems(params, { where, attributes, order, include:includes, replacements })
569
- if(Array.isArray(postLoadItems)){
570
- items = postLoadItems.concat(items)
571
- }
572
- }
573
-
574
- if(this.socket){
575
- this.socket.join(this.channel)
576
- }
577
-
578
- return {
579
- items,
580
- hasNext,
581
- count,
582
- derivedSql,
583
- where,
584
- replacements
585
- }
586
- },
587
-
588
- async loadBarSummary(summary, derivedSql){
589
-
590
- if(!summary.bar) return
591
-
592
- const { columns, rows, values } = summary.bar
593
-
594
- if(!Array.isArray(columns) || columns.length !== 1 || !columns[0].key) return
595
- if(!Array.isArray(rows) || rows.length !== 1 || !rows[0].key) return
596
- if(!Array.isArray(values) || values.length !== 1 || !values[0].aggregrate) return
597
-
598
- const col = columns[0]
599
- let columnValues = []
600
- let colKey
601
- if(col.key !== '(none)'){
602
- colKey = col.key
603
- const [ _columnValues ] = await this.conn.query(`
604
- SELECT
605
- DISTINCT(${colKey}) AS cols
606
- FROM (${derivedSql}) AS derived
607
- ORDER BY cols ASC
608
- `)
609
-
610
- columnValues = _columnValues
611
- }
612
- if(columnValues.length > 100){
613
- throw new Error('Too many columns')
614
- }
615
-
616
- const attributes = []
617
- const group = []
618
- const summaryColumns = [
619
- /*{ key:"dfDate", label:"Date", width:"200px", visible:true },
620
- { key:"type-1", label:"Type 1", type:"number", visible:true },
621
- { key:"type-2", label:"Type 2", type:"number", visible:true },
622
- { key:"type-3", label:"Type 3", type:"number", visible:true },
623
- { key:"type-4", label:"Type 4", type:"number", visible:true },
624
- { key:"type-8", label:"Type 8", type:"number", visible:true },*/
625
- ]
626
-
627
- const row = rows[0]
628
- const rowKey = row.key
629
- const rowLabel = this.columns[row.key].label
630
- switch(row.format){
631
- case 'date':
632
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y-%m-%d') as dfDate`)
633
- group.push(`DATE_FORMAT(${rowKey}, '%Y-%m-%d')`)
634
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"D MMM" })
635
- break
636
-
637
- case 'month':
638
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y-%m') as dfDate`)
639
- group.push(`DATE_FORMAT(${rowKey}, '%Y-%m')`)
640
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"MMM YYYY" })
641
- break
642
-
643
- case 'quarter':
644
- attributes.push(`CONCAT(YEAR(${rowKey}), ' Q', QUARTER(${rowKey})) as dfDate`)
645
- group.push(`CONCAT(YEAR(${rowKey}), ' Q', QUARTER(${rowKey}))`)
646
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"MMM YYYY" })
647
- break
648
-
649
- case 'year':
650
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y') as dfDate`)
651
- group.push(`DATE_FORMAT(${rowKey}, '%Y')`)
652
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"YYYY" })
653
- break
654
-
655
- default:
656
- attributes.push(`${rowKey} as dfDate`)
657
- group.push(`${rowKey}`)
658
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true })
659
- break
660
- }
661
-
662
- const value = values[0]
663
- if(columnValues.length > 0){
664
- columnValues.forEach((obj) => {
665
- const columnValue = obj.cols
666
-
667
- let columnLabel = (columnValue ?? '').toString()
668
- const baseColumn = this.columns[colKey]
669
- switch(baseColumn.type){
670
-
671
- case 'enum':
672
- const enumValue = baseColumn.typeParams.filter((_) => _.value === columnValue).pop()
673
- if(enumValue) columnLabel = enumValue.text
674
- break
675
- }
676
-
677
- switch(value.aggregrate){
678
- case 'count':
679
- const fn = columnValue === null ? `${colKey} is null` : `${colKey} = '${columnValue}'`
680
- attributes.push(`SUM(IF(${fn}, 1, 0)) as \`${colKey}-${columnValue}\``)
681
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
682
- break
683
-
684
- case 'min':
685
- attributes.push(`MIN(${colKey}) as \`${colKey}-${columnValue}\``)
686
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
687
- break
688
-
689
- case 'max':
690
- attributes.push(`MAX(${colKey}) as \`${colKey}-${columnValue}\``)
691
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
692
- break
693
-
694
- case 'avg':
695
- attributes.push(`AVG(${colKey}) as \`${colKey}-${columnValue}\``)
696
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
697
- break
698
- }
699
- })
700
- }
701
- else{
702
- switch(value.aggregrate) {
703
- case 'count':
704
- default:
705
- attributes.push(`COUNT(*) as \`Count\``)
706
- summaryColumns.push({ key:'Count', label:'Count', type:"number", visible:true, aggregrate:"count" })
707
- }
708
- }
709
-
710
- let [ summaryItems ] = await this.conn.query(`
711
- SELECT
712
- ${attributes.join(', ')}
713
- FROM (
714
- ${derivedSql}
715
- ) as t1
716
- GROUP BY ${group[0]}
717
- ORDER BY dfDate ASC
718
- `)
719
-
720
- if(this.columns[rowKey] && this.columns[rowKey].type === 'enum'){
721
- summaryItems = summaryItems.map((_) => {
722
-
723
- const typeParam = this.columns[rowKey].typeParams.filter((__) => __.value === _.dfDate).pop()
724
- if(typeParam){
725
- _.dfDate = typeParam.text
726
- }
727
-
728
- return _
729
- })
730
- }
731
-
732
- const result = {
733
- mode: "bar",
734
- columns: summaryColumns,
735
- items: summaryItems
736
- /*items: [
737
- { date:"21 Jan 23", "type-1":12, "type-2":11, "type-3":16, "type-4":2, "type-8":8 },
738
- { date:"22 Jan 23", "type-1":51, "type-2":87, "type-3":86, "type-4":3, "type-8":9 },
739
- { date:"23 Jan 23", "type-1":14, "type-2":66, "type-3":77, "type-4":4, "type-8":18 },
740
- { date:"24 Jan 23", "type-1":7, "type-2":3, "type-3":63, "type-4":5, "type-8":28 },
741
- { date:"25 Jan 23", "type-1":88, "type-2":55, "type-3":68, "type-4":6, "type-8":38 },
742
- { date:"26 Jan 23", "type-1":172, "type-2":13, "type-3":6, "type-4":7, "type-8":48 }
743
- ]*/
744
- }
745
-
746
- return result
747
- },
748
-
749
- async loadLineSummary(summary, derivedSql){
750
-
751
- if(!summary.line) return
752
-
753
- const { columns, rows, values } = summary.line
754
-
755
- if(!Array.isArray(columns) || columns.length !== 1 || !columns[0].key) return
756
- if(!Array.isArray(rows) || rows.length !== 1 || !rows[0].key) return
757
- if(!Array.isArray(values) || values.length !== 1 || !values[0].aggregrate) return
758
-
759
- const col = columns[0]
760
- let columnValues = []
761
- let colKey
762
- if(col.key !== '(none)'){
763
- colKey = col.key
764
- const [ _columnValues ] = await this.conn.query(`
765
- SELECT
766
- DISTINCT(${colKey}) AS cols
767
- FROM (${derivedSql}) AS derived
768
- ORDER BY cols ASC
769
- `)
770
-
771
- columnValues = _columnValues
772
- }
773
- if(columnValues.length > 100){
774
- throw new Error('Too many columns')
775
- }
776
-
777
- const attributes = []
778
- const group = []
779
- const summaryColumns = [
780
- /*{ key:"dfDate", label:"Date", width:"200px", visible:true },
781
- { key:"type-1", label:"Type 1", type:"number", visible:true },
782
- { key:"type-2", label:"Type 2", type:"number", visible:true },
783
- { key:"type-3", label:"Type 3", type:"number", visible:true },
784
- { key:"type-4", label:"Type 4", type:"number", visible:true },
785
- { key:"type-8", label:"Type 8", type:"number", visible:true },*/
786
- ]
787
-
788
- const row = rows[0]
789
- const rowKey = row.key
790
- const rowLabel = this.columns[row.key].label
791
- switch(row.format){
792
- case 'date':
793
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y-%m-%d') as dfDate`)
794
- group.push(`DATE_FORMAT(${rowKey}, '%Y-%m-%d')`)
795
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"D MMM" })
796
- break
797
-
798
- case 'month':
799
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y-%m') as dfDate`)
800
- group.push(`DATE_FORMAT(${rowKey}, '%Y-%m')`)
801
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"MMM YYYY" })
802
- break
803
-
804
- case 'quarter':
805
- attributes.push(`CONCAT(YEAR(${rowKey}), ' Q', QUARTER(${rowKey})) as dfDate`)
806
- group.push(`CONCAT(YEAR(${rowKey}), ' Q', QUARTER(${rowKey}))`)
807
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"MMM YYYY" })
808
- break
809
-
810
- case 'year':
811
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y') as dfDate`)
812
- group.push(`DATE_FORMAT(${rowKey}, '%Y')`)
813
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"YYYY" })
814
- break
815
-
816
- default:
817
- attributes.push(`${rowKey} as dfDate`)
818
- group.push(`${rowKey}`)
819
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true })
820
- break
821
- }
822
-
823
- const value = values[0]
824
- if(columnValues.length > 0){
825
- columnValues.forEach((obj) => {
826
- const columnValue = obj.cols
827
-
828
- let columnLabel = (columnValue ?? '').toString()
829
- const baseColumn = this.columns[colKey]
830
- switch(baseColumn.type){
831
-
832
- case 'enum':
833
- const enumValue = baseColumn.typeParams.filter((_) => _.value === columnValue).pop()
834
- if(enumValue) columnLabel = enumValue.text
835
- break
836
- }
837
-
838
- switch(value.aggregrate){
839
- case 'count':
840
- const fn = columnValue === null ? `${colKey} is null` : `${colKey} = '${columnValue}'`
841
- attributes.push(`SUM(IF(${fn}, 1, 0)) as \`${colKey}-${columnValue}\``)
842
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
843
- break
844
-
845
- case 'min':
846
- attributes.push(`MIN(${colKey}) as \`${colKey}-${columnValue}\``)
847
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
848
- break
849
-
850
- case 'max':
851
- attributes.push(`MAX(${colKey}) as \`${colKey}-${columnValue}\``)
852
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
853
- break
854
-
855
- case 'avg':
856
- attributes.push(`AVG(${colKey}) as \`${colKey}-${columnValue}\``)
857
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
858
- break
859
- }
860
- })
861
- }
862
- else{
863
- switch(value.aggregrate) {
864
- case 'count':
865
- default:
866
- attributes.push(`COUNT(*) as \`Count\``)
867
- summaryColumns.push({ key:'Count', label:'Count', type:"number", visible:true, aggregrate:"count" })
868
- }
869
- }
870
-
871
- let [ summaryItems ] = await this.conn.query(`
872
- SELECT
873
- ${attributes.join(', ')}
874
- FROM (
875
- ${derivedSql}
876
- ) as t1
877
- GROUP BY ${group[0]}
878
- ORDER BY dfDate ASC
879
- `)
880
-
881
- if(this.columns[rowKey] && this.columns[rowKey].type === 'enum'){
882
- summaryItems = summaryItems.map((_) => {
883
-
884
- const typeParam = this.columns[rowKey].typeParams.filter((__) => __.value === _.dfDate).pop()
885
- if(typeParam){
886
- _.dfDate = typeParam.text
887
- }
888
-
889
- return _
890
- })
891
- }
892
-
893
- const result = {
894
- mode: "line",
895
- columns: summaryColumns,
896
- items: summaryItems
897
- /*items: [
898
- { date:"21 Jan 23", "type-1":12, "type-2":11, "type-3":16, "type-4":2, "type-8":8 },
899
- { date:"22 Jan 23", "type-1":51, "type-2":87, "type-3":86, "type-4":3, "type-8":9 },
900
- { date:"23 Jan 23", "type-1":14, "type-2":66, "type-3":77, "type-4":4, "type-8":18 },
901
- { date:"24 Jan 23", "type-1":7, "type-2":3, "type-3":63, "type-4":5, "type-8":28 },
902
- { date:"25 Jan 23", "type-1":88, "type-2":55, "type-3":68, "type-4":6, "type-8":38 },
903
- { date:"26 Jan 23", "type-1":172, "type-2":13, "type-3":6, "type-4":7, "type-8":48 }
904
- ]*/
905
- }
906
-
907
- return result
908
- },
909
-
910
- async loadTableSummary(summary, derivedSql){
911
-
912
- if(!summary.table) return
913
-
914
- const { columns, rows, values } = summary.table
915
-
916
- if(!Array.isArray(columns) || columns.length !== 1 || !columns[0].key) return
917
- if(!Array.isArray(rows) || rows.length !== 1 || !rows[0].key) return
918
- if(!Array.isArray(values) || values.length !== 1 || !values[0].aggregrate) return
919
-
920
- const col = columns[0]
921
- let columnValues = []
922
- let colKey
923
- if(col.key !== '(none)'){
924
- colKey = col.key
925
- const [ _columnValues ] = await this.conn.query(`
926
- SELECT
927
- DISTINCT(${colKey}) AS cols
928
- FROM (${derivedSql}) AS derived
929
- ORDER BY cols ASC
930
- `)
931
-
932
- columnValues = _columnValues
933
- }
934
- if(columnValues.length > 100){
935
- throw new Error('Too many columns')
936
- }
937
-
938
- const attributes = []
939
- const group = []
940
- const summaryColumns = [
941
- /*{ key:"dfDate", label:"Date", width:"200px", visible:true },
942
- { key:"type-1", label:"Type 1", type:"number", visible:true },
943
- { key:"type-2", label:"Type 2", type:"number", visible:true },
944
- { key:"type-3", label:"Type 3", type:"number", visible:true },
945
- { key:"type-4", label:"Type 4", type:"number", visible:true },
946
- { key:"type-8", label:"Type 8", type:"number", visible:true },*/
947
- ]
948
-
949
- const row = rows[0]
950
- const rowKey = row.key
951
- const rowLabel = this.columns[row.key].label
952
- switch(row.format){
953
- case 'date':
954
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y-%m-%d') as dfDate`)
955
- group.push(`DATE_FORMAT(${rowKey}, '%Y-%m-%d')`)
956
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"D MMM" })
957
- break
958
-
959
- case 'month':
960
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y-%m') as dfDate`)
961
- group.push(`DATE_FORMAT(${rowKey}, '%Y-%m')`)
962
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"MMM YYYY" })
963
- break
964
-
965
- case 'quarter':
966
- attributes.push(`CONCAT(YEAR(${rowKey}), ' Q', QUARTER(${rowKey})) as dfDate`)
967
- group.push(`CONCAT(YEAR(${rowKey}), ' Q', QUARTER(${rowKey}))`)
968
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"MMM YYYY" })
969
- break
970
-
971
- case 'year':
972
- attributes.push(`DATE_FORMAT(${rowKey}, '%Y') as dfDate`)
973
- group.push(`DATE_FORMAT(${rowKey}, '%Y')`)
974
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true, type:"date", format:"YYYY" })
975
- break
976
-
977
- default:
978
- attributes.push(`${rowKey} as dfDate`)
979
- group.push(`${rowKey}`)
980
- summaryColumns.push({ key:"dfDate", label:rowLabel, width:"200px", visible:true })
981
- break
982
- }
983
-
984
- const value = values[0]
985
- if(columnValues.length > 0){
986
- columnValues.forEach((obj) => {
987
- const columnValue = obj.cols
988
-
989
- let columnLabel = (columnValue ?? '').toString()
990
- const baseColumn = this.columns[colKey]
991
- switch(baseColumn.type){
992
-
993
- case 'enum':
994
- const enumValue = baseColumn.typeParams.filter((_) => _.value === columnValue).pop()
995
- if(enumValue) columnLabel = enumValue.text
996
- break
997
- }
998
-
999
- switch(value.aggregrate){
1000
- case 'count':
1001
- const fn = columnValue === null ? `${colKey} is null` : `${colKey} = '${columnValue}'`
1002
- attributes.push(`SUM(IF(${fn}, 1, 0)) as \`${colKey}-${columnValue}\``)
1003
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
1004
- break
1005
-
1006
- case 'min':
1007
- attributes.push(`MIN(${colKey}) as \`${colKey}-${columnValue}\``)
1008
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
1009
- break
1010
-
1011
- case 'max':
1012
- attributes.push(`MAX(${colKey}) as \`${colKey}-${columnValue}\``)
1013
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
1014
- break
1015
-
1016
- case 'avg':
1017
- attributes.push(`AVG(${colKey}) as \`${colKey}-${columnValue}\``)
1018
- summaryColumns.push({ key:colKey + "-" + columnValue, label:columnLabel, visible:true, aggregrate:"count" })
1019
- break
1020
- }
1021
- })
1022
- }
1023
- else{
1024
- switch(value.aggregrate) {
1025
- case 'count':
1026
- default:
1027
- attributes.push(`COUNT(*) as \`Count\``)
1028
- summaryColumns.push({ key:'Count', label:'Count', type:"number", visible:true, aggregrate:"count" })
1029
- }
1030
- }
1031
-
1032
- let [ summaryItems ] = await this.conn.query(`
1033
- SELECT
1034
- ${attributes.join(', ')}
1035
- FROM (
1036
- ${derivedSql}
1037
- ) as t1
1038
- GROUP BY ${group[0]}
1039
- ORDER BY dfDate ASC
1040
- `)
1041
-
1042
- if(this.columns[rowKey] && this.columns[rowKey].type === 'enum'){
1043
- summaryItems = summaryItems.map((_) => {
1044
-
1045
- const typeParam = this.columns[rowKey].typeParams.filter((__) => __.value === _.dfDate).pop()
1046
- if(typeParam){
1047
- _.dfDate = typeParam.text
1048
- }
1049
-
1050
- return _
1051
- })
1052
- }
1053
-
1054
- const result = {
1055
- mode: "table",
1056
- columns: summaryColumns,
1057
- items: summaryItems
1058
- /*items: [
1059
- { date:"21 Jan 23", "type-1":12, "type-2":11, "type-3":16, "type-4":2, "type-8":8 },
1060
- { date:"22 Jan 23", "type-1":51, "type-2":87, "type-3":86, "type-4":3, "type-8":9 },
1061
- { date:"23 Jan 23", "type-1":14, "type-2":66, "type-3":77, "type-4":4, "type-8":18 },
1062
- { date:"24 Jan 23", "type-1":7, "type-2":3, "type-3":63, "type-4":5, "type-8":28 },
1063
- { date:"25 Jan 23", "type-1":88, "type-2":55, "type-3":68, "type-4":6, "type-8":38 },
1064
- { date:"26 Jan 23", "type-1":172, "type-2":13, "type-3":6, "type-4":7, "type-8":48 }
1065
- ]*/
1066
- }
1067
-
1068
- return result
1069
- },
1070
-
1071
-
1072
-
1073
- getPresetFilterParams(preset, includes){
1074
-
1075
- let where = {}
1076
- let replacements = []
1077
-
1078
- if(preset.filters){
1079
-
1080
- preset.filters.forEach((filter) => {
1081
-
1082
- if(!filter.enabled) return
1083
-
1084
- const key = filter.key
1085
-
1086
- const whereValue = this.getWhereValue(filter)
1087
- const operand = filter.operand === 'or' ? 'or' : 'and'
1088
-
1089
- // Nested filter attribute
1090
- if(key.indexOf('.') > -1){
1091
-
1092
- const inclKeys = key.split('.')
1093
- if(inclKeys.length !== 2){
1094
- console.warn('Filter key not handled', key)
1095
- }
1096
- else{
1097
- const inclAs = inclKeys[0]
1098
- const inclKey = inclKeys[1]
1099
- const inclIndex = (includes ?? []).findIndex((_) => _.as === inclAs)
1100
- if(inclIndex > -1){
1101
-
1102
- let includeWhere = includes[inclIndex].where ?? {}
1103
-
1104
- switch(operand){
1105
-
1106
- case 'or':
1107
- includeWhere = {
1108
- ...includeWhere,
1109
- [inclKey]: {
1110
- [Op.or]: whereValue
1111
- }
1112
- }
1113
- break
1114
-
1115
- default:
1116
- includeWhere = {
1117
- ...where,
1118
- [inclKey]: {
1119
- [Op.and]: whereValue
1120
- }
1121
- }
1122
- break
1123
- }
1124
-
1125
- includes[inclIndex].where = includeWhere
1126
- }
1127
- else{
1128
- console.warn('Unsupported filter key', key)
1129
- }
1130
- }
1131
- }
1132
-
1133
- // Unnested filter attribute
1134
- else{
1135
- switch(operand){
1136
-
1137
- case 'or':
1138
- where = {
1139
- ...where,
1140
- [key]: {
1141
- [Op.or]: whereValue
1142
- }
1143
- }
1144
- break
1145
-
1146
- default:
1147
- where = {
1148
- ...where,
1149
- [key]: {
1150
- [Op.and]: whereValue
1151
- }
1152
- }
1153
- break
1154
- }
1155
- }
1156
- })
1157
- }
1158
-
1159
- return {
1160
- where,
1161
- replacements
1162
- }
1163
- },
1164
-
1165
- getWhereValue(filter){
1166
-
1167
- let whereValue = []
1168
- const type = filter.type
1169
- const items = filter.filters ?? []
1170
- switch(type){
1171
-
1172
- case 'date':
1173
- items.forEach((item) => {
1174
- if(!('operator' in item) || (item.operator === 'between' && !('value' in item))) return
1175
-
1176
- const operator = item.operator
1177
- const value = item.value
1178
-
1179
- switch(operator){
1180
-
1181
- case 'today':
1182
- whereValue = {
1183
- ...whereValue,
1184
- [Op.eq]: dayjs().format('YYYY-MM-DD'),
1185
- }
1186
- break
1187
-
1188
- case 'thisWeek':
1189
- whereValue = {
1190
- ...whereValue,
1191
- [Op.gte]: dayjs().startOf('week').format('YYYY-MM-DD 00:00:00'),
1192
- [Op.lt]: dayjs().endOf('week').format('YYYY-MM-DD 23:59:59'),
1193
- }
1194
- break
1195
-
1196
- case 'weekAgo':
1197
- whereValue = {
1198
- ...whereValue,
1199
- [Op.gte]: dayjs().add(-1, 'week').format('YYYY-MM-DD 00:00:00'),
1200
- [Op.lt]: dayjs().format('YYYY-MM-DD 23:59:59'),
1201
- }
1202
- break
1203
-
1204
- case 'thisMonth':
1205
- whereValue = {
1206
- ...whereValue,
1207
- [Op.gte]: dayjs().format('YYYY-MM-01 00:00:00'),
1208
- [Op.lt]: dayjs().endOf('month').format('YYYY-MM-DD 23:59:59'),
1209
- }
1210
- break
1211
-
1212
- case 'monthAgo':
1213
- whereValue = {
1214
- ...whereValue,
1215
- [Op.gte]: dayjs().add(-1, 'month').format('YYYY-MM-DD 00:00:00'),
1216
- [Op.lt]: dayjs().format('YYYY-MM-DD 23:59:59'),
1217
- }
1218
- break
1219
-
1220
- case 'lastMonth':
1221
- whereValue = {
1222
- [Op.gte]: dayjs().add(-1, 'month').format('YYYY-MM-01 00:00:00'),
1223
- [Op.lte]: dayjs().add(-1, 'month').endOf('month').format('YYYY-MM-DD 23:59:59'),
1224
- }
1225
- break
1226
-
1227
- case 'thisYear':
1228
- whereValue = {
1229
- ...whereValue,
1230
- [Op.gte]: dayjs().startOf('year').format('YYYY-MM-DD 00:00:00'),
1231
- [Op.lt]: dayjs().endOf('year').format('YYYY-MM-DD 23:59:59'),
1232
- }
1233
- break
1234
-
1235
- case 'lastYear':
1236
- whereValue = {
1237
- ...whereValue,
1238
- [Op.gte]: dayjs().add(-1, 'year').startOf('year').format('YYYY-MM-DD 00:00:00'),
1239
- [Op.lt]: dayjs().add(-1, 'year').endOf('year').format('YYYY-MM-DD 23:59:59'),
1240
- }
1241
- break
1242
-
1243
- case 'between':
1244
- whereValue = {
1245
- ...whereValue,
1246
- [Op.gte]: dayjs(value[0]).format('YYYY-MM-DD 00:00:00'),
1247
- [Op.lt]: dayjs(value[1]).format('YYYY-MM-DD 23:59:59'),
1248
- }
1249
- break
1250
- }
1251
- })
1252
- break
1253
-
1254
- case 'enum':
1255
- items.forEach((item) => {
1256
- if(!('value' in item)) return
1257
-
1258
- const value = item.value ?? []
1259
- whereValue = {
1260
- ...whereValue,
1261
- [Op.in]: value
1262
- }
1263
- })
1264
- break
1265
-
1266
- case 'number':
1267
- case 'currency':
1268
- items.forEach((item) => {
1269
- if(!('operator' in item) || !('value' in item)) return
1270
-
1271
- const operator = item.operator
1272
- const value = item.value
1273
-
1274
- switch(operator){
1275
-
1276
- case '>':
1277
- whereValue = {
1278
- ...whereValue,
1279
- [Op.gt]: parseFloat(value)
1280
- }
1281
- break
1282
-
1283
- case '>=':
1284
- whereValue = {
1285
- ...whereValue,
1286
- [Op.gte]: parseFloat(value)
1287
- }
1288
- break
1289
-
1290
- case '=':
1291
- whereValue = {
1292
- ...whereValue,
1293
- [Op.eq]: parseFloat(value)
1294
- }
1295
- break
1296
-
1297
- case '<':
1298
- whereValue = {
1299
- ...whereValue,
1300
- [Op.lt]: parseFloat(value)
1301
- }
1302
- break
1303
-
1304
- case '<=':
1305
- whereValue = {
1306
- ...whereValue,
1307
- [Op.lte]: parseFloat(value)
1308
- }
1309
- break
1310
-
1311
- case '<>':
1312
- case '!=':
1313
- whereValue = {
1314
- ...whereValue,
1315
- [Op.ne]: parseFloat(value)
1316
- }
1317
- break
1318
-
1319
- case 'in':
1320
- whereValue = {
1321
- ...whereValue,
1322
- [Op.in]: Array.isArray(value) ? value : (value.toString().split(','))
1323
- }
1324
- break
1325
- }
1326
- })
1327
- break
1328
-
1329
- default:
1330
- items.forEach((item) => {
1331
- if(!('operator' in item) ||
1332
- ([ 'startsWith', 'endsWith', 'contains', '=' ].includes(item.operator) && !'value' in item))
1333
- return
1334
-
1335
- const operator = item.operator
1336
- const value = item.value
1337
-
1338
- switch(operator){
1339
-
1340
- case 'startsWith':
1341
- whereValue.push({
1342
- [Op.like]: `${value}%`
1343
- })
1344
- break
1345
-
1346
- case 'endsWith':
1347
- whereValue.push({
1348
- [Op.like]: `%${value}`
1349
- })
1350
- break
1351
-
1352
- case 'contains':
1353
- whereValue.push({
1354
- [Op.like]: `%${value}%`
1355
- })
1356
- break
1357
-
1358
- case '=':
1359
- whereValue.push({
1360
- [Op.eq]: value
1361
- })
1362
- break
1363
-
1364
- case '<>':
1365
- case '!=':
1366
- whereValue.push({
1367
- [Op.ne]: value
1368
- })
1369
- break
1370
-
1371
- case 'empty':
1372
- whereValue.push({
1373
- [Op.or]: [
1374
- { [Op.eq]: null },
1375
- { [Op.eq]: '' },
1376
- ]
1377
- })
1378
- break
1379
-
1380
- case 'notEmpty':
1381
- whereValue.push({
1382
- [Op.and]: [
1383
- { [Op.ne]: null },
1384
- { [Op.ne]: '' },
1385
- ]
1386
- })
1387
- break
1388
-
1389
- case 'length':
1390
- break
1391
-
1392
- case 'regex':
1393
- whereValue.push({
1394
- [Op.regexp]: value
1395
- })
1396
- break
1397
-
1398
- case 'in':
1399
- console.log('#number in', Array.isArray(value) ? value : (value.toString().split(',')))
1400
- whereValue = {
1401
- ...whereValue,
1402
- [Op.in]: Array.isArray(value) ? value : (value.toString().split(','))
1403
- }
1404
- break
1405
- }
1406
- })
1407
- break
1408
- }
1409
-
1410
- return whereValue
1411
- },
1412
-
1413
- getPresetSortParams(preset, includes){
1414
-
1415
- if(preset.sorts && preset.sorts.length > 0){
1416
- let order = []
1417
- preset.sorts.forEach((sort) => {
1418
- const key = sort.key
1419
- const type = sort.type === 'desc' ? 'desc' : 'asc'
1420
- if(key.indexOf('.') > -1){
1421
-
1422
- const inclKeys = key.split('.')
1423
- if(inclKeys.length !== 2){
1424
- console.warn('Filter key not handled', key)
1425
- }
1426
- else {
1427
- const inclAs = inclKeys[0]
1428
- const inclKey = inclKeys[1]
1429
- const inclIndex = (includes ?? []).findIndex((_) => _.as === inclAs)
1430
-
1431
- if(inclIndex > -1){
1432
- order.push([
1433
- {
1434
- model: includes[inclIndex].model,
1435
- as: inclAs
1436
- },
1437
- inclKey,
1438
- type
1439
- ])
1440
- }
1441
- else{
1442
- console.warn('Unsupported sort key', key)
1443
- }
1444
- }
1445
- }
1446
- else{
1447
- order.push([ key, type ])
1448
- }
1449
- })
1450
- order.push([ 'id', 'desc' ])
1451
-
1452
- return {
1453
- order
1454
- }
1455
- }
1456
- return {}
1457
- },
1458
-
1459
-
1460
-
1461
- async onHooks(model, event, items, socket){
1462
-
1463
- if(socket.loadParams && socket.loadParams[this.name] && [ 'create', 'update' ].includes(event)){
1464
- const loadParams = { ...socket.loadParams[this.name] }
1465
-
1466
- if(!loadParams.preset.filters)
1467
- loadParams.preset.filters = []
1468
- const filterIndex = loadParams.preset.filters.findIndex(filter => filter.key === 'id')
1469
- if(filterIndex > -1){
1470
- loadParams.preset.filters[filterIndex] = {
1471
- enabled: true,
1472
- type: "number",
1473
- key: "id",
1474
- filters: [
1475
- {
1476
- operator: "in",
1477
- value: items.map((_) => _.id)
1478
- }
1479
- ]
1480
- }
1481
- }
1482
- else{
1483
- loadParams.preset.filters.push({
1484
- enabled: true,
1485
- type: "number",
1486
- key: "id",
1487
- filters: [
1488
- {
1489
- operator: "in",
1490
- value: items.map((_) => _.id)
1491
- }
1492
- ]
1493
- })
1494
- }
1495
-
1496
- const res = await this.load(loadParams)
1497
- items = res.items
1498
- }
1499
-
1500
- socket.emit(model, event, items)
1501
- }
1502
-
1503
-
1504
-
1505
- }
1506
-
1507
- module.exports = ListPage1