@apia/dashboard-controller 2.0.9 → 2.0.11
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.
- package/dist/actions/basicAction.d.ts +15 -0
- package/dist/actions/basicAction.d.ts.map +1 -0
- package/dist/actions/basicAction.js +40 -0
- package/dist/actions/basicAction.js.map +1 -0
- package/dist/actions/externalFirePanelAction.d.ts +6 -0
- package/dist/actions/externalFirePanelAction.d.ts.map +1 -0
- package/dist/actions/externalFirePanelAction.js +12 -0
- package/dist/actions/externalFirePanelAction.js.map +1 -0
- package/dist/actions/firePanelAction.d.ts +6 -0
- package/dist/actions/firePanelAction.d.ts.map +1 -0
- package/dist/actions/firePanelAction.js +75 -0
- package/dist/actions/firePanelAction.js.map +1 -0
- package/dist/actions/usePanelActions.d.ts +63 -0
- package/dist/actions/usePanelActions.d.ts.map +1 -0
- package/dist/actions/usePanelActions.js +55 -0
- package/dist/actions/usePanelActions.js.map +1 -0
- package/dist/actions/usePanelIsLoading.d.ts +4 -0
- package/dist/actions/usePanelIsLoading.d.ts.map +1 -0
- package/dist/actions/usePanelIsLoading.js +14 -0
- package/dist/actions/usePanelIsLoading.js.map +1 -0
- package/dist/actions/usePanelNetworkState.d.ts +8 -0
- package/dist/actions/usePanelNetworkState.d.ts.map +1 -0
- package/dist/actions/usePanelNetworkState.js +21 -0
- package/dist/actions/usePanelNetworkState.js.map +1 -0
- package/dist/common/usePanelIdentity.d.ts +10 -0
- package/dist/common/usePanelIdentity.d.ts.map +1 -0
- package/dist/common/usePanelIdentity.js +12 -0
- package/dist/common/usePanelIdentity.js.map +1 -0
- package/dist/config/parametersStore.d.ts +15 -0
- package/dist/config/parametersStore.d.ts.map +1 -0
- package/dist/config/parametersStore.js +25 -0
- package/dist/config/parametersStore.js.map +1 -0
- package/dist/config/saveParameters.d.ts +11 -0
- package/dist/config/saveParameters.d.ts.map +1 -0
- package/dist/config/saveParameters.js +16 -0
- package/dist/config/saveParameters.js.map +1 -0
- package/dist/config/usePanelConfig.js +22 -0
- package/dist/config/usePanelConfig.js.map +1 -0
- package/dist/config/usePanelParametersSelector.d.ts +25 -0
- package/dist/config/usePanelParametersSelector.d.ts.map +1 -0
- package/dist/config/usePanelParametersSelector.js +17 -0
- package/dist/config/usePanelParametersSelector.js.map +1 -0
- package/dist/dashboard/DashboardContext.d.ts +6 -0
- package/dist/dashboard/DashboardContext.d.ts.map +1 -0
- package/dist/dashboard/DashboardContext.js +12 -0
- package/dist/dashboard/DashboardContext.js.map +1 -0
- package/dist/dashboard/DashboardPanel.d.ts +45 -0
- package/dist/dashboard/DashboardPanel.d.ts.map +1 -0
- package/dist/dashboard/DashboardPanel.js +236 -0
- package/dist/dashboard/DashboardPanel.js.map +1 -0
- package/dist/dashboard/DashboardPanelContext.d.ts +6 -0
- package/dist/dashboard/DashboardPanelContext.d.ts.map +1 -0
- package/dist/dashboard/DashboardPanelContext.js +12 -0
- package/dist/dashboard/DashboardPanelContext.js.map +1 -0
- package/dist/dashboard/DashboardPanelsBootstraper.d.ts +33 -0
- package/dist/dashboard/DashboardPanelsBootstraper.d.ts.map +1 -0
- package/dist/dashboard/DashboardPanelsBootstraper.js +135 -0
- package/dist/dashboard/DashboardPanelsBootstraper.js.map +1 -0
- package/dist/dashboard/DashboardRouter.d.ts +30 -0
- package/dist/dashboard/DashboardRouter.d.ts.map +1 -0
- package/dist/dashboard/DashboardRouter.js +74 -0
- package/dist/dashboard/DashboardRouter.js.map +1 -0
- package/dist/dashboard/PanelNotFound.js +14 -0
- package/dist/dashboard/PanelNotFound.js.map +1 -0
- package/dist/dashboard/dashboard.d.ts +26 -0
- package/dist/dashboard/dashboard.d.ts.map +1 -0
- package/dist/dashboard/dashboard.js +167 -0
- package/dist/dashboard/dashboard.js.map +1 -0
- package/dist/eventsController/eventsController.d.ts +11 -0
- package/dist/eventsController/eventsController.d.ts.map +1 -0
- package/dist/eventsController/eventsController.js +57 -0
- package/dist/eventsController/eventsController.js.map +1 -0
- package/dist/eventsController/types.d.ts +21 -0
- package/dist/eventsController/types.d.ts.map +1 -0
- package/dist/eventsController/usePanelFireEvent.d.ts +13 -0
- package/dist/eventsController/usePanelFireEvent.d.ts.map +1 -0
- package/dist/eventsController/usePanelFireEvent.js +21 -0
- package/dist/eventsController/usePanelFireEvent.js.map +1 -0
- package/dist/eventsController/usePanelOnEvent.d.ts +12 -0
- package/dist/eventsController/usePanelOnEvent.d.ts.map +1 -0
- package/dist/eventsController/usePanelOnEvent.js +14 -0
- package/dist/eventsController/usePanelOnEvent.js.map +1 -0
- package/dist/index.d.ts +23 -409
- package/dist/index.js +22 -2201
- package/dist/index.js.map +1 -1
- package/dist/panelsStore/createPanelStore.d.ts +16 -0
- package/dist/panelsStore/createPanelStore.d.ts.map +1 -0
- package/dist/panelsStore/createPanelStore.js +58 -0
- package/dist/panelsStore/createPanelStore.js.map +1 -0
- package/dist/panelsStore/panelsStore.js +59 -0
- package/dist/panelsStore/panelsStore.js.map +1 -0
- package/dist/panelsStore/usePanelSelector.js +32 -0
- package/dist/panelsStore/usePanelSelector.js.map +1 -0
- package/dist/panelsUtil/usePanelChangeTitle.d.ts +5 -0
- package/dist/panelsUtil/usePanelChangeTitle.d.ts.map +1 -0
- package/dist/panelsUtil/usePanelChangeTitle.js +23 -0
- package/dist/panelsUtil/usePanelChangeTitle.js.map +1 -0
- package/dist/panelsUtil/usePanelTitleAction.js +34 -0
- package/dist/panelsUtil/usePanelTitleAction.js.map +1 -0
- package/dist/position/usePanelPosition.d.ts +13 -0
- package/dist/position/usePanelPosition.d.ts.map +1 -0
- package/dist/position/usePanelPosition.js +40 -0
- package/dist/position/usePanelPosition.js.map +1 -0
- package/dist/splash/events/Dragleave.js +15 -0
- package/dist/splash/events/Dragleave.js.map +1 -0
- package/dist/splash/events/Dragover.js +120 -0
- package/dist/splash/events/Dragover.js.map +1 -0
- package/dist/splash/events/Dragstart.js +65 -0
- package/dist/splash/events/Dragstart.js.map +1 -0
- package/dist/splash/events/Drop.js +60 -0
- package/dist/splash/events/Drop.js.map +1 -0
- package/dist/splash/panels/DefaultPanelWrapper/NetworkState.js +28 -0
- package/dist/splash/panels/DefaultPanelWrapper/NetworkState.js.map +1 -0
- package/dist/splash/panels/DefaultPanelWrapper/PanelButtons.js +16 -0
- package/dist/splash/panels/DefaultPanelWrapper/PanelButtons.js.map +1 -0
- package/dist/splash/panels/DefaultPanelWrapper/RefreshButton.js +35 -0
- package/dist/splash/panels/DefaultPanelWrapper/RefreshButton.js.map +1 -0
- package/dist/splash/panels/DefaultPanelWrapper/SettingsButton.js +45 -0
- package/dist/splash/panels/DefaultPanelWrapper/SettingsButton.js.map +1 -0
- package/dist/splash/panels/DefaultPanelWrapper/defaultPanelWrapperStyles.js +103 -0
- package/dist/splash/panels/DefaultPanelWrapper/defaultPanelWrapperStyles.js.map +1 -0
- package/dist/splash/panels/DefaultPanelWrapper/index.js +57 -0
- package/dist/splash/panels/DefaultPanelWrapper/index.js.map +1 -0
- package/dist/splash/panels/LandingPagePanelWrapper.d.ts +6 -0
- package/dist/splash/panels/LandingPagePanelWrapper.d.ts.map +1 -0
- package/dist/splash/panels/LandingPagePanelWrapper.js +52 -0
- package/dist/splash/panels/LandingPagePanelWrapper.js.map +1 -0
- package/dist/splash/panels/PanelContext/PanelFooter.js +71 -0
- package/dist/splash/panels/PanelContext/PanelFooter.js.map +1 -0
- package/dist/splash/panels/PanelContext/index.d.ts +31 -0
- package/dist/splash/panels/PanelContext/index.d.ts.map +1 -0
- package/dist/splash/panels/PanelContext/index.js +69 -0
- package/dist/splash/panels/PanelContext/index.js.map +1 -0
- package/dist/splash/panels/PanelContext/usePanelContextLayout.d.ts +6 -0
- package/dist/splash/panels/PanelContext/usePanelContextLayout.d.ts.map +1 -0
- package/dist/splash/panels/PanelContext/usePanelContextLayout.js +38 -0
- package/dist/splash/panels/PanelContext/usePanelContextLayout.js.map +1 -0
- package/dist/splash/panels/PanelContext/usePanelFooter.js +38 -0
- package/dist/splash/panels/PanelContext/usePanelFooter.js.map +1 -0
- package/dist/splash/panels/PanelContext/useYieldPanelIsReady.d.ts +45 -0
- package/dist/splash/panels/PanelContext/useYieldPanelIsReady.d.ts.map +1 -0
- package/dist/splash/panels/PanelContext/useYieldPanelIsReady.js +12 -0
- package/dist/splash/panels/PanelContext/useYieldPanelIsReady.js.map +1 -0
- package/dist/splash/panels/PanelErrorBoundary.js +53 -0
- package/dist/splash/panels/PanelErrorBoundary.js.map +1 -0
- package/dist/splash/panels/PanelIdentifier.d.ts +16 -0
- package/dist/splash/panels/PanelIdentifier.d.ts.map +1 -0
- package/dist/splash/panels/PanelIdentifier.js +19 -0
- package/dist/splash/panels/PanelIdentifier.js.map +1 -0
- package/dist/splash/util/DragAndDrop.js +243 -0
- package/dist/splash/util/DragAndDrop.js.map +1 -0
- package/dist/splash/util/getColumnAreas.js +19 -0
- package/dist/splash/util/getColumnAreas.js.map +1 -0
- package/dist/splash/util/isCursorInArea.js +13 -0
- package/dist/splash/util/isCursorInArea.js.map +1 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/util.d.ts +8 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +29 -0
- package/dist/util.js.map +1 -0
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,2202 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return /* @__PURE__ */ jsx(PanelIdentifierContext.Provider, { value: contextValue, children });
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function usePanelIdentity() {
|
|
27
|
-
const context = useContext(PanelIdentifierContext);
|
|
28
|
-
if (!context)
|
|
29
|
-
throw new Error("Trying to access an unexistent PanelIdentifierContext");
|
|
30
|
-
return context;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
class PanelPositionEmitter extends EventEmitter {
|
|
34
|
-
}
|
|
35
|
-
const panelPositionEmitter = new PanelPositionEmitter();
|
|
36
|
-
function usePanelPosition() {
|
|
37
|
-
const { panelId } = usePanelIdentity();
|
|
38
|
-
const [position, setPosition] = useState();
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
return panelPositionEmitter.on("panelUpdate", (ev) => {
|
|
41
|
-
if (ev.panelId === panelId)
|
|
42
|
-
setPosition({ containerId: ev.containerId, position: ev.newPosition });
|
|
43
|
-
});
|
|
44
|
-
}, [panelId]);
|
|
45
|
-
return position;
|
|
46
|
-
}
|
|
47
|
-
async function updatePanelPosition(panelId, containerId, newPosition) {
|
|
48
|
-
const result = await ApiaApi.post(
|
|
49
|
-
makeApiaUrl({
|
|
50
|
-
action: "panelMove",
|
|
51
|
-
pnlId: panelId,
|
|
52
|
-
containerId,
|
|
53
|
-
newPosition
|
|
54
|
-
})
|
|
55
|
-
);
|
|
56
|
-
const hasUpdated = result?.data && !result.hasError && !result.hasMessages;
|
|
57
|
-
if (hasUpdated)
|
|
58
|
-
panelPositionEmitter.emit("panelUpdate", {
|
|
59
|
-
panelId,
|
|
60
|
-
containerId,
|
|
61
|
-
newPosition
|
|
62
|
-
});
|
|
63
|
-
return hasUpdated;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const DashboardPanelContext = createContext(null);
|
|
67
|
-
function useDashboardPanel() {
|
|
68
|
-
const context = useContext(DashboardPanelContext);
|
|
69
|
-
if (!context)
|
|
70
|
-
throw new Error("There is no DashboardPanelContext");
|
|
71
|
-
return context;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
var __defProp$7 = Object.defineProperty;
|
|
75
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
76
|
-
var __publicField$7 = (obj, key, value) => {
|
|
77
|
-
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
78
|
-
return value;
|
|
79
|
-
};
|
|
80
|
-
const panelActionsEmitter = new class PanelActionsEmitter {
|
|
81
|
-
constructor() {
|
|
82
|
-
__publicField$7(this, "listeners", {});
|
|
83
|
-
__publicField$7(this, "on", (panelId, action, cb) => {
|
|
84
|
-
if (!this.listeners[panelId])
|
|
85
|
-
this.listeners[panelId] = {};
|
|
86
|
-
if (!this.listeners[panelId][action])
|
|
87
|
-
this.listeners[panelId][action] = [];
|
|
88
|
-
this.listeners[panelId][action].push(cb);
|
|
89
|
-
return () => {
|
|
90
|
-
this.listeners[panelId][action] = this.listeners[panelId][action].filter(
|
|
91
|
-
(current) => current !== cb
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
});
|
|
95
|
-
__publicField$7(this, "emit", (panelId, action, data) => {
|
|
96
|
-
this.listeners[panelId]?.[action]?.forEach((current) => {
|
|
97
|
-
window.requestAnimationFrame(() => {
|
|
98
|
-
current({ action, panelId, data });
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}();
|
|
104
|
-
function usePanelActions(actionsHandler) {
|
|
105
|
-
const { panelId } = usePanelIdentity();
|
|
106
|
-
useMount(() => {
|
|
107
|
-
const subscriptions = [];
|
|
108
|
-
Object.entries(actionsHandler ?? {}).forEach(([action, handler]) => {
|
|
109
|
-
subscriptions.push(
|
|
110
|
-
panelActionsEmitter.on(panelId, action, (res) => {
|
|
111
|
-
handler(res.data);
|
|
112
|
-
})
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
return () => {
|
|
116
|
-
subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
const panel = useDashboardPanel();
|
|
120
|
-
return panel.fireAction;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
class PanelNetworkStateEmitter extends EventEmitter {
|
|
124
|
-
}
|
|
125
|
-
const panelNetworkStateEmitter = new PanelNetworkStateEmitter();
|
|
126
|
-
const usePanelNetworkState = () => {
|
|
127
|
-
const [isConnected, setIsConnected] = useState(true);
|
|
128
|
-
const { panelId } = usePanelIdentity();
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
return panelNetworkStateEmitter.on("stateChange", (ev) => {
|
|
131
|
-
if (ev.panelId === panelId && ev.isConnected !== isConnected)
|
|
132
|
-
setIsConnected(ev.isConnected);
|
|
133
|
-
});
|
|
134
|
-
}, [isConnected, panelId]);
|
|
135
|
-
return isConnected;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
var __defProp$6 = Object.defineProperty;
|
|
139
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
140
|
-
var __publicField$6 = (obj, key, value) => {
|
|
141
|
-
__defNormalProp$6(obj, key + "" , value);
|
|
142
|
-
return value;
|
|
143
|
-
};
|
|
144
|
-
function identifierAfitsOnB(a, b) {
|
|
145
|
-
for (const key of Object.keys(a)) {
|
|
146
|
-
if (a[key] !== b[key])
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
const eventsController = new class EventsController {
|
|
152
|
-
constructor() {
|
|
153
|
-
__publicField$6(this, "callbacks", []);
|
|
154
|
-
}
|
|
155
|
-
broadcast(eventType, payload) {
|
|
156
|
-
const origin = {
|
|
157
|
-
panelId: "broadcast",
|
|
158
|
-
panelName: "broadcast",
|
|
159
|
-
panelType: "broadcast",
|
|
160
|
-
panelTitle: "broadcast"
|
|
161
|
-
};
|
|
162
|
-
this.callbacks.forEach(({ callback, ...current }) => {
|
|
163
|
-
if (eventType === current.eventType) {
|
|
164
|
-
callback({ ...origin, eventType, payload });
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
fireEvent(origin, eventType, payload) {
|
|
169
|
-
if ([origin.panelId, origin.panelName, origin.panelType].includes("*"))
|
|
170
|
-
throw new Error(
|
|
171
|
-
"Broadcast is not allowed through fireEvent, use broadcast instead"
|
|
172
|
-
);
|
|
173
|
-
this.callbacks.forEach(({ callback, ...current }) => {
|
|
174
|
-
if (identifierAfitsOnB(current, { ...origin, eventType })) {
|
|
175
|
-
callback({ ...origin, eventType, payload });
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
onEvent(distinction, callback) {
|
|
180
|
-
const register = {
|
|
181
|
-
...distinction,
|
|
182
|
-
callback
|
|
183
|
-
};
|
|
184
|
-
this.callbacks.push(register);
|
|
185
|
-
return () => {
|
|
186
|
-
this.callbacks = this.callbacks.filter((current) => {
|
|
187
|
-
return current !== register;
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
}();
|
|
192
|
-
|
|
193
|
-
function usePanelFireEvent() {
|
|
194
|
-
const { panelId, panelName, panelType, panelTitle } = usePanelIdentity();
|
|
195
|
-
const fireEvent = useCallback(
|
|
196
|
-
(eventType, payload) => {
|
|
197
|
-
eventsController.fireEvent(
|
|
198
|
-
{ panelId, panelName, panelType, panelTitle },
|
|
199
|
-
eventType,
|
|
200
|
-
payload
|
|
201
|
-
);
|
|
202
|
-
},
|
|
203
|
-
[panelId, panelName, panelType, panelTitle]
|
|
204
|
-
);
|
|
205
|
-
return fireEvent;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function usePanelOnEvent(distinction, callback) {
|
|
209
|
-
useEffect(() => {
|
|
210
|
-
const unsuscriber = eventsController.onEvent(distinction, callback);
|
|
211
|
-
return () => {
|
|
212
|
-
unsuscriber();
|
|
213
|
-
};
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function changePanelTitle(panelId, newTitle) {
|
|
218
|
-
eventsController.fireEvent(
|
|
219
|
-
{ panelId },
|
|
220
|
-
"changeTitle",
|
|
221
|
-
newTitle
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
function usePanelChangeTitle() {
|
|
225
|
-
const fireEvent = usePanelFireEvent();
|
|
226
|
-
return useCallback(
|
|
227
|
-
(newTitle) => {
|
|
228
|
-
fireEvent("changeTitle", newTitle);
|
|
229
|
-
},
|
|
230
|
-
[fireEvent]
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function changePanelFooter(panelId, footer) {
|
|
235
|
-
eventsController.fireEvent(
|
|
236
|
-
{ panelId },
|
|
237
|
-
"changeFooter",
|
|
238
|
-
footer
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
function usePanelFooter(panelId, { initialData }) {
|
|
242
|
-
const [footer, setFooter] = useState(
|
|
243
|
-
initialData?.footer?.footer?.text ? initialData?.footer?.footer : null
|
|
244
|
-
);
|
|
245
|
-
const handleFooterClick = useCallback(
|
|
246
|
-
(ev) => {
|
|
247
|
-
console.log(ev.type);
|
|
248
|
-
if (footer)
|
|
249
|
-
handleAction(panelId, ev, footer);
|
|
250
|
-
},
|
|
251
|
-
[footer, panelId]
|
|
252
|
-
);
|
|
253
|
-
usePanelOnEvent(
|
|
254
|
-
{ eventType: "changeFooter", panelId },
|
|
255
|
-
(ev) => {
|
|
256
|
-
if (!ev.payload.text)
|
|
257
|
-
setFooter(null);
|
|
258
|
-
else
|
|
259
|
-
setFooter(ev.payload);
|
|
260
|
-
}
|
|
261
|
-
);
|
|
262
|
-
return { footer, handleFooterClick };
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const paramsSlice = createSlice({
|
|
266
|
-
initialState: {},
|
|
267
|
-
name: "panelParameters",
|
|
268
|
-
reducers: {
|
|
269
|
-
udpate(state, {
|
|
270
|
-
payload
|
|
271
|
-
}) {
|
|
272
|
-
if (!state[payload.panelId])
|
|
273
|
-
state[payload.panelId] = {};
|
|
274
|
-
state[payload.panelId] = {
|
|
275
|
-
...state[payload.panelId],
|
|
276
|
-
...payload.parameters
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
const { store, useSelector } = injectReducers({
|
|
282
|
-
panelParameters: paramsSlice.reducer
|
|
283
|
-
});
|
|
284
|
-
const parametersActions = paramsSlice.actions;
|
|
285
|
-
|
|
286
|
-
function saveParameters(panelId, parameters, refresh = true) {
|
|
287
|
-
store.dispatch(parametersActions.udpate({ panelId, parameters }));
|
|
288
|
-
if (refresh) {
|
|
289
|
-
panelActionsEmitter.emit(panelId, "configurationApply", {
|
|
290
|
-
data: parameters
|
|
291
|
-
});
|
|
292
|
-
firePanelAction(panelId, "refresh");
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
const DashboardContext = createContext(null);
|
|
297
|
-
function useDashboardContext() {
|
|
298
|
-
const context = useContext(DashboardContext);
|
|
299
|
-
if (!context)
|
|
300
|
-
throw new Error("There is no Dashboard context");
|
|
301
|
-
return context;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const defaultPanelWrapperStyles = {
|
|
305
|
-
pb: spacing(6),
|
|
306
|
-
"&:last-child": {
|
|
307
|
-
pb: 0
|
|
308
|
-
},
|
|
309
|
-
".panel__container": {
|
|
310
|
-
background: "palette.background.paper",
|
|
311
|
-
border: "1px solid",
|
|
312
|
-
borderColor: "palette.gray.800",
|
|
313
|
-
display: "flex",
|
|
314
|
-
flexDirection: "column",
|
|
315
|
-
borderRadius: "panel",
|
|
316
|
-
boxShadow: "panel"
|
|
317
|
-
},
|
|
318
|
-
".panel__header": {
|
|
319
|
-
alignItems: "center",
|
|
320
|
-
cursor: "grab",
|
|
321
|
-
display: "flex",
|
|
322
|
-
flexWrap: "nowrap",
|
|
323
|
-
fontWeight: "bold",
|
|
324
|
-
justifyContent: "space-between",
|
|
325
|
-
maxWidth: "100%",
|
|
326
|
-
overflow: "hidden",
|
|
327
|
-
backgroundColor: "palette.secondary.light",
|
|
328
|
-
borderBottomRightRadius: "0px !important",
|
|
329
|
-
borderBottomLeftRadius: "0px !important",
|
|
330
|
-
pl: 4,
|
|
331
|
-
py: 4,
|
|
332
|
-
borderRadius: "panel",
|
|
333
|
-
".panel__header__left": {
|
|
334
|
-
alignItems: "center",
|
|
335
|
-
display: "flex",
|
|
336
|
-
gap: 2,
|
|
337
|
-
svg: {
|
|
338
|
-
color: "palette.error.dark"
|
|
339
|
-
}
|
|
340
|
-
},
|
|
341
|
-
"& > *": {
|
|
342
|
-
flexShrink: 0
|
|
343
|
-
},
|
|
344
|
-
".panel__header__buttons": {
|
|
345
|
-
alignSelf: "end",
|
|
346
|
-
display: "flex",
|
|
347
|
-
flexGrow: 1,
|
|
348
|
-
fontWeight: "normal",
|
|
349
|
-
gap: 2,
|
|
350
|
-
justifyContent: "end",
|
|
351
|
-
right: 0,
|
|
352
|
-
background: "transparent",
|
|
353
|
-
pr: 3,
|
|
354
|
-
opacity: responsive({ 0: 1, 3: 0 }),
|
|
355
|
-
alignItems: "center",
|
|
356
|
-
pl: 3,
|
|
357
|
-
height: "24px",
|
|
358
|
-
button: {
|
|
359
|
-
width: "30px",
|
|
360
|
-
height: "30px"
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
".panel__content": {
|
|
365
|
-
...getSpacingLayouts()
|
|
366
|
-
},
|
|
367
|
-
".panel__container:hover, .panel__container:focus, .panel__container:focus-within, .panel__container.isLoading": {
|
|
368
|
-
".panel__header__buttons, .lastUpdate__wrapper": {
|
|
369
|
-
opacity: responsive({ 0: 1 })
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
".panel__footer": {
|
|
373
|
-
display: "flex",
|
|
374
|
-
justifyContent: "space-between",
|
|
375
|
-
gap: spacing(3),
|
|
376
|
-
background: "palette.secondary.light",
|
|
377
|
-
px: 4,
|
|
378
|
-
py: 3,
|
|
379
|
-
color: "palette.text.primary",
|
|
380
|
-
borderRadius: "panel",
|
|
381
|
-
borderTopRightRadius: "0px",
|
|
382
|
-
borderTopLeftRadius: "0px",
|
|
383
|
-
overflow: "hidden",
|
|
384
|
-
alignItems: "center"
|
|
385
|
-
},
|
|
386
|
-
".panel__iconButton, .lastUpdate__wrapper": {
|
|
387
|
-
transition: "opacity 300ms"
|
|
388
|
-
},
|
|
389
|
-
".lastUpdate__wrapper": {
|
|
390
|
-
fontSize: 14,
|
|
391
|
-
opacity: 0,
|
|
392
|
-
flexShrink: 0
|
|
393
|
-
},
|
|
394
|
-
".panel__footer__text": {
|
|
395
|
-
overflow: "hidden",
|
|
396
|
-
flexShrink: 1
|
|
397
|
-
},
|
|
398
|
-
"span.panel__title": {
|
|
399
|
-
flexShrink: "1 !important"
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
const RefreshButton = (props) => {
|
|
404
|
-
const [isDisabled, setIsDisabled] = useState(false);
|
|
405
|
-
const isLoading = usePanelIsLoading();
|
|
406
|
-
const dispatch = usePanelActions();
|
|
407
|
-
useImperativeComponentEvents({
|
|
408
|
-
disable(newDisabledValue) {
|
|
409
|
-
setIsDisabled(newDisabledValue);
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
return /* @__PURE__ */ jsx(
|
|
413
|
-
IconButton,
|
|
414
|
-
{
|
|
415
|
-
icon: "Refresh",
|
|
416
|
-
variant: "buttons.icon-outline",
|
|
417
|
-
className: "panel__iconButton",
|
|
418
|
-
size: "Md",
|
|
419
|
-
onClick: useCallback(() => {
|
|
420
|
-
void dispatch({ action: "refresh" });
|
|
421
|
-
}, [dispatch]),
|
|
422
|
-
title: getLabel("lblRefreshPnl", { text: { TOK1: props.title } }).text,
|
|
423
|
-
isLoading,
|
|
424
|
-
disabled: isDisabled
|
|
425
|
-
}
|
|
426
|
-
);
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
class ConfigEmitter extends EventEmitter {
|
|
430
|
-
}
|
|
431
|
-
new ConfigEmitter();
|
|
432
|
-
function usePanelConfig() {
|
|
433
|
-
const { panelId } = usePanelIdentity();
|
|
434
|
-
return function config() {
|
|
435
|
-
void ApiaApi.post(
|
|
436
|
-
makeApiaUrl({
|
|
437
|
-
action: "panelEdit",
|
|
438
|
-
pnlId: panelId
|
|
439
|
-
}),
|
|
440
|
-
{ handleLoad: true }
|
|
441
|
-
);
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
const SettingsButton = (props) => {
|
|
446
|
-
const { panelId } = usePanelIdentity();
|
|
447
|
-
const configure = usePanelConfig();
|
|
448
|
-
const [isDisabled, setIsDisabled] = useState(false);
|
|
449
|
-
useImperativeComponentEvents({
|
|
450
|
-
disable(newDisabledValue) {
|
|
451
|
-
setIsDisabled(newDisabledValue);
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
usePanelActions({
|
|
455
|
-
refresh() {
|
|
456
|
-
panelButtonsActions(panelId, "disable", false);
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
const openSettings = useCallback(() => {
|
|
460
|
-
try {
|
|
461
|
-
configure();
|
|
462
|
-
} catch (e) {
|
|
463
|
-
}
|
|
464
|
-
}, [configure]);
|
|
465
|
-
return /* @__PURE__ */ jsx(
|
|
466
|
-
IconButton,
|
|
467
|
-
{
|
|
468
|
-
icon: "Settings",
|
|
469
|
-
size: "Md",
|
|
470
|
-
variant: "buttons.icon-outline",
|
|
471
|
-
className: "panel__iconButton",
|
|
472
|
-
onClick: openSettings,
|
|
473
|
-
title: getLabel("lblOpenPnlConf", { text: { TOK1: props.title } }).text,
|
|
474
|
-
disabled: isDisabled
|
|
475
|
-
}
|
|
476
|
-
);
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
const [, panelButtonsActions, PanelButtons] = makeImperativeComponent()({
|
|
480
|
-
Component: (props) => {
|
|
481
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
482
|
-
props.isRefreshable && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(RefreshButton, { ...props }) }),
|
|
483
|
-
props.isConfigurable && /* @__PURE__ */ jsx(SettingsButton, { title: props.title })
|
|
484
|
-
] });
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
function usePanelContextLayout() {
|
|
489
|
-
const elRef = useRef(null);
|
|
490
|
-
const layoutRef = useRef("clever");
|
|
491
|
-
const clearClassNames = useCallback(() => {
|
|
492
|
-
spacingLayouts.forEach(
|
|
493
|
-
(current) => elRef.current?.querySelector(".panel__content")?.classList.remove(current)
|
|
494
|
-
);
|
|
495
|
-
}, []);
|
|
496
|
-
const setRef = useCallback(
|
|
497
|
-
(el) => {
|
|
498
|
-
if (el instanceof HTMLDivElement) {
|
|
499
|
-
elRef.current = el;
|
|
500
|
-
clearClassNames();
|
|
501
|
-
(el?.querySelector(".panel__content")).classList.add(
|
|
502
|
-
layoutRef.current
|
|
503
|
-
);
|
|
504
|
-
}
|
|
505
|
-
},
|
|
506
|
-
[clearClassNames]
|
|
507
|
-
);
|
|
508
|
-
const setLayout = useCallback(
|
|
509
|
-
(layout) => {
|
|
510
|
-
if (layoutRef.current === layout)
|
|
511
|
-
return;
|
|
512
|
-
layoutRef.current = layout;
|
|
513
|
-
clearClassNames();
|
|
514
|
-
elRef.current?.querySelector(".panel__content")?.classList.add(layoutRef.current);
|
|
515
|
-
},
|
|
516
|
-
[clearClassNames]
|
|
517
|
-
);
|
|
518
|
-
return { ref: setRef, setLayout };
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
function useYieldPanelIsReady() {
|
|
522
|
-
const { setRef } = usePanelContext();
|
|
523
|
-
useMount(() => {
|
|
524
|
-
setRef({});
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
const PanelContext = createContext(null);
|
|
529
|
-
function usePanelContext() {
|
|
530
|
-
const context = useContext(PanelContext);
|
|
531
|
-
if (!context)
|
|
532
|
-
throw new Error("No panel wrapper context defined");
|
|
533
|
-
return context;
|
|
534
|
-
}
|
|
535
|
-
const PanelContextProvider = ({
|
|
536
|
-
children,
|
|
537
|
-
value
|
|
538
|
-
}) => {
|
|
539
|
-
return /* @__PURE__ */ jsx(PanelContext.Provider, { value, children });
|
|
540
|
-
};
|
|
541
|
-
function useMakePanelContext(panelId, panelProps) {
|
|
542
|
-
const setTitle = useCallback(
|
|
543
|
-
(newTitle) => {
|
|
544
|
-
changePanelTitle(panelId, newTitle);
|
|
545
|
-
},
|
|
546
|
-
[panelId]
|
|
547
|
-
);
|
|
548
|
-
const { ref, setLayout } = usePanelContextLayout();
|
|
549
|
-
const [title, setTitleState] = useState(panelProps.title);
|
|
550
|
-
usePanelOnEvent(
|
|
551
|
-
{ eventType: "changeTitle", panelId },
|
|
552
|
-
(ev) => {
|
|
553
|
-
setTitleState(ev.payload);
|
|
554
|
-
}
|
|
555
|
-
);
|
|
556
|
-
const { footer, handleFooterClick } = usePanelFooter(
|
|
557
|
-
panelId,
|
|
558
|
-
panelProps.initialData
|
|
559
|
-
);
|
|
560
|
-
const dispatch = usePanelActions();
|
|
561
|
-
const hasRefreshedOnStartup = useRef(false);
|
|
562
|
-
const dashboard = useDashboardContext();
|
|
563
|
-
const setRef = useCallback(
|
|
564
|
-
(el) => {
|
|
565
|
-
if (el && !hasRefreshedOnStartup.current) {
|
|
566
|
-
hasRefreshedOnStartup.current = true;
|
|
567
|
-
if (panelProps.refreshOnStart) {
|
|
568
|
-
void dispatch({ action: "refresh" }).then(() => {
|
|
569
|
-
dashboard.bootstrapper.setPanelHasLoaded(panelId);
|
|
570
|
-
});
|
|
571
|
-
} else {
|
|
572
|
-
dashboard.bootstrapper.setPanelHasLoaded(panelId);
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
},
|
|
576
|
-
[dashboard.bootstrapper, dispatch, panelId, panelProps.refreshOnStart]
|
|
577
|
-
);
|
|
578
|
-
const contextValue = useMemo(
|
|
579
|
-
() => ({
|
|
580
|
-
setTitle,
|
|
581
|
-
setLayout,
|
|
582
|
-
panelProps,
|
|
583
|
-
setRef
|
|
584
|
-
}),
|
|
585
|
-
[setTitle, setLayout, panelProps, setRef]
|
|
586
|
-
);
|
|
587
|
-
return { title, footer, handleFooterClick, contextValue, ref };
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
const PanelFooter = ({
|
|
591
|
-
isRefreshable,
|
|
592
|
-
footer,
|
|
593
|
-
handleFooterClick
|
|
594
|
-
}) => {
|
|
595
|
-
const [lastUpdate, setLastUpdate] = useState(0);
|
|
596
|
-
usePanelActions({
|
|
597
|
-
refresh() {
|
|
598
|
-
setLastUpdate(Date.now());
|
|
599
|
-
}
|
|
600
|
-
});
|
|
601
|
-
return /* @__PURE__ */ jsx(Fragment, { children: (isRefreshable || footer) && /* @__PURE__ */ jsxs("div", { className: "panel__footer", children: [
|
|
602
|
-
footer && (!footer.action || footer.actionBehavior === "DO_NOTHING") && /* @__PURE__ */ jsx("div", { className: "panel__footer__text", children: /* @__PURE__ */ jsx(
|
|
603
|
-
AutoEllipsis,
|
|
604
|
-
{
|
|
605
|
-
overrideStyles: (el) => {
|
|
606
|
-
const styles = window.getComputedStyle(
|
|
607
|
-
el.closest(".panel__footer")
|
|
608
|
-
);
|
|
609
|
-
const width = Number.parseInt(styles.width, 10);
|
|
610
|
-
const padding = Number.parseInt(styles.paddingLeft, 10) + Number.parseInt(styles.paddingRight, 10);
|
|
611
|
-
return {
|
|
612
|
-
width: `${width - padding}px`
|
|
613
|
-
};
|
|
614
|
-
},
|
|
615
|
-
children: footer.text
|
|
616
|
-
}
|
|
617
|
-
) }),
|
|
618
|
-
footer?.action && footer.actionBehavior !== "DO_NOTHING" && /* @__PURE__ */ jsx(
|
|
619
|
-
SimpleButton,
|
|
620
|
-
{
|
|
621
|
-
onClick: handleFooterClick,
|
|
622
|
-
onDoubleClick: handleFooterClick,
|
|
623
|
-
variant: "link",
|
|
624
|
-
className: "panel__footer__text",
|
|
625
|
-
children: /* @__PURE__ */ jsx(
|
|
626
|
-
AutoEllipsis,
|
|
627
|
-
{
|
|
628
|
-
overrideStyles: (el) => {
|
|
629
|
-
const styles = window.getComputedStyle(
|
|
630
|
-
el.closest(".panel__footer")
|
|
631
|
-
);
|
|
632
|
-
const width = Number.parseInt(styles.width, 10);
|
|
633
|
-
const padding = Number.parseInt(styles.paddingLeft, 10) + Number.parseInt(styles.paddingRight, 10);
|
|
634
|
-
return {
|
|
635
|
-
width: `${width - padding}px`
|
|
636
|
-
};
|
|
637
|
-
},
|
|
638
|
-
children: footer.text
|
|
639
|
-
}
|
|
640
|
-
)
|
|
641
|
-
}
|
|
642
|
-
),
|
|
643
|
-
!footer && /* @__PURE__ */ jsx("div", {}),
|
|
644
|
-
lastUpdate > 0 && /* @__PURE__ */ jsxs(Box, { className: "lastUpdate__wrapper", children: [
|
|
645
|
-
new Date(lastUpdate).toLocaleDateString(),
|
|
646
|
-
" ",
|
|
647
|
-
new Date(lastUpdate).toLocaleTimeString()
|
|
648
|
-
] })
|
|
649
|
-
] }) });
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
const DefaultPanelWrapper = makeStyledComponent(
|
|
653
|
-
"DefaultPanelWrapper",
|
|
654
|
-
"layout.common.dashboards.panel",
|
|
655
|
-
defaultPanelWrapperStyles,
|
|
656
|
-
({ children, ...props }) => {
|
|
657
|
-
const { panelId, panelName, panelType } = usePanelIdentity();
|
|
658
|
-
const { contextValue, title, ref, ...footerProps } = useMakePanelContext(
|
|
659
|
-
panelId,
|
|
660
|
-
props
|
|
661
|
-
);
|
|
662
|
-
const panelTitleDescription = usePanelTitleDescription();
|
|
663
|
-
const showHeader = props.showTitle || props.isConfigurable || props.isRefreshable;
|
|
664
|
-
const isLoading = usePanelIsLoading();
|
|
665
|
-
return /* @__PURE__ */ jsx(PanelContextProvider, { value: contextValue, children: /* @__PURE__ */ jsxs(
|
|
666
|
-
"div",
|
|
667
|
-
{
|
|
668
|
-
ref,
|
|
669
|
-
className: `panel__container ${isLoading ? "isLoading" : ""}`,
|
|
670
|
-
"data-panelname": panelName,
|
|
671
|
-
"data-paneltype": panelType,
|
|
672
|
-
"data-panelid": panelId,
|
|
673
|
-
children: [
|
|
674
|
-
showHeader && /* @__PURE__ */ jsxs("div", { draggable: props.canMove, className: `panel__header`, children: [
|
|
675
|
-
/* @__PURE__ */ jsxs("div", { className: "panel__header__left", children: [
|
|
676
|
-
props.showTitle && /* @__PURE__ */ jsx(
|
|
677
|
-
"span",
|
|
678
|
-
{
|
|
679
|
-
className: "panel__title",
|
|
680
|
-
title: panelTitleDescription ?? title,
|
|
681
|
-
children: title
|
|
682
|
-
}
|
|
683
|
-
),
|
|
684
|
-
/* @__PURE__ */ jsx(NetworkState, { title })
|
|
685
|
-
] }),
|
|
686
|
-
/* @__PURE__ */ jsx("div", { className: `panel__header__buttons`, children: /* @__PURE__ */ jsx(PanelButtons, { ...props, id: panelId }) })
|
|
687
|
-
] }),
|
|
688
|
-
/* @__PURE__ */ jsx("div", { className: "panel__content", children }),
|
|
689
|
-
/* @__PURE__ */ jsx(PanelFooter, { isRefreshable: props.isRefreshable, ...footerProps })
|
|
690
|
-
]
|
|
691
|
-
}
|
|
692
|
-
) });
|
|
693
|
-
}
|
|
694
|
-
);
|
|
695
|
-
|
|
696
|
-
var __defProp$5 = Object.defineProperty;
|
|
697
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
698
|
-
var __publicField$5 = (obj, key, value) => {
|
|
699
|
-
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
700
|
-
return value;
|
|
701
|
-
};
|
|
702
|
-
var __accessCheck$4 = (obj, member, msg) => {
|
|
703
|
-
if (!member.has(obj))
|
|
704
|
-
throw TypeError("Cannot " + msg);
|
|
705
|
-
};
|
|
706
|
-
var __privateGet$4 = (obj, member, getter) => {
|
|
707
|
-
__accessCheck$4(obj, member, "read from private field");
|
|
708
|
-
return member.get(obj);
|
|
709
|
-
};
|
|
710
|
-
var __privateAdd$4 = (obj, member, value) => {
|
|
711
|
-
if (member.has(obj))
|
|
712
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
713
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
714
|
-
};
|
|
715
|
-
var __privateSet$2 = (obj, member, value, setter) => {
|
|
716
|
-
__accessCheck$4(obj, member, "write to private field");
|
|
717
|
-
member.set(obj, value);
|
|
718
|
-
return value;
|
|
719
|
-
};
|
|
720
|
-
var _hasLoadedAll, _bootstrappedPanels, _hasLoaded, _initTimestamp, _timeoutTreshold, _checkAllHasLoaded, _removeSkeletons;
|
|
721
|
-
class DashboardPanelsBootstraper {
|
|
722
|
-
constructor(dashboard) {
|
|
723
|
-
this.dashboard = dashboard;
|
|
724
|
-
__privateAdd$4(this, _hasLoadedAll, false);
|
|
725
|
-
__privateAdd$4(this, _bootstrappedPanels, {});
|
|
726
|
-
__privateAdd$4(this, _hasLoaded, {});
|
|
727
|
-
__privateAdd$4(this, _initTimestamp, Date.now());
|
|
728
|
-
__privateAdd$4(this, _timeoutTreshold, (window.DASH_COURTAIN_TRESHOLD ?? 5) * 1e3);
|
|
729
|
-
__privateAdd$4(this, _checkAllHasLoaded, () => {
|
|
730
|
-
if (__privateGet$4(this, _hasLoadedAll))
|
|
731
|
-
return true;
|
|
732
|
-
const keys = Object.keys(__privateGet$4(this, _bootstrappedPanels));
|
|
733
|
-
const hasLoadedAllPanels = !keys.find(
|
|
734
|
-
(current) => !__privateGet$4(this, _hasLoaded)[current] && this.dashboard.getPanel(current).isVisible
|
|
735
|
-
);
|
|
736
|
-
const hasTimedOutLoading = Date.now() - __privateGet$4(this, _initTimestamp) > __privateGet$4(this, _timeoutTreshold);
|
|
737
|
-
if (hasLoadedAllPanels || hasTimedOutLoading) {
|
|
738
|
-
if (hasTimedOutLoading) {
|
|
739
|
-
const nonBootstrappedPanels = Object.keys(__privateGet$4(this, _bootstrappedPanels)).filter((current) => !__privateGet$4(this, _hasLoaded)[current]).map((panelId) => {
|
|
740
|
-
const panelProps = this.dashboard.getPanel(panelId).props;
|
|
741
|
-
return panelProps;
|
|
742
|
-
});
|
|
743
|
-
console.warn(
|
|
744
|
-
`The courtain was removed because of timeout, check that all panels are reporting according to useYieldPanelIsReady's documentation.
|
|
745
|
-
|
|
746
|
-
It might have happened that all panels are reporting but the browser was too busy to handle all of them in time, in order to determine what is actually happen you can raise the DASH_COURTAIN_TRESHOLD to a very large number, like 20 for example.`,
|
|
747
|
-
{ nonBootstrappedPanels }
|
|
748
|
-
);
|
|
749
|
-
}
|
|
750
|
-
__privateSet$2(this, _hasLoadedAll, true);
|
|
751
|
-
__privateGet$4(this, _removeSkeletons).call(this);
|
|
752
|
-
return true;
|
|
753
|
-
}
|
|
754
|
-
return false;
|
|
755
|
-
});
|
|
756
|
-
__privateAdd$4(this, _removeSkeletons, () => {
|
|
757
|
-
const skeleton = document.querySelector(
|
|
758
|
-
"#DashLayoutCourtain"
|
|
759
|
-
);
|
|
760
|
-
const dashContent = document.querySelector(
|
|
761
|
-
"#DashLayoutContent"
|
|
762
|
-
);
|
|
763
|
-
skeleton.style.display = "none";
|
|
764
|
-
dashContent.style.visibility = "initial";
|
|
765
|
-
skeleton.remove();
|
|
766
|
-
});
|
|
767
|
-
/**
|
|
768
|
-
* El bootstraper se basa en dos elementos: setHasLoadedInitialData y
|
|
769
|
-
* SuspendPanelUntilDashboardReady.
|
|
770
|
-
*
|
|
771
|
-
* El funcionamiento es muy elemental: Cada panel utiliza el Suspend como
|
|
772
|
-
* wrapper y éste registra el id del panel en un array de paneles pendientes
|
|
773
|
-
* por cargar.
|
|
774
|
-
*
|
|
775
|
-
* Una vez que todos los paneles cargaron, el suspense retoma su tarea y
|
|
776
|
-
* renderiza el panel normalmente.
|
|
777
|
-
*/
|
|
778
|
-
__publicField$5(this, "setPanelHasLoaded", (panelId) => {
|
|
779
|
-
__privateGet$4(this, _hasLoaded)[panelId] = true;
|
|
780
|
-
this.dashboard.getPanel(panelId).setHasLoaded();
|
|
781
|
-
});
|
|
782
|
-
__publicField$5(this, "SuspendPanelUntilDashbordReady", ({
|
|
783
|
-
children,
|
|
784
|
-
panelId
|
|
785
|
-
}) => {
|
|
786
|
-
const [hasBootstraped, setHasBootstraped] = useState(false);
|
|
787
|
-
const deferredHasBootstraped = useDeferredValue(hasBootstraped);
|
|
788
|
-
__privateGet$4(this, _bootstrappedPanels)[panelId] = true;
|
|
789
|
-
const LoadWaiter = useCallback(() => {
|
|
790
|
-
if (!__privateGet$4(this, _checkAllHasLoaded).call(this))
|
|
791
|
-
void new Promise((resolve) => {
|
|
792
|
-
const interval = setInterval(() => {
|
|
793
|
-
if (__privateGet$4(this, _checkAllHasLoaded).call(this)) {
|
|
794
|
-
resolve();
|
|
795
|
-
clearInterval(interval);
|
|
796
|
-
}
|
|
797
|
-
}, 300);
|
|
798
|
-
});
|
|
799
|
-
return null;
|
|
800
|
-
}, []);
|
|
801
|
-
if (!deferredHasBootstraped)
|
|
802
|
-
return /* @__PURE__ */ jsx(
|
|
803
|
-
"div",
|
|
804
|
-
{
|
|
805
|
-
ref: (el) => {
|
|
806
|
-
if (el)
|
|
807
|
-
setHasBootstraped(true);
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
);
|
|
811
|
-
return /* @__PURE__ */ jsxs(Suspense, { fallback: null, children: [
|
|
812
|
-
children,
|
|
813
|
-
/* @__PURE__ */ jsx(LoadWaiter, {})
|
|
814
|
-
] });
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
_hasLoadedAll = new WeakMap();
|
|
819
|
-
_bootstrappedPanels = new WeakMap();
|
|
820
|
-
_hasLoaded = new WeakMap();
|
|
821
|
-
_initTimestamp = new WeakMap();
|
|
822
|
-
_timeoutTreshold = new WeakMap();
|
|
823
|
-
_checkAllHasLoaded = new WeakMap();
|
|
824
|
-
_removeSkeletons = new WeakMap();
|
|
825
|
-
|
|
826
|
-
const PanelNotFound = () => {
|
|
827
|
-
const props = usePanelIdentity();
|
|
828
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Heading, { children: [
|
|
829
|
-
"Panel not found: ",
|
|
830
|
-
props.panelType
|
|
831
|
-
] }) });
|
|
832
|
-
};
|
|
833
|
-
|
|
834
|
-
const importedPanels = {};
|
|
835
|
-
function importPanel(path) {
|
|
836
|
-
if (!importedPanels[path])
|
|
837
|
-
importedPanels[path] = lazy(() => {
|
|
838
|
-
return new Promise((resolve) => {
|
|
839
|
-
import(
|
|
840
|
-
/* webpackChunkName: "[request]" */
|
|
841
|
-
/* webpackInclude: /\.tsx?$/ */
|
|
842
|
-
/* webpackPreload: true */
|
|
843
|
-
`/panels/${path}`
|
|
844
|
-
).then(
|
|
845
|
-
(result) => {
|
|
846
|
-
console.log(result);
|
|
847
|
-
resolve(result.default);
|
|
848
|
-
}
|
|
849
|
-
).catch(() => {
|
|
850
|
-
resolve({
|
|
851
|
-
default: PanelNotFound
|
|
852
|
-
});
|
|
853
|
-
});
|
|
854
|
-
});
|
|
855
|
-
});
|
|
856
|
-
return importedPanels[path];
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
var __defProp$4 = Object.defineProperty;
|
|
860
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
861
|
-
var __publicField$4 = (obj, key, value) => {
|
|
862
|
-
__defNormalProp$4(obj, key + "" , value);
|
|
863
|
-
return value;
|
|
864
|
-
};
|
|
865
|
-
const Error2 = makeStyledComponent(
|
|
866
|
-
"Error",
|
|
867
|
-
"layout.panels.error",
|
|
868
|
-
{
|
|
869
|
-
".panelError__wrapper": {
|
|
870
|
-
display: "flex",
|
|
871
|
-
flexDirection: "column",
|
|
872
|
-
gap: 3,
|
|
873
|
-
h3: {
|
|
874
|
-
color: "palette.error.main"
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
},
|
|
878
|
-
({ error }) => {
|
|
879
|
-
return /* @__PURE__ */ jsxs(Box, { className: "panelError__wrapper", children: [
|
|
880
|
-
/* @__PURE__ */ jsx(Heading, { as: "h3", children: "Oops! Something went wrong" }),
|
|
881
|
-
/* @__PURE__ */ jsx(Heading, { as: "h4", children: "Error:" }),
|
|
882
|
-
/* @__PURE__ */ jsx(Paragraph, { children: error })
|
|
883
|
-
] });
|
|
884
|
-
}
|
|
885
|
-
);
|
|
886
|
-
class PanelErrorBoundary extends Component {
|
|
887
|
-
constructor() {
|
|
888
|
-
super(...arguments);
|
|
889
|
-
__publicField$4(this, "state", {
|
|
890
|
-
hasError: false,
|
|
891
|
-
errorMessage: ""
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
static getDerivedStateFromError(error) {
|
|
895
|
-
if (!(error instanceof Promise))
|
|
896
|
-
return { hasError: true, errorMessage: String(error) };
|
|
897
|
-
}
|
|
898
|
-
render() {
|
|
899
|
-
if (this.state.hasError) {
|
|
900
|
-
return /* @__PURE__ */ jsx(Error2, { error: this.state.errorMessage });
|
|
901
|
-
}
|
|
902
|
-
return this.props.children;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
var __defProp$3 = Object.defineProperty;
|
|
907
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
908
|
-
var __publicField$3 = (obj, key, value) => {
|
|
909
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
910
|
-
return value;
|
|
911
|
-
};
|
|
912
|
-
var __accessCheck$3 = (obj, member, msg) => {
|
|
913
|
-
if (!member.has(obj))
|
|
914
|
-
throw TypeError("Cannot " + msg);
|
|
915
|
-
};
|
|
916
|
-
var __privateGet$3 = (obj, member, getter) => {
|
|
917
|
-
__accessCheck$3(obj, member, "read from private field");
|
|
918
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
919
|
-
};
|
|
920
|
-
var __privateAdd$3 = (obj, member, value) => {
|
|
921
|
-
if (member.has(obj))
|
|
922
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
923
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
924
|
-
};
|
|
925
|
-
var _elements, _loaders;
|
|
926
|
-
const noData = { initialData: {} };
|
|
927
|
-
function parameterValue(value) {
|
|
928
|
-
if (value === "true")
|
|
929
|
-
return true;
|
|
930
|
-
if (value === "false")
|
|
931
|
-
return false;
|
|
932
|
-
return value;
|
|
933
|
-
}
|
|
934
|
-
class DashboardPanel extends EventEmitter {
|
|
935
|
-
constructor({
|
|
936
|
-
id,
|
|
937
|
-
dashboard,
|
|
938
|
-
PanelContainer: PanelContainer2
|
|
939
|
-
}) {
|
|
940
|
-
super();
|
|
941
|
-
__publicField$3(this, "dashboard");
|
|
942
|
-
__publicField$3(this, "hasInited", false);
|
|
943
|
-
__publicField$3(this, "hasLoaded", false);
|
|
944
|
-
__publicField$3(this, "id");
|
|
945
|
-
__publicField$3(this, "initialData", null);
|
|
946
|
-
__publicField$3(this, "isVisible", false);
|
|
947
|
-
__publicField$3(this, "portal");
|
|
948
|
-
__publicField$3(this, "props", {});
|
|
949
|
-
__privateAdd$3(this, _elements, {
|
|
950
|
-
props: () => {
|
|
951
|
-
const panelData = document.querySelector(
|
|
952
|
-
`panel-props[id="${this.id}"]`
|
|
953
|
-
);
|
|
954
|
-
if (!panelData) {
|
|
955
|
-
console.error("Panel with no id:", this.id);
|
|
956
|
-
throw new Error("A panel has no data element in the DOM.");
|
|
957
|
-
}
|
|
958
|
-
return panelData;
|
|
959
|
-
}
|
|
960
|
-
});
|
|
961
|
-
__privateAdd$3(this, _loaders, {
|
|
962
|
-
loadAll: () => {
|
|
963
|
-
void __privateGet$3(this, _loaders).initialData();
|
|
964
|
-
__privateGet$3(this, _loaders).parameters();
|
|
965
|
-
__privateGet$3(this, _loaders).props();
|
|
966
|
-
},
|
|
967
|
-
initialData: () => {
|
|
968
|
-
const panel = this.getContainer();
|
|
969
|
-
const panelContent = panel.querySelector(
|
|
970
|
-
".panel__content"
|
|
971
|
-
);
|
|
972
|
-
const xml = panelContent.innerHTML.replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
973
|
-
panelContent.innerHTML = "";
|
|
974
|
-
this.initialData = parseXmlAsync(xml.replace(/<!--?[^>]+>/, ""));
|
|
975
|
-
return this.initialData;
|
|
976
|
-
},
|
|
977
|
-
parameters: () => {
|
|
978
|
-
if (store.getState().panelParameters[this.id])
|
|
979
|
-
return;
|
|
980
|
-
const panelData = __privateGet$3(this, _elements).props();
|
|
981
|
-
const options = Object.fromEntries(
|
|
982
|
-
[...panelData.querySelectorAll("panel-option")].map(
|
|
983
|
-
(current) => {
|
|
984
|
-
return [
|
|
985
|
-
current.getAttribute("name"),
|
|
986
|
-
parameterValue(current.getAttribute("value"))
|
|
987
|
-
];
|
|
988
|
-
}
|
|
989
|
-
)
|
|
990
|
-
);
|
|
991
|
-
const parameters = Object.fromEntries(
|
|
992
|
-
[...panelData.querySelectorAll("panel-parameter")].map(
|
|
993
|
-
(current) => {
|
|
994
|
-
return [
|
|
995
|
-
current.getAttribute("name"),
|
|
996
|
-
parameterValue(current.getAttribute("value"))
|
|
997
|
-
];
|
|
998
|
-
}
|
|
999
|
-
)
|
|
1000
|
-
);
|
|
1001
|
-
saveParameters(this.id, Object.assign(options, parameters), false);
|
|
1002
|
-
},
|
|
1003
|
-
props: () => {
|
|
1004
|
-
const panelData = __privateGet$3(this, _elements).props();
|
|
1005
|
-
const panel = this.getContainer();
|
|
1006
|
-
const props = {
|
|
1007
|
-
id: this.id,
|
|
1008
|
-
name: panelData.getAttribute("name"),
|
|
1009
|
-
canMove: toBoolean(panelData.getAttribute("canMove")),
|
|
1010
|
-
hasRss: toBoolean(panelData.getAttribute("hasRss")),
|
|
1011
|
-
isConfigurable: toBoolean(panelData.getAttribute("isConfigurable")),
|
|
1012
|
-
isRefreshable: toBoolean(panelData.getAttribute("isRefreshable")),
|
|
1013
|
-
refreshOnHome: toBoolean(panelData.getAttribute("refreshOnHome")),
|
|
1014
|
-
refreshOnStart: toBoolean(panelData.getAttribute("refreshOnStart")),
|
|
1015
|
-
showTitle: toBoolean(panelData.getAttribute("showTitle")),
|
|
1016
|
-
title: panelData.getAttribute("title"),
|
|
1017
|
-
type: panel.dataset.panel
|
|
1018
|
-
};
|
|
1019
|
-
this.props = props;
|
|
1020
|
-
}
|
|
1021
|
-
});
|
|
1022
|
-
__publicField$3(this, "fireAction", ({ action, ...parameters }, options) => {
|
|
1023
|
-
if (!this.isVisible)
|
|
1024
|
-
return new Promise((resolve) => resolve(null));
|
|
1025
|
-
const postData = {};
|
|
1026
|
-
Object.entries(parameters).forEach(([name, value]) => {
|
|
1027
|
-
postData[`p_${name}`] = value;
|
|
1028
|
-
});
|
|
1029
|
-
return new Promise((resolve, reject) => {
|
|
1030
|
-
firePanelAction(this.id, action, postData, {
|
|
1031
|
-
...options,
|
|
1032
|
-
onComplete(hasSucceed, data) {
|
|
1033
|
-
options?.onComplete?.(hasSucceed, data);
|
|
1034
|
-
if (hasSucceed) {
|
|
1035
|
-
resolve(data);
|
|
1036
|
-
} else
|
|
1037
|
-
reject();
|
|
1038
|
-
}
|
|
1039
|
-
});
|
|
1040
|
-
});
|
|
1041
|
-
});
|
|
1042
|
-
__publicField$3(this, "PanelElement", ({
|
|
1043
|
-
ActualPanelContainer,
|
|
1044
|
-
Element
|
|
1045
|
-
}) => {
|
|
1046
|
-
const [resolvedInitialData, setResolvedInitialData] = useState(null);
|
|
1047
|
-
const [isVisible, setIsVisible] = useState(this.isVisible);
|
|
1048
|
-
useMount(() => {
|
|
1049
|
-
void this.initialData?.then((data) => {
|
|
1050
|
-
setResolvedInitialData(data ?? noData);
|
|
1051
|
-
});
|
|
1052
|
-
return this.on(
|
|
1053
|
-
"isVisible",
|
|
1054
|
-
(ev) => setIsVisible((current) => ev || current)
|
|
1055
|
-
);
|
|
1056
|
-
});
|
|
1057
|
-
if (resolvedInitialData === null || resolvedInitialData === noData)
|
|
1058
|
-
return null;
|
|
1059
|
-
return /* @__PURE__ */ jsx(DashboardPanelContext.Provider, { value: this, children: /* @__PURE__ */ jsx(PanelIdentifier, { ...this.props, children: /* @__PURE__ */ jsx(
|
|
1060
|
-
ActualPanelContainer,
|
|
1061
|
-
{
|
|
1062
|
-
...this.props,
|
|
1063
|
-
initialData: resolvedInitialData,
|
|
1064
|
-
children: /* @__PURE__ */ jsx(
|
|
1065
|
-
this.dashboard.bootstrapper.SuspendPanelUntilDashbordReady,
|
|
1066
|
-
{
|
|
1067
|
-
panelId: this.id,
|
|
1068
|
-
children: /* @__PURE__ */ jsx(PanelErrorBoundary, { children: isVisible ? /* @__PURE__ */ jsx(Element, { initialData: resolvedInitialData.initialData }) : null })
|
|
1069
|
-
}
|
|
1070
|
-
)
|
|
1071
|
-
}
|
|
1072
|
-
) }) });
|
|
1073
|
-
});
|
|
1074
|
-
this.dashboard = dashboard;
|
|
1075
|
-
this.id = id;
|
|
1076
|
-
__privateGet$3(this, _loaders).loadAll();
|
|
1077
|
-
this.portal = createPortal(
|
|
1078
|
-
/* @__PURE__ */ jsx(
|
|
1079
|
-
this.PanelElement,
|
|
1080
|
-
{
|
|
1081
|
-
ActualPanelContainer: PanelContainer2,
|
|
1082
|
-
Element: importPanel(this.props.type)
|
|
1083
|
-
}
|
|
1084
|
-
),
|
|
1085
|
-
this.getContainer().querySelector(".panel__content"),
|
|
1086
|
-
this.id
|
|
1087
|
-
);
|
|
1088
|
-
}
|
|
1089
|
-
getContainer() {
|
|
1090
|
-
const panel = document.querySelector(
|
|
1091
|
-
`[data-id="${this.id}"][data-panel]`
|
|
1092
|
-
);
|
|
1093
|
-
if (!panel) {
|
|
1094
|
-
console.error("Panel not found in dom:", this.id);
|
|
1095
|
-
throw new Error("Panel not found in DOM.");
|
|
1096
|
-
}
|
|
1097
|
-
return panel;
|
|
1098
|
-
}
|
|
1099
|
-
getParameters() {
|
|
1100
|
-
return store.getState().panelParameters[this.id];
|
|
1101
|
-
}
|
|
1102
|
-
hide() {
|
|
1103
|
-
const container = this.getContainer();
|
|
1104
|
-
container.style.display = "none";
|
|
1105
|
-
container.ariaHidden = "true";
|
|
1106
|
-
this.isVisible = false;
|
|
1107
|
-
this.emit("isVisible", this.isVisible);
|
|
1108
|
-
}
|
|
1109
|
-
refresh() {
|
|
1110
|
-
return this.fireAction({ action: "refresh" });
|
|
1111
|
-
}
|
|
1112
|
-
setHasLoaded() {
|
|
1113
|
-
this.hasLoaded = true;
|
|
1114
|
-
this.emit("hasLoaded", true);
|
|
1115
|
-
}
|
|
1116
|
-
show() {
|
|
1117
|
-
const container = this.getContainer();
|
|
1118
|
-
container.style.display = "block";
|
|
1119
|
-
container.ariaHidden = "false";
|
|
1120
|
-
this.hasInited = true;
|
|
1121
|
-
this.isVisible = true;
|
|
1122
|
-
this.emit("isVisible", this.isVisible);
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
_elements = new WeakMap();
|
|
1126
|
-
_loaders = new WeakMap();
|
|
1127
|
-
|
|
1128
|
-
function dragleave(_ev, DragAndDrop2) {
|
|
1129
|
-
const ev = _ev;
|
|
1130
|
-
if (ev.relatedTarget === null || isChild(ev.relatedTarget, (current) => {
|
|
1131
|
-
return current.parentElement === null && current === document.getRootNode() && current.dataset.splash === void 0;
|
|
1132
|
-
})) {
|
|
1133
|
-
const shadows = document.querySelectorAll(".apia_panel_falseDiv");
|
|
1134
|
-
shadows.forEach((el) => el.remove());
|
|
1135
|
-
DragAndDrop2.draggingPanel?.setAttribute("style", "");
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
const isCursorInArea = ({
|
|
1140
|
-
top,
|
|
1141
|
-
bottom,
|
|
1142
|
-
left,
|
|
1143
|
-
right,
|
|
1144
|
-
cursorX,
|
|
1145
|
-
cursorY
|
|
1146
|
-
}) => {
|
|
1147
|
-
return top <= cursorY && cursorY <= bottom && left <= cursorX && cursorX <= right;
|
|
1148
|
-
};
|
|
1149
|
-
|
|
1150
|
-
const getColumnAreas = (specificPanel) => {
|
|
1151
|
-
return {
|
|
1152
|
-
top: {
|
|
1153
|
-
top: specificPanel.panelTop,
|
|
1154
|
-
bottom: specificPanel.panelTop + specificPanel.panelHeight / 2,
|
|
1155
|
-
left: specificPanel.panelLeft,
|
|
1156
|
-
right: specificPanel.panelRight
|
|
1157
|
-
},
|
|
1158
|
-
bottom: {
|
|
1159
|
-
top: specificPanel.panelBottom - specificPanel.panelHeight / 2,
|
|
1160
|
-
bottom: specificPanel.panelBottom,
|
|
1161
|
-
right: specificPanel.panelRight,
|
|
1162
|
-
left: specificPanel.panelLeft
|
|
1163
|
-
}
|
|
1164
|
-
};
|
|
1165
|
-
};
|
|
1166
|
-
|
|
1167
|
-
function dragover(event, DragAndDrop2) {
|
|
1168
|
-
const ev = event;
|
|
1169
|
-
ev.preventDefault();
|
|
1170
|
-
DragAndDrop2.timeout = -1;
|
|
1171
|
-
if ((ev.clientX !== DragAndDrop2.dragoverPosition.x || ev.clientY !== DragAndDrop2.dragoverPosition.y) && DragAndDrop2.draggingPanelId !== "" && DragAndDrop2.shadowDiv) {
|
|
1172
|
-
DragAndDrop2.clearTimeout();
|
|
1173
|
-
DragAndDrop2.currentBottomPanel = DragAndDrop2.findBottomPanel(
|
|
1174
|
-
ev.clientX,
|
|
1175
|
-
ev.clientY + DragAndDrop2.currentScroll
|
|
1176
|
-
);
|
|
1177
|
-
DragAndDrop2.dragoverPosition.x = ev.clientX;
|
|
1178
|
-
DragAndDrop2.dragoverPosition.y = ev.clientY;
|
|
1179
|
-
const snapshotSection = DragAndDrop2.findBottomSection(
|
|
1180
|
-
ev.clientX,
|
|
1181
|
-
ev.clientY + DragAndDrop2.currentScroll
|
|
1182
|
-
);
|
|
1183
|
-
if (DragAndDrop2.shadowDivData && isCursorInArea({
|
|
1184
|
-
cursorX: ev.clientX,
|
|
1185
|
-
cursorY: ev.clientY + DragAndDrop2.currentScroll,
|
|
1186
|
-
bottom: DragAndDrop2.shadowDivData?.panelBottom,
|
|
1187
|
-
top: DragAndDrop2.shadowDivData?.panelTop,
|
|
1188
|
-
left: DragAndDrop2.shadowDivData?.panelLeft,
|
|
1189
|
-
right: DragAndDrop2.shadowDivData?.panelRight
|
|
1190
|
-
})) {
|
|
1191
|
-
return;
|
|
1192
|
-
}
|
|
1193
|
-
if (DragAndDrop2.currentBottomPanel && snapshotSection) {
|
|
1194
|
-
const bottomPanel = DragAndDrop2.splash.querySelector(
|
|
1195
|
-
`[data-panel][data-id='${DragAndDrop2.currentBottomPanel.id}']`
|
|
1196
|
-
);
|
|
1197
|
-
const draggingPanel = DragAndDrop2.splash.querySelector(
|
|
1198
|
-
`[data-panel][data-id='${DragAndDrop2.draggingPanelId}']`
|
|
1199
|
-
);
|
|
1200
|
-
const bottomSection = DragAndDrop2.splash.querySelector(
|
|
1201
|
-
`[data-locationid='${snapshotSection.sectionId}']`
|
|
1202
|
-
);
|
|
1203
|
-
if (bottomSection) {
|
|
1204
|
-
if (isCursorInArea({
|
|
1205
|
-
cursorX: ev.clientX,
|
|
1206
|
-
cursorY: ev.clientY + DragAndDrop2.currentScroll,
|
|
1207
|
-
...getColumnAreas({
|
|
1208
|
-
...DragAndDrop2.currentBottomPanel,
|
|
1209
|
-
panelLeft: bottomSection?.getBoundingClientRect().left ?? 0,
|
|
1210
|
-
panelRight: bottomSection?.getBoundingClientRect().right ?? 0
|
|
1211
|
-
}).top
|
|
1212
|
-
})) {
|
|
1213
|
-
if (draggingPanel) {
|
|
1214
|
-
draggingPanel.setAttribute("style", "display: none; height: 0;");
|
|
1215
|
-
}
|
|
1216
|
-
if (bottomPanel && snapshotSection) {
|
|
1217
|
-
if (bottomSection) {
|
|
1218
|
-
DragAndDrop2.shadowDiv.setAttribute("style", "opacity: 50%;");
|
|
1219
|
-
DragAndDrop2.debounceBefore(
|
|
1220
|
-
bottomPanel,
|
|
1221
|
-
DragAndDrop2.shadowDiv,
|
|
1222
|
-
bottomSection
|
|
1223
|
-
);
|
|
1224
|
-
DragAndDrop2.snapshot();
|
|
1225
|
-
DragAndDrop2.clearTimeout();
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
} else if (isCursorInArea({
|
|
1229
|
-
cursorX: ev.clientX,
|
|
1230
|
-
cursorY: ev.clientY + DragAndDrop2.currentScroll,
|
|
1231
|
-
...getColumnAreas({
|
|
1232
|
-
...DragAndDrop2.currentBottomPanel,
|
|
1233
|
-
panelLeft: bottomSection?.getBoundingClientRect().left ?? 0,
|
|
1234
|
-
panelRight: bottomSection?.getBoundingClientRect().right ?? 0
|
|
1235
|
-
}).bottom
|
|
1236
|
-
})) {
|
|
1237
|
-
const bottomPanel2 = DragAndDrop2.splash.querySelector(
|
|
1238
|
-
`[data-panel][data-id='${DragAndDrop2.currentBottomPanel.id}']`
|
|
1239
|
-
);
|
|
1240
|
-
const draggingPanel2 = DragAndDrop2.splash.querySelector(
|
|
1241
|
-
`[data-panel][data-id='${DragAndDrop2.draggingPanelId}']`
|
|
1242
|
-
);
|
|
1243
|
-
if (draggingPanel2) {
|
|
1244
|
-
draggingPanel2.setAttribute("style", "display: none;");
|
|
1245
|
-
}
|
|
1246
|
-
if (bottomPanel2 && snapshotSection) {
|
|
1247
|
-
const bottomSection2 = DragAndDrop2.splash.querySelector(
|
|
1248
|
-
`[data-locationid='${snapshotSection.sectionId}']`
|
|
1249
|
-
);
|
|
1250
|
-
if (bottomSection2) {
|
|
1251
|
-
DragAndDrop2.shadowDiv.setAttribute("style", "opacity: 50%;");
|
|
1252
|
-
DragAndDrop2.debounceAfter(DragAndDrop2.shadowDiv, bottomPanel2);
|
|
1253
|
-
DragAndDrop2.snapshot();
|
|
1254
|
-
DragAndDrop2.clearTimeout();
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
} else if (!DragAndDrop2.currentBottomPanel && snapshotSection) {
|
|
1260
|
-
const bottomSection = DragAndDrop2.splash.querySelector(
|
|
1261
|
-
`[data-locationid='${snapshotSection.sectionId}']`
|
|
1262
|
-
);
|
|
1263
|
-
if (bottomSection) {
|
|
1264
|
-
const draggingPanel = DragAndDrop2.splash.querySelector(
|
|
1265
|
-
`[data-panel][data-id='${DragAndDrop2.draggingPanelId}']`
|
|
1266
|
-
);
|
|
1267
|
-
if (draggingPanel) {
|
|
1268
|
-
draggingPanel.setAttribute("style", "display: none;");
|
|
1269
|
-
}
|
|
1270
|
-
DragAndDrop2.shadowDiv.setAttribute("style", "opacity: 50%;");
|
|
1271
|
-
DragAndDrop2.debounceAppend(
|
|
1272
|
-
bottomSection,
|
|
1273
|
-
DragAndDrop2.shadowDiv
|
|
1274
|
-
);
|
|
1275
|
-
DragAndDrop2.snapshot();
|
|
1276
|
-
DragAndDrop2.clearTimeout();
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
function dragstart(ev, el, DragAndDrop2) {
|
|
1283
|
-
if (!(el instanceof HTMLElement))
|
|
1284
|
-
return;
|
|
1285
|
-
DragAndDrop2.drawMinimap();
|
|
1286
|
-
DragAndDrop2.sectionData = [];
|
|
1287
|
-
const targetPanel = getSpecificParent(
|
|
1288
|
-
ev.target,
|
|
1289
|
-
(current) => !!current.dataset?.id && !!current.dataset?.panel
|
|
1290
|
-
);
|
|
1291
|
-
ev?.dataTransfer?.setData("text", targetPanel?.dataset.id);
|
|
1292
|
-
if (targetPanel) {
|
|
1293
|
-
DragAndDrop2.placeholderImage = targetPanel.cloneNode(true);
|
|
1294
|
-
DragAndDrop2.placeholderImage.style.position = "fixed";
|
|
1295
|
-
DragAndDrop2.placeholderImage.style.top = "-10000000.45px";
|
|
1296
|
-
const children = DragAndDrop2.placeholderImage.querySelectorAll("*");
|
|
1297
|
-
children.forEach((current) => current.style.overflow = "hidden");
|
|
1298
|
-
document.body.append(DragAndDrop2.placeholderImage);
|
|
1299
|
-
ev?.dataTransfer?.setDragImage(DragAndDrop2.placeholderImage, 0, 0);
|
|
1300
|
-
}
|
|
1301
|
-
if (ev.dataTransfer) {
|
|
1302
|
-
ev.dataTransfer.effectAllowed = "move";
|
|
1303
|
-
}
|
|
1304
|
-
setTimeout(() => {
|
|
1305
|
-
const targetSection = getSpecificParent(
|
|
1306
|
-
ev.target,
|
|
1307
|
-
(current) => !!current.dataset?.locationid
|
|
1308
|
-
);
|
|
1309
|
-
const sections = DragAndDrop2.body?.querySelectorAll("[data-locationid]");
|
|
1310
|
-
const emptySectionsId = [];
|
|
1311
|
-
sections?.forEach((sec) => {
|
|
1312
|
-
if (sec.children.length === 0) {
|
|
1313
|
-
emptySectionsId.push(sec.dataset.locationid ?? "");
|
|
1314
|
-
}
|
|
1315
|
-
});
|
|
1316
|
-
emptySectionsId.forEach((emptySecId) => {
|
|
1317
|
-
const section = DragAndDrop2.body?.querySelector(
|
|
1318
|
-
`[data-locationid="${emptySecId}"]`
|
|
1319
|
-
);
|
|
1320
|
-
if (section) {
|
|
1321
|
-
section.setAttribute("style", "padding: 10px; border:2px dashed #ccc");
|
|
1322
|
-
}
|
|
1323
|
-
});
|
|
1324
|
-
DragAndDrop2.snapshot();
|
|
1325
|
-
if (targetPanel) {
|
|
1326
|
-
DragAndDrop2.draggingPanelSectionId = targetSection?.dataset.locationid ?? "";
|
|
1327
|
-
DragAndDrop2.draggingPanelId = targetPanel.dataset.id;
|
|
1328
|
-
DragAndDrop2.draggingPanel = targetPanel;
|
|
1329
|
-
}
|
|
1330
|
-
if (DragAndDrop2.draggingPanelId === "") {
|
|
1331
|
-
return;
|
|
1332
|
-
}
|
|
1333
|
-
const falseDiv = targetPanel?.cloneNode(true);
|
|
1334
|
-
falseDiv.style.opacity = `50%`;
|
|
1335
|
-
falseDiv.style.width = `100%`;
|
|
1336
|
-
falseDiv.style.height = `auto`;
|
|
1337
|
-
falseDiv.style.backgroundColor = `rgba(0,0,0,0.1)`;
|
|
1338
|
-
falseDiv.className = "apia_panel_falseDiv";
|
|
1339
|
-
DragAndDrop2.shadowDiv = falseDiv;
|
|
1340
|
-
}, 0);
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
function Drop(event, DragAndDrop2) {
|
|
1344
|
-
if (DragAndDrop2.body) {
|
|
1345
|
-
const ev = event;
|
|
1346
|
-
const data = ev?.dataTransfer?.getData("text");
|
|
1347
|
-
const sections = DragAndDrop2.body?.querySelectorAll("[data-locationid]");
|
|
1348
|
-
sections.forEach((sec) => {
|
|
1349
|
-
sec.setAttribute("style", "");
|
|
1350
|
-
});
|
|
1351
|
-
const draggingPanel = DragAndDrop2.body.querySelector(
|
|
1352
|
-
`[data-panel][data-id="${DragAndDrop2.draggingPanelId}"]:not(.apia_panel_falseDiv)`
|
|
1353
|
-
);
|
|
1354
|
-
if (draggingPanel) {
|
|
1355
|
-
draggingPanel.setAttribute("style", "");
|
|
1356
|
-
}
|
|
1357
|
-
const falseDiv = document.querySelector(".apia_panel_falseDiv");
|
|
1358
|
-
if (data) {
|
|
1359
|
-
const child = document.querySelector(
|
|
1360
|
-
`[data-panel][data-id="${data}"]:not(.apia_panel_falseDiv)`
|
|
1361
|
-
);
|
|
1362
|
-
sections.forEach((sec) => {
|
|
1363
|
-
if (sec.children.length === 1) {
|
|
1364
|
-
sec.setAttribute("style", "");
|
|
1365
|
-
}
|
|
1366
|
-
});
|
|
1367
|
-
if (falseDiv) {
|
|
1368
|
-
const newSection = getSpecificParent(
|
|
1369
|
-
falseDiv,
|
|
1370
|
-
(current) => !!current.dataset.locationid
|
|
1371
|
-
);
|
|
1372
|
-
if (newSection) {
|
|
1373
|
-
const panelsArray = Array.from(newSection.children);
|
|
1374
|
-
const childId = child.dataset.id;
|
|
1375
|
-
if (childId) {
|
|
1376
|
-
const index = panelsArray.findIndex(
|
|
1377
|
-
(panel) => panel.dataset.id === childId
|
|
1378
|
-
);
|
|
1379
|
-
if (typeof index === "number" && newSection.dataset.locationid) {
|
|
1380
|
-
void updatePanelPosition(
|
|
1381
|
-
childId,
|
|
1382
|
-
newSection.dataset.locationid,
|
|
1383
|
-
index + 1
|
|
1384
|
-
);
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
falseDiv.replaceWith(child);
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
DragAndDrop2.draggingPanelId = "";
|
|
1392
|
-
DragAndDrop2.panelData = [];
|
|
1393
|
-
DragAndDrop2.drawMinimap();
|
|
1394
|
-
DragAndDrop2.removePlaceholder();
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
var __defProp$2 = Object.defineProperty;
|
|
1399
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1400
|
-
var __publicField$2 = (obj, key, value) => {
|
|
1401
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1402
|
-
return value;
|
|
1403
|
-
};
|
|
1404
|
-
var __accessCheck$2 = (obj, member, msg) => {
|
|
1405
|
-
if (!member.has(obj))
|
|
1406
|
-
throw TypeError("Cannot " + msg);
|
|
1407
|
-
};
|
|
1408
|
-
var __privateGet$2 = (obj, member, getter) => {
|
|
1409
|
-
__accessCheck$2(obj, member, "read from private field");
|
|
1410
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
1411
|
-
};
|
|
1412
|
-
var __privateAdd$2 = (obj, member, value) => {
|
|
1413
|
-
if (member.has(obj))
|
|
1414
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
1415
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1416
|
-
};
|
|
1417
|
-
var __privateSet$1 = (obj, member, value, setter) => {
|
|
1418
|
-
__accessCheck$2(obj, member, "write to private field");
|
|
1419
|
-
member.set(obj, value);
|
|
1420
|
-
return value;
|
|
1421
|
-
};
|
|
1422
|
-
var _unsuscribers;
|
|
1423
|
-
class DragAndDrop {
|
|
1424
|
-
constructor() {
|
|
1425
|
-
__privateAdd$2(this, _unsuscribers, []);
|
|
1426
|
-
__publicField$2(this, "bootstrap", () => {
|
|
1427
|
-
__privateGet$2(this, _unsuscribers).forEach((unsuscribe) => unsuscribe());
|
|
1428
|
-
__privateSet$1(this, _unsuscribers, []);
|
|
1429
|
-
this.body.addEventListener("dragover", this.dragOver);
|
|
1430
|
-
this.body.addEventListener("drop", this.drop);
|
|
1431
|
-
__privateGet$2(this, _unsuscribers).push(() => {
|
|
1432
|
-
this.body.removeEventListener("dragover", this.dragOver);
|
|
1433
|
-
this.body.removeEventListener("drop", this.drop);
|
|
1434
|
-
});
|
|
1435
|
-
if (this.splash) {
|
|
1436
|
-
this.splash.addEventListener("dragleave", this.dragLeave);
|
|
1437
|
-
this.splash.addEventListener("dragenter", this.dragEnter);
|
|
1438
|
-
this.body.addEventListener("dragenter", this.dragEnter);
|
|
1439
|
-
__privateGet$2(this, _unsuscribers).push(() => {
|
|
1440
|
-
this.splash.removeEventListener("dragleave", this.dragLeave);
|
|
1441
|
-
this.splash.removeEventListener("dragenter", this.dragEnter);
|
|
1442
|
-
this.body.removeEventListener("dragenter", this.dragEnter);
|
|
1443
|
-
});
|
|
1444
|
-
}
|
|
1445
|
-
this.panels.map((el) => {
|
|
1446
|
-
el.addEventListener("dragstart", (ev) => {
|
|
1447
|
-
this.dragStart(ev, el);
|
|
1448
|
-
});
|
|
1449
|
-
__privateGet$2(this, _unsuscribers).push(() => {
|
|
1450
|
-
el.removeEventListener("dragstart", (ev) => {
|
|
1451
|
-
this.dragStart(ev, el);
|
|
1452
|
-
});
|
|
1453
|
-
});
|
|
1454
|
-
return el;
|
|
1455
|
-
});
|
|
1456
|
-
});
|
|
1457
|
-
__publicField$2(this, "panelData", []);
|
|
1458
|
-
__publicField$2(this, "minimap", null);
|
|
1459
|
-
__publicField$2(this, "timeout", -1);
|
|
1460
|
-
__publicField$2(this, "sectionData", []);
|
|
1461
|
-
__publicField$2(this, "body", document.querySelector("[data-layout]"));
|
|
1462
|
-
__publicField$2(this, "splash", document.querySelector("[data-splash]"));
|
|
1463
|
-
__publicField$2(this, "dragoverPosition", { x: 0, y: 0 });
|
|
1464
|
-
__publicField$2(this, "shadowDivData", null);
|
|
1465
|
-
__publicField$2(this, "shadowDiv", null);
|
|
1466
|
-
__publicField$2(this, "placeholderImage", null);
|
|
1467
|
-
__publicField$2(this, "panels", [
|
|
1468
|
-
...document.querySelectorAll("[data-panel][data-id]")
|
|
1469
|
-
]);
|
|
1470
|
-
__publicField$2(this, "currentScroll", document.scrollingElement?.scrollTop ?? 0);
|
|
1471
|
-
__publicField$2(this, "draggingPanel", null);
|
|
1472
|
-
__publicField$2(this, "draggingPanelId", "");
|
|
1473
|
-
__publicField$2(this, "draggingPanelSectionId", "");
|
|
1474
|
-
__publicField$2(this, "currentBottomPanel");
|
|
1475
|
-
__publicField$2(this, "updateMinimap", () => {
|
|
1476
|
-
const frameElement = document.querySelector(".windowFrame");
|
|
1477
|
-
if (frameElement) {
|
|
1478
|
-
frameElement.style.top = `${(document.scrollingElement?.scrollTop ?? 0) * Number(frameElement.dataset.aspect)}px`;
|
|
1479
|
-
}
|
|
1480
|
-
});
|
|
1481
|
-
__publicField$2(this, "removePlaceholder", () => {
|
|
1482
|
-
this.clearTimeout();
|
|
1483
|
-
const falseDivs = document.querySelectorAll(".apia_panel_falseDiv");
|
|
1484
|
-
falseDivs.forEach((el) => {
|
|
1485
|
-
el.remove();
|
|
1486
|
-
});
|
|
1487
|
-
this.placeholderImage?.remove();
|
|
1488
|
-
this.placeholderImage = null;
|
|
1489
|
-
});
|
|
1490
|
-
__publicField$2(this, "clearTimeout", () => {
|
|
1491
|
-
clearTimeout(this.timeout);
|
|
1492
|
-
});
|
|
1493
|
-
__publicField$2(this, "debounceAppend", (target, child) => {
|
|
1494
|
-
if (!this.draggingPanelId)
|
|
1495
|
-
return;
|
|
1496
|
-
if (this.timeout === -1) {
|
|
1497
|
-
target.appendChild(child);
|
|
1498
|
-
}
|
|
1499
|
-
clearTimeout(this.timeout);
|
|
1500
|
-
this.timeout = setTimeout(() => {
|
|
1501
|
-
target.appendChild(child);
|
|
1502
|
-
}, 500);
|
|
1503
|
-
});
|
|
1504
|
-
__publicField$2(this, "debounceBefore", (reference, child, container) => {
|
|
1505
|
-
if (!this.draggingPanelId)
|
|
1506
|
-
return;
|
|
1507
|
-
if (this.timeout === -1)
|
|
1508
|
-
container.insertBefore(child, reference);
|
|
1509
|
-
clearTimeout(this.timeout);
|
|
1510
|
-
this.timeout = setTimeout(() => {
|
|
1511
|
-
container.insertBefore(child, reference);
|
|
1512
|
-
}, 500);
|
|
1513
|
-
});
|
|
1514
|
-
__publicField$2(this, "debounceAfter", (child, reference) => {
|
|
1515
|
-
if (!this.draggingPanelId)
|
|
1516
|
-
return;
|
|
1517
|
-
if (this.timeout === -1)
|
|
1518
|
-
reference.after(child);
|
|
1519
|
-
clearTimeout(this.timeout);
|
|
1520
|
-
this.timeout = setTimeout(() => {
|
|
1521
|
-
reference.after(child);
|
|
1522
|
-
}, 500);
|
|
1523
|
-
});
|
|
1524
|
-
__publicField$2(this, "dragOver", (event) => {
|
|
1525
|
-
dragover(event, this);
|
|
1526
|
-
this.updateMinimap();
|
|
1527
|
-
});
|
|
1528
|
-
__publicField$2(this, "dragStart", (ev, el) => {
|
|
1529
|
-
dragstart(ev, el, this);
|
|
1530
|
-
});
|
|
1531
|
-
__publicField$2(this, "dragLeave", (_ev) => {
|
|
1532
|
-
dragleave(_ev, this);
|
|
1533
|
-
});
|
|
1534
|
-
__publicField$2(this, "dragEnter", (_ev) => {
|
|
1535
|
-
_ev.preventDefault();
|
|
1536
|
-
});
|
|
1537
|
-
__publicField$2(this, "drop", (event) => {
|
|
1538
|
-
Drop(event, this);
|
|
1539
|
-
});
|
|
1540
|
-
__publicField$2(this, "snapshot", () => {
|
|
1541
|
-
this.panelData = [];
|
|
1542
|
-
const innerPanels = this.body.querySelectorAll(
|
|
1543
|
-
"[data-panel][data-id]"
|
|
1544
|
-
);
|
|
1545
|
-
innerPanels.forEach((panel) => {
|
|
1546
|
-
if (panel.classList.contains("apia_panel_falseDiv")) {
|
|
1547
|
-
this.shadowDivData = {
|
|
1548
|
-
id: panel.getAttribute("data-id") ?? "",
|
|
1549
|
-
isShadow: true,
|
|
1550
|
-
panelBottom: panel.getBoundingClientRect().bottom + this.currentScroll,
|
|
1551
|
-
panelTop: panel.getBoundingClientRect().top + this.currentScroll,
|
|
1552
|
-
panelRight: panel.getBoundingClientRect().right,
|
|
1553
|
-
panelLeft: panel.getBoundingClientRect().left,
|
|
1554
|
-
panelWidth: panel.getBoundingClientRect().width,
|
|
1555
|
-
panelHeight: panel.getBoundingClientRect().height,
|
|
1556
|
-
row: getSpecificParent(
|
|
1557
|
-
panel,
|
|
1558
|
-
(current) => !!current.dataset.locationid
|
|
1559
|
-
)?.classList.contains("apia_section_row") ?? false,
|
|
1560
|
-
sectionId: getSpecificParent(
|
|
1561
|
-
panel,
|
|
1562
|
-
(current) => !!current.dataset.locationid
|
|
1563
|
-
)?.dataset.locationid ?? 0
|
|
1564
|
-
};
|
|
1565
|
-
}
|
|
1566
|
-
if (this.panelData.every((innerPanel) => {
|
|
1567
|
-
return innerPanel.id !== panel.getAttribute("data-id") && !panel.classList.contains("apia_panel_falseDiv");
|
|
1568
|
-
})) {
|
|
1569
|
-
this.panelData.push({
|
|
1570
|
-
isShadow: panel.classList.contains("apia_panel_falseDiv"),
|
|
1571
|
-
panelBottom: panel.getBoundingClientRect().bottom + this.currentScroll,
|
|
1572
|
-
panelTop: panel.getBoundingClientRect().top + this.currentScroll,
|
|
1573
|
-
panelRight: panel.getBoundingClientRect().right,
|
|
1574
|
-
panelLeft: panel.getBoundingClientRect().left,
|
|
1575
|
-
panelWidth: panel.getBoundingClientRect().width,
|
|
1576
|
-
panelHeight: panel.getBoundingClientRect().height,
|
|
1577
|
-
row: getSpecificParent(
|
|
1578
|
-
panel,
|
|
1579
|
-
(current) => !!current.dataset.locationid
|
|
1580
|
-
)?.classList.contains("apia_section_row") ?? false,
|
|
1581
|
-
sectionId: getSpecificParent(
|
|
1582
|
-
panel,
|
|
1583
|
-
(current) => !!current.dataset.locationid
|
|
1584
|
-
)?.dataset.locationid ?? 0,
|
|
1585
|
-
id: getSpecificParent(
|
|
1586
|
-
panel,
|
|
1587
|
-
(current) => !!current.dataset.id
|
|
1588
|
-
)?.dataset.id ?? 0
|
|
1589
|
-
});
|
|
1590
|
-
}
|
|
1591
|
-
});
|
|
1592
|
-
this.sectionData = [];
|
|
1593
|
-
const sections = this.body?.querySelectorAll("[data-locationid]");
|
|
1594
|
-
sections?.forEach((sec) => {
|
|
1595
|
-
if (this.sectionData.every(
|
|
1596
|
-
(innerSection) => innerSection.sectionId !== sec.getAttribute("data-locationid")
|
|
1597
|
-
)) {
|
|
1598
|
-
this.sectionData.push({
|
|
1599
|
-
sectionBottom: sec.getBoundingClientRect().bottom + this.currentScroll,
|
|
1600
|
-
sectionLeft: sec.getBoundingClientRect().left,
|
|
1601
|
-
sectionTop: sec.getBoundingClientRect().top + this.currentScroll,
|
|
1602
|
-
sectionRight: sec.getBoundingClientRect().right,
|
|
1603
|
-
sectionWidth: sec.getBoundingClientRect().width,
|
|
1604
|
-
sectionHeight: sec.getBoundingClientRect().height,
|
|
1605
|
-
sectionId: getSpecificParent(
|
|
1606
|
-
sec,
|
|
1607
|
-
(current) => !!current.dataset.locationid
|
|
1608
|
-
)?.dataset.locationid ?? 0
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
});
|
|
1612
|
-
this.drawMinimap();
|
|
1613
|
-
});
|
|
1614
|
-
__publicField$2(this, "findBottomPanel", (x, y) => {
|
|
1615
|
-
const bottomPanel = this.panelData.find((panel) => {
|
|
1616
|
-
return panel.panelBottom >= y && panel.panelTop <= y && panel.panelLeft <= x && panel.panelRight >= x;
|
|
1617
|
-
});
|
|
1618
|
-
return bottomPanel;
|
|
1619
|
-
});
|
|
1620
|
-
__publicField$2(this, "findBottomSection", (x, y) => {
|
|
1621
|
-
const bottomSection = this.sectionData.find((sec) => {
|
|
1622
|
-
return sec.sectionBottom >= y && sec.sectionTop <= y && sec.sectionLeft <= x && sec.sectionRight >= x;
|
|
1623
|
-
});
|
|
1624
|
-
return bottomSection;
|
|
1625
|
-
});
|
|
1626
|
-
}
|
|
1627
|
-
drawMinimap() {
|
|
1628
|
-
return;
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
_unsuscribers = new WeakMap();
|
|
1632
|
-
|
|
1633
|
-
var __defProp$1 = Object.defineProperty;
|
|
1634
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1635
|
-
var __publicField$1 = (obj, key, value) => {
|
|
1636
|
-
__defNormalProp$1(obj, key + "" , value);
|
|
1637
|
-
return value;
|
|
1638
|
-
};
|
|
1639
|
-
var __accessCheck$1 = (obj, member, msg) => {
|
|
1640
|
-
if (!member.has(obj))
|
|
1641
|
-
throw TypeError("Cannot " + msg);
|
|
1642
|
-
};
|
|
1643
|
-
var __privateGet$1 = (obj, member, getter) => {
|
|
1644
|
-
__accessCheck$1(obj, member, "read from private field");
|
|
1645
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
1646
|
-
};
|
|
1647
|
-
var __privateAdd$1 = (obj, member, value) => {
|
|
1648
|
-
if (member.has(obj))
|
|
1649
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
1650
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1651
|
-
};
|
|
1652
|
-
var _matchLocation, _evalRoutes;
|
|
1653
|
-
class Router extends EventEmitter {
|
|
1654
|
-
constructor() {
|
|
1655
|
-
super();
|
|
1656
|
-
__privateAdd$1(this, _matchLocation, (regexp) => {
|
|
1657
|
-
const path = "/" + (window.location.href.replaceAll("%20", " ").match(new RegExp(`${window.CONTEXT}/?([^?]+)?(?:\\?.*)?`))?.[1] ?? "");
|
|
1658
|
-
return path.match(regexp);
|
|
1659
|
-
});
|
|
1660
|
-
__privateAdd$1(this, _evalRoutes, (routes) => {
|
|
1661
|
-
for (let i = 0; i < routes.length; i++) {
|
|
1662
|
-
const match = __privateGet$1(this, _matchLocation).call(this, routes[i].route);
|
|
1663
|
-
if (match) {
|
|
1664
|
-
return { route: routes[i], match };
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
});
|
|
1668
|
-
/**
|
|
1669
|
-
* Se evaluarán las rutas en orden y la primera en coincidir será tomada como
|
|
1670
|
-
* resultado del cambio de ruta.
|
|
1671
|
-
*
|
|
1672
|
-
* Las rutas provistas deberán matchear contra el path actual. El path actual
|
|
1673
|
-
* es la porción de la ruta luego del dominio y el contexto. Ejemplo:
|
|
1674
|
-
*
|
|
1675
|
-
* http://localhost/apia => path='/'
|
|
1676
|
-
* http://localhost/apia/spa/categories/comidas/1 => path='/spa/categories/comidas/1'
|
|
1677
|
-
*/
|
|
1678
|
-
__publicField$1(this, "useSwitch", (routes) => {
|
|
1679
|
-
const lastMatch = useRef(null);
|
|
1680
|
-
useMount(() => {
|
|
1681
|
-
const result = __privateGet$1(this, _evalRoutes).call(this, routes);
|
|
1682
|
-
if (result) {
|
|
1683
|
-
result.route.callback(result.match);
|
|
1684
|
-
}
|
|
1685
|
-
return this.on("newRoute", () => {
|
|
1686
|
-
const result2 = __privateGet$1(this, _evalRoutes).call(this, routes);
|
|
1687
|
-
if (result2 && !shallowEqual(result2.match, lastMatch.current)) {
|
|
1688
|
-
result2.route.callback(result2.match);
|
|
1689
|
-
}
|
|
1690
|
-
});
|
|
1691
|
-
});
|
|
1692
|
-
});
|
|
1693
|
-
window.addEventListener("popstate", () => {
|
|
1694
|
-
this.emit("newRoute", window.location.href);
|
|
1695
|
-
});
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
_matchLocation = new WeakMap();
|
|
1699
|
-
_evalRoutes = new WeakMap();
|
|
1700
|
-
|
|
1701
|
-
var __defProp = Object.defineProperty;
|
|
1702
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1703
|
-
var __publicField = (obj, key, value) => {
|
|
1704
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1705
|
-
return value;
|
|
1706
|
-
};
|
|
1707
|
-
var __accessCheck = (obj, member, msg) => {
|
|
1708
|
-
if (!member.has(obj))
|
|
1709
|
-
throw TypeError("Cannot " + msg);
|
|
1710
|
-
};
|
|
1711
|
-
var __privateGet = (obj, member, getter) => {
|
|
1712
|
-
__accessCheck(obj, member, "read from private field");
|
|
1713
|
-
return member.get(obj);
|
|
1714
|
-
};
|
|
1715
|
-
var __privateAdd = (obj, member, value) => {
|
|
1716
|
-
if (member.has(obj))
|
|
1717
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
1718
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1719
|
-
};
|
|
1720
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
1721
|
-
__accessCheck(obj, member, "write to private field");
|
|
1722
|
-
member.set(obj, value);
|
|
1723
|
-
return value;
|
|
1724
|
-
};
|
|
1725
|
-
var _currentScene, _dragAndDrop, _PanelContainer, _panelsRenderedPortals, _loadPanels, _Context, _suscribeToEvents, _usePanelsList, _SceneRenderer;
|
|
1726
|
-
class Dashboard extends EventEmitter {
|
|
1727
|
-
constructor(panelsContainer = DefaultPanelWrapper, urlContext) {
|
|
1728
|
-
super();
|
|
1729
|
-
this.urlContext = urlContext;
|
|
1730
|
-
__publicField(this, "bootstrapper", new DashboardPanelsBootstraper(this));
|
|
1731
|
-
__publicField(this, "panels", null);
|
|
1732
|
-
__publicField(this, "router", new Router());
|
|
1733
|
-
__publicField(this, "scenes", {});
|
|
1734
|
-
__privateAdd(this, _currentScene, "/");
|
|
1735
|
-
__privateAdd(this, _dragAndDrop, new DragAndDrop());
|
|
1736
|
-
__privateAdd(this, _PanelContainer, DefaultPanelWrapper);
|
|
1737
|
-
__privateAdd(this, _panelsRenderedPortals, []);
|
|
1738
|
-
__publicField(this, "getPanel", (id) => this.panels?.[id]);
|
|
1739
|
-
__publicField(this, "getPanelByName", (name) => Object.values(this.panels ?? {}).find(
|
|
1740
|
-
(current) => current.props.name === name
|
|
1741
|
-
));
|
|
1742
|
-
__privateAdd(this, _loadPanels, () => {
|
|
1743
|
-
this.panels = {};
|
|
1744
|
-
const panelsElements = document.querySelectorAll(
|
|
1745
|
-
"[data-panel]"
|
|
1746
|
-
);
|
|
1747
|
-
Array.from(panelsElements).forEach((current) => {
|
|
1748
|
-
const panel = new DashboardPanel({
|
|
1749
|
-
dashboard: this,
|
|
1750
|
-
PanelContainer: __privateGet(this, _PanelContainer),
|
|
1751
|
-
id: current.dataset.id
|
|
1752
|
-
});
|
|
1753
|
-
let panelPath = panel.getParameters().PAR_SPA_PATH || "*";
|
|
1754
|
-
if (panelPath === "/")
|
|
1755
|
-
panelPath = `/${this.urlContext}`;
|
|
1756
|
-
if (panelPath !== "*")
|
|
1757
|
-
panel.hide();
|
|
1758
|
-
else
|
|
1759
|
-
panel.show();
|
|
1760
|
-
const paths = panelPath.split(",");
|
|
1761
|
-
paths.forEach((currentPath) => {
|
|
1762
|
-
if (!this.scenes[currentPath])
|
|
1763
|
-
this.scenes[currentPath] = [];
|
|
1764
|
-
this.scenes[currentPath].push(panel.props.id);
|
|
1765
|
-
});
|
|
1766
|
-
this.panels[panel.props.id] = panel;
|
|
1767
|
-
__privateGet(this, _panelsRenderedPortals).push(panel.portal);
|
|
1768
|
-
});
|
|
1769
|
-
__privateGet(this, _dragAndDrop).bootstrap();
|
|
1770
|
-
});
|
|
1771
|
-
__privateAdd(this, _Context, ({ children }) => {
|
|
1772
|
-
return /* @__PURE__ */ jsx(DashboardContext.Provider, { value: this, children });
|
|
1773
|
-
});
|
|
1774
|
-
__privateAdd(this, _suscribeToEvents, () => {
|
|
1775
|
-
eventsController.onEvent({ eventType: "dashboard__focus" }, () => {
|
|
1776
|
-
Object.values(this.panels ?? {}).forEach((current) => {
|
|
1777
|
-
if (current.props.refreshOnHome) {
|
|
1778
|
-
void current.refresh();
|
|
1779
|
-
}
|
|
1780
|
-
});
|
|
1781
|
-
});
|
|
1782
|
-
});
|
|
1783
|
-
__privateAdd(this, _usePanelsList, () => {
|
|
1784
|
-
const [panels, setPanels] = useState(null);
|
|
1785
|
-
const deferredPanels = useDeferredValue(panels);
|
|
1786
|
-
useMount(() => {
|
|
1787
|
-
this.loadScene();
|
|
1788
|
-
setPanels(__privateGet(this, _panelsRenderedPortals));
|
|
1789
|
-
});
|
|
1790
|
-
this.router.useSwitch([
|
|
1791
|
-
{
|
|
1792
|
-
route: new RegExp(`(?:/spa)?/(\\w+)`),
|
|
1793
|
-
callback: (result) => {
|
|
1794
|
-
console.log("Dashboard", { scene: result[1] });
|
|
1795
|
-
this.loadScene(result[1]);
|
|
1796
|
-
}
|
|
1797
|
-
},
|
|
1798
|
-
{
|
|
1799
|
-
route: new RegExp(`/`),
|
|
1800
|
-
callback: () => {
|
|
1801
|
-
console.log("Dashboard", { noScene: "/" });
|
|
1802
|
-
this.loadScene("/");
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
]);
|
|
1806
|
-
return deferredPanels;
|
|
1807
|
-
});
|
|
1808
|
-
__privateAdd(this, _SceneRenderer, () => {
|
|
1809
|
-
const Context = __privateGet(this, _Context);
|
|
1810
|
-
const panels = __privateGet(this, _usePanelsList).call(this);
|
|
1811
|
-
return /* @__PURE__ */ jsx(Context, { children: panels });
|
|
1812
|
-
});
|
|
1813
|
-
__publicField(this, "loadScene", (scene = __privateGet(this, _currentScene)) => {
|
|
1814
|
-
let actualScene = scene;
|
|
1815
|
-
if (!actualScene.startsWith("/"))
|
|
1816
|
-
actualScene = `/${actualScene}`;
|
|
1817
|
-
if (!this.panels)
|
|
1818
|
-
__privateGet(this, _loadPanels).call(this);
|
|
1819
|
-
if (!this.scenes[actualScene])
|
|
1820
|
-
this.scenes[actualScene] = [];
|
|
1821
|
-
this.scenes[__privateGet(this, _currentScene)].forEach((scenePanelId) => {
|
|
1822
|
-
if (!this.scenes[actualScene].includes(scenePanelId))
|
|
1823
|
-
this.panels?.[scenePanelId]?.hide();
|
|
1824
|
-
});
|
|
1825
|
-
this.scenes[actualScene].forEach((scenePanelIds) => {
|
|
1826
|
-
const panel = this.panels?.[scenePanelIds];
|
|
1827
|
-
if (panel) {
|
|
1828
|
-
panel.show();
|
|
1829
|
-
if (panel.hasInited && panel.props.refreshOnStart)
|
|
1830
|
-
void panel.refresh();
|
|
1831
|
-
}
|
|
1832
|
-
});
|
|
1833
|
-
__privateSet(this, _currentScene, actualScene);
|
|
1834
|
-
return __privateGet(this, _panelsRenderedPortals);
|
|
1835
|
-
});
|
|
1836
|
-
__publicField(this, "Component", () => {
|
|
1837
|
-
const R = __privateGet(this, _SceneRenderer);
|
|
1838
|
-
return /* @__PURE__ */ jsx(R, {});
|
|
1839
|
-
});
|
|
1840
|
-
__privateSet(this, _currentScene, `/`);
|
|
1841
|
-
__privateSet(this, _PanelContainer, panelsContainer ?? __privateGet(this, _PanelContainer));
|
|
1842
|
-
__privateGet(this, _suscribeToEvents).call(this);
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
_currentScene = new WeakMap();
|
|
1846
|
-
_dragAndDrop = new WeakMap();
|
|
1847
|
-
_PanelContainer = new WeakMap();
|
|
1848
|
-
_panelsRenderedPortals = new WeakMap();
|
|
1849
|
-
_loadPanels = new WeakMap();
|
|
1850
|
-
_Context = new WeakMap();
|
|
1851
|
-
_suscribeToEvents = new WeakMap();
|
|
1852
|
-
_usePanelsList = new WeakMap();
|
|
1853
|
-
_SceneRenderer = new WeakMap();
|
|
1854
|
-
|
|
1855
|
-
function usePanelParametersSelector(selector, panelName) {
|
|
1856
|
-
const { panelId } = usePanelIdentity();
|
|
1857
|
-
const dashboard = useDashboardContext();
|
|
1858
|
-
const id = panelName !== void 0 ? dashboard.getPanelByName(panelName)?.id ?? "" : panelId;
|
|
1859
|
-
return useSelector((global) => {
|
|
1860
|
-
const currentParams = global.panelParameters[id];
|
|
1861
|
-
return selector(currentParams ?? {});
|
|
1862
|
-
}, shallowEqual);
|
|
1863
|
-
}
|
|
1864
|
-
|
|
1865
|
-
const panelActionParameterName = "__panelTitleAction";
|
|
1866
|
-
const panelDescriptionParameterName = "__panelTitleDescription";
|
|
1867
|
-
function setPanelTitleAction(panelId, newAction) {
|
|
1868
|
-
store.dispatch(
|
|
1869
|
-
parametersActions.udpate({
|
|
1870
|
-
panelId,
|
|
1871
|
-
parameters: { [panelActionParameterName]: newAction }
|
|
1872
|
-
})
|
|
1873
|
-
);
|
|
1874
|
-
}
|
|
1875
|
-
function setPanelTitleDescritpion(panelId, newDescription) {
|
|
1876
|
-
store.dispatch(
|
|
1877
|
-
parametersActions.udpate({
|
|
1878
|
-
panelId,
|
|
1879
|
-
parameters: { [panelDescriptionParameterName]: newDescription }
|
|
1880
|
-
})
|
|
1881
|
-
);
|
|
1882
|
-
}
|
|
1883
|
-
function usePanelTitleAction() {
|
|
1884
|
-
return usePanelParametersSelector(
|
|
1885
|
-
(current) => current[panelActionParameterName]
|
|
1886
|
-
);
|
|
1887
|
-
}
|
|
1888
|
-
function usePanelTitleDescription() {
|
|
1889
|
-
return usePanelParametersSelector(
|
|
1890
|
-
(current) => current[panelDescriptionParameterName]
|
|
1891
|
-
);
|
|
1892
|
-
}
|
|
1893
|
-
|
|
1894
|
-
function firePanelAction(panelId, action, parameters, options) {
|
|
1895
|
-
const postData = { p_action: action, ...parameters };
|
|
1896
|
-
panelActionsEmitter.emit(panelId, `pre${ucfirst(action)}`, null);
|
|
1897
|
-
void ApiaApi.post(
|
|
1898
|
-
makeApiaUrl({
|
|
1899
|
-
action: "panelAction",
|
|
1900
|
-
pnlId: panelId
|
|
1901
|
-
}),
|
|
1902
|
-
{ postData, postDataTreatement: "stringify", ...options?.requestConfig }
|
|
1903
|
-
).then((result) => {
|
|
1904
|
-
if (result?.status !== 200) {
|
|
1905
|
-
console.log("ERROR", panelId);
|
|
1906
|
-
panelNetworkStateEmitter.emit("stateChange", {
|
|
1907
|
-
panelId,
|
|
1908
|
-
isConnected: false
|
|
1909
|
-
});
|
|
1910
|
-
} else {
|
|
1911
|
-
panelNetworkStateEmitter.emit("stateChange", {
|
|
1912
|
-
panelId,
|
|
1913
|
-
isConnected: true
|
|
1914
|
-
});
|
|
1915
|
-
}
|
|
1916
|
-
try {
|
|
1917
|
-
if (result) {
|
|
1918
|
-
startTransition(() => {
|
|
1919
|
-
if (result?.data?.title) {
|
|
1920
|
-
changePanelTitle(
|
|
1921
|
-
panelId,
|
|
1922
|
-
result?.data?.title
|
|
1923
|
-
);
|
|
1924
|
-
}
|
|
1925
|
-
if (result?.data?.footer) {
|
|
1926
|
-
changePanelFooter(
|
|
1927
|
-
panelId,
|
|
1928
|
-
result?.data?.footer
|
|
1929
|
-
);
|
|
1930
|
-
}
|
|
1931
|
-
if (result?.data?.titleAction) {
|
|
1932
|
-
setPanelTitleAction(panelId, result?.data?.titleAction);
|
|
1933
|
-
}
|
|
1934
|
-
if (result?.data?.titleDescription) {
|
|
1935
|
-
setPanelTitleDescritpion(
|
|
1936
|
-
panelId,
|
|
1937
|
-
result?.data?.titleDescription
|
|
1938
|
-
);
|
|
1939
|
-
}
|
|
1940
|
-
options?.onComplete?.(true, result);
|
|
1941
|
-
panelActionsEmitter.emit(panelId, action, result);
|
|
1942
|
-
});
|
|
1943
|
-
} else
|
|
1944
|
-
options?.onComplete?.(false, null);
|
|
1945
|
-
} catch (e) {
|
|
1946
|
-
console.error(e);
|
|
1947
|
-
}
|
|
1948
|
-
}).catch((e) => {
|
|
1949
|
-
console.error(e);
|
|
1950
|
-
panelNetworkStateEmitter.emit("stateChange", {
|
|
1951
|
-
panelId,
|
|
1952
|
-
isConnected: false
|
|
1953
|
-
});
|
|
1954
|
-
options?.onComplete?.(false, null);
|
|
1955
|
-
});
|
|
1956
|
-
}
|
|
1957
|
-
|
|
1958
|
-
function handleAction(panelId, event, action) {
|
|
1959
|
-
if (event.type === "dblclick" && action.actionSource === "DOUBLE_CLICK" || (event.type === "click" || event.type === "mousedown") && action.actionSource === "CLICK" || event.type === "keydown" && event.code === "Enter") {
|
|
1960
|
-
if (action?.action) {
|
|
1961
|
-
switch (action.actionBehavior) {
|
|
1962
|
-
case "CALL_AJAX_URL":
|
|
1963
|
-
void ApiaApi.post(action.action, { handleLoad: true });
|
|
1964
|
-
break;
|
|
1965
|
-
case "DO_NOTHING":
|
|
1966
|
-
break;
|
|
1967
|
-
case "NAVIGATE_URL":
|
|
1968
|
-
window.location.assign(action.action);
|
|
1969
|
-
break;
|
|
1970
|
-
case "OPEN_TAB":
|
|
1971
|
-
window.top?.tabsController.openTabByUrl(
|
|
1972
|
-
action.actionNewTabTitle || action.text,
|
|
1973
|
-
action.action
|
|
1974
|
-
);
|
|
1975
|
-
break;
|
|
1976
|
-
case "RUN_ACTION":
|
|
1977
|
-
firePanelAction(
|
|
1978
|
-
panelId,
|
|
1979
|
-
action.action,
|
|
1980
|
-
{},
|
|
1981
|
-
{ requestConfig: {
|
|
1982
|
-
handleLoad: true
|
|
1983
|
-
} }
|
|
1984
|
-
);
|
|
1985
|
-
break;
|
|
1986
|
-
default:
|
|
1987
|
-
console.error("Unknown action behavior: ", action);
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
|
|
1993
|
-
const externalFirePanelAction = (panelId, { action, ...parameters }, options) => {
|
|
1994
|
-
const postData = {};
|
|
1995
|
-
Object.entries(parameters).forEach(([name, value]) => {
|
|
1996
|
-
postData[`p_${name}`] = value;
|
|
1997
|
-
});
|
|
1998
|
-
firePanelAction(panelId, action, postData, options);
|
|
1999
|
-
};
|
|
2000
|
-
|
|
2001
|
-
function usePanelIsLoading() {
|
|
2002
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
2003
|
-
usePanelActions({
|
|
2004
|
-
preRefresh: () => setIsLoading(true),
|
|
2005
|
-
refresh: () => setIsLoading(false)
|
|
2006
|
-
});
|
|
2007
|
-
return isLoading;
|
|
2008
|
-
}
|
|
2009
|
-
|
|
2010
|
-
const NetworkState = ({ title }) => {
|
|
2011
|
-
const isConnected = usePanelNetworkState();
|
|
2012
|
-
return /* @__PURE__ */ jsx(Fragment, { children: !isConnected && /* @__PURE__ */ jsx(
|
|
2013
|
-
Icon,
|
|
2014
|
-
{
|
|
2015
|
-
tabIndex: 0,
|
|
2016
|
-
title: getLabel("lblTestDBNoOk", {
|
|
2017
|
-
text: {
|
|
2018
|
-
TOK1: title
|
|
2019
|
-
}
|
|
2020
|
-
}).text,
|
|
2021
|
-
"aria-label": getLabel("lblTestDBNoOk", {
|
|
2022
|
-
text: {
|
|
2023
|
-
TOK1: title
|
|
2024
|
-
}
|
|
2025
|
-
}).text,
|
|
2026
|
-
name: "Alert"
|
|
2027
|
-
}
|
|
2028
|
-
) });
|
|
2029
|
-
};
|
|
2030
|
-
|
|
2031
|
-
const LandingPagePanelWrapper = ({
|
|
2032
|
-
children,
|
|
2033
|
-
...props
|
|
2034
|
-
}) => {
|
|
2035
|
-
const { panelId, panelName, panelType } = usePanelIdentity();
|
|
2036
|
-
const { contextValue, title, ref, ...footerProps } = useMakePanelContext(
|
|
2037
|
-
panelId,
|
|
2038
|
-
props
|
|
2039
|
-
);
|
|
2040
|
-
const panelTitleAction = usePanelTitleAction();
|
|
2041
|
-
const panelTitleDescription = usePanelTitleDescription();
|
|
2042
|
-
const dashboard = useDashboardContext();
|
|
2043
|
-
if (dashboard.getPanel(panelId).props.hasRss)
|
|
2044
|
-
console.log(dashboard.getPanel(panelId).props);
|
|
2045
|
-
return /* @__PURE__ */ jsx(PanelContextProvider, { value: contextValue, children: /* @__PURE__ */ jsxs(
|
|
2046
|
-
"div",
|
|
2047
|
-
{
|
|
2048
|
-
className: "panel__container",
|
|
2049
|
-
"data-panelname": panelName,
|
|
2050
|
-
"data-paneltype": panelType,
|
|
2051
|
-
"data-panelid": panelId,
|
|
2052
|
-
ref,
|
|
2053
|
-
children: [
|
|
2054
|
-
/* @__PURE__ */ jsx("div", { className: "panel__header", children: /* @__PURE__ */ jsxs("div", { className: "panel__header__left", children: [
|
|
2055
|
-
props.showTitle && /* @__PURE__ */ jsx("span", { className: "panel__title", children: panelTitleAction ? /* @__PURE__ */ jsx(
|
|
2056
|
-
"a",
|
|
2057
|
-
{
|
|
2058
|
-
title: panelTitleDescription,
|
|
2059
|
-
className: "panel__title__link",
|
|
2060
|
-
href: panelTitleAction,
|
|
2061
|
-
children: title
|
|
2062
|
-
}
|
|
2063
|
-
) : title }),
|
|
2064
|
-
/* @__PURE__ */ jsx(NetworkState, { title })
|
|
2065
|
-
] }) }),
|
|
2066
|
-
/* @__PURE__ */ jsx("div", { className: "panel__content", children }),
|
|
2067
|
-
/* @__PURE__ */ jsx(PanelFooter, { isRefreshable: false, ...footerProps })
|
|
2068
|
-
]
|
|
2069
|
-
}
|
|
2070
|
-
) });
|
|
2071
|
-
};
|
|
2072
|
-
|
|
2073
|
-
const reducers = {};
|
|
2074
|
-
function initPanelTypeUpdater(panelType) {
|
|
2075
|
-
if (!reducers[panelType]) {
|
|
2076
|
-
reducers[panelType] = {
|
|
2077
|
-
defaultReducer: (panelsState, payload) => {
|
|
2078
|
-
Object.assign(panelsState, payload);
|
|
2079
|
-
}
|
|
2080
|
-
};
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
function registerReducers(panelType, newReducers) {
|
|
2084
|
-
initPanelTypeUpdater(panelType);
|
|
2085
|
-
Object.assign(reducers[panelType], newReducers);
|
|
2086
|
-
}
|
|
2087
|
-
function initPanelState(state, panelType, panelId, initialState) {
|
|
2088
|
-
if (!state[panelType]) {
|
|
2089
|
-
state[panelType] = {};
|
|
2090
|
-
}
|
|
2091
|
-
if (!state[panelType][panelId])
|
|
2092
|
-
state[panelType][panelId] = {};
|
|
2093
|
-
state[panelType][panelId] = initialState;
|
|
2094
|
-
}
|
|
2095
|
-
const panelsSlice = createSlice({
|
|
2096
|
-
name: "panelsSlice",
|
|
2097
|
-
initialState: {},
|
|
2098
|
-
reducers: {
|
|
2099
|
-
initState(state, {
|
|
2100
|
-
payload: { panelId, panelType, initialState }
|
|
2101
|
-
}) {
|
|
2102
|
-
if (!state[panelType]?.[panelId]) {
|
|
2103
|
-
initPanelState(state, panelType, panelId, initialState);
|
|
2104
|
-
state[panelType][panelId] = initialState;
|
|
2105
|
-
}
|
|
2106
|
-
},
|
|
2107
|
-
updatePanelStore(state, {
|
|
2108
|
-
payload: { data, panelId, panelType, reducer, initialState }
|
|
2109
|
-
}) {
|
|
2110
|
-
if (!state[panelType]?.[panelId]) {
|
|
2111
|
-
initPanelState(state, panelType, panelId, initialState ?? {});
|
|
2112
|
-
}
|
|
2113
|
-
const panelsStore2 = state[panelType][panelId];
|
|
2114
|
-
initPanelTypeUpdater(panelType);
|
|
2115
|
-
if (!reducers[panelType][reducer ?? "default"]) {
|
|
2116
|
-
return;
|
|
2117
|
-
}
|
|
2118
|
-
const currentReducer = reducers[panelType][reducer ?? "default"];
|
|
2119
|
-
currentReducer(panelsStore2, data);
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
});
|
|
2123
|
-
const { useSelector: usePanelStoreSelector, store: panelsStore } = injectReducers({
|
|
2124
|
-
panelsSlice: panelsSlice.reducer
|
|
2125
|
-
});
|
|
2126
|
-
const panelsActions = panelsSlice.actions;
|
|
2127
|
-
|
|
2128
|
-
const undefinedObject = {};
|
|
2129
|
-
function usePanelSelector(panelType, panelName, initialState, selector, comparator = shallowEqual$1) {
|
|
2130
|
-
const { panelId } = usePanelIdentity();
|
|
2131
|
-
if (!panelId)
|
|
2132
|
-
throw new Error(`Cannot find panel with name ${panelName}`);
|
|
2133
|
-
const storeState = panelsStore.getState().panelsSlice[panelType];
|
|
2134
|
-
const [selection, setSelection] = useState(
|
|
2135
|
-
initialState ? selector(storeState?.[panelId] ?? initialState) : {}
|
|
2136
|
-
);
|
|
2137
|
-
const previousSelected = useRef(
|
|
2138
|
-
selection ?? undefinedObject
|
|
2139
|
-
);
|
|
2140
|
-
usePanelStoreSelector((global) => {
|
|
2141
|
-
const newState = global.panelsSlice[panelType]?.[panelId];
|
|
2142
|
-
if (newState !== void 0) {
|
|
2143
|
-
const newSelected = selector(newState);
|
|
2144
|
-
if (previousSelected.current === undefinedObject || !comparator(previousSelected.current, newSelected)) {
|
|
2145
|
-
previousSelected.current = newSelected;
|
|
2146
|
-
setSelection(newSelected);
|
|
2147
|
-
}
|
|
2148
|
-
}
|
|
2149
|
-
});
|
|
2150
|
-
return selection;
|
|
2151
|
-
}
|
|
2152
|
-
|
|
2153
|
-
function createPanelStore(panelType, initialState, reducers) {
|
|
2154
|
-
const useSelector = (panelName, selector, comparator = shallowEqual$1) => {
|
|
2155
|
-
const dashboard = useDashboardContext();
|
|
2156
|
-
const props = useMemo(
|
|
2157
|
-
() => dashboard.getPanelByName(panelName)?.props,
|
|
2158
|
-
[dashboard, panelName]
|
|
2159
|
-
);
|
|
2160
|
-
const propsRef = useLatest(props);
|
|
2161
|
-
useEffect(() => {
|
|
2162
|
-
panelsStore.dispatch(
|
|
2163
|
-
panelsActions.initState({
|
|
2164
|
-
panelType,
|
|
2165
|
-
panelId: propsRef.current.id,
|
|
2166
|
-
initialState
|
|
2167
|
-
})
|
|
2168
|
-
);
|
|
2169
|
-
}, []);
|
|
2170
|
-
return usePanelSelector(
|
|
2171
|
-
panelType,
|
|
2172
|
-
panelName,
|
|
2173
|
-
initialState,
|
|
2174
|
-
selector,
|
|
2175
|
-
comparator
|
|
2176
|
-
);
|
|
2177
|
-
};
|
|
2178
|
-
registerReducers(panelType, reducers);
|
|
2179
|
-
const usePanelDispatcher = () => {
|
|
2180
|
-
const { panelName: contextPanelName } = usePanelIdentity();
|
|
2181
|
-
const dispatchers = {};
|
|
2182
|
-
const dashboard = useDashboardContext();
|
|
2183
|
-
Object.entries(reducers).forEach(([name]) => {
|
|
2184
|
-
dispatchers[name] = (payload, panelName) => {
|
|
2185
|
-
const props = dashboard.getPanelByName(panelName ?? contextPanelName)?.props;
|
|
2186
|
-
panelsStore.dispatch(
|
|
2187
|
-
panelsActions.updatePanelStore({
|
|
2188
|
-
panelId: props.id,
|
|
2189
|
-
panelType,
|
|
2190
|
-
data: { payload },
|
|
2191
|
-
reducer: name
|
|
2192
|
-
})
|
|
2193
|
-
);
|
|
2194
|
-
};
|
|
2195
|
-
});
|
|
2196
|
-
return dispatchers;
|
|
2197
|
-
};
|
|
2198
|
-
return [usePanelDispatcher, useSelector];
|
|
2199
|
-
}
|
|
2200
|
-
|
|
2201
|
-
export { Dashboard, LandingPagePanelWrapper, PanelIdentifier, PanelIdentifierContext, changePanelTitle, createPanelStore, eventsController, externalFirePanelAction, handleAction, store as parametersStore, saveParameters, useDashboardContext, useDashboardPanel, usePanelActions, usePanelChangeTitle, usePanelContext, usePanelFireEvent, usePanelIdentity, usePanelIsLoading, usePanelNetworkState, usePanelOnEvent, usePanelParametersSelector, usePanelPosition, useYieldPanelIsReady };
|
|
1
|
+
export { usePanelPosition } from './position/usePanelPosition.js';
|
|
2
|
+
export { LandingPagePanelWrapper } from './splash/panels/LandingPagePanelWrapper.js';
|
|
3
|
+
export { PanelIdentifier, PanelIdentifierContext } from './splash/panels/PanelIdentifier.js';
|
|
4
|
+
export { usePanelContext } from './splash/panels/PanelContext/index.js';
|
|
5
|
+
export { useYieldPanelIsReady } from './splash/panels/PanelContext/useYieldPanelIsReady.js';
|
|
6
|
+
export { externalFirePanelAction } from './actions/externalFirePanelAction.js';
|
|
7
|
+
export { usePanelActions } from './actions/usePanelActions.js';
|
|
8
|
+
export { usePanelIsLoading } from './actions/usePanelIsLoading.js';
|
|
9
|
+
export { usePanelNetworkState } from './actions/usePanelNetworkState.js';
|
|
10
|
+
export { handleAction } from './actions/basicAction.js';
|
|
11
|
+
export { usePanelIdentity } from './common/usePanelIdentity.js';
|
|
12
|
+
export { usePanelParametersSelector } from './config/usePanelParametersSelector.js';
|
|
13
|
+
export { saveParameters } from './config/saveParameters.js';
|
|
14
|
+
export { parametersStore } from './config/parametersStore.js';
|
|
15
|
+
export { Dashboard } from './dashboard/dashboard.js';
|
|
16
|
+
export { useDashboardContext } from './dashboard/DashboardContext.js';
|
|
17
|
+
export { useDashboardPanel } from './dashboard/DashboardPanelContext.js';
|
|
18
|
+
export { usePanelFireEvent } from './eventsController/usePanelFireEvent.js';
|
|
19
|
+
export { usePanelOnEvent } from './eventsController/usePanelOnEvent.js';
|
|
20
|
+
export { eventsController } from './eventsController/eventsController.js';
|
|
21
|
+
export { changePanelTitle, usePanelChangeTitle } from './panelsUtil/usePanelChangeTitle.js';
|
|
22
|
+
export { createPanelStore } from './panelsStore/createPanelStore.js';
|
|
2202
23
|
//# sourceMappingURL=index.js.map
|