Skip to content

Commit

Permalink
Add "Check Network Access" feature
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrho committed Oct 14, 2024
1 parent ecf98c2 commit be47675
Show file tree
Hide file tree
Showing 17 changed files with 18,022 additions and 16,662 deletions.
Binary file added demo/check-network-access.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33,150 changes: 16,617 additions & 16,533 deletions jccm/package-lock.json

Large diffs are not rendered by default.

190 changes: 100 additions & 90 deletions jccm/package.json
Original file line number Diff line number Diff line change
@@ -1,92 +1,102 @@
{
"name": "jccm",
"productName": "Juniper Cloud Connection Manager",
"version": "1.2.3",
"description": "Juniper Cloud Connection Manager",
"main": ".webpack/main",
"scripts": {
"start": "pkill -9 node; nodemon --watch ./src --ext js,json --ignore ./src/Frontend/ --exec 'electron-forge start'",
"package": "electron-forge package",
"make": "electron-forge make",
"make-deb": "electron-forge make --platform=linux --arch=x64 --targets=@electron-forge/maker-deb",
"make-rpm": "electron-forge make --platform=linux --arch=x64 --targets=@electron-forge/maker-rpm",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"devDependencies": {
"@electron-forge/cli": "^7.4.0",
"@electron-forge/maker-deb": "^7.4.0",
"@electron-forge/maker-dmg": "^7.4.0",
"@electron-forge/maker-rpm": "^7.4.0",
"@electron-forge/maker-squirrel": "^7.4.0",
"@electron-forge/maker-zip": "^7.4.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.4.0",
"@electron-forge/plugin-fuses": "^7.4.0",
"@electron-forge/plugin-webpack": "^7.4.0",
"@electron/fuses": "^1.8.0",
"@vercel/webpack-asset-relocator-loader": "1.7.3",
"concurrently": "^8.2.2",
"css-loader": "^6.0.0",
"electron": "30.0.1",
"node-loader": "^2.0.0",
"nodemon": "^3.1.0",
"stream-browserify": "^3.0.0",
"style-loader": "^3.0.0",
"svg-inline-loader": "^0.8.2"
},
"keywords": [],
"author": {
"name": "simonrho",
"email": "srho@juniper.net"
},
"license": "MIT",
"dependencies": {
"@babel/core": "^7.24.4",
"@babel/preset-env": "^7.24.4",
"@babel/preset-react": "^7.24.1",
"@electron-forge/maker-pkg": "^7.4.0",
"@fluentui/react-components": "^9.49.2",
"@fluentui/react-icons": "^2.0.239",
"@microlink/react-json-view": "^1.23.1",
"@xterm/addon-fit": "^0.10.0",
"@xterm/xterm": "^5.5.0",
"ag-grid-react": "^31.3.2",
"babel-loader": "^9.1.3",
"buffer": "^6.0.3",
"cookie": "^0.6.0",
"date-fns": "^3.6.0",
"electron-reload": "^2.0.0-alpha.1",
"electron-squirrel-startup": "^1.0.0",
"electron-titlebar-windows": "^3.0.0",
"express": "^4.19.2",
"fetch-cookie": "^3.0.1",
"fs": "^0.0.1-security",
"immutable": "^4.3.6",
"ip": "^2.0.1",
"lodash": "^4.17.21",
"mitt": "^3.0.1",
"nedb": "^1.8.0",
"nedb-promises": "^6.2.3",
"node-cache": "^5.1.2",
"node-fetch": "^3.3.2",
"node-ssh": "^13.2.0",
"os-browserify": "^0.3.0",
"pako": "^2.1.0",
"path": "^0.12.7",
"path-browserify": "^1.0.1",
"react": "^18.3.0",
"react-dom": "^18.3.0",
"react-window": "^1.8.10",
"sequelize": "^6.37.3",
"set-cookie-parser": "^2.6.0",
"socket.io-client": "^4.7.5",
"ssh2": "^1.15.0",
"tough-cookie": "^4.1.4",
"uuid": "^9.0.1",
"validator": "^13.12.0",
"xlsx": "^0.18.5",
"xml2js": "^0.6.2",
"xterm-addon-fit": "^0.8.0",
"zustand": "^4.5.2"
}
"name": "jccm",
"productName": "Juniper Cloud Connection Manager",
"description": "Juniper Cloud Connection Manager",
"version": "1.2.3",
"build": {
"publish": [
{
"provider": "github",
"owner": "simonrho",
"repo": "juniper-jccm"
}
]
},
"main": ".webpack/main",
"scripts": {
"start": "pkill -9 node; nodemon --watch ./src --ext js,json --ignore ./src/Frontend/ --exec 'electron-forge start'",
"package": "electron-forge package",
"make": "electron-forge make",
"make-deb": "electron-forge make --platform=linux --arch=x64 --targets=@electron-forge/maker-deb",
"make-rpm": "electron-forge make --platform=linux --arch=x64 --targets=@electron-forge/maker-rpm",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"devDependencies": {
"@electron-forge/cli": "^7.4.0",
"@electron-forge/maker-deb": "^7.4.0",
"@electron-forge/maker-dmg": "^7.4.0",
"@electron-forge/maker-rpm": "^7.4.0",
"@electron-forge/maker-squirrel": "^7.4.0",
"@electron-forge/maker-zip": "^7.4.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.4.0",
"@electron-forge/plugin-fuses": "^7.4.0",
"@electron-forge/plugin-webpack": "^7.4.0",
"@electron/fuses": "^1.8.0",
"@vercel/webpack-asset-relocator-loader": "1.7.3",
"concurrently": "^8.2.2",
"css-loader": "^6.0.0",
"electron": "30.0.1",
"node-loader": "^2.0.0",
"nodemon": "^3.1.0",
"stream-browserify": "^3.0.0",
"style-loader": "^3.0.0",
"svg-inline-loader": "^0.8.2"
},
"keywords": [],
"author": {
"name": "simonrho",
"email": "srho@juniper.net"
},
"license": "MIT",
"dependencies": {
"@babel/core": "^7.24.4",
"@babel/preset-env": "^7.24.4",
"@babel/preset-react": "^7.24.1",
"@electron-forge/maker-pkg": "^7.4.0",
"@fluentui/react-components": "^9.49.2",
"@fluentui/react-icons": "^2.0.239",
"@microlink/react-json-view": "^1.23.1",
"@xterm/addon-fit": "^0.10.0",
"@xterm/xterm": "^5.5.0",
"ag-grid-react": "^31.3.2",
"babel-loader": "^9.1.3",
"buffer": "^6.0.3",
"cookie": "^0.6.0",
"date-fns": "^3.6.0",
"electron-reload": "^2.0.0-alpha.1",
"electron-squirrel-startup": "^1.0.0",
"electron-titlebar-windows": "^3.0.0",
"electron-updater": "^6.3.9",
"express": "^4.19.2",
"fetch-cookie": "^3.0.1",
"fs": "^0.0.1-security",
"immutable": "^4.3.6",
"ip": "^2.0.1",
"lodash": "^4.17.21",
"mitt": "^3.0.1",
"nedb": "^1.8.0",
"nedb-promises": "^6.2.3",
"node-cache": "^5.1.2",
"node-fetch": "^3.3.2",
"node-ssh": "^13.2.0",
"os-browserify": "^0.3.0",
"pako": "^2.1.0",
"path": "^0.12.7",
"path-browserify": "^1.0.1",
"react": "^18.3.0",
"react-dom": "^18.3.0",
"react-window": "^1.8.10",
"sequelize": "^6.37.3",
"set-cookie-parser": "^2.6.0",
"socket.io-client": "^4.7.5",
"ssh2": "^1.15.0",
"tough-cookie": "^4.1.4",
"uuid": "^9.0.1",
"validator": "^13.12.0",
"xlsx": "^0.18.5",
"xml2js": "^0.6.2",
"xterm-addon-fit": "^0.8.0",
"zustand": "^4.5.2"
}
}
81 changes: 81 additions & 0 deletions jccm/src/Frontend/Common/StateStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,87 @@ const useStore = create((set, get) => ({
}
return {};
}),

deviceNetworkCondition: {},

setDeviceNetworkConditionAll: (networkCondition) =>
set(() => ({
deviceNetworkCondition: networkCondition,
})),

setDeviceNetworkCondition: (path, value) =>
set((state) => ({
deviceNetworkCondition: {
...state.deviceNetworkCondition,
[path]: value,
},
})),

resetDeviceNetworkConditionAll: () =>
set(() => ({
deviceNetworkCondition: {},
})),

deleteDeviceNetworkCondition: (path) =>
set((state) => {
const { [path]: _, ...rest } = state.deviceNetworkCondition;
return { deviceNetworkCondition: rest };
}),

cleanUpDeviceNetworkCondition: () => {
const state = get();
const inventoryPaths = new Set(
state.inventory.map((item) => item._path)
);

// Filter `deviceNetworkCondition` by keys that exist in `inventoryPaths`
const cleanedDeviceNetworkCondition = Object.fromEntries(
Object.entries(state.deviceNetworkCondition).filter(([key]) =>
inventoryPaths.has(key)
)
);

// Update the state with the cleaned `deviceNetworkCondition` object
set(() => ({
deviceNetworkCondition: cleanedDeviceNetworkCondition,
}));
},

isTesting: {},
setIsTesting: (path, value) =>
set((state) => ({
isTesting: { ...state.isTesting, [path]: value },
})),

resetIsTestingAll: () =>
set(() => ({
isTesting: {},
})),

resetIsTesting: (path) =>
set((state) => {
const { [path]: _, ...rest } = state.isTesting;
return { isTesting: rest };
}),

cleanUpIsTesting: async () => {
const state = get();
const inventoryPaths = new Set(
state.inventory.map((item) => item._path)
);

// Filter `isTesting` by keys that exist in `inventoryPaths`
const cleanedIsTesting = Object.fromEntries(
Object.entries(state.isTesting).filter(([key]) =>
inventoryPaths.has(key)
)
);

// Update the state with the cleaned `isTesting` object
set(() => ({
isTesting: cleanedIsTesting,
}));
},
}));

export default useStore;
12 changes: 12 additions & 0 deletions jccm/src/Frontend/Layout/Devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,15 @@ export const executeJunosCommand = async (device, command) => {
}
};

export const getDeviceNetworkCondition = async (device, bastionHost = {}, termServer='oc-term.mistsys.net', termPort=2200) => {
const { address, port, username, password, timeout } = device;
const response = await electronAPI.saGetDeviceNetworkCondition({ address, port, username, password, timeout, bastionHost, termServer, termPort });

if (response.networkConditionCollect) {
return { status: true, result: response.reply };
} else {
return { status: false, result: response.reply };
}
};


Loading

0 comments on commit be47675

Please sign in to comment.