@quillsql/admin 1.3.1 → 1.3.3

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 (216) hide show
  1. package/{lib → dist}/Admin.d.ts +12 -7
  2. package/dist/Admin.d.ts.map +1 -0
  3. package/{lib → dist}/Admin.js +534 -671
  4. package/dist/Admin.js.map +1 -0
  5. package/{lib → dist}/AdminProvider.d.ts +41 -27
  6. package/dist/AdminProvider.d.ts.map +1 -0
  7. package/{lib → dist}/AdminProvider.js +90 -69
  8. package/dist/AdminProvider.js.map +1 -0
  9. package/dist/api/ConnectionClient.d.ts +24 -0
  10. package/dist/api/ConnectionClient.d.ts.map +1 -0
  11. package/dist/api/ConnectionClient.js +259 -0
  12. package/dist/api/ConnectionClient.js.map +1 -0
  13. package/dist/components/Banner/index.d.ts +3 -0
  14. package/dist/components/Banner/index.d.ts.map +1 -0
  15. package/dist/components/Banner/index.js +34 -0
  16. package/dist/components/Banner/index.js.map +1 -0
  17. package/dist/components/CardSection.d.ts +3 -0
  18. package/dist/components/CardSection.d.ts.map +1 -0
  19. package/dist/components/CardSection.js +13 -0
  20. package/dist/components/CardSection.js.map +1 -0
  21. package/dist/components/CardTitle.d.ts +3 -0
  22. package/dist/components/CardTitle.d.ts.map +1 -0
  23. package/dist/components/CardTitle.js +15 -0
  24. package/dist/components/CardTitle.js.map +1 -0
  25. package/dist/components/DashboardSelectPopover.d.ts +11 -0
  26. package/dist/components/DashboardSelectPopover.d.ts.map +1 -0
  27. package/{lib → dist}/components/DashboardSelectPopover.js +66 -74
  28. package/dist/components/DashboardSelectPopover.js.map +1 -0
  29. package/dist/components/DatabaseSelector.d.ts +11 -0
  30. package/dist/components/DatabaseSelector.d.ts.map +1 -0
  31. package/dist/components/DatabaseSelector.js +26 -0
  32. package/dist/components/DatabaseSelector.js.map +1 -0
  33. package/dist/components/DeleteButton.d.ts +3 -0
  34. package/dist/components/DeleteButton.d.ts.map +1 -0
  35. package/dist/components/DeleteButton.js +14 -0
  36. package/dist/components/DeleteButton.js.map +1 -0
  37. package/{lib → dist}/components/DropDownMenu.d.ts +1 -0
  38. package/dist/components/DropDownMenu.d.ts.map +1 -0
  39. package/{lib → dist}/components/DropDownMenu.js +17 -17
  40. package/{lib → dist}/components/DropDownMenu.js.map +1 -1
  41. package/dist/components/DropDownMenuWithLabel.d.ts +12 -0
  42. package/dist/components/DropDownMenuWithLabel.d.ts.map +1 -0
  43. package/dist/components/DropDownMenuWithLabel.js +51 -0
  44. package/dist/components/DropDownMenuWithLabel.js.map +1 -0
  45. package/{lib → dist}/components/EnvSelectPopover.d.ts +1 -0
  46. package/dist/components/EnvSelectPopover.d.ts.map +1 -0
  47. package/dist/components/EnvSelectPopover.js +209 -0
  48. package/dist/components/EnvSelectPopover.js.map +1 -0
  49. package/dist/components/InputLabel.d.ts +3 -0
  50. package/dist/components/InputLabel.d.ts.map +1 -0
  51. package/dist/components/InputLabel.js +14 -0
  52. package/dist/components/InputLabel.js.map +1 -0
  53. package/{lib → dist}/components/OrgSelect.d.ts +1 -0
  54. package/dist/components/OrgSelect.d.ts.map +1 -0
  55. package/{lib → dist}/components/OrgSelect.js +63 -54
  56. package/dist/components/OrgSelect.js.map +1 -0
  57. package/dist/components/SqlViewTile.d.ts +8 -0
  58. package/dist/components/SqlViewTile.d.ts.map +1 -0
  59. package/dist/components/SqlViewTile.js +70 -0
  60. package/dist/components/SqlViewTile.js.map +1 -0
  61. package/dist/components/StepDisplay.d.ts +10 -0
  62. package/dist/components/StepDisplay.d.ts.map +1 -0
  63. package/dist/components/StepDisplay.js +19 -0
  64. package/dist/components/StepDisplay.js.map +1 -0
  65. package/{lib → dist}/components/index.d.ts +1 -0
  66. package/dist/components/index.d.ts.map +1 -0
  67. package/dist/forms/client_onboard/ConnectDatabase.d.ts +11 -0
  68. package/dist/forms/client_onboard/ConnectDatabase.d.ts.map +1 -0
  69. package/dist/forms/client_onboard/ConnectDatabase.js +144 -0
  70. package/dist/forms/client_onboard/ConnectDatabase.js.map +1 -0
  71. package/dist/forms/client_onboard/ConnectSchema.d.ts +13 -0
  72. package/dist/forms/client_onboard/ConnectSchema.d.ts.map +1 -0
  73. package/dist/forms/client_onboard/ConnectSchema.js +178 -0
  74. package/dist/forms/client_onboard/ConnectSchema.js.map +1 -0
  75. package/dist/forms/client_onboard/CreateSqlViews.d.ts +15 -0
  76. package/dist/forms/client_onboard/CreateSqlViews.d.ts.map +1 -0
  77. package/dist/forms/client_onboard/CreateSqlViews.js +209 -0
  78. package/dist/forms/client_onboard/CreateSqlViews.js.map +1 -0
  79. package/dist/hooks/useItemBeingEdited.d.ts +4 -0
  80. package/dist/hooks/useItemBeingEdited.d.ts.map +1 -0
  81. package/dist/hooks/useItemBeingEdited.js +31 -0
  82. package/dist/hooks/useItemBeingEdited.js.map +1 -0
  83. package/{lib → dist}/icons/ArrowDownHeadIcon.d.ts +1 -0
  84. package/dist/icons/ArrowDownHeadIcon.d.ts.map +1 -0
  85. package/dist/icons/XMarkIcon.d.ts +3 -0
  86. package/dist/icons/XMarkIcon.d.ts.map +1 -0
  87. package/dist/icons/XMarkIcon.js +15 -0
  88. package/dist/icons/XMarkIcon.js.map +1 -0
  89. package/{lib → dist}/icons/index.d.ts +1 -0
  90. package/dist/icons/index.d.ts.map +1 -0
  91. package/{lib → dist}/index.d.ts +2 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/{lib → dist}/index.js +3 -1
  94. package/dist/index.js.map +1 -0
  95. package/{lib → dist}/modals/EditDashboardsModal.d.ts +1 -0
  96. package/dist/modals/EditDashboardsModal.d.ts.map +1 -0
  97. package/{lib → dist}/modals/EditDashboardsModal.js +24 -23
  98. package/dist/modals/EditDashboardsModal.js.map +1 -0
  99. package/dist/modals/NewDashboardModal.d.ts +19 -0
  100. package/dist/modals/NewDashboardModal.d.ts.map +1 -0
  101. package/dist/modals/NewDashboardModal.js +284 -0
  102. package/dist/modals/NewDashboardModal.js.map +1 -0
  103. package/{lib → dist}/modals/PromoteDashModal.d.ts +2 -1
  104. package/dist/modals/PromoteDashModal.d.ts.map +1 -0
  105. package/{lib → dist}/modals/PromoteDashModal.js +39 -38
  106. package/dist/modals/PromoteDashModal.js.map +1 -0
  107. package/{lib → dist}/modals/PromoteViewModal.d.ts +1 -0
  108. package/dist/modals/PromoteViewModal.d.ts.map +1 -0
  109. package/{lib → dist}/modals/PromoteViewModal.js +2 -1
  110. package/dist/modals/PromoteViewModal.js.map +1 -0
  111. package/{lib → dist}/modals/ReorderDashboardModal.d.ts +4 -1
  112. package/dist/modals/ReorderDashboardModal.d.ts.map +1 -0
  113. package/{lib → dist}/modals/ReorderDashboardModal.js +36 -34
  114. package/dist/modals/ReorderDashboardModal.js.map +1 -0
  115. package/{lib → dist}/modals/index.d.ts +1 -0
  116. package/dist/modals/index.d.ts.map +1 -0
  117. package/{lib → dist}/primitives/ButtonPrimitive.d.ts +3 -0
  118. package/dist/primitives/ButtonPrimitive.d.ts.map +1 -0
  119. package/dist/primitives/ButtonPrimitive.js +50 -0
  120. package/dist/primitives/ButtonPrimitive.js.map +1 -0
  121. package/{lib → dist}/primitives/HeaderPrimitive.d.ts +1 -0
  122. package/dist/primitives/HeaderPrimitive.d.ts.map +1 -0
  123. package/{lib → dist}/primitives/ModalPrimitive.d.ts +3 -1
  124. package/dist/primitives/ModalPrimitive.d.ts.map +1 -0
  125. package/{lib → dist}/primitives/ModalPrimitive.js +2 -1
  126. package/dist/primitives/ModalPrimitive.js.map +1 -0
  127. package/{lib → dist}/primitives/SecondaryButtonPrimitive.d.ts +1 -0
  128. package/dist/primitives/SecondaryButtonPrimitive.d.ts.map +1 -0
  129. package/{lib → dist}/primitives/SelectPrimitive.d.ts +1 -0
  130. package/dist/primitives/SelectPrimitive.d.ts.map +1 -0
  131. package/{lib → dist}/primitives/SelectPrimitive.js +1 -1
  132. package/{lib → dist}/primitives/SelectPrimitive.js.map +1 -1
  133. package/{lib → dist}/primitives/TextInputPrimitive.d.ts +2 -0
  134. package/dist/primitives/TextInputPrimitive.d.ts.map +1 -0
  135. package/dist/primitives/TextInputPrimitive.js +27 -0
  136. package/dist/primitives/TextInputPrimitive.js.map +1 -0
  137. package/dist/primitives/TogglePrimitive.d.ts +6 -0
  138. package/dist/primitives/TogglePrimitive.d.ts.map +1 -0
  139. package/dist/primitives/TogglePrimitive.js +48 -0
  140. package/dist/primitives/TogglePrimitive.js.map +1 -0
  141. package/{lib → dist}/primitives/index.d.ts +1 -0
  142. package/dist/primitives/index.d.ts.map +1 -0
  143. package/dist/public_components/CreateEnvironment.d.ts +6 -0
  144. package/dist/public_components/CreateEnvironment.d.ts.map +1 -0
  145. package/dist/public_components/CreateEnvironment.js +142 -0
  146. package/dist/public_components/CreateEnvironment.js.map +1 -0
  147. package/{lib → dist}/public_components/DashboardBuilder.d.ts +2 -1
  148. package/dist/public_components/DashboardBuilder.d.ts.map +1 -0
  149. package/{lib → dist}/public_components/DashboardBuilder.js +72 -39
  150. package/dist/public_components/DashboardBuilder.js.map +1 -0
  151. package/{lib → dist}/public_components/DashboardManager.d.ts +2 -1
  152. package/dist/public_components/DashboardManager.d.ts.map +1 -0
  153. package/dist/public_components/DashboardManager.js +312 -0
  154. package/dist/public_components/DashboardManager.js.map +1 -0
  155. package/{lib → dist}/public_components/SQLViewManager.d.ts +2 -1
  156. package/dist/public_components/SQLViewManager.d.ts.map +1 -0
  157. package/{lib → dist}/public_components/SQLViewManager.js +130 -129
  158. package/dist/public_components/SQLViewManager.js.map +1 -0
  159. package/dist/utils/constants.d.ts +26 -0
  160. package/dist/utils/constants.d.ts.map +1 -0
  161. package/dist/utils/constants.js +17 -0
  162. package/dist/utils/constants.js.map +1 -0
  163. package/dist/utils/databases.d.ts +34 -0
  164. package/dist/utils/databases.d.ts.map +1 -0
  165. package/dist/utils/databases.js +57 -0
  166. package/dist/utils/databases.js.map +1 -0
  167. package/dist/utils/delay.d.ts +2 -0
  168. package/dist/utils/delay.d.ts.map +1 -0
  169. package/dist/utils/delay.js +8 -0
  170. package/dist/utils/delay.js.map +1 -0
  171. package/dist/utils/schema.d.ts +22 -0
  172. package/dist/utils/schema.d.ts.map +1 -0
  173. package/dist/utils/schema.js +3 -0
  174. package/dist/utils/schema.js.map +1 -0
  175. package/dist/utils/table.d.ts +16 -0
  176. package/dist/utils/table.d.ts.map +1 -0
  177. package/dist/utils/table.js +3 -0
  178. package/dist/utils/table.js.map +1 -0
  179. package/package.json +22 -24
  180. package/LICENSE +0 -21
  181. package/README.md +0 -10
  182. package/lib/Admin.js.map +0 -1
  183. package/lib/AdminProvider.js.map +0 -1
  184. package/lib/components/DashboardSelectPopover.d.ts +0 -9
  185. package/lib/components/DashboardSelectPopover.js.map +0 -1
  186. package/lib/components/EnvSelectPopover.js +0 -190
  187. package/lib/components/EnvSelectPopover.js.map +0 -1
  188. package/lib/components/OrgSelect.js.map +0 -1
  189. package/lib/index.js.map +0 -1
  190. package/lib/modals/EditDashboardsModal.js.map +0 -1
  191. package/lib/modals/PromoteDashModal.js.map +0 -1
  192. package/lib/modals/PromoteViewModal.js.map +0 -1
  193. package/lib/modals/ReorderDashboardModal.js.map +0 -1
  194. package/lib/primitives/ButtonPrimitive.js +0 -25
  195. package/lib/primitives/ButtonPrimitive.js.map +0 -1
  196. package/lib/primitives/ModalPrimitive.js.map +0 -1
  197. package/lib/primitives/TextInputPrimitive.js +0 -26
  198. package/lib/primitives/TextInputPrimitive.js.map +0 -1
  199. package/lib/public_components/DashboardBuilder.js.map +0 -1
  200. package/lib/public_components/DashboardManager.js +0 -255
  201. package/lib/public_components/DashboardManager.js.map +0 -1
  202. package/lib/public_components/SQLViewManager.js.map +0 -1
  203. /package/{lib → dist}/components/index.js +0 -0
  204. /package/{lib → dist}/components/index.js.map +0 -0
  205. /package/{lib → dist}/icons/ArrowDownHeadIcon.js +0 -0
  206. /package/{lib → dist}/icons/ArrowDownHeadIcon.js.map +0 -0
  207. /package/{lib → dist}/icons/index.js +0 -0
  208. /package/{lib → dist}/icons/index.js.map +0 -0
  209. /package/{lib → dist}/modals/index.js +0 -0
  210. /package/{lib → dist}/modals/index.js.map +0 -0
  211. /package/{lib → dist}/primitives/HeaderPrimitive.js +0 -0
  212. /package/{lib → dist}/primitives/HeaderPrimitive.js.map +0 -0
  213. /package/{lib → dist}/primitives/SecondaryButtonPrimitive.js +0 -0
  214. /package/{lib → dist}/primitives/SecondaryButtonPrimitive.js.map +0 -0
  215. /package/{lib → dist}/primitives/index.js +0 -0
  216. /package/{lib → dist}/primitives/index.js.map +0 -0
@@ -33,8 +33,9 @@ const react_1 = require("react");
33
33
  const react_2 = require("@quillsql/react");
34
34
  const nightOwlLight_1 = __importDefault(require("prism-react-renderer/themes/nightOwlLight"));
