Skip to content

Commit

Permalink
Merge pull request #118 from SUNET/feature.show_config_modal
Browse files Browse the repository at this point in the history
add modal that shows running config and generated config for a device
  • Loading branch information
indy-independence committed Jul 5, 2024
2 parents 1df8ada + 261208d commit 45adae6
Show file tree
Hide file tree
Showing 3 changed files with 402 additions and 0 deletions.
40 changes: 40 additions & 0 deletions public/components/DeviceList/DeviceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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");

Expand Down Expand Up @@ -58,6 +59,9 @@ class DeviceList extends React.Component {
mgmtUpdateModalInput: {},
mgmtAddModalInput: {},
mgmtDomainsData: [],
showConfigModalOpen: false,
showConfigModalHostname: null,
showConfigModalState: null,
};

discovered_device_ids = new Set();
Expand Down Expand Up @@ -840,6 +844,22 @@ 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");
Expand Down Expand Up @@ -985,6 +1005,13 @@ class DeviceList extends React.Component {
text="Make unmanaged"
onClick={() => this.changeStateAction(device.id, "UNMANAGED")}
/>,
<Dropdown.Item
key="showconfig"
text="Show configuration"
onClick={() =>
this.showConfigModalOpen(device.hostname, device.state)
}
/>,
<Dropdown.Item
key="delete"
text="Delete device..."
Expand Down Expand Up @@ -1019,6 +1046,13 @@ class DeviceList extends React.Component {
text="Make managed"
onClick={() => this.changeStateAction(device.id, "MANAGED")}
/>,
<Dropdown.Item
key="showconfig"
text="Show configuration"
onClick={() =>
this.showConfigModalOpen(device.hostname, device.state)
}
/>,
<Dropdown.Item
key="delete"
text="Delete device..."
Expand Down Expand Up @@ -1351,6 +1385,12 @@ class DeviceList extends React.Component {
onDelete={(v) => this.handleDeleteMgmtDomain(v)}
onUpdate={(v) => this.handleUpdateMgmtDomains(v)}
/>
<ShowConfigModal
hostname={this.state.showConfigModalHostname}
state={this.state.showConfigModalState}
isOpen={this.state.showConfigModalOpen}
closeAction={() => this.showConfigModalClose()}
/>
<div className="table_options">
<Popup
on="click"
Expand Down
Loading

0 comments on commit 45adae6

Please sign in to comment.