From 56bec4ff70a5993ab01253c853a427165c163edf Mon Sep 17 00:00:00 2001 From: Sovas Tiwari Date: Tue, 14 Oct 2025 13:26:15 +0100 Subject: [PATCH 1/2] Add the link existing dashboard support for the tabbed dashboard --- web/client/actions/widgets.js | 13 ++ .../components/dashboard/ConfigureView.jsx | 161 ++++++++++++------ web/client/components/dashboard/Dashboard.jsx | 56 +++--- web/client/components/dashboard/Layouts.jsx | 43 +++++ .../dashboard/WidgetViewWrapper.jsx | 44 +++-- .../dashboard/hooks/useLoadDashboardData.js | 83 +++++++++ web/client/epics/widgets.js | 5 +- web/client/plugins/AddWidgetDashboard.jsx | 15 +- web/client/plugins/Dashboard.jsx | 24 ++- web/client/plugins/MapConnectionDashboard.jsx | 16 +- web/client/reducers/widgets.js | 59 ++++++- web/client/selectors/widgets.js | 50 +++++- web/client/themes/default/less/dashboard.less | 17 +- web/client/translations/data.ca-ES.json | 3 +- web/client/translations/data.da-DK.json | 3 +- web/client/translations/data.de-DE.json | 3 +- web/client/translations/data.en-US.json | 3 +- web/client/translations/data.es-ES.json | 3 +- web/client/translations/data.fi-FI.json | 3 +- web/client/translations/data.fr-FR.json | 3 +- web/client/translations/data.hr-HR.json | 3 +- web/client/translations/data.is-IS.json | 3 +- web/client/translations/data.it-IT.json | 3 +- web/client/translations/data.nl-NL.json | 3 +- web/client/translations/data.pt-PT.json | 3 +- web/client/translations/data.sk-SK.json | 3 +- web/client/translations/data.sv-SE.json | 3 +- web/client/translations/data.vi-VN.json | 3 +- web/client/translations/data.zh-ZH.json | 3 +- web/client/utils/GeostoreUtils.js | 42 ++++- web/client/utils/WidgetsUtils.js | 42 +++++ .../utils/__tests__/WidgetsUtils-test.js | 39 ++++- 32 files changed, 592 insertions(+), 165 deletions(-) create mode 100644 web/client/components/dashboard/Layouts.jsx create mode 100644 web/client/components/dashboard/hooks/useLoadDashboardData.js diff --git a/web/client/actions/widgets.js b/web/client/actions/widgets.js index efcf27eee5..054eb3a8be 100644 --- a/web/client/actions/widgets.js +++ b/web/client/actions/widgets.js @@ -46,6 +46,7 @@ export const TOGGLE_TRAY = "WIDGET:TOGGLE_TRAY"; export const REPLACE_LAYOUT_VIEW = "WIDGET:REPLACE_LAYOUT_VIEW"; export const SET_SELECTED_LAYOUT_VIEW_ID = "WIDGET:SET_SELECTED_LAYOUT_VIEW_ID"; +export const SET_LINKED_DASHBOARD_DATA = "WIDGET:SET_LINKED_DASHBOARD_DATA"; /** * Intent to create a new Widgets @@ -348,3 +349,15 @@ export const setSelectedLayoutViewId = (viewId, target = DEFAULT_TARGET) => ({ target, viewId }); + +/** + * Set the layouts, widgets of the linked dashboard + * @param {object} data The layouts and widgets + * @param {string} [target=floating] the target container of the layouts + * @return {object} action with type `WIDGETS:SET_LINKED_DASHBOARD_DATA`, the data and the target + */ +export const setLinkedDashboardData = (data, target = DEFAULT_TARGET) => ({ + type: SET_LINKED_DASHBOARD_DATA, + data, + target +}); diff --git a/web/client/components/dashboard/ConfigureView.jsx b/web/client/components/dashboard/ConfigureView.jsx index 3c0c726a0c..6b20e4baec 100644 --- a/web/client/components/dashboard/ConfigureView.jsx +++ b/web/client/components/dashboard/ConfigureView.jsx @@ -1,67 +1,118 @@ import React, { useEffect, useState } from 'react'; import Dialog from '../misc/Dialog'; -import { Button, ControlLabel, FormControl, FormGroup, Glyphicon } from 'react-bootstrap'; +import { Button, ControlLabel, FormControl, FormGroup, Glyphicon, InputGroup } from 'react-bootstrap'; import Message from '../I18N/Message'; import ColorSelector from '../style/ColorSelector'; +import Select from 'react-select'; +import { connect } from 'react-redux'; +import { createStructuredSelector } from 'reselect'; +import { userSelector } from '../../selectors/security'; +import { getMonitoredStateSelector } from '../../plugins/ResourcesCatalog/selectors/resources'; +import Portal from '../misc/Portal'; +import { getCatalogResources } from '../../api/persistence'; -const ConfigureView = ({ active, onToggle, name, color, onSave }) => { +const ConfigureView = ({ active, onToggle, data, onSave, user, monitoredState }) => { const [setting, setSetting] = useState({ name: null, color: null }); + const [dashboardOptions, setDashboardOptions] = useState([]); + + useEffect(() => { + setSetting(data); + }, [data]); + useEffect(() => { - setSetting({ name, color }); - }, [name, color]); - return ( -
- {active && ( - - - - - -
- - - { - const { value } = event.target || {}; - setSetting(prev => ({ ...prev, name: value })); - }} + if (!setting?.linkExistingDashboard) return; + const args = [{ params: { pageSize: 9999999 }, monitoredState }, { user }, ["DASHBOARD"]]; + const catalogResources = getCatalogResources(...args).toPromise(); + catalogResources.then(res => { + const options = res.resources.map(d => ({ + value: d.id || d.pk, + label: d.name + })); + setDashboardOptions(options); + }); + }, [setting?.linkExistingDashboard]); + + return active && ( + + + + + + +
+ + + { + const { value } = event.target || {}; + setSetting(prev => ({ ...prev, name: value })); + }} + /> + + + + + colorVal && setSetting(prev =>({ + ...prev, + color: colorVal + }))} + placement="right" + /> + + + + Link existing dashboard + { + const { checked } = event.target || {}; + setSetting(prev => ({ ...prev, linkExistingDashboard: checked })); + }} + /> + + {setting.linkExistingDashboard && ( + + Select dashboard +