35
35
  const prism_react_renderer_1 = __importStar(require("prism-react-renderer"));
36
- const react_3 = __importDefault(require("@monaco-editor/react"));
37
36
  const core_1 = require("@dnd-kit/core");
37
+ const InputLabel_1 = __importDefault(require("./components/InputLabel"));
38
+ const CardSection_1 = __importDefault(require("./components/CardSection"));
38
39
  const sortable_1 = require("@dnd-kit/sortable");
39
40
  const utilities_1 = require("@dnd-kit/utilities");
40
41
  const components_1 = require("./components");
@@ -42,110 +43,57 @@ const AdminProvider_1 = require("./AdminProvider");
42
43
  const primitives_1 = require("./primitives");
43
44
  const DashboardBuilder_1 = __importDefault(require("./public_components/DashboardBuilder"));
44
45
  const SQLViewManager_1 = __importDefault(require("./public_components/SQLViewManager"));
45
- const CONTAINER = {
46
- display: "flex",
47
- flexDirection: "row",
48
- height: "800px",
49
- background: "white",
50
- marginTop: 32,
51
- width: "calc(100% - 50px)",
52
- // borderRadius: 12,
53
- overflow: "hidden",
54
- borderRadius: 12,
55
- // border: "1px solid #EDEDED",
56
- boxShadow: "0px 1px 24px 0px rgba(0, 0, 0, 0.09)",
57
- };
58
- const customStyles = {
59
- content: {
60
- top: "50%",
61
- left: "50%",
62
- right: "auto",
63
- bottom: "auto",
64
- marginRight: "-50%",
65
- border: "none",
66
- transform: "translate(-50%, -50%)",
67
- borderRadius: 6,
68
- zIndex: 4,
69
- boxShadow: "0px 2px 24px 0px rgb(63,82,149, 0.09)",
70
- },
71
- };
72
- const THEME = {
73
- /* Components font family */
74
- // fontFamily: 'BlinkMacSystemFont',
75
- fontFamily: "Inter",
76
- /* Default font size */
77
- fontSize: 14,
78
- /* Header font size */
79
- headerFontSize: 18,
80
- editorDarkMode: true,
81
- /* Primary color */
82
- primaryColor: "#212121",
83
- buttonUnderlayColor: "#000000",
84
- /* Secondary color */
85
- secondaryColor: "white",
86
- selectedTabColor: "white",
87
- /* When you select underlay */
88
- selectUnderlayColor: "#F5F5F5",
89
- /* Background color */
90
- backgroundColor: "#FFFFFF",
91
- editorBackgroundColor: "#FBFBFB",
92
- elevatedCardColor: "#FFFFFF",
93
- /* Primary font color */
94
- fontColor: "#212121",
95
- /* Secondary font color */
96
- secondaryFontColor: "#777777",
97
- selectedFontColor: "#212121",
98
- unselectedFontColor: "#777777",
99
- buttonLabelColor: "white",
100
- buttonFontWeight: "500",
101
- /* Label font weight */
102
- labelFontWeight: "500",
103
- /* Header font weight */
104
- headerFontWeight: "500",
105
- /* Selected font weight */
106
- selectedFontWeight: "700",
107
- /* Padding for containers */
108
- padding: 25,
109
- /* Border radius for selected Quill elements */
110
- borderRadius: "8px",
111
- /* Box shadow applied on Quill components */
112
- boxShadow: "0px 1px 8px 0px rgb(63,82,149, 0.09)",
113
- shadowColor: "rgba(0, 0, 0, 0.09)",
114
- primaryButtonColor: "#212121",
115
- };
116
- const frontendApi = "clerk.withquill.com";
46
+ const constants_1 = require("./utils/constants");
47
+ const TogglePrimitive_1 = __importDefault(require("./primitives/TogglePrimitive"));
117
48
  const defaultTheme = {
118
- fontFamily: "Inter; Helvetica",
119
- backgroundColor: "#FFFFFF",
120
- primaryTextColor: "#364153",
121
- secondaryTextColor: "#6C727F",
122
- chartLabelFontFamily: "Inter; Helvetica",
123
- chartLabelColor: "#666666",
124
- chartTickColor: "#CCCCCC",
49
+ fontFamily: 'Inter; Helvetica',
50
+ backgroundColor: '#FFFFFF',
51
+ primaryTextColor: '#364153',
52
+ secondaryTextColor: '#6C727F',
53
+ chartLabelFontFamily: 'Inter; Helvetica',
54
+ chartLabelColor: '#666666',
55
+ chartTickColor: '#CCCCCC',
125
56
  // chartColors: ["#6269E9", "#E14F62"],
126
- borderColor: "#E5E7EB",
127
- primaryButtonColor: "#364153",
57
+ borderColor: '#E5E7EB',
58
+ primaryButtonColor: '#364153',
128
59
  borderWidth: 1,
129
- labelFontWeight: "500",
60
+ labelFontWeight: '500',
130
61
  fontSize: 14,
131
62
  };
