From 1df8ada5a55fb40d49c16d1d1799bfbf1d3c7528 Mon Sep 17 00:00:00 2001 From: Johan Marcusson Date: Thu, 4 Jul 2024 16:48:50 +0200 Subject: [PATCH] Revert "add modal that shows running config and generated config for a device" should be in branch This reverts commit 6d5253cea2ca0751723865f38f0ef281dbc792e4. --- public/components/DeviceList/DeviceList.js | 40 --- .../components/DeviceList/ShowConfigModal.js | 235 ------------------ public/styles/main.css | 15 -- 3 files changed, 290 deletions(-) delete mode 100644 public/components/DeviceList/ShowConfigModal.js diff --git a/public/components/DeviceList/DeviceList.js b/public/components/DeviceList/DeviceList.js index 783ac5b..ede5633 100644 --- a/public/components/DeviceList/DeviceList.js +++ b/public/components/DeviceList/DeviceList.js @@ -20,7 +20,6 @@ import { deleteData } from "../../utils/sendData"; import DeviceInfoBlock from "./DeviceInfoBlock"; import AddMgmtDomainModal from "./AddMgmtDomainModal"; import UpdateMgmtDomainModal from "./UpdateMgmtDomainModal"; -import ShowConfigModal from "./ShowConfigModal"; const io = require("socket.io-client"); @@ -59,9 +58,6 @@ class DeviceList extends React.Component { mgmtUpdateModalInput: {}, mgmtAddModalInput: {}, mgmtDomainsData: [], - showConfigModalOpen: false, - showConfigModalHostname: null, - showConfigModalState: null, }; discovered_device_ids = new Set(); @@ -844,22 +840,6 @@ class DeviceList extends React.Component { }); } - showConfigModalOpen(hostname, state) { - this.setState({ - showConfigModalOpen: true, - showConfigModalHostname: hostname, - showConfigModalState: state, - }); - } - - showConfigModalClose() { - this.setState({ - showConfigModalOpen: false, - showConfigModalHostname: null, - showConfigModalState: null, - }); - } - changeStateAction(device_id, state) { console.log(`Change state for device_id: ${device_id}`); const credentials = localStorage.getItem("token"); @@ -1005,13 +985,6 @@ class DeviceList extends React.Component { text="Make unmanaged" onClick={() => this.changeStateAction(device.id, "UNMANAGED")} />, - - this.showConfigModalOpen(device.hostname, device.state) - } - />, this.changeStateAction(device.id, "MANAGED")} />, - - this.showConfigModalOpen(device.hostname, device.state) - } - />, this.handleDeleteMgmtDomain(v)} onUpdate={(v) => this.handleUpdateMgmtDomains(v)} /> - this.showConfigModalClose()} - />
}); - getData( - `${process.env.API_URL}/api/v1.0/device/${hostname}/running_config`, - credentials, - ) - .then((resp) => { - setRunningConfig(resp.data); - }) - .catch((error) => { - // loading status - setErrors([error]); - setRunningConfig({ config: error.message }); - }); - } - - function getGeneratedConfig() { - setGeneratedConfig({ - generated_config: , - }); - const credentials = localStorage.getItem("token"); - getData( - `${process.env.API_URL}/api/v1.0/device/${hostname}/generate_config`, - credentials, - ) - .then((resp) => { - setGeneratedConfig(resp.data.config); - }) - .catch((error) => { - // loading status - setErrors([error]); - setRunningConfig({ generated_config: error.message }); - }); - } - - useEffect(() => { - if (hostname) { - if (state === "MANAGED") { - getRunningConfig(); - } - getGeneratedConfig(); - } else { - clearForm(); - } - }, [hostname, state]); - - return ( - - Show config for {hostname} - - - - - -

Device Running Config

-
- -

NMS Generated Config

-
-
- - - - - navigator.clipboard.writeText(runningConfig.config) - } - icon="copy" - size="small" - /> - } - position="bottom right" - /> - getRunningConfig()} - icon="refresh" - size="small" - /> - } - position="bottom right" - /> - - - {typeof runningConfig.config === "object" ? ( - runningConfig.config - ) : ( -
{runningConfig.config}
- )} -
-
- - - - navigator.clipboard.writeText( - generatedConfig.generated_config, - ) - } - icon="copy" - size="small" - /> - } - position="bottom center" - /> - getGeneratedConfig()} - icon="refresh" - size="small" - /> - } - position="bottom center" - /> - - navigator.clipboard.writeText( - JSON.stringify( - generatedConfig.available_variables, - null, - 2, - ), - ) - } - icon="code" - size="small" - /> - } - position="bottom center" - /> - - - - {typeof generatedConfig.generated_config === "object" ? ( -
{generatedConfig.generated_config}
- ) : ( -
-                      {generatedConfig.generated_config}
-                    
- )} -
-
-
- - -
    - {errors.map((err, index) => ( - // eslint-disable-next-line react/no-array-index-key -
  • {err.message}
  • - ))} -
-
-
-
-
-
- - - -
- ); -} - -ShowConfigModal.propTypes = { - hostname: PropTypes.string, - state: PropTypes.string, - isOpen: PropTypes.bool.isRequired, - closeAction: PropTypes.func.isRequired, -}; - -ShowConfigModal.defaultProps = { - hostname: null, - state: "MANAGED", -}; - -export default ShowConfigModal; diff --git a/public/styles/main.css b/public/styles/main.css index e3cfcd6..ad9a637 100644 --- a/public/styles/main.css +++ b/public/styles/main.css @@ -364,10 +364,6 @@ progress::-moz-progress-bar { font-size: 80%; } -.fullconfig { - overflow-x: scroll; -} - /* log output styles */ .logoutput { overflow-y: scroll; @@ -382,14 +378,3 @@ progress::-moz-progress-bar { .job_ticket_ref { width: 15em; } - -/* Workaround for an unfixed bug with Loaders not showing up properly in Modals - * https://github.com/Semantic-Org/Semantic-UI-React/issues/3133 - */ -.ui.dimmer .ui.modalloader.loader:before { - border-color: rgba(0, 0, 0, 0.1); -} - -.ui.dimmer .ui.modalloader.loader:after { - border-color: #767676 transparent transparent; -}