Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add modal that shows running config and generated config for a device #118

Merged
merged 3 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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