132
- function EditFiltersModal({ isOpen, dashboardData, selectedDashboard, client, setIsOpen, filters, dateFilter, openAddFilterModal, ModalComponent, TextInputComponent, ButtonComponent, HeaderComponent, SelectComponent, selectedEditDashboard, dashNames, setSelectedEditDashboard, SecondaryButtonComponent, }) {
63
+ function EditFiltersModal({ isOpen, dashboardData, selectedDashboard, client, setIsOpen, onSave, ModalComponent, TextInputComponent, ButtonComponent, HeaderComponent, SelectComponent, dashNames, setSelectedEditDashboard, SecondaryButtonComponent, openAddFilterModal, openEditOrderModal, }) {
133
64
  const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
134
- const [selectedDashboardName, setSelectedDashboardName] = (0, react_1.useState)("");
65
+ const [selectedDashboardName, setSelectedDashboardName] = (0, react_1.useState)(selectedDashboard);
135
66
  (0, react_1.useEffect)(() => {
136
67
  setSelectedDashboardName(selectedDashboard);
137
68
  }, [selectedDashboard]);
69
+ const { data } = (0, react_2.useDashboard)(selectedDashboard);
138
70
  const [newFilters, setNewFilters] = (0, react_1.useState)([]);
71
+ const [isDateComparison, setIsDateComparison] = (0, react_1.useState)(state.dateFilter.comparison);
72
+ const [initialRange, setInitialRange] = (0, react_1.useState)(constants_1.defaultDateRange);
73
+ const [showDateFilter, setShowDateFilter] = (0, react_1.useState)(true);
139
74
  const [newDateFilter, setNewDateFilter] = (0, react_1.useState)(null);
140
- // const [tables, setTables] = useContext<TablesContextType>(TablesContext);
141
75
  const [selectedTable, setSelectedTable] = (0, react_1.useState)(null);
142
- const [field, setField] = (0, react_1.useState)("");
76
+ const [field, setField] = (0, react_1.useState)('');
77
+ (0, react_1.useEffect)(() => {
78
+ if (data && data.dateFilter) {
79
+ dispatch('SET_DATE_FILTER', {
80
+ ...state.dateFilter,
81
+ comparison: data.dateFilter.comparison,
82
+ });
83
+ }
84
+ }, [state.dateFilter, data]);
85
+ (0, react_1.useEffect)(() => {
86
+ setIsDateComparison(!!state.dateFilter.comparison);
87
+ }, [state.dateFilter]);
143
88
  (0, react_1.useEffect)(() => {
144
89
  if (state.tables.length) {
145
- setSelectedTable(state.tables[0]);
146
- setField(state.tables[0].columns.map((elem) => elem.name)[0]);
90
+ const defaultTable = state.tables[0];
91
+ const name = state.editDashboardData?.filters[0]?.table;
92
+ const table = state.tables.find((t) => t.name === name) ?? defaultTable;
93
+ setSelectedTable(table);
94
+ setField(table.columns.map((elem) => elem.name)[0]);
147
95
  }
148
- }, [state.tables]);
96
+ }, [state.tables, state.editDashboardData]);
149
97
  (0, react_1.useEffect)(() => {
150
98
  if (dashboardData && dashboardData.filters) {
151
99
  setNewFilters(dashboardData.filters);
@@ -155,7 +103,7 @@ function EditFiltersModal({ isOpen, dashboardData, selectedDashboard, client, se
155
103
  }
156
104
  }, [dashboardData]);
157
105
  const handleAddFilter = async () => {
158
- setNewFilters([...newFilters, { label: "", field }]);
106
+ setNewFilters([...newFilters, { label: '', field }]);
159
107
  };
160
108
  const handleSubmitDashboardChanges = async () => {
161
109
  if (!selectedDashboardName ||
@@ -163,7 +111,7 @@ function EditFiltersModal({ isOpen, dashboardData, selectedDashboard, client, se
163
111
  (newDateFilter &&
164
112
  Object.keys(newDateFilter).length &&
165
113
  !newDateFilter.label)) {
166
- alert("Empty fields");
114
+ alert('Empty fields');
167
115
  return;
168
116
  }
169
117
  if (newFilters.filter((elem) => !elem.field).length) {
@@ -184,7 +132,7 @@ function EditFiltersModal({ isOpen, dashboardData, selectedDashboard, client, se
184
132
  dashNames.length > 0 &&
185
133
  dashNames.some((dashName) => dashName.name === selectedDashboardName &&
186
134
  selectedDashboardName !== selectedDashboard)) {
187
- alert("Dashboard name already taken!");
135
+ alert('Dashboard name already taken!');
188
136
  return;
189
137
  }
190
138
  const fieldsSet = new Set();
@@ -199,201 +147,194 @@ function EditFiltersModal({ isOpen, dashboardData, selectedDashboard, client, se
199
147
  });
200
148
  if (hasDuplicateField ||
201
149
  (Object.keys(newDateFilter).length > 0 &&
202
- updatedFilters.some((filter) => filter.filterType === "date"))) {
203
- alert("Maximum of one filter per field");
150
+ updatedFilters.some((filter) => filter.filterType === 'date'))) {
151
+ alert('Maximum of one filter per field');
204
152
  return;
205
153
  }
206
154
  let allValid = true;
207
155
  updatedFilters.forEach((filter) => {
208
- if (filter.filterType !== "string" && filter.filterType !== "date") {
156
+ if (filter.filterType !== 'string' && filter.filterType !== 'date') {
209
157
  allValid = false;
210
158
  console.error(`Invalid filterType found: ${filter.filterType}`);
211
159
  }
212
160
  });
213
161
  if (!allValid) {
214
- alert("We only support string and filters.");
162
+ alert('We only support string and filters.');
215
163
  return;
216
164
  }
217
- let responseData;
218
- const url = `https://quill-344421.uc.r.appspot.com/dashfilter/${client._id}/`;
165
+ const url = `${constants_1.QUILL_SERVER}/dashfilter/${client._id}/`;
219
166
  const body = {
220
167
  newDashboardName: selectedDashboardName,
221
168
  filters: updatedFilters,
222
- dateFilter: newDateFilter,
169
+ dateFilter: {
170
+ ...newDateFilter,
171
+ comparison: isDateComparison,
172
+ primaryRange: initialRange,
173
+ },
223
174
  name: selectedDashboard,
224
175
  };
176
+ dispatch({ type: 'SET_DATE_FILTER', payload: body.dateFilter });
225
177
  const headers = {
226
- "Content-Type": "application/json",
178
+ 'Content-Type': 'application/json',
227
179
  Authorization: `Bearer `,
228
180
  };
229
181
  try {
230
182
  const response = await fetch(url, {
231
- method: "POST",
183
+ method: 'POST',
232
184
  headers: headers,
233
185
  body: JSON.stringify(body),
234
186
  });
235
187
  setSelectedEditDashboard(null);
236
188
  setIsOpen(false);
189
+ onSave();
237
190
  }
238
191
  catch (e) {
239
- console.log("error");
192
+ console.log('error');
240
193
  }
241
194
  };
242
- // const handleDeleteFilter = async () => {
243
- // const url = `https://quill-344421.uc.r.appspot.com/dashfilterdelete/${client._id}/`;
244
- // const body = {
245
- // name: selectedDashboard.name,
246
- // filterId: "DATE_RANGE", //TODO: Change this?
247
- // };
248
- // const headers = {
249
- // "Content-Type": "application/json",
250
- // Authorization: `Bearer `,
251
- // };
252
- // try {
253
- // const response = await fetch(url, {
254
- // method: "POST",
255
- // headers: headers,
256
- // body: JSON.stringify(body),
257
- // });
258
- // if (!response.ok) {
259
- // throw new Error(`HTTP error! Status: ${response.status}`);
260
- // }
261
- // const responseData = await response.json();
262
- // if (responseData) {
263
- // setIsOpen(false);
264
- // return;
265
- // }
266
- // } catch (error) {
267
- // console.error("There was a problem with the fetch operation:", error);
268
- // }
269
- // };
270
195
  const handleDeleteFilter = (filter) => {
271
196
  setNewFilters(newFilters.filter((f) => f !== filter));
272
197
  };
273
198
  const handleDeleteDateFilter = async () => {
274
- // const response2 = await axios.post(
275
- // `https://quill-344421.uc.r.appspot.com/dashfilterdelete/${client._id}/`,
276
- // {
277
- // name: selectedDashboard.name,
278
- // filterId: "DATE_RANGE",
279
- // },
280
- // { headers: { Authorization: `Bearer ` } }
281
- // );
282
- // if (response2 && response2.data) {
283
- // setIsOpen(false);
284
- // return;
285
- // }
199
+ setShowDateFilter(false);
286
200
  setNewDateFilter({});
287
201
  };
202
+ const handleAddDateFilter = async () => {
203
+ setShowDateFilter(true);
204
+ if (dashboardData && dashboardData.dateFilter) {
205
+ setNewDateFilter(dashboardData.dateFilter);
206
+ }
207
+ };
208
+ const handleDeleteDashboard = async () => {
209
+ if (confirm('Are you sure? This action cannot be undone.')) {
210
+ const URL = `${constants_1.QUILL_SERVER}/dashboard/${selectedDashboard}`;
211
+ const res = await fetch(URL, {
212
+ method: 'DELETE',
213
+ headers: { 'Content-Type': 'application/json' },
214
+ body: JSON.stringify({ clientId: client._id }),
215
+ });
216
+ alert(JSON.stringify(res));
217
+ }
218
+ };
288
219
  return ((0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, close: () => {
289
220
  setIsOpen(false);
221
+ setNewFilters([]);
222
+ setIsDateComparison(state.dateFilter.comparison);
223
+ }, style: {
224
+ minWidth: '814px',
225
+ maxWidth: '814px',
290
226
  }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
291
- display: "flex",
292
- flexDirection: "column",
293
- width: "100%",
294
- // alignItems: "center",
295
- }, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { label: "Edit dashboard" }), (0, jsx_runtime_1.jsx)("div", { style: {
296
- fontFamily: exports.theme.fontFamily,
297
- color: exports.theme.secondaryTextColor,
298
- fontSize: 14,
299
- fontWeight: "600",
300
- marginBottom: 3,
301
- marginTop: 8,
302
- }, children: "Dashboard name" }), (0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 230 }, children: (0, jsx_runtime_1.jsx)(TextInputComponent, { value: selectedDashboardName, onChange: (e) => setSelectedDashboardName(e.target.value) }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 8 } }), (0, jsx_runtime_1.jsxs)("div", { children: [newDateFilter &&
303
- Object.values(newDateFilter).length > 0 &&
304
- newDateFilter.label ? ((0, jsx_runtime_1.jsxs)("div", { style: {
305
- display: "flex",
306
- flexDirection: "column",
307
- gap: "10px",
308
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
309
- fontFamily: exports.theme.fontFamily,
310
- color: exports.theme.primaryTextColor,
311
- fontSize: 16,
312
- fontWeight: "600",
313
- }, children: "Date filter" }), (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", flexDirection: "column" }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
314
- fontFamily: exports.theme.fontFamily,
315
- color: exports.theme.secondaryTextColor,
316
- fontSize: 14,
317
- fontWeight: "600",
318
- marginBottom: 3,
319
- }, children: "Label" }), (0, jsx_runtime_1.jsxs)("div", { style: {
320
- display: "flex",
321
- flexDirection: "row",
322
- alignItems: "center",
323
- }, children: [(0, jsx_runtime_1.jsx)(TextInputComponent, { value: newDateFilter.label, onChange: (e) => {
324
- setNewDateFilter({
325
- ...newDateFilter,
326
- label: e.target.value,
327
- });
328
- } }), (0, jsx_runtime_1.jsx)("div", { onClick: () => handleDeleteDateFilter(), style: {
329
- height: 38,
330
- width: 42,
331
- alignItems: "center",
332
- justifyContent: "center",
333
- display: "flex",
334
- }, children: (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#4C5462", width: "20", height: "20", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M5.47 5.47a.75.75 0 011.06 0L12 10.94l5.47-5.47a.75.75 0 111.06 1.06L13.06 12l5.47 5.47a.75.75 0 11-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 01-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 010-1.06z", clipRule: "evenodd" }) }) })] })] })] })) : null, (0, jsx_runtime_1.jsxs)("div", { style: {
335
- display: "flex",
336
- flexDirection: "row",
337
- alignItems: "center",
338
- justifyContent: "space-between",
227
+ display: 'flex',
228
+ gap: 16,
229
+ flexDirection: 'column',
230
+ width: '100%',
231
+ height: '100%',
232
+ maxHeight: '100%',
233
+ overflowY: 'auto'
234
+ }, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { label: "Manage dashboard" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Name" }), (0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 230 }, children: (0, jsx_runtime_1.jsx)(TextInputComponent, { value: selectedDashboardName, onChange: (e) => setSelectedDashboardName(e.target.value) }) })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: {
235
+ display: 'flex',
236
+ flexDirection: 'column',
237
+ gap: '10px',
238
+ }, children: [(0, jsx_runtime_1.jsx)(CardSection_1.default, { children: "Date Filter" }), showDateFilter && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
239
+ display: 'flex',
240
+ flexDirection: 'row',
241
+ gap: '10px',
242
+ }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Label" }), (0, jsx_runtime_1.jsx)("div", { style: {
243
+ display: 'flex',
244
+ flexDirection: 'row',
245
+ alignItems: 'center',
246
+ }, children: (0, jsx_runtime_1.jsx)(TextInputComponent, { value: newDateFilter?.label, onChange: (e) => {
247
+ setNewDateFilter({
248
+ ...newDateFilter,
249
+ label: e.target.value,
250
+ });
251
+ } }) })] }), (0, jsx_runtime_1.jsx)("div", { style: {
252
+ display: 'flex',
253
+ flexDirection: 'row',
254
+ gap: '10px',
255
+ }, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Initial Range" }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: initialRange.label, onChange: (e) => {
256
+ setInitialRange(constants_1.InitialDateRangeOptions.find((table) => table.label === e) ?? initialRange);
257
+ }, options: constants_1.InitialDateRangeOptions.map((table) => {
258
+ return { label: table.label, value: table.label };
259
+ }) })] }) }), (0, jsx_runtime_1.jsx)("div", { style: {
260
+ display: 'flex',
261
+ flexDirection: 'row',
262
+ gap: '10px',
263
+ }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
264
+ display: 'flex',
265
+ flexDirection: 'column',
266
+ }, children: [(0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Date Comparison" }), (0, jsx_runtime_1.jsx)("div", { style: {
267
+ display: 'flex',
268
+ flexDirection: 'column',
269
+ justifyContent: 'center',
270
+ width: '100%',
271
+ height: '100%',
272
+ minWidth: 230,
273
+ maxWidth: 230,
274
+ width: 230,
275
+ }, children: (0, jsx_runtime_1.jsx)(TogglePrimitive_1.default, { value: isDateComparison, onClick: () => {
276
+ setIsDateComparison((isDateComparison) => !isDateComparison);
277
+ } }) })] }) }), (0, jsx_runtime_1.jsx)("div", { style: {
278
+ display: 'flex',
279
+ flexGrow: 1,
280
+ flexDirection: 'row',
281
+ alignItems: 'end',
282
+ justifyContent: 'end',
283
+ gap: '10px',
284
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: {
285
+ display: 'flex',
286
+ flexDirection: 'column',
287
+ justifyContent: 'center',
288
+ }, children: (0, jsx_runtime_1.jsx)("div", { onClick: () => handleDeleteDateFilter(), style: {
289
+ height: 38,
290
+ width: 42,
291
+ alignItems: 'center',
292
+ justifyContent: 'center',
293
+ display: 'flex',
294
+ cursor: 'pointer',
295
+ }, children: (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#4C5462", width: "20", height: "20", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M5.47 5.47a.75.75 0 011.06 0L12 10.94l5.47-5.47a.75.75 0 111.06 1.06L13.06 12l5.47 5.47a.75.75 0 11-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 01-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 010-1.06z", clipRule: "evenodd" }) }) }) }) })] }) })), !showDateFilter && ((0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 230 }, children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleAddDateFilter, label: "Add date filter +" }) }))] }), (0, jsx_runtime_1.jsx)("div", { style: {
296
+ display: 'flex',
297
+ flexDirection: 'row',
298
+ alignItems: 'center',
299
+ justifyContent: 'space-between',
339
300
  marginTop: 20,
340
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
341
- fontFamily: exports.theme.fontFamily,
342
- color: exports.theme.primaryTextColor,
343
- fontSize: 17,
344
- fontWeight: "600",
345
- }, children: "Filters" }), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleAddFilter, label: "Add filter +" })] }), newFilters.length > 0 && ((0, jsx_runtime_1.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: newFilters.map((filter, index) => {
301
+ }, children: (0, jsx_runtime_1.jsx)(CardSection_1.default, { children: "Filters" }) }), newFilters.length > 0 && ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: '6px' }, children: newFilters.map((filter, index) => {
346
302
  return ((0, jsx_runtime_1.jsxs)("div", { style: {
347
- display: "flex",
348
- flexDirection: "row",
349
- gap: "10px",
303
+ display: 'flex',
304
+ flexDirection: 'row',
305
+ gap: '10px',
350
306
  }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
351
- display: "flex",
352
- flexDirection: "column",
307
+ display: 'flex',
308
+ flexDirection: 'column',
353
309
  maxWidth: 300,
354
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
355
- fontFamily: exports.theme.fontFamily,
356
- color: exports.theme.secondaryTextColor,
357
- fontSize: 14,
358
- fontWeight: "600",
359
- marginBottom: 3,
360
- }, children: "Label" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { value: filter.label, onChange: (e) => {
310
+ }, children: [index === 0 && (0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Label" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { value: filter.label, onChange: (e) => {
361
311
  const updatedFilters = newFilters.map((otherFilter, i) => index === i
362
312
  ? { ...otherFilter, label: e.target.value }
363
313
  : otherFilter);
364
314
  setNewFilters(updatedFilters);
365
315
  } })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
366
- display: "flex",
367
- flexDirection: "column",
316
+ display: 'flex',
317
+ flexDirection: 'column',
368
318
  maxWidth: 300,
369
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
370
- fontFamily: exports.theme.fontFamily,
371
- color: exports.theme.secondaryTextColor,
372
- fontSize: 14,
373
- fontWeight: "600",
374
- marginBottom: 3,
375
- }, children: "Table" }), (0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: selectedTable ? selectedTable.name : "", onChange: (e) => setSelectedTable(state.tables.find((table) => table.name === e)), options: state.tables.map((table) => {
319
+ }, children: [index === 0 && (0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Table" }), (0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: selectedTable ? selectedTable.name : '', onChange: (e) => setSelectedTable(state.tables.find((table) => table.name === e)), options: state.tables.map((table) => {
376
320
  return { label: table.name, value: table.name };
377
321
  }) })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
378
- display: "flex",
379
- flexDirection: "column",
322
+ display: 'flex',
323
+ flexDirection: 'column',
380
324
  maxWidth: 300,
381
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
382
- fontFamily: exports.theme.fontFamily,
383
- color: exports.theme.secondaryTextColor,
384
- fontSize: 14,
385
- fontWeight: "600",
386
- marginBottom: 3,
387
- }, children: "Field" }), (0, jsx_runtime_1.jsx)("div", { style: {
388
- display: "flex",
389
- flexDirection: "column",
390
- alignItems: "center",
325
+ }, children: [index === 0 && (0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Field" }), (0, jsx_runtime_1.jsx)("div", { style: {
326
+ display: 'flex',
327
+ flexDirection: 'column',
328
+ alignItems: 'center',
391
329
  }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
392
- display: "flex",
393
- flexDirection: "row",
394
- alignItems: "center",
395
- }, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: filter && filter.field ? filter.field : "", options: selectedTable?.columns.map((column) => {
396
- return { label: column.name, value: column.name };
330
+ display: 'flex',
331
+ flexDirection: 'row',
332
+ alignItems: 'center',
333
+ }, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: filter && filter.field ? filter.field : '', options: selectedTable?.columns.map((column) => {
334
+ return {
335
+ label: column.name,
336
+ value: column.name,
337
+ };
397
338
  }), onChange: (e) => {
398
339
  const updatedFilters = newFilters.map((otherFilter, i) => index === i
399
340
  ? { ...otherFilter, field: e }
@@ -402,19 +343,19 @@ function EditFiltersModal({ isOpen, dashboardData, selectedDashboard, client, se
402
343
  } }), (0, jsx_runtime_1.jsx)("div", { onClick: () => handleDeleteFilter(filter), style: {
403
344
  height: 38,
404
345
  width: 42,
405
- alignItems: "center",
406
- justifyContent: "center",
407
- display: "flex",
408
- cursor: "pointer",
346
+ alignItems: 'center',
347
+ justifyContent: 'center',
348
+ display: 'flex',
349
+ cursor: 'pointer',
409
350
  }, children: (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#4C5462", width: "20", height: "20", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M5.47 5.47a.75.75 0 011.06 0L12 10.94l5.47-5.47a.75.75 0 111.06 1.06L13.06 12l5.47 5.47a.75.75 0 11-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 01-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 010-1.06z", clipRule: "evenodd" }) }) })] }) })] })] }));
410
- }) }))] }), (0, jsx_runtime_1.jsx)("div", { style: { height: 24 } }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleSubmitDashboardChanges, label: "Save changes" })] }) }));
351
+ }) })), (0, jsx_runtime_1.jsx)("div", { style: { height: 12 } }), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleAddFilter, label: "Add filter +" })] }), (0, jsx_runtime_1.jsx)(CardSection_1.default, { children: "Chart order" }), (0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 230 }, children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => openEditOrderModal(selectedDashboardName), label: "Edit chart order" }) }), (0, jsx_runtime_1.jsx)(CardSection_1.default, { children: "Danger Zone" }), (0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 230 }, children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleDeleteDashboard, label: "Delete Dashboard" }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 18 } }), (0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 230 }, children: (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleSubmitDashboardChanges, label: "Save changes" }) })] }) }));
411
352
  }
412
353
  exports.EditFiltersModal = EditFiltersModal;
413
354
  function AddFilterModal({ isOpen, selectedDashboard, client, setIsOpen, ModalComponent, TextInputComponent, SelectComponent, HeaderComponent, ButtonComponent, openAddDashboardModal, }) {
414
355
  const [selectedTable, setSelectedTable] = (0, react_1.useState)(null);
415
- const [name, setName] = (0, react_1.useState)("");
416
- const [field, setField] = (0, react_1.useState)("");
417
- const [filterType, setFilterType] = (0, react_1.useState)("string");
356
+ const [name, setName] = (0, react_1.useState)('');
357
+ const [field, setField] = (0, react_1.useState)('');
358
+ const [filterType, setFilterType] = (0, react_1.useState)('string');
418
359
  const [dateRange, setDateRange] = (0, react_1.useState)([new Date(), new Date()]);
419
360
  const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
420
361
  (0, react_1.useEffect)(() => {
@@ -429,12 +370,12 @@ function AddFilterModal({ isOpen, selectedDashboard, client, setIsOpen, ModalCom
429
370
  return;
430
371
  }
431
372
  const filterType = getPostgresBasicType(selectedTable.columns.find((col) => col.name === field));
432
- if (filterType !== "string" && filterType !== "date") {
433
- alert("We only support string and filters.");
373
+ if (filterType !== 'string' && filterType !== 'date') {
374
+ alert('We only support string and filters.');
434
375
  return;
435
376
  }
436
377
  let responseData;
437
- const url = `https://quill-344421.uc.r.appspot.com/dashfilter/${client._id}/`;
378
+ const url = `${constants_1.QUILL_SERVER}/dashfilter/${client._id}/`;
438
379
  const body = {
439
380
  name: selectedDashboard,
440
381
  filter: {
@@ -446,12 +387,12 @@ function AddFilterModal({ isOpen, selectedDashboard, client, setIsOpen, ModalCom
446
387
  },
447
388
  };
448
389
  const headers = {
449
- "Content-Type": "application/json",
390
+ 'Content-Type': 'application/json',
450
391
  Authorization: `Bearer `,
451
392
  };
452
393
  try {
453
394
  const response = await fetch(url, {
454
- method: "POST",
395
+ method: 'POST',
455
396
  headers: headers,
456
397
  body: JSON.stringify(body),
457
398
  });
@@ -461,21 +402,21 @@ function AddFilterModal({ isOpen, selectedDashboard, client, setIsOpen, ModalCom
461
402
  responseData = await response.json();
462
403
  }
463
404
  catch (error) {
464
- console.error("There was a problem with the fetch operation:", error);
405
+ console.error('There was a problem with the fetch operation:', error);
465
406
  }
466
407
  if (responseData) {
467
408
  setIsOpen(false);
468
- setName("");
469
- setField("");
409
+ setName('');
410
+ setField('');
470
411
  return;
471
412
  }
472
413
  };
473
414
  if (!selectedTable) {
474
415
  return null;
475
416
  }
476
- return ((0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, close: () => setIsOpen(false), children: (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", flexDirection: "column" }, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { label: "Add filter" }), (0, jsx_runtime_1.jsx)("div", { children: "Label" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { value: name, onChange: (e) => setName(e.target.value) }), (0, jsx_runtime_1.jsx)("div", { children: "Table" }), (0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: selectedTable ? selectedTable : "", onChange: (e) => setSelectedTable(e.target.value), options: state.tables.map((table) => {
417
+ return ((0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, close: () => setIsOpen(false), children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { label: "Add filter" }), (0, jsx_runtime_1.jsx)("div", { children: "Label" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { value: name, onChange: (e) => setName(e.target.value) }), (0, jsx_runtime_1.jsx)("div", { children: "Table" }), (0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: selectedTable ? selectedTable : '', onChange: (e) => setSelectedTable(e.target.value), QuillOptions: state.tables.map((table) => {
477
418
  return { label: table.name, value: table.name };
478
- }) }), (0, jsx_runtime_1.jsx)("div", { children: "Field" }), (0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: field ? field : "", options: selectedTable.columns.map((column) => {
419
+ }) }), (0, jsx_runtime_1.jsx)("div", { children: "Field" }), (0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: field ? field : '', QuillOptions: selectedTable.columns.map((column) => {
479
420
  return { label: column.name, value: column.name };
480
421
  }), onChange: (e) => {
481
422
  setField(e);
@@ -497,34 +438,34 @@ function Navigation({ TextInputComponent, ButtonComponent, SecondaryButtonCompon
497
438
  }
498
439
  const renderComponentBasedOnName = () => {
499
440
  switch (state.activeComponent) {
500
- case "Dashboards":
501
- return ((0, jsx_runtime_1.jsx)(components_1.DashboardManager, { TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, ModalComponent: ModalComponent, SelectComponent: SelectComponent, HeaderComponent: HeaderComponent, setReportId: (id) => dispatch({ type: "SET_REPORT_ID", payload: id }), queryEndpoint: queryEndpoint, queryHeaders: queryHeaders, withCredentials: withCredentials }));
502
- case "SQL editor":
441
+ case 'Dashboards':
442
+ return ((0, jsx_runtime_1.jsx)(components_1.DashboardManager, { TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, ModalComponent: ModalComponent, SelectComponent: SelectComponent, HeaderComponent: HeaderComponent, setReportId: (id) => dispatch({ type: 'SET_REPORT_ID', payload: id }), queryEndpoint: queryEndpoint, queryHeaders: queryHeaders, withCredentials: withCredentials }));
443
+ case 'SQL editor':
503
444
  return (0, jsx_runtime_1.jsx)(DashboardBuilder_1.default, {});
504
- case "Report":
445
+ case 'Report':
505
446
  return ((0, jsx_runtime_1.jsx)(ReportWrapper, { TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, ModalComponent: ModalComponent, SelectComponent: SelectComponent, OrganizationSelectComponent: OrganizationSelectComponent, organizationId: state.organizationId, queryEndpoint: queryEndpoint, queryHeaders: queryHeaders, withCredentials: withCredentials }));
506
- case "SQL views":
447
+ case 'SQL views':
507
448
  return (0, jsx_runtime_1.jsx)(SQLViewManager_1.default, {});
508
449
  default:
509
- return ((0, jsx_runtime_1.jsx)(Dashboards, { TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, OrganizationSelectComponent: OrganizationSelectComponent, ModalComponent: ModalComponent, SelectComponent: SelectComponent, HeaderComponent: HeaderComponent, setReportId: (id) => dispatch({ type: "SET_REPORT_ID", payload: id }), queryEndpoint: queryEndpoint, organizationId: state.organizationId, queryHeaders: queryHeaders, withCredentials: withCredentials }));
450
+ return ((0, jsx_runtime_1.jsx)(Dashboards, { TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, OrganizationSelectComponent: OrganizationSelectComponent, ModalComponent: ModalComponent, SelectComponent: SelectComponent, HeaderComponent: HeaderComponent, setReportId: (id) => dispatch({ type: 'SET_REPORT_ID', payload: id }), queryEndpoint: queryEndpoint, organizationId: state.organizationId, queryHeaders: queryHeaders, withCredentials: withCredentials }));
510
451
  }
511
452
  };
512
453
  return ((0, jsx_runtime_1.jsxs)("div", { style: {
513
- display: "flex",
514
- flexDirection: "column",
515
- height: "100vh",
516
- width: "100vw",
454
+ display: 'flex',
455
+ flexDirection: 'column',
456
+ height: '100vh',
457
+ width: '100vw',
517
458
  }, children: [(0, jsx_runtime_1.jsxs)("nav", { style: {
518
459
  zIndex: 2,
519
- height: "70px",
520
- width: "100%",
521
- display: "flex",
522
- flexDirection: "row",
523
- justifyContent: "space-between",
524
- alignItems: "center",
525
- backgroundColor: "white",
526
- padding: "0",
527
- position: "fixed",
460
+ height: '70px',
461
+ width: '100%',
462
+ display: 'flex',
463
+ flexDirection: 'row',
464
+ justifyContent: 'space-between',
465
+ alignItems: 'center',
466
+ backgroundColor: 'white',
467
+ padding: '0',
468
+ position: 'fixed',
528
469
  top: 0,
529
470
  left: 0,
530
471
  right: 0,
@@ -532,74 +473,74 @@ function Navigation({ TextInputComponent, ButtonComponent, SecondaryButtonCompon
532
473
  borderTopWidth: 0,
533
474
  borderLeftWidth: 0,
534
475
  borderRightWidth: 0,
535
- borderStyle: "solid",
476
+ borderStyle: 'solid',
536
477
  borderColor: exports.theme.borderColor,
537
478
  }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
538
- paddingTop: "18px",
539
- paddingLeft: "14px",
540
- paddingBottom: "18px",
479
+ paddingTop: '18px',
480
+ paddingLeft: '14px',
481
+ paddingBottom: '18px',
541
482
  width: 230,
542
- }, children: (0, jsx_runtime_1.jsxs)("svg", { width: "45", height: "18", viewBox: "0 0 45 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("g", { clipPath: "url(#clip0_2489_282)", children: (0, jsx_runtime_1.jsx)("path", { d: "M18.634 17.3008H9.196C7.97867 17.3008 6.84933 17.1248 5.808 16.7728C4.78133 16.4061 3.894 15.8781 3.146 15.1888C2.398 14.4994 1.81133 13.6634 1.386 12.6808C0.960667 11.6981 0.748 10.5761 0.748 9.31478C0.748 8.14145 0.960667 7.06345 1.386 6.08078C1.826 5.09811 2.42 4.25478 3.168 3.55078C3.916 2.84678 4.796 2.30411 5.808 1.92278C6.82 1.52678 7.90533 1.32878 9.064 1.32878C10.2227 1.32878 11.308 1.52678 12.32 1.92278C13.332 2.31878 14.212 2.86878 14.96 3.57278C15.708 4.27678 16.2947 5.12011 16.72 6.10278C17.16 7.07078 17.38 8.14145 17.38 9.31478C17.38 9.87211 17.314 10.4148 17.182 10.9428C17.0647 11.4708 16.8813 11.9694 16.632 12.4388C16.3827 12.9081 16.06 13.3334 15.664 13.7148C15.268 14.0814 14.806 14.3821 14.278 14.6168V14.6608H18.634V17.3008ZM4.312 9.31478C4.312 9.98945 4.43667 10.6201 4.686 11.2068C4.93533 11.7934 5.27267 12.3068 5.698 12.7468C6.138 13.1721 6.644 13.5094 7.216 13.7588C7.788 14.0081 8.404 14.1328 9.064 14.1328C9.724 14.1328 10.34 14.0081 10.912 13.7588C11.484 13.5094 11.9827 13.1721 12.408 12.7468C12.848 12.3068 13.1927 11.7934 13.442 11.2068C13.6913 10.6201 13.816 9.98945 13.816 9.31478C13.816 8.64011 13.6913 8.00945 13.442 7.42278C13.1927 6.83611 12.848 6.33011 12.408 5.90478C11.9827 5.46478 11.484 5.12011 10.912 4.87078C10.34 4.62145 9.724 4.49678 9.064 4.49678C8.404 4.49678 7.788 4.62145 7.216 4.87078C6.644 5.12011 6.138 5.46478 5.698 5.90478C5.27267 6.33011 4.93533 6.83611 4.686 7.42278C4.43667 8.00945 4.312 8.64011 4.312 9.31478ZM29.3164 17.3008H26.1484V15.8488H26.1044C25.987 16.0541 25.833 16.2594 25.6424 16.4648C25.4664 16.6701 25.2464 16.8534 24.9824 17.0148C24.7184 17.1761 24.4177 17.3081 24.0804 17.4108C23.743 17.5134 23.3764 17.5648 22.9804 17.5648C22.1444 17.5648 21.4624 17.4401 20.9344 17.1908C20.421 16.9268 20.0177 16.5674 19.7244 16.1128C19.4457 15.6581 19.255 15.1228 19.1524 14.5068C19.0644 13.8908 19.0204 13.2234 19.0204 12.5048V6.60878H22.3204V11.8448C22.3204 12.1528 22.3277 12.4754 22.3424 12.8128C22.3717 13.1354 22.4377 13.4361 22.5404 13.7148C22.6577 13.9934 22.8264 14.2208 23.0464 14.3968C23.281 14.5728 23.611 14.6608 24.0364 14.6608C24.4617 14.6608 24.8064 14.5874 25.0704 14.4408C25.3344 14.2794 25.5324 14.0741 25.6644 13.8248C25.811 13.5608 25.9064 13.2674 25.9504 12.9448C25.9944 12.6221 26.0164 12.2848 26.0164 11.9328V6.60878H29.3164V17.3008ZM30.8172 6.60878H34.1172V17.3008H30.8172V6.60878ZM30.5532 3.24278C30.5532 2.71478 30.7365 2.26745 31.1032 1.90078C31.4845 1.51945 31.9392 1.32878 32.4672 1.32878C32.9952 1.32878 33.4425 1.51945 33.8092 1.90078C34.1905 2.26745 34.3812 2.71478 34.3812 3.24278C34.3812 3.77078 34.1905 4.22545 33.8092 4.60678C33.4425 4.97345 32.9952 5.15678 32.4672 5.15678C31.9392 5.15678 31.4845 4.97345 31.1032 4.60678C30.7365 4.22545 30.5532 3.77078 30.5532 3.24278ZM35.652 0.66878H38.952V17.3008H35.652V0.66878ZM40.4869 0.66878H43.7869V17.3008H40.4869V0.66878Z", fill: "#212121" }) }), (0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: "clip0_2489_282", children: (0, jsx_runtime_1.jsx)("rect", { width: "45", height: "18", fill: "white" }) }) })] }) }), (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", flexDirection: "row" }, children: [(0, jsx_runtime_1.jsx)("button", { style: {
543
- color: "#212121",
544
- backgroundColor: state.activeComponent === "Dashboards"
545
- ? "#2121210A"
546
- : "transparent",
547
- padding: "8px 12px",
548
- height: "38px",
549
- marginBottom: "4px",
550
- fontWeight: "bold",
551
- fontSize: "0.875rem",
552
- borderRadius: "4px",
553
- transition: "background-color 0.3s",
554
- border: "none",
555
- outline: "none",
483
+ }, children: (0, jsx_runtime_1.jsxs)("svg", { width: "45", height: "18", viewBox: "0 0 45 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("g", { clipPath: "url(#clip0_2489_282)", children: (0, jsx_runtime_1.jsx)("path", { d: "M18.634 17.3008H9.196C7.97867 17.3008 6.84933 17.1248 5.808 16.7728C4.78133 16.4061 3.894 15.8781 3.146 15.1888C2.398 14.4994 1.81133 13.6634 1.386 12.6808C0.960667 11.6981 0.748 10.5761 0.748 9.31478C0.748 8.14145 0.960667 7.06345 1.386 6.08078C1.826 5.09811 2.42 4.25478 3.168 3.55078C3.916 2.84678 4.796 2.30411 5.808 1.92278C6.82 1.52678 7.90533 1.32878 9.064 1.32878C10.2227 1.32878 11.308 1.52678 12.32 1.92278C13.332 2.31878 14.212 2.86878 14.96 3.57278C15.708 4.27678 16.2947 5.12011 16.72 6.10278C17.16 7.07078 17.38 8.14145 17.38 9.31478C17.38 9.87211 17.314 10.4148 17.182 10.9428C17.0647 11.4708 16.8813 11.9694 16.632 12.4388C16.3827 12.9081 16.06 13.3334 15.664 13.7148C15.268 14.0814 14.806 14.3821 14.278 14.6168V14.6608H18.634V17.3008ZM4.312 9.31478C4.312 9.98945 4.43667 10.6201 4.686 11.2068C4.93533 11.7934 5.27267 12.3068 5.698 12.7468C6.138 13.1721 6.644 13.5094 7.216 13.7588C7.788 14.0081 8.404 14.1328 9.064 14.1328C9.724 14.1328 10.34 14.0081 10.912 13.7588C11.484 13.5094 11.9827 13.1721 12.408 12.7468C12.848 12.3068 13.1927 11.7934 13.442 11.2068C13.6913 10.6201 13.816 9.98945 13.816 9.31478C13.816 8.64011 13.6913 8.00945 13.442 7.42278C13.1927 6.83611 12.848 6.33011 12.408 5.90478C11.9827 5.46478 11.484 5.12011 10.912 4.87078C10.34 4.62145 9.724 4.49678 9.064 4.49678C8.404 4.49678 7.788 4.62145 7.216 4.87078C6.644 5.12011 6.138 5.46478 5.698 5.90478C5.27267 6.33011 4.93533 6.83611 4.686 7.42278C4.43667 8.00945 4.312 8.64011 4.312 9.31478ZM29.3164 17.3008H26.1484V15.8488H26.1044C25.987 16.0541 25.833 16.2594 25.6424 16.4648C25.4664 16.6701 25.2464 16.8534 24.9824 17.0148C24.7184 17.1761 24.4177 17.3081 24.0804 17.4108C23.743 17.5134 23.3764 17.5648 22.9804 17.5648C22.1444 17.5648 21.4624 17.4401 20.9344 17.1908C20.421 16.9268 20.0177 16.5674 19.7244 16.1128C19.4457 15.6581 19.255 15.1228 19.1524 14.5068C19.0644 13.8908 19.0204 13.2234 19.0204 12.5048V6.60878H22.3204V11.8448C22.3204 12.1528 22.3277 12.4754 22.3424 12.8128C22.3717 13.1354 22.4377 13.4361 22.5404 13.7148C22.6577 13.9934 22.8264 14.2208 23.0464 14.3968C23.281 14.5728 23.611 14.6608 24.0364 14.6608C24.4617 14.6608 24.8064 14.5874 25.0704 14.4408C25.3344 14.2794 25.5324 14.0741 25.6644 13.8248C25.811 13.5608 25.9064 13.2674 25.9504 12.9448C25.9944 12.6221 26.0164 12.2848 26.0164 11.9328V6.60878H29.3164V17.3008ZM30.8172 6.60878H34.1172V17.3008H30.8172V6.60878ZM30.5532 3.24278C30.5532 2.71478 30.7365 2.26745 31.1032 1.90078C31.4845 1.51945 31.9392 1.32878 32.4672 1.32878C32.9952 1.32878 33.4425 1.51945 33.8092 1.90078C34.1905 2.26745 34.3812 2.71478 34.3812 3.24278C34.3812 3.77078 34.1905 4.22545 33.8092 4.60678C33.4425 4.97345 32.9952 5.15678 32.4672 5.15678C31.9392 5.15678 31.4845 4.97345 31.1032 4.60678C30.7365 4.22545 30.5532 3.77078 30.5532 3.24278ZM35.652 0.66878H38.952V17.3008H35.652V0.66878ZM40.4869 0.66878H43.7869V17.3008H40.4869V0.66878Z", fill: "#212121" }) }), (0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: "clip0_2489_282", children: (0, jsx_runtime_1.jsx)("rect", { width: "45", height: "18", fill: "white" }) }) })] }) }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row' }, children: [(0, jsx_runtime_1.jsx)("button", { style: {
484
+ color: '#212121',
485
+ backgroundColor: state.activeComponent === 'Dashboards'
486
+ ? '#2121210A'
487
+ : 'transparent',
488
+ padding: '8px 12px',
489
+ height: '38px',
490
+ marginBottom: '4px',
491
+ fontWeight: 'bold',
492
+ fontSize: '0.875rem',
493
+ borderRadius: '4px',
494
+ transition: 'background-color 0.3s',
495
+ border: 'none',
496
+ outline: 'none',
556
497
  },
557
498
  // onClick={() => setActiveComponent("Dashboards")}
558
- onClick: () => dispatch({ type: "SET_ACTIVE_COMPONENT", payload: "Dashboards" }), children: "Dashboards" }), (0, jsx_runtime_1.jsx)("button", { style: {
559
- color: "#212121",
560
- backgroundColor: state.activeComponent === "SQL editor"
561
- ? "#2121210A"
562
- : "transparent",
563
- padding: "8px 12px",
564
- height: "38px",
565
- marginBottom: "4px",
566
- fontWeight: "bold",
567
- fontSize: "0.875rem",
568
- borderRadius: "4px",
569
- transition: "background-color 0.3s",
570
- border: "none",
571
- outline: "none",
499
+ onClick: () => dispatch({ type: 'SET_ACTIVE_COMPONENT', payload: 'Dashboards' }), children: "Dashboards" }), (0, jsx_runtime_1.jsx)("button", { style: {
500
+ color: '#212121',
501
+ backgroundColor: state.activeComponent === 'SQL editor'
502
+ ? '#2121210A'
503
+ : 'transparent',
504
+ padding: '8px 12px',
505
+ height: '38px',
506
+ marginBottom: '4px',
507
+ fontWeight: 'bold',
508
+ fontSize: '0.875rem',
509
+ borderRadius: '4px',
510
+ transition: 'background-color 0.3s',
511
+ border: 'none',
512
+ outline: 'none',
572
513
  },
573
514
  // onClick={() => setActiveComponent("SQL editor")}
574
- onClick: () => dispatch({ type: "SET_ACTIVE_COMPONENT", payload: "SQL editor" }), children: "SQL editor" }), (0, jsx_runtime_1.jsx)("button", { style: {
575
- color: "#212121",
576
- backgroundColor: state.activeComponent === "SQL views"
577
- ? "#2121210A"
578
- : "transparent",
579
- padding: "8px 12px",
580
- height: "38px",
581
- marginBottom: "4px",
582
- fontWeight: "bold",
583
- fontSize: "0.875rem",
584
- borderRadius: "4px",
585
- transition: "background-color 0.3s",
586
- border: "none",
587
- outline: "none",
515
+ onClick: () => dispatch({ type: 'SET_ACTIVE_COMPONENT', payload: 'SQL editor' }), children: "SQL editor" }), (0, jsx_runtime_1.jsx)("button", { style: {
516
+ color: '#212121',
517
+ backgroundColor: state.activeComponent === 'SQL views'
518
+ ? '#2121210A'
519
+ : 'transparent',
520
+ padding: '8px 12px',
521
+ height: '38px',
522
+ marginBottom: '4px',
523
+ fontWeight: 'bold',
524
+ fontSize: '0.875rem',
525
+ borderRadius: '4px',
526
+ transition: 'background-color 0.3s',
527
+ border: 'none',
528
+ outline: 'none',
588
529
  },
589
530
  // onClick={() => setActiveComponent("SQL views")}
590
- onClick: () => dispatch({ type: "SET_ACTIVE_COMPONENT", payload: "SQL views" }), children: "SQL views" })] }), (0, jsx_runtime_1.jsx)("div", { style: {
591
- display: "flex",
592
- flexDirection: "row",
593
- minHeight: "50px",
594
- justifyContent: "flex-end",
595
- alignItems: "center",
596
- paddingRight: "8px",
531
+ onClick: () => dispatch({ type: 'SET_ACTIVE_COMPONENT', payload: 'SQL views' }), children: "SQL views" })] }), (0, jsx_runtime_1.jsx)("div", { style: {
532
+ display: 'flex',
533
+ flexDirection: 'row',
534
+ minHeight: '50px',
535
+ justifyContent: 'flex-end',
536
+ alignItems: 'center',
537
+ paddingRight: '8px',
597
538
  width: 230,
598
539
  }, children: UserManagementComponent && (0, jsx_runtime_1.jsx)(UserManagementComponent, {}) })] }), (0, jsx_runtime_1.jsx)("div", { style: {
599
- display: "flex",
600
- flexDirection: "column",
601
- height: "100%",
602
- width: "100%",
540
+ display: 'flex',
541
+ flexDirection: 'column',
542
+ height: '100%',
543
+ width: '100%',
603
544
  // marginTop: activeComponent !== 'Report' ? '70px' : undefined
604
545
  }, children: (0, jsx_runtime_1.jsx)(react_2.QuillProvider
605
546
  // organizationId={'2'}
@@ -610,20 +551,20 @@ function Navigation({ TextInputComponent, ButtonComponent, SecondaryButtonCompon
610
551
  organizationId: state.organizationId, queryEndpoint: queryEndpoint, withCredentials: withCredentials, queryHeaders: queryHeaders, publicKey: state.client._id, environment: state.environment, theme: exports.theme, children: renderComponentBasedOnName() }) })] }));
611
552
  }
612
553
  exports.theme = {
613
- fontFamily: "Inter; Helvetica",
614
- backgroundColor: "#FFFFFF",
615
- primaryTextColor: "#364153",
616
- secondaryTextColor: "#6C727F",
617
- chartLabelFontFamily: "Inter; Helvetica",
618
- chartLabelColor: "#666666",
619
- chartTickColor: "#CCCCCC",
620
- // chartColors: ["#6269E9", "#E14F62"],
621
- borderColor: "#E5E7EB",
554
+ fontFamily: 'Inter; Helvetica',
555
+ backgroundColor: '#FFFFFF',
556
+ primaryTextColor: '#364153',
557
+ secondaryTextColor: '#6C727F',
558
+ chartLabelFontFamily: 'Inter; Helvetica',
559
+ chartLabelColor: '#666666',
560
+ chartTickColor: '#CCCCCC',
561
+ chartColors: ['#6269E9', '#E14F62'],
562
+ borderColor: '#E5E7EB',
622
563
  labelFontWeight: 500,
623
564
  fontSize: 14,
624
565
  borderWidth: 1,
625
- primaryButtonColor: "#212121",
626
- primaryButtonTextColor: "#FFFFFF",
566
+ primaryButtonColor: '#212121',
567
+ primaryButtonTextColor: '#FFFFFF',
627
568
  };
628
569
  function convertPostgresColumn(column) {
629
570
  let format;
@@ -631,22 +572,22 @@ function convertPostgresColumn(column) {
631
572
  case 20: // int8
632
573
  case 21: // int2
633
574
  case 23: // int4
634
- format = "whole_number";
575
+ format = 'whole_number';
635
576
  break;
636
577
  case 700: // float4
637
578
  case 701: // float8
638
579
  case 1700: // numeric
639
- format = "two_decimal_places";
580
+ format = 'two_decimal_places';
640
581
  break;
641
582
  case 1082: // date
642
583
  case 1083: // time
643
584
  case 1184: // timestamptz
644
585
  case 1114: // timestamp
645
- format = "MMM_dd_yyyy";
586
+ format = 'MMM_dd_yyyy';
646
587
  break;
647
588
  case 1043: // varchar
648
589
  default:
649
- format = "string";
590
+ format = 'string';
650
591
  }
651
592
  return {
652
593
  label: column.name,
@@ -666,46 +607,46 @@ function getPostgresBasicType(column) {
666
607
  case 700: // float4
667
608
  case 701: // float8
668
609
  case 1700: // numeric
669
- format = "number";
610
+ format = 'number';
670
611
  break;
671
612
  case 1082: // date
672
613
  case 1083: // time
673
614
  case 1184: // timestamptz
674
615
  case 1114: // timestamp
675
- format = "date";
616
+ format = 'date';
676
617
  break;
677
618
  case 1043: // varchar
678
619
  default:
679
- format = "string";
620
+ format = 'string';
680
621
  }
681
622
  }
682
623
  else if (column.fieldType) {
683
624
  // if column.dataTypeID doesn't exist, check column.fieldType
684
625
  switch (column.fieldType) {
685
- case "int8":
686
- case "int2":
687
- case "int4":
688
- case "float4":
689
- case "float8":
690
- case "numeric":
691
- format = "number";
626
+ case 'int8':
627
+ case 'int2':
628
+ case 'int4':
629
+ case 'float4':
630
+ case 'float8':
631
+ case 'numeric':
632
+ format = 'number';
692
633
  break;
693
- case "date":
694
- case "time":
695
- case "timestamptz":
696
- case "timestamp":
697
- format = "date";
634
+ case 'date':
635
+ case 'time':
636
+ case 'timestamptz':
637
+ case 'timestamp':
638
+ format = 'date';
698
639
  break;
699
- case "varchar":
640
+ case 'varchar':
700
641
  default:
701
- format = "string";
642
+ format = 'string';
702
643
  }
703
644
  }
704
645
  return format;
705
646
  }
706
647
  exports.getPostgresBasicType = getPostgresBasicType;
707
648
  function classNames(...classes) {
708
- return classes.filter(Boolean).join(" ");
649
+ return classes.filter(Boolean).join(' ');
709
650
  }
710
651
  exports.classNames = classNames;
711
652
  function AddDashboardModal({ selectedDashboard, isOpen, setIsOpen, client, ModalComponent, TextInputComponent, SelectComponent, HeaderComponent, ButtonComponent, dashNames, getDashNames, organizationId, }) {
@@ -713,9 +654,9 @@ function AddDashboardModal({ selectedDashboard, isOpen, setIsOpen, client, Modal
713
654
  const [selectedDashboardName, setSelectedDashboardName] = (0, react_1.useState)(selectedDashboard?.name);
714
655
  // const [tables] = useContext(TablesContext);
715
656
  const [selectedTable, setSelectedTable] = (0, react_1.useState)(null);
716
- const [name, setName] = (0, react_1.useState)("");
717
- const [field, setField] = (0, react_1.useState)("");
718
- const [filterType, setFilterType] = (0, react_1.useState)("string");
657
+ const [name, setName] = (0, react_1.useState)('');
658
+ const [field, setField] = (0, react_1.useState)('');
659
+ const [filterType, setFilterType] = (0, react_1.useState)('string');
719
660
  const [dateRange, setDateRange] = (0, react_1.useState)([new Date(), new Date()]);
720
661
  const [newFilters, setNewFilters] = (0, react_1.useState)([]);
721
662
  const [newDateFilter, setNewDateFilter] = (0, react_1.useState)(null);
@@ -733,11 +674,11 @@ function AddDashboardModal({ selectedDashboard, isOpen, setIsOpen, client, Modal
733
674
  if (!selectedDashboardName ||
734
675
  newFilters.some((filter) => !filter.label) ||
735
676
  (newDateFilter && newDateFilter.label)) {
736
- alert("Empty labels");
677
+ alert('Empty labels');
737
678
  return;
738
679
  }
739
680
  if (newFilters.some((filter) => !filter.field)) {
740
- alert("Empty fields");
681
+ alert('Empty fields');
741
682
  return;
742
683
  }
743
684
  if (!selectedTable || !field) {
@@ -746,7 +687,7 @@ function AddDashboardModal({ selectedDashboard, isOpen, setIsOpen, client, Modal
746
687
  if (dashNames &&
747
688
  dashNames.length > 0 &&
748
689
  dashNames.some((dashName) => dashName.name === selectedDashboardName)) {
749
- alert("Dashboard name already taken!");
690
+ alert('Dashboard name already taken!');
750
691
  return;
751
692
  }
752
693
  let updatedFilters = newFilters.map((filter) => {
@@ -770,26 +711,26 @@ function AddDashboardModal({ selectedDashboard, isOpen, setIsOpen, client, Modal
770
711
  }
771
712
  });
772
713
  if (hasDuplicateField) {
773
- alert("Maximum of one filter per field");
714
+ alert('Maximum of one filter per field');
774
715
  return;
775
716
  }
776
717
  let allValid = true;
777
718
  updatedFilters.forEach((filter) => {
778
- if (filter.filterType !== "string" && filter.filterType !== "date") {
719
+ if (filter.filterType !== 'string' && filter.filterType !== 'date') {
779
720
  allValid = false;
780
721
  console.error(`Invalid filterType found: ${filter.filterType}`);
781
722
  }
782
723
  });
783
724
  if (!allValid) {
784
- alert("We only support string and filters.");
725
+ alert('We only support string and filters.');
785
726
  return;
786
727
  }
787
- if (updatedFilters.filter((filter) => filter.filterType === "date").length > 1) {
788
- alert("More than one date filter");
728
+ if (updatedFilters.filter((filter) => filter.filterType === 'date').length > 1) {
729
+ alert('More than one date filter');
789
730
  return;
790
731
  }
791
732
  let responseData;
792
- const url = `https://quill-344421.uc.r.appspot.com/newdash/${client._id}/`;
733
+ const url = `${constants_1.QUILL_SERVER}/newdash/${client._id}/`;
793
734
  const body = newDateFilter && Object.keys(newDateFilter).length
794
735
  ? {
795
736
  dateFilter: newDateFilter,
@@ -803,12 +744,12 @@ function AddDashboardModal({ selectedDashboard, isOpen, setIsOpen, client, Modal
803
744
  organizationId,
804
745
  };
805
746
  const headers = {
806
- "Content-Type": "application/json",
747
+ 'Content-Type': 'application/json',
807
748
  Authorization: `Bearer `,
808
749
  };
809
750
  try {
810
751
  const response = await fetch(url, {
811
- method: "POST",
752
+ method: 'POST',
812
753
  headers: headers,
813
754
  body: JSON.stringify(body),
814
755
  });
@@ -818,12 +759,12 @@ function AddDashboardModal({ selectedDashboard, isOpen, setIsOpen, client, Modal
818
759
  responseData = await response.json();
819
760
  }
820
761
  catch (e) {
821
- console.log("error");
762
+ console.log('error');
822
763
  }
823
764
  if (responseData) {
824
765
  setIsOpen(false);
825
- setName("");
826
- setSelectedDashboardName("");
766
+ setName('');
767
+ setSelectedDashboardName('');
827
768
  setNewFilters([]);
828
769
  setNewDateFilter(null);
829
770
  getDashNames();
@@ -834,27 +775,27 @@ function AddDashboardModal({ selectedDashboard, isOpen, setIsOpen, client, Modal
834
775
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
835
776
  }
836
777
  const handleAddFilter = async () => {
837
- setNewFilters([...newFilters, { label: "", field }]);
778
+ setNewFilters([...newFilters, { label: '', field }]);
838
779
  };
839
780
  return ((0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, close: () => setIsOpen(false), children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(TextInputComponent, { placeholder: "Enter Dashboard Name...", onChange: (e) => setSelectedDashboardName(e.target.value), value: selectedDashboardName }), (0, jsx_runtime_1.jsxs)("div", { style: {
840
- display: "flex",
841
- flexDirection: "column",
842
- alignItems: "center",
781
+ display: 'flex',
782
+ flexDirection: 'column',
783
+ alignItems: 'center',
843
784
  }, children: [newFilters.map((filter, index) => {
844
- return ((0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", flexDirection: "row" }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", flexDirection: "column" }, children: [(0, jsx_runtime_1.jsx)("h2", { children: "Label" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { value: filter.label, onChange: (e) => {
785
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("h2", { children: "Label" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { value: filter.label, onChange: (e) => {
845
786
  const updatedFilters = newFilters.map((otherFilter, i) => index === i
846
787
  ? { ...otherFilter, label: e.target.value }
847
788
  : otherFilter);
848
789
  setNewFilters(updatedFilters);
849
- } })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", flexDirection: "column" }, children: [(0, jsx_runtime_1.jsx)("h4", { children: "Field" }), (0, jsx_runtime_1.jsx)("div", { style: {
850
- display: "flex",
851
- flexDirection: "column",
852
- alignItems: "center",
790
+ } })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("h4", { children: "Field" }), (0, jsx_runtime_1.jsx)("div", { style: {
791
+ display: 'flex',
792
+ flexDirection: 'column',
793
+ alignItems: 'center',
853
794
  }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
854
- display: "flex",
855
- flexDirection: "row",
856
- alignItems: "center",
857
- }, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: filter && filter.field ? filter.field : "", options: selectedTable.columns.map((column) => {
795
+ display: 'flex',
796
+ flexDirection: 'row',
797
+ alignItems: 'center',
798
+ }, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: filter && filter.field ? filter.field : '', QuillOptions: selectedTable.columns.map((column) => {
858
799
  return { label: column.name, value: column.name };
859
800
  }), onChange: (e) => {
860
801
  const updatedFilters = newFilters.map((otherFilter, i) => index === i
@@ -864,9 +805,9 @@ function AddDashboardModal({ selectedDashboard, isOpen, setIsOpen, client, Modal
864
805
  } }), (0, jsx_runtime_1.jsx)("div", { onClick: () => handleDeleteFilter(filter), style: {
865
806
  height: 38,
866
807
  width: 42,
867
- alignItems: "center",
868
- justifyContent: "center",
869
- display: "flex",
808
+ alignItems: 'center',
809
+ justifyContent: 'center',
810
+ display: 'flex',
870
811
  }, children: (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#4C5462", width: "20", height: "20", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M5.47 5.47a.75.75 0 011.06 0L12 10.94l5.47-5.47a.75.75 0 111.06 1.06L13.06 12l5.47 5.47a.75.75 0 11-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 01-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 010-1.06z", clipRule: "evenodd" }) }) })] }) })] })] }, filter.field + index));
871
812
  }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleAddFilter, label: "Add new filter +" }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleAddDashboardSubmit, label: "Add Dashboard +" })] })] }) }));
872
813
  }
@@ -876,17 +817,17 @@ function TableCell({ table, clickTableCell }) {
876
817
  clickTableCell(table);
877
818
  };
878
819
  return ((0, jsx_runtime_1.jsxs)("div", { onClick: handleClickTableCell, style: {
879
- marginBottom: "54px",
820
+ marginBottom: '54px',
880
821
  flex: 1,
881
- minWidth: "540px",
882
- maxWidth: "540px",
883
- cursor: "pointer",
884
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { display: "flex", flexDirection: "row", alignItems: "center" }, children: (0, jsx_runtime_1.jsx)("h3", { style: { color: "#384151" }, children: table.displayName }) }), (0, jsx_runtime_1.jsx)(prism_react_renderer_1.default, { ...prism_react_renderer_1.defaultProps, theme: nightOwlLight_1.default, code: table.viewQuery, language: "sql", children: ({ className, style, tokens, getLineProps, getTokenProps }) => ((0, jsx_runtime_1.jsx)("pre", { className: className, style: {
822
+ minWidth: '540px',
823
+ maxWidth: '540px',
824
+ cursor: 'pointer',
825
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'row', alignItems: 'center' }, children: (0, jsx_runtime_1.jsx)("h3", { style: { color: '#384151' }, children: table.displayName }) }), (0, jsx_runtime_1.jsx)(prism_react_renderer_1.default, { ...prism_react_renderer_1.defaultProps, theme: nightOwlLight_1.default, code: table.viewQuery, language: "sql", children: ({ className, style, tokens, getLineProps, getTokenProps }) => ((0, jsx_runtime_1.jsx)("pre", { className: className, style: {
885
826
  ...style,
886
- textAlign: "left",
887
- margin: "1em 0",
888
- padding: "0.5em",
889
- overflow: "scroll",
827
+ textAlign: 'left',
828
+ margin: '1em 0',
829
+ padding: '0.5em',
830
+ overflow: 'scroll',
890
831
  maxHeight: 120,
891
832
  maxWidth: 520,
892
833
  // lineHeight: "1.3em",
@@ -915,26 +856,26 @@ theme,
915
856
  // padding: "20px 30px 20px 20px",
916
857
  // marginLeft: 20,
917
858
  borderRadius: 6,
918
- overflow: "hidden",
919
- }, children: [(0, jsx_runtime_1.jsx)(react_2.SQLEditor, { containerStyle: { height: "calc(100vh - 270px)", width: "100%" }, onChangeQuery: (query) => setQuery(query), onChangeData: (data) => setRows(data), onChangeColumns: (columns) => setColumns(columns), onChangeFields: (fields) => setFields(fields), defaultQuery: state.activeQuery ? state.activeQuery : "" }), rows.length > 0 && ((0, jsx_runtime_1.jsx)("button", { style: {
859
+ overflow: 'hidden',
860
+ }, children: [(0, jsx_runtime_1.jsx)(react_2.SQLEditor, { containerStyle: { height: 'calc(100vh - 270px)', width: '100%' }, onChangeQuery: (query) => setQuery(query), onChangeData: (data) => setRows(data), onChangeColumns: (columns) => setColumns(columns), onChangeFields: (fields) => setFields(fields), defaultQuery: state.activeQuery ? state.activeQuery : '' }), rows.length > 0 && ((0, jsx_runtime_1.jsx)("button", { style: {
920
861
  height: 36,
921
862
  marginLeft: 250,
922
863
  marginTop: 20,
923
864
  background: theme.primaryButtonColor,
924
865
  color: theme.backgroundColor,
925
- display: "flex",
866
+ display: 'flex',
926
867
  borderRadius: 6,
927
- alignItems: "center",
928
- justifyContent: "center",
929
- outline: "none",
930
- cursor: "pointer",
868
+ alignItems: 'center',
869
+ justifyContent: 'center',
870
+ outline: 'none',
871
+ cursor: 'pointer',
931
872
  fontFamily: theme.fontFamily,
932
873
  fontWeight: theme.buttonFontWeight || 600,
933
- border: "none",
874
+ border: 'none',
934
875
  fontSize: 14,
935
876
  paddingLeft: 20,
936
877
  paddingRight: 20,
937
- }, onClick: () => setIsOpen(true), children: "Add to dashboard" })), (0, jsx_runtime_1.jsx)(react_2.AddToDashboardModal, { isOpen: isOpen, setIsOpen: setIsOpen, rows: rows, columns: columns, query: query, showTableFormatOptions: true, showDateFieldOptions: true, showAccessControlOptions: true, fields: fields })] }));
878
+ }, onClick: () => setIsOpen(true), children: "Add to dashboard" })), (0, jsx_runtime_1.jsx)(react_2.AddToDashboardModal, { isOpen: isOpen, setIsOpen: setIsOpen, rows: rows, columns: columns, query: query, showTableFormatQuillOptions: true, showDateFieldQuillOptions: true, showAccessControlQuillOptions: true, fields: fields })] }));
938
879
  };
939
880
  exports.SQLEditorComponent = SQLEditorComponent;
940
881
  const SchemaListComponent = ({ schema, theme }) => {
@@ -943,7 +884,7 @@ const SchemaListComponent = ({ schema, theme }) => {
943
884
  maxHeight: 700,
944
885
  width: 300,
945
886
  minWidth: 300,
946
- overflowY: "scroll",
887
+ overflowY: 'scroll',
947
888
  // maxHeight: "100%",
948
889
  paddingLeft: 20,
949
890
  paddingRight: 20,
@@ -952,8 +893,8 @@ const SchemaListComponent = ({ schema, theme }) => {
952
893
  function SchemaItem({ elem, theme, index }) {
953
894
  const [isOpen, setIsOpen] = (0, react_1.useState)(index === 0);
954
895
  const schemaContainerStyle = {
955
- display: "flex",
956
- flexDirection: "column",
896
+ display: 'flex',
897
+ flexDirection: 'column',
957
898
  // WebkitTouchCallout: "none",
958
899
  // WebkitUserSelect: "none",
959
900
  // KhtmlUserSelect: "none",
@@ -962,12 +903,12 @@ function SchemaItem({ elem, theme, index }) {
962
903
  // userSelect: "none",
963
904
  };
964
905
  const schemaRowStyle = {
965
- display: "flex",
966
- flexDirection: "row",
967
- alignItems: "center",
968
- width: "100%",
969
- justifyContent: "space-between",
970
- cursor: "pointer",
906
+ display: 'flex',
907
+ flexDirection: 'row',
908
+ alignItems: 'center',
909
+ width: '100%',
910
+ justifyContent: 'space-between',
911
+ cursor: 'pointer',
971
912
  };
972
913
  const schemaRowHoverStyle = {
973
914
  background: theme.selectUnderlayColor,
@@ -975,37 +916,37 @@ function SchemaItem({ elem, theme, index }) {
975
916
  return ((0, jsx_runtime_1.jsxs)("div", { style: schemaContainerStyle, children: [(0, jsx_runtime_1.jsxs)("div", { style: { ...schemaRowStyle, ...(isOpen && schemaRowHoverStyle) }, onClick: () => setIsOpen(!isOpen), children: [(0, jsx_runtime_1.jsx)("p", { style: {
976
917
  marginLeft: theme.padding,
977
918
  fontSize: theme.fontSize,
978
- color: "#384151",
979
- fontWeight: "500",
919
+ color: '#384151',
920
+ fontWeight: '500',
980
921
  }, children: elem.displayName }), (0, jsx_runtime_1.jsx)("div", { style: {
981
- display: "flex",
982
- alignItems: "center",
983
- justifyContent: "center",
922
+ display: 'flex',
923
+ alignItems: 'center',
924
+ justifyContent: 'center',
984
925
  // paddingRight: 25,
985
926
  paddingTop: 20,
986
927
  paddingBottom: 20,
987
928
  paddingLeft: 0,
988
- cursor: "pointer",
929
+ cursor: 'pointer',
989
930
  }, children: isOpen ? ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "h-5 w-5 text-gray-400", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) })) : ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "h-5 w-5", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 4.5l7.5 7.5-7.5 7.5" }) })) })] }), isOpen ? ((0, jsx_runtime_1.jsx)("div", { style: {
990
931
  paddingBottom: theme.padding,
991
- display: "flex",
992
- flexDirection: "column",
932
+ display: 'flex',
933
+ flexDirection: 'column',
993
934
  paddingLeft: theme.padding,
994
935
  paddingRight: theme.padding,
995
936
  }, children: elem.columns.map((elem, index) => ((0, jsx_runtime_1.jsxs)("div", { style: {
996
937
  paddingTop: theme.padding,
997
- display: "flex",
998
- flexDirection: "row",
999
- alignItems: "center",
1000
- justifyContent: "space-between",
938
+ display: 'flex',
939
+ flexDirection: 'row',
940
+ alignItems: 'center',
941
+ justifyContent: 'space-between',
1001
942
  }, children: [(0, jsx_runtime_1.jsx)("div", { title: elem.displayName, className: "text-gray-500", style: {
1002
943
  fontSize: 13,
1003
944
  // color: theme.secondaryFontColor,
1004
- whiteSpace: "nowrap",
945
+ whiteSpace: 'nowrap',
1005
946
  padding: 0,
1006
947
  margin: 0,
1007
- textOverflow: "ellipsis",
1008
- overflow: "hidden",
948
+ textOverflow: 'ellipsis',
949
+ overflow: 'hidden',
1009
950
  width: 200,
1010
951
  maxWidth: 200,
1011
952
  }, children: elem.displayName }), (0, jsx_runtime_1.jsx)("div", { className: "text-gray-500", title: elem.displayName, style: {
@@ -1016,29 +957,29 @@ function SchemaItem({ elem, theme, index }) {
1016
957
  }, children: elem.fieldType })] }, elem.displayName + elem.index))) })) : null] }));
1017
958
  }
1018
959
  function defineEditorTheme(monaco, theme) {
1019
- monaco.editor.defineTheme("onedark", {
1020
- base: theme.darkMode ? "vs-dark" : "vs",
960
+ monaco.editor.defineTheme('onedark', {
961
+ base: theme.darkMode ? 'vs-dark' : 'vs',
1021
962
  inherit: true,
1022
963
  rules: [
1023
964
  {
1024
- token: "comment",
1025
- foreground: "#5d7988",
1026
- fontStyle: "italic",
965
+ token: 'comment',
966
+ foreground: '#5d7988',
967
+ fontStyle: 'italic',
1027
968
  },
1028
- { token: "constant", foreground: "#e06c75" },
969
+ { token: 'constant', foreground: '#e06c75' },
1029
970
  ],
1030
971
  colors: {
1031
- "editor.background": "#F9F9F9",
972
+ 'editor.background': '#F9F9F9',
1032
973
  },
1033
974
  });
1034
975
  }
1035
976
  exports.defineEditorTheme = defineEditorTheme;
1036
977
  function setEditorTheme(editor, monaco) {
1037
978
  try {
1038
- monaco.editor.setTheme("onedark");
979
+ monaco.editor.setTheme('onedark');
1039
980
  }
1040
981
  catch (e) {
1041
- console.log("ERROR: ", e);
982
+ console.log('ERROR: ', e);
1042
983
  }
1043
984
  }
1044
985
  exports.setEditorTheme = setEditorTheme;
@@ -1054,8 +995,8 @@ function formatDateBuckets(startDate, endDate) {
1054
995
  // Check if the distance is less than or equal to one hour
1055
996
  if (distanceInHours <= 1) {
1056
997
  return {
1057
- unit: "hour",
1058
- format: "h a",
998
+ unit: 'hour',
999
+ format: 'h a',
1059
1000
  startOf: startOfHour,
1060
1001
  };
1061
1002
  }
@@ -1064,8 +1005,8 @@ function formatDateBuckets(startDate, endDate) {
1064
1005
  // Check if the distance is less than or equal to one day
1065
1006
  if (distanceInDays <= 1) {
1066
1007
  return {
1067
- unit: "day",
1068
- format: "MMM d",
1008
+ unit: 'day',
1009
+ format: 'MMM d',
1069
1010
  startOf: startOfDay,
1070
1011
  };
1071
1012
  }
@@ -1074,8 +1015,8 @@ function formatDateBuckets(startDate, endDate) {
1074
1015
  // Check if the distance is less than or equal to one month
1075
1016
  if (distanceInMonths <= 1) {
1076
1017
  return {
1077
- unit: "month",
1078
- format: "MMM yyyy",
1018
+ unit: 'month',
1019
+ format: 'MMM yyyy',
1079
1020
  startOf: startOfMonth,
1080
1021
  };
1081
1022
  }
@@ -1084,39 +1025,39 @@ function formatDateBuckets(startDate, endDate) {
1084
1025
  // Check if the distance is less than or equal to one year
1085
1026
  if (distanceInYears <= 1) {
1086
1027
  return {
1087
- unit: "year",
1088
- format: "yyyy",
1028
+ unit: 'year',
1029
+ format: 'yyyy',
1089
1030
  startOf: startOfYear,
1090
1031
  };
1091
1032
  }
1092
1033
  // Otherwise, the distance is more than one year
1093
1034
  return {
1094
- unit: "year",
1095
- format: "yyyy",
1035
+ unit: 'year',
1036
+ format: 'yyyy',
1096
1037
  startOf: startOfYear,
1097
1038
  };
1098
1039
  }
1099
1040
  exports.formatDateBuckets = formatDateBuckets;
1100
1041
  const POSTGRES_DATE_TYPES = [
1101
- "timestamp",
1102
- "date",
1103
- "timestamptz",
1104
- "time",
1105
- "timetz",
1042
+ 'timestamp',
1043
+ 'date',
1044
+ 'timestamptz',
1045
+ 'time',
1046
+ 'timetz',
1106
1047
  ];
1107
- const FORMAT_OPTIONS = [
1108
- { value: "whole_number", label: "whole number" },
1109
- { value: "one_decimal_place", label: "one decimal place" },
1110
- { value: "dollar_amount", label: "dollar amount" },
1111
- { value: "MMM_yyyy", label: "month" },
1112
- { value: "MMM_dd-MMM_dd", label: "week" },
1113
- { value: "MMM_dd_yyyy", label: "day" },
1114
- { value: "MMM_dd_hh:mm_ap_pm", label: "day and time" },
1115
- { value: "hh_ap_pm", label: "hour" },
1116
- { value: "percent", label: "percent" },
1117
- { value: "string", label: "string" },
1048
+ const FORMAT_QuillOptionS = [
1049
+ { value: 'whole_number', label: 'whole number' },
1050
+ { value: 'one_decimal_place', label: 'one decimal place' },
1051
+ { value: 'dollar_amount', label: 'dollar amount' },
1052
+ { value: 'MMM_yyyy', label: 'month' },
1053
+ { value: 'MMM_dd-MMM_dd', label: 'week' },
1054
+ { value: 'MMM_dd_yyyy', label: 'day' },
1055
+ { value: 'MMM_dd_hh:mm_ap_pm', label: 'day and time' },
1056
+ { value: 'hh_ap_pm', label: 'hour' },
1057
+ { value: 'percent', label: 'percent' },
1058
+ { value: 'string', label: 'string' },
1118
1059
  ];
1119
- function Report({ reportId, saveDashboardItem, isOpen, setIsOpen, isEditQueryOpen, setIsEditQueryOpen, SecondaryButtonComponent, ButtonComponent, deleteReport, updateQuery, OrganizationSelectComponent, ModalComponent, NavigateToDashboardBuilder, }) {
1060
+ function Report({ reportId, saveDashboardItem, isOpen, setIsOpen, isEditQueryOpen, SecondaryButtonComponent, ButtonComponent, deleteReport, updateQuery, OrganizationSelectComponent, ModalComponent, NavigateToDashboardBuilder, }) {
1120
1061
  const { data, loading, error } = (0, react_2.useQuill)(reportId);
1121
1062
  const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
1122
1063
  const downloadCSV = () => {
@@ -1128,27 +1069,27 @@ function Report({ reportId, saveDashboardItem, isOpen, setIsOpen, isEditQueryOpe
1128
1069
  const fields = Object.keys(json[0]); // Assumes all objects have same keys
1129
1070
  const csvRows = [];
1130
1071
  // Header row
1131
- csvRows.push(fields.join(","));
1072
+ csvRows.push(fields.join(','));
1132
1073
  // Data rows
1133
1074
  for (let row of json) {
1134
- let values = fields.map((field) => JSON.stringify(row[field] || ""));
1135
- csvRows.push(values.join(","));
1075
+ let values = fields.map((field) => JSON.stringify(row[field] || ''));
1076
+ csvRows.push(values.join(','));
1136
1077
  }
1137
1078
  // Create CSV string and create a 'blob' with it
1138
- const csvString = csvRows.join("\r\n");
1139
- const csvBlob = new Blob([csvString], { type: "text/csv" });
1079
+ const csvString = csvRows.join('\r\n');
1080
+ const csvBlob = new Blob([csvString], { type: 'text/csv' });
1140
1081
  // Create a download link and click it
1141
- const downloadLink = document.createElement("a");
1142
- downloadLink.download = "download.csv";
1082
+ const downloadLink = document.createElement('a');
1083
+ downloadLink.download = 'download.csv';
1143
1084
  downloadLink.href = URL.createObjectURL(csvBlob);
1144
- downloadLink.style.display = "none";
1085
+ downloadLink.style.display = 'none';
1145
1086
  document.body.appendChild(downloadLink);
1146
1087
  downloadLink.click();
1147
1088
  document.body.removeChild(downloadLink);
1148
1089
  };
1149
1090
  const goBack = () => {
1150
1091
  // setActiveComponent("Dashboards");
1151
- dispatch({ type: "SET_ACTIVE_COMPONENT", payload: "Dashboards" });
1092
+ dispatch({ type: 'SET_ACTIVE_COMPONENT', payload: 'Dashboards' });
1152
1093
  };
1153
1094
  if (!data || loading) {
1154
1095
  return null;
@@ -1158,158 +1099,82 @@ function Report({ reportId, saveDashboardItem, isOpen, setIsOpen, isEditQueryOpe
1158
1099
  }
1159
1100
  return ((0, jsx_runtime_1.jsxs)("div", { style: { paddingLeft: 40, paddingRight: 40 }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1160
1101
  // width: 'calc(100vw - 30px)',
1161
- display: "flex",
1162
- position: "fixed",
1163
- backgroundColor: "white",
1102
+ display: 'flex',
1103
+ position: 'fixed',
1104
+ backgroundColor: 'white',
1164
1105
  zIndex: 1,
1165
1106
  left: 0,
1166
1107
  right: 0,
1167
1108
  top: 0,
1168
- flexDirection: "row",
1109
+ flexDirection: 'row',
1169
1110
  paddingTop: 85,
1170
- alignItems: "center",
1171
- justifyContent: "space-between",
1172
- paddingLeft: "30px",
1173
- paddingRight: "30px",
1111
+ alignItems: 'center',
1112
+ justifyContent: 'space-between',
1113
+ paddingLeft: '30px',
1114
+ paddingRight: '30px',
1174
1115
  borderBottomWidth: 1,
1175
1116
  borderTopWidth: 0,
1176
1117
  borderLeftWidth: 0,
1177
1118
  borderRightWidth: 0,
1178
- borderStyle: "solid",
1119
+ borderStyle: 'solid',
1179
1120
  borderColor: exports.theme.borderColor,
1180
1121
  paddingBottom: 20,
1181
- boxShadow: "0px 1px 4px 0px rgba(0, 0, 0, 0.07)",
1122
+ boxShadow: '0px 1px 4px 0px rgba(0, 0, 0, 0.07)',
1182
1123
  // paddingRight: '50px',
1183
1124
  // position: 'absolute'
1184
1125
  // // zIndex: 10
1185
1126
  }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
1186
- display: "flex",
1187
- flexDirection: "row",
1188
- alignItems: "flex-end",
1189
- justifyContent: "space-between",
1190
- width: "100%",
1127
+ display: 'flex',
1128
+ flexDirection: 'row',
1129
+ alignItems: 'flex-end',
1130
+ justifyContent: 'space-between',
1131
+ width: '100%',
1191
1132
  // marginLeft: '25px'
1192
1133
  }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
1193
- display: "flex",
1194
- flexDirection: "row",
1195
- alignItems: "center",
1134
+ display: 'flex',
1135
+ flexDirection: 'row',
1136
+ alignItems: 'center',
1196
1137
  paddingBottom: 4,
1197
1138
  }, children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: "\u2190 Back", onClick: goBack }), (0, jsx_runtime_1.jsx)("h1", { style: {
1198
- fontSize: "36px",
1199
- paddingTop: "0px",
1200
- fontWeight: "600",
1201
- color: "#384151",
1139
+ fontSize: '36px',
1140
+ paddingTop: '0px',
1141
+ fontWeight: '600',
1142
+ color: '#384151',
1202
1143
  margin: 0,
1203
1144
  paddingLeft: 16,
1204
1145
  }, children: data.name })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
1205
- display: "flex",
1206
- flexDirection: "row",
1207
- alignItems: "center",
1208
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { width: "20px" } }), (0, jsx_runtime_1.jsx)("div", { style: { display: "flex", flexDirection: "column" }, children: (0, jsx_runtime_1.jsx)("div", { style: {
1209
- display: "flex",
1210
- flexDirection: "row",
1211
- alignItems: "flex-end",
1146
+ display: 'flex',
1147
+ flexDirection: 'row',
1148
+ alignItems: 'center',
1149
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: { width: '20px' } }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
1150
+ display: 'flex',
1151
+ flexDirection: 'row',
1152
+ alignItems: 'flex-end',
1212
1153
  gap: 16,
1213
- }, children: (0, jsx_runtime_1.jsx)(components_1.OrgSelect, { environment: state.environment, setEnvironment: (env) => dispatch({ type: "SET_ENVIRONMENT", payload: env }), organizations: state.organizations, organizationId: state.organizationId, setOrganizationId: (orgId) => dispatch({ type: "SET_ORGANIZATION_ID", payload: orgId }), theme: state.theme }) }) })] })] }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 240 } }), (0, jsx_runtime_1.jsx)(react_2.Chart, { chartId: reportId, colors: exports.theme.chartColors, containerStyle: {
1214
- width: "calc(100vw - 80px)",
1215
- height: data.chartType === "table" ? 600 : 400,
1154
+ }, children: (0, jsx_runtime_1.jsx)(components_1.OrgSelect, { environment: state.environment, setEnvironment: (env) => dispatch({ type: 'SET_ENVIRONMENT', payload: env }), organizations: state.organizations, organizationId: state.organizationId, setOrganizationId: (orgId) => dispatch({ type: 'SET_ORGANIZATION_ID', payload: orgId }), theme: state.theme }) }) })] })] }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 240 } }), (0, jsx_runtime_1.jsx)(react_2.Chart, { chartId: reportId, colors: exports.theme.chartColors, containerStyle: {
1155
+ width: 'calc(100vw - 80px)',
1156
+ height: data.chartType === 'table' ? 600 : 400,
1216
1157
  } }), (0, jsx_runtime_1.jsxs)("div", { style: {
1217
- display: "flex",
1218
- alignItems: "center",
1158
+ display: 'flex',
1159
+ alignItems: 'center',
1219
1160
  gap: 16,
1220
1161
  marginTop: 20,
1221
- }, children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: "Edit chart", onClick: () => setIsOpen(true) }), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: "Edit query", onClick: () => setIsEditQueryOpen(true) }), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: "Open query", onClick: () => {
1222
- // setActiveQuery(data.queryString);
1223
- dispatch({ type: "SET_ACTIVE_QUERY", payload: data.queryString });
1224
- // setActiveComponent("SQL editor");
1225
- if (state.navigateToDashboardBuilder) {
1226
- state.navigateToDashboardBuilder();
1227
- }
1228
- } }), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: "Delete", onClick: deleteReport })] }), data.chartType !== "table" && ((0, jsx_runtime_1.jsx)(react_2.Table
1229
- // containerStyle={{ width: "80vw", height: 1100 }}
1230
- , {
1231
- // containerStyle={{ width: "80vw", height: 1100 }}
1232
- containerStyle: { height: 400, width: "100%", marginTop: 24 }, chartId: reportId })), (0, jsx_runtime_1.jsx)(EditVisualizationModal, { isOpen: isOpen, setIsOpen: setIsOpen, report: data, data: data.rows, query: data.queryString, columns: data.columns, fields: data.fields }), (0, jsx_runtime_1.jsx)(EditQueryModal, { theme: exports.theme, ModalComponent: ModalComponent, query: data.queryString, report: data, isOpen: isEditQueryOpen, setIsOpen: setIsEditQueryOpen, updateQuery: updateQuery, ButtonComponent: ButtonComponent })] }));
1162
+ }, children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: "Edit chart", onClick: () => setIsOpen(true) }), state.navigateToDashboardBuilder && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: "Edit query", onClick: () => {
1163
+ dispatch({ type: 'SET_ACTIVE_QUERY', payload: data.queryString });
1164
+ dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: data });
1165
+ state.navigateToDashboardBuilder();
1166
+ } })), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: "Delete", onClick: deleteReport })] }), data.chartType !== 'table' && ((0, jsx_runtime_1.jsx)(react_2.Table, { containerStyle: { height: 400, width: '100%', marginTop: 24 }, chartId: reportId })), (0, jsx_runtime_1.jsx)(EditVisualizationModal, { isOpen: isOpen, setIsOpen: setIsOpen, report: data, isEditMode: !!state.activeQuery, data: data.rows, query: data.queryString, columns: data.columns, fields: data.fields })] }));
1233
1167
  }
1234
- function EditQueryModal({ query, report, isOpen, setIsOpen, updateQuery, ModalComponent, ButtonComponent, theme, }) {
1235
- const [newQuery, setNewQuery] = (0, react_1.useState)(query);
1236
- const hasQueryChanged = (0, react_1.useMemo)(() => {
1237
- return newQuery !== query;
1238
- }, [newQuery]);
1239
- if (!query || !report) {
1240
- return null;
1241
- }
1242
- return ((0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, close: () => {
1243
- setIsOpen(false);
1244
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
1245
- display: "flex",
1246
- alignItems: "center",
1247
- justifyContent: "center",
1248
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: { background: "white" }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1249
- fontFamily: theme.fontFamily,
1250
- color: theme.primaryTextColor,
1251
- fontSize: 20,
1252
- fontWeight: 600,
1253
- }, children: "Edit query" }), (0, jsx_runtime_1.jsx)("div", { style: {
1254
- background: theme.backgroundColor,
1255
- height: 422,
1256
- maxHeight: 422,
1257
- marginTop: 24,
1258
- minHeight: 422,
1259
- width: 722,
1260
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
1261
- background: theme.editorBackgroundColor || theme.backgroundColor,
1262
- marginRight: theme.padding,
1263
- borderBottomRightRadius: 4,
1264
- borderBottomLeftRadius: 4,
1265
- borderTopRightRadius: 4,
1266
- borderTopLeftRadius: 4,
1267
- overflow: "hidden",
1268
- }, children: (0, jsx_runtime_1.jsx)(react_3.default, { height: "400px", defaultLanguage: "pgsql", defaultValue: "", value: newQuery, loading: (0, jsx_runtime_1.jsx)("div", {}), options: {
1269
- wordWrap: "on",
1270
- minimap: {
1271
- enabled: false,
1272
- },
1273
- padding: { top: 16 },
1274
- }, onChange: (query) => setNewQuery(query), beforeMount: (monaco) => defineEditorTheme(monaco, theme), onMount: setEditorTheme }) }) }), (0, jsx_runtime_1.jsx)("button", {
1275
- // disabled={isSubmitting}
1276
- theme: theme, onClick: hasQueryChanged
1277
- ? () => updateQuery(report?._id, newQuery)
1278
- : undefined, style: {
1279
- borderRadius: 6,
1280
- backgroundColor: hasQueryChanged
1281
- ? "#384151"
1282
- : "rgba(56, 65, 81, 0.7)",
1283
- // padding: "0.625rem 1rem", // combined px-4 and py-2.5
1284
- fontSize: "14px",
1285
- fontWeight: "600",
1286
- color: "white",
1287
- paddingLeft: 12,
1288
- paddingRight: 12,
1289
- paddingTop: 6,
1290
- paddingBottom: 6,
1291
- // Hover and focus styles can't be applied directly with inline styles. You'll need JavaScript or external CSS for that.
1292
- }, children: "Save changes" })] }) }) }));
1293
- }
1294
- function EditVisualizationModal({ isOpen, setIsOpen, report, columns, data, fields, query, }) {
1295
- // const [tables] = useContext(TablesContext);
1296
- // const [organization] = useContext(OrganizationContext);
1168
+ function EditVisualizationModal({ isOpen, setIsOpen, report, data, isEditMode, }) {
1297
1169
  if (!report && !data?.length) {
1298
1170
  return null;
1299
1171
  }
1300
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isOpen && ((0, jsx_runtime_1.jsxs)("div", { className: "fixed inset-0 overflow-y-auto relative", style: { zIndex: 120 }, children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 bg-black/30", "aria-hidden": "true", onClick: () => setIsOpen(false) }), (0, jsx_runtime_1.jsx)("div", { className: "flex min-h-full items-center justify-center p-4", children: (0, jsx_runtime_1.jsx)("div", { className: "bg-white px-7 py-7 rounded-lg", children: (0, jsx_runtime_1.jsx)(react_2.ChartEditor, { isOpen: isOpen, setIsOpen: setIsOpen, chartId: report._id, admin: true }) }) })] })) }));
1172
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isOpen && ((0, jsx_runtime_1.jsxs)("div", { className: "inset-0 overflow-y-auto relative", style: { zIndex: 120 }, children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 bg-black/30", "aria-hidden": "true", onClick: () => setIsOpen(false) }), (0, jsx_runtime_1.jsx)("div", { className: "flex min-h-full items-center justify-center p-4", children: (0, jsx_runtime_1.jsx)("div", { className: "bg-white px-7 py-7 rounded-lg", children: (0, jsx_runtime_1.jsx)(react_2.ChartEditor, { isOpen: isOpen, setIsOpen: setIsOpen, isEditMode: isEditMode, chartId: report._id, admin: true }) }) })] })) }));
1301
1173
  }
1302
1174
  function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, ModalComponent, SelectComponent, OrganizationSelectComponent, organizationId, queryEndpoint, queryHeaders, withCredentials, }) {
1303
1175
  const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
1304
- // const [organization, setOrganization] = useContext(OrganizationContext);
1305
- // const [client] = useContext(ClientContext);
1306
- // const [environment] = useContext(EnvironmentContext);
1307
- // const [reportId, setReportId] = useContext(ReportIdContext);
1308
1176
  let [isOpen, setIsOpen] = (0, react_1.useState)(false);
1309
1177
  const [isEditQueryOpen, setIsEditQueryOpen] = (0, react_1.useState)(false);
1310
- // const [activeComponent, setActiveComponent] = useContext(
1311
- // ActiveComponentContext
1312
- // );
1313
1178
  const updateQuery = async (dashboardItemId, query) => {
1314
1179
  if (!state.client || !dashboardItemId || !query) {
1315
1180
  return;
@@ -1317,53 +1182,51 @@ function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, ModalCompone
1317
1182
  let responseData;
1318
1183
  if (queryEndpoint) {
1319
1184
  const response = await fetch(queryEndpoint, {
1320
- method: "POST",
1185
+ method: 'POST',
1321
1186
  headers: {
1322
1187
  ...queryHeaders,
1323
- "Content-Type": "application/json",
1188
+ 'Content-Type': 'application/json',
1324
1189
  },
1325
1190
  body: JSON.stringify({
1326
1191
  metadata: organizationId
1327
1192
  ? {
1328
1193
  orgId: organizationId,
1329
- task: "edit_query",
1194
+ task: 'edit_query',
1330
1195
  id: state.reportId,
1331
1196
  query,
1332
1197
  }
1333
- : { task: "edit_query", id: state.reportId, query },
1198
+ : { task: 'edit_query', id: state.reportId, query },
1334
1199
  }),
1335
- credentials: withCredentials ? "include" : "omit",
1200
+ credentials: withCredentials ? 'include' : 'omit',
1336
1201
  });
1337
1202
  responseData = await response.json();
1338
1203
  }
1339
1204
  else {
1340
- const url = `https://quill-344421.uc.r.appspot.com/updatequery/${state.client._id}/${organizationId}/`;
1341
- // const url = `https://quill-344421.uc.r.appspot.com/updatequery/${state.client._id}/${organizationId}/`;
1205
+ const url = `${constants_1.QUILL_SERVER}/updatequery/${state.client._id}/${organizationId}/`;
1342
1206
  const requestBody = {
1343
1207
  dashboardItemId,
1344
1208
  query,
1345
1209
  };
1346
1210
  const response = await fetch(url, {
1347
- method: "POST",
1211
+ method: 'POST',
1348
1212
  headers: {
1349
- "Content-Type": "application/json",
1350
- Authorization: "Bearer ",
1213
+ 'Content-Type': 'application/json',
1214
+ Authorization: 'Bearer ',
1351
1215
  environment: state.environment || undefined,
1352
1216
  },
1353
1217
  body: JSON.stringify(requestBody),
1354
1218
  });
1355
- // To get JSON data from the response:
1356
1219
  responseData = await response.json();
1357
1220
  }
1358
1221
  if (responseData) {
1359
1222
  if (responseData.error) {
1360
- alert(`Failed to save query. ${typeof responseData.error === "string"
1223
+ alert(`Failed to save query. ${typeof responseData.error === 'string'
1361
1224
  ? responseData.error
1362
- : responseData.error?.routine === "errorMissingColumn"
1225
+ : responseData.error?.routine === 'errorMissingColumn'
1363
1226
  ? "A column was referenced that doesn't exist."
1364
1227
  : responseData.error?.routine
1365
1228
  ? responseData.error?.routine
1366
- : "Error parsing SQL query"}`);
1229
+ : 'Error parsing SQL query'}`);
1367
1230
  return;
1368
1231
  }
1369
1232
  setIsEditQueryOpen(false);
@@ -1376,37 +1239,44 @@ function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, ModalCompone
1376
1239
  if (!state.client) {
1377
1240
  return;
1378
1241
  }
1242
+ if (!confirm('Are you sure?')) {
1243
+ return;
1244
+ }
1379
1245
  let responseData;
1380
1246
  if (queryEndpoint) {
1381
1247
  const response = await fetch(queryEndpoint, {
1382
- method: "POST",
1248
+ method: 'POST',
1383
1249
  headers: {
1384
1250
  ...queryHeaders,
1385
- "Content-Type": "application/json",
1251
+ 'Content-Type': 'application/json',
1386
1252
  },
1387
1253
  body: JSON.stringify({
1388
1254
  metadata: organizationId
1389
1255
  ? {
1390
1256
  orgId: organizationId,
1391
- task: "delete",
1392
- id: state.reportId,
1257
+ task: 'delete',
1258
+ dashboardItemId: state.reportId,
1393
1259
  clientId: state.client._id,
1394
1260
  }
1395
- : { task: "delete", id: state.reportId, clientId: state.client._id },
1261
+ : {
1262
+ task: 'delete',
1263
+ dashboardItemId: state.reportId,
1264
+ clientId: state.client._id,
1265
+ },
1396
1266
  }),
1397
- credentials: withCredentials ? "include" : "omit", // If withCredentials is true, set to 'include'. Otherwise, set to 'omit'.
1267
+ credentials: withCredentials ? 'include' : 'omit', // If withCredentials is true, set to 'include'. Otherwise, set to 'omit'.
1398
1268
  });
1399
1269
  responseData = await response.json(); // If the server returns JSON data
1400
1270
  }
1401
1271
  else {
1402
- const url = `https://quill-344421.uc.r.appspot.com/deletedash/${state.client._id}/${organizationId}/`;
1272
+ const url = `${constants_1.QUILL_SERVER}/deletedash/${state.client._id}/${organizationId}/`;
1403
1273
  const requestBody = {
1404
1274
  dashboardItemId: state.reportId,
1405
1275
  };
1406
1276
  const response = await fetch(url, {
1407
- method: "POST",
1277
+ method: 'POST',
1408
1278
  headers: {
1409
- "Content-Type": "application/json",
1279
+ 'Content-Type': 'application/json',
1410
1280
  environment: state.environment || undefined,
1411
1281
  },
1412
1282
  body: JSON.stringify(requestBody),
@@ -1415,7 +1285,7 @@ function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, ModalCompone
1415
1285
  responseData = await response.json();
1416
1286
  }
1417
1287
  if (responseData) {
1418
- dispatch({ type: "SET_ACTIVE_COMPONENT", payload: "Dashboards" });
1288
+ dispatch({ type: 'SET_ACTIVE_COMPONENT', payload: 'Dashboards' });
1419
1289
  }
1420
1290
  };
1421
1291
  return ((0, jsx_runtime_1.jsx)(Report, { reportId: state.reportId, updateQuery: updateQuery, isOpen: isOpen, setIsOpen: setIsOpen, isEditQueryOpen: isEditQueryOpen, setIsEditQueryOpen: setIsEditQueryOpen, deleteReport: deleteReport, SecondaryButtonComponent: SecondaryButtonComponent, ButtonComponent: ButtonComponent, ModalComponent: ModalComponent, SelectComponent: SelectComponent, OrganizationSelectComponent: OrganizationSelectComponent }));
@@ -1426,13 +1296,13 @@ const measuringConfig = {
1426
1296
  strategy: core_1.MeasuringStrategy.Always,
1427
1297
  },
1428
1298
  };
1429
- function ReorderableList({ initialItems, itemMap, ButtonComponent, closeModal, }) {
1299
+ function ReorderableList({ initialItems, client, itemMap, ButtonComponent, closeModal, onSave, }) {
1430
1300
  const [items, setItems] = (0, react_1.useState)([]);
1431
1301
  // const [client] = useContext(ClientContext);
1432
1302
  const sensors = (0, core_1.useSensors)((0, core_1.useSensor)(core_1.PointerSensor), (0, core_1.useSensor)(core_1.KeyboardSensor, {
1433
1303
  coordinateGetter: sortable_1.sortableKeyboardCoordinates,
1434
1304
  }), (0, core_1.useSensor)(core_1.TouchSensor, {
1435
- activationConstraint: "",
1305
+ activationConstraint: '',
1436
1306
  }));
1437
1307
  (0, react_1.useEffect)(() => {
1438
1308
  setItems(initialItems
@@ -1455,10 +1325,10 @@ function ReorderableList({ initialItems, itemMap, ButtonComponent, closeModal, }
1455
1325
  return;
1456
1326
  }
1457
1327
  try {
1458
- const response = await fetch("https://quill-344421.uc.r.appspot.com/dashorder/", {
1459
- method: "POST",
1328
+ const response = await fetch(`${constants_1.QUILL_SERVER}/dashorder/`, {
1329
+ method: 'POST',
1460
1330
  headers: {
1461
- "Content-Type": "application/json",
1331
+ 'Content-Type': 'application/json',
1462
1332
  },
1463
1333
  body: JSON.stringify({
1464
1334
  publicKey: client._id,
@@ -1467,9 +1337,10 @@ function ReorderableList({ initialItems, itemMap, ButtonComponent, closeModal, }
1467
1337
  });
1468
1338
  if (!response.ok) {
1469
1339
  const errorData = await response.json();
1470
- throw new Error(`Error: ${errorData.error || "Unknown error"}`);
1340
+ throw new Error(`Error: ${errorData.error || 'Unknown error'}`);
1471
1341
  }
1472
1342
  const data = await response.json();
1343
+ onSave();
1473
1344
  closeModal();
1474
1345
  }
1475
1346
  catch (error) {
@@ -1477,19 +1348,19 @@ function ReorderableList({ initialItems, itemMap, ButtonComponent, closeModal, }
1477
1348
  }
1478
1349
  };
1479
1350
  return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(core_1.DndContext, { sensors: sensors, collisionDetection: core_1.closestCenter, onDragEnd: handleDragEnd, measuring: measuringConfig, children: (0, jsx_runtime_1.jsx)(sortable_1.SortableContext, { items: items, strategy: sortable_1.verticalListSortingStrategy, children: (0, jsx_runtime_1.jsxs)("div", { style: {
1480
- background: "white",
1481
- position: "fixed",
1482
- width: "100%",
1483
- height: "calc(100% - 40px)",
1484
- overflowY: "scroll",
1485
- overflowX: "hidden",
1351
+ background: 'white',
1352
+ position: 'fixed',
1353
+ width: '100%',
1354
+ height: 'calc(100% - 40px)',
1355
+ overflowY: 'scroll',
1356
+ overflowX: 'hidden',
1486
1357
  maxWidth: 700,
1487
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 80 } }), items.map((id) => ((0, jsx_runtime_1.jsx)(SortableItem, { id: id, name: itemMap?.get(id).name }, id))), (0, jsx_runtime_1.jsx)("div", { style: { height: 100, width: "100%" } })] }) }) }), (0, jsx_runtime_1.jsx)("div", { style: {
1358
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 80 } }), items.map((id) => ((0, jsx_runtime_1.jsx)(SortableItem, { id: id, name: itemMap?.get(id).name }, id))), (0, jsx_runtime_1.jsx)("div", { style: { height: 100, width: '100%' } })] }) }) }), (0, jsx_runtime_1.jsx)("div", { style: {
1488
1359
  height: 80,
1489
1360
  paddingTop: 20,
1490
- width: "100%",
1491
- background: "white",
1492
- position: "absolute",
1361
+ width: '100%',
1362
+ background: 'white',
1363
+ position: 'absolute',
1493
1364
  bottom: -20,
1494
1365
  left: 0,
1495
1366
  right: 0,
@@ -1519,53 +1390,45 @@ function SortableItem({ id, name }) {
1519
1390
  const style = {
1520
1391
  transform: utilities_1.CSS.Translate.toString(transform),
1521
1392
  transition,
1522
- display: "flex",
1523
- justifyContent: "space-between",
1524
- alignItems: "center",
1525
- borderRadius: "10px",
1526
- border: "1px solid #E7E7E7",
1527
- boxShadow: "0px 2px 8px 0px rgba(56, 65, 81, 0.08)",
1528
- // padding: "20px",
1529
- // height: `${height}px`,
1530
- cursor: "grab",
1531
- userSelect: "none",
1393
+ display: 'flex',
1394
+ justifyContent: 'space-between',
1395
+ alignItems: 'center',
1396
+ borderRadius: '10px',
1397
+ border: '1px solid #E7E7E7',
1398
+ boxShadow: '0px 2px 8px 0px rgba(56, 65, 81, 0.08)',
1399
+ cursor: 'grab',
1400
+ userSelect: 'none',
1532
1401
  marginBottom: 20,
1533
- background: "white",
1402
+ background: 'white',
1534
1403
  };
1535
1404
  return ((0, jsx_runtime_1.jsx)("div", { ref: setNodeRef, style: style, ...attributes, children: (0, jsx_runtime_1.jsxs)("div", { style: {
1536
- // border: "1px solid grey",
1537
- // background: "grey",
1538
- // color: "white",
1539
- // borderRadius: "10px",
1540
- // padding: "15px",
1541
- cursor: "pointer",
1542
- // background: "red",
1543
- width: "100%",
1544
- display: "flex",
1545
- flexDirection: "row",
1546
- alignItems: "center",
1547
- justifyContent: "space-between",
1405
+ cursor: 'pointer',
1406
+ width: '100%',
1407
+ display: 'flex',
1408
+ flexDirection: 'row',
1409
+ alignItems: 'center',
1410
+ justifyContent: 'space-between',
1548
1411
  height: 260,
1549
1412
  }, ...listeners, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
1550
- display: "flex",
1551
- flexDirection: "column",
1552
- justifyContent: "space-between",
1413
+ display: 'flex',
1414
+ flexDirection: 'column',
1415
+ justifyContent: 'space-between',
1553
1416
  height: 260,
1554
1417
  paddingTop: 20,
1555
1418
  paddingBottom: 20,
1556
- width: "100%",
1419
+ width: '100%',
1557
1420
  }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1558
1421
  minWidth: 600,
1559
- width: "100%",
1422
+ width: '100%',
1560
1423
  paddingLeft: 20,
1561
1424
  fontSize: 18,
1562
- fontWeight: "500",
1425
+ fontWeight: '500',
1563
1426
  }, children: name }), (0, jsx_runtime_1.jsx)(react_2.Chart, { chartId: id, containerStyle: {
1564
1427
  height: 180,
1565
- width: "100%",
1428
+ width: '100%',
1566
1429
  } })] }), (0, jsx_runtime_1.jsx)("div", { style: {
1567
- display: "flex",
1568
- flexDirection: "column",
1430
+ display: 'flex',
1431
+ flexDirection: 'column',
1569
1432
  paddingRight: 20,
1570
1433
  paddingLeft: 20,
1571
1434
  }, children: (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "#6D727E", height: 24, width: 24, children: (0, jsx_runtime_1.jsx)("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" }) }) })] }) }));