From ca601e410b519a130de3cd7bcd22e223f2fc8537 Mon Sep 17 00:00:00 2001 From: Rajnikant Lodhi Date: Wed, 20 Jul 2022 14:28:13 +0530 Subject: [PATCH] Renamed server.id and serverId into controller.id and controllerId and modified the all unit test cases --- e2e/helpers/server.po.ts | 12 +- e2e/project-map.e2e-spec.ts | 12 +- e2e/projects.e2e-spec.ts | 12 +- e2e/servers.e2e-spec.ts | 8 +- local-server.js | 144 +++++++++--------- src/ReleaseNotes.txt | 10 +- src/app/app-routing.module.ts | 4 +- .../components/d3-map/d3-map.component.html | 2 +- .../components/d3-map/d3-map.component.ts | 2 +- .../text-editor/text-editor.component.ts | 4 +- src/app/cartography/models/map/map-link.ts | 16 +- .../bundled-server-finder.component.spec.ts | 18 +-- .../bundled-server-finder.component.ts | 4 +- .../add-controller-dialog.component.html | 10 +- .../add-controller-dialog.component.ts | 28 ++-- .../controller-discovery.component.html | 2 +- .../controller-discovery.component.spec.ts | 64 ++++---- .../controller-discovery.component.ts | 40 ++--- .../controllers/controllers.component.html | 10 +- .../controllers/controllers.component.ts | 74 ++++----- .../direct-link/direct-link.component.html | 6 +- .../direct-link/direct-link.component.ts | 30 ++-- .../drawing-added/drawing-added.component.ts | 4 +- .../drawing-dragged.component.ts | 4 +- .../drawing-resized.component.ts | 4 +- .../interface-label-dragged.component.ts | 4 +- .../link-created/link-created.component.ts | 6 +- .../node-dragged/node-dragged.component.ts | 4 +- .../node-label-dragged.component.ts | 4 +- .../text-added/text-added.component.ts | 4 +- .../text-edited/text-edited.component.ts | 4 +- .../export-portable-project.component.ts | 6 +- .../add-image-dialog.component.spec.ts | 2 +- .../add-image-dialog.component.ts | 8 +- .../deleteallfiles-dialog.component.spec.ts | 2 +- .../image-manager.component.spec.ts | 4 +- .../image-manager/image-manager.component.ts | 18 +-- src/app/components/login/login.component.ts | 28 ++-- .../built-in-preferences.component.html | 8 +- .../built-in-preferences.component.spec.ts | 4 +- .../built-in-preferences.component.ts | 4 +- ...cloud-nodes-add-template.component.spec.ts | 6 +- .../cloud-nodes-add-template.component.ts | 10 +- ...d-nodes-template-details.component.spec.ts | 4 +- .../cloud-nodes-template-details.component.ts | 12 +- .../cloud-nodes-templates.component.html | 12 +- .../cloud-nodes-templates.component.spec.ts | 2 +- .../cloud-nodes-templates.component.ts | 8 +- ...hernet-hubs-add-template.component.spec.ts | 8 +- .../ethernet-hubs-add-template.component.ts | 10 +- ...et-hubs-template-details.component.spec.ts | 4 +- ...thernet-hubs-template-details.component.ts | 12 +- .../ethernet-hubs-templates.component.html | 12 +- .../ethernet-hubs-templates.component.spec.ts | 2 +- .../ethernet-hubs-templates.component.ts | 8 +- ...et-switches-add-template.component.spec.ts | 8 +- ...thernet-switches-add-template.component.ts | 10 +- ...witches-template-details.component.spec.ts | 4 +- ...net-switches-template-details.component.ts | 12 +- ...ethernet-switches-templates.component.html | 12 +- ...ernet-switches-templates.component.spec.ts | 2 +- .../ethernet-switches-templates.component.ts | 8 +- .../delete-template.component.ts | 4 +- .../symbols-menu/symbols-menu.component.html | 2 +- .../symbols-menu/symbols-menu.component.ts | 2 +- .../common/symbols/symbols.component.ts | 8 +- .../add-docker-template.component.spec.ts | 2 +- .../add-docker-template.component.ts | 12 +- .../copy-docker-template.component.ts | 12 +- .../docker-template-details.component.spec.ts | 4 +- .../docker-template-details.component.ts | 12 +- .../docker-templates.component.html | 12 +- .../docker-templates.component.spec.ts | 2 +- .../docker-templates.component.ts | 10 +- .../add-ios-template.component.spec.ts | 10 +- .../add-ios-template.component.ts | 16 +- .../copy-ios-template.component.ts | 12 +- .../dynamips-preferences.component.ts | 6 +- .../ios-template-details.component.spec.ts | 4 +- .../ios-template-details.component.ts | 12 +- .../ios-templates.component.html | 12 +- .../ios-templates.component.spec.ts | 2 +- .../ios-templates/ios-templates.component.ts | 10 +- .../general-preferences.component.spec.ts | 4 +- .../general/general-preferences.component.ts | 4 +- .../add-iou-template.component.spec.ts | 8 +- .../add-iou-template.component.ts | 16 +- .../copy-iou-template.component.ts | 12 +- .../iou-template-details.component.spec.ts | 4 +- .../iou-template-details.component.ts | 12 +- .../iou-templates.component.html | 12 +- .../iou-templates.component.spec.ts | 2 +- .../iou-templates/iou-templates.component.ts | 10 +- .../preferences/preferences.component.html | 16 +- .../preferences/preferences.component.spec.ts | 2 +- .../preferences/preferences.component.ts | 4 +- .../add-qemu-vm-template.component.spec.ts | 12 +- .../add-qemu-vm-template.component.ts | 20 +-- .../copy-qemu-vm-template.component.ts | 12 +- .../qemu-preferences.component.html | 4 +- .../qemu-preferences.component.ts | 12 +- ...qemu-vm-template-details.component.spec.ts | 8 +- .../qemu-vm-template-details.component.ts | 14 +- .../qemu-vm-templates.component.html | 12 +- .../qemu-vm-templates.component.spec.ts | 2 +- .../qemu-vm-templates.component.ts | 10 +- ...add-virtual-box-template.component.spec.ts | 8 +- .../add-virtual-box-template.component.ts | 12 +- .../virtual-box-preferences.component.ts | 6 +- ...ual-box-template-details.component.spec.ts | 4 +- .../virtual-box-template-details.component.ts | 12 +- .../virtual-box-templates.component.html | 12 +- .../virtual-box-templates.component.spec.ts | 2 +- .../virtual-box-templates.component.ts | 8 +- .../add-vmware-template.component.ts | 12 +- .../add-vmware.component.template.spec.ts | 8 +- .../vmware-preferences.component.ts | 6 +- .../vmware-template-details.component.spec.ts | 4 +- .../vmware-template-details.component.ts | 12 +- .../vmware-templates.component.html | 12 +- .../vmware-templates.component.spec.ts | 2 +- .../vmware-templates.component.ts | 8 +- .../add-vpcs-template.component.spec.ts | 8 +- .../add-vpcs-template.component.ts | 10 +- .../vpcs-preferences.component.ts | 6 +- .../vpcs-template-details.component.spec.ts | 4 +- .../vpcs-template-details.component.ts | 12 +- .../vpcs-templates.component.html | 12 +- .../vpcs-templates.component.spec.ts | 2 +- .../vpcs-templates.component.ts | 8 +- .../change-hostname-dialog.component.ts | 6 +- .../change-symbol-dialog.component.html | 2 +- .../change-symbol-dialog.component.ts | 4 +- .../console-wrapper.component.html | 4 +- .../console-wrapper.component.ts | 4 +- .../context-console-menu.component.spec.ts | 2 +- .../context-console-menu.component.ts | 6 +- .../align-horizontally.component.ts | 4 +- .../align-vertically.component.ts | 4 +- .../bring-to-front-action.component.ts | 6 +- .../change-hostname-action.component.ts | 4 +- .../change-symbol-action.component.ts | 4 +- .../config-action/config-action.component.ts | 4 +- ...console-device-action-browser.component.ts | 6 +- .../console-device-action.component.spec.ts | 6 +- .../console-device-action.component.ts | 4 +- .../delete-action/delete-action.component.ts | 8 +- .../duplicate-action.component.ts | 6 +- .../edit-config-action.component.ts | 4 +- .../edit-link-style-action.component.ts | 4 +- .../edit-style-action.component.ts | 4 +- .../edit-text-action.component.ts | 4 +- .../export-config-action.component.ts | 8 +- .../http-console-new-tab-action.component.ts | 2 +- .../http-console-action.component.ts | 2 +- .../import-config-action.component.ts | 6 +- .../isolate-node-action.component.ts | 4 +- .../lock-action/lock-action.component.ts | 6 +- .../move-layer-down-action.component.ts | 6 +- .../move-layer-up-action.component.ts | 6 +- .../open-file-explorer-action.component.ts | 2 +- .../packet-filters-action.component.ts | 4 +- .../reload-node-action.component.ts | 4 +- .../reset-link/reset-link-action.component.ts | 4 +- .../resume-link-action.component.ts | 4 +- .../show-node-action.component.ts | 4 +- ...start-capture-on-started-link.component.ts | 4 +- .../start-capture-action.component.ts | 4 +- .../start-node-action.component.ts | 5 +- .../stop-capture-action.component.ts | 4 +- .../stop-node-action.component.ts | 4 +- .../suspend-link-action.component.ts | 4 +- .../suspend-node-action.component.ts | 4 +- .../unisolate-node-action.component.ts | 4 +- .../context-menu/context-menu.component.html | 72 ++++----- .../context-menu.component.spec.ts | 2 +- .../context-menu/context-menu.component.ts | 4 +- .../link-style-editor.component.ts | 4 +- .../style-editor/style-editor.component.ts | 4 +- .../text-editor/text-editor.component.ts | 8 +- .../import-appliance.component.ts | 20 +-- .../info-dialog/info-dialog.component.ts | 4 +- .../log-console/log-console.component.spec.ts | 2 +- .../log-console/log-console.component.ts | 26 ++-- .../new-template-dialog.component.ts | 56 +++---- .../template-name-dialog.component.ts | 6 +- .../config-editor.component.spec.ts | 10 +- .../config-editor/config-editor.component.ts | 10 +- .../configurator-atm-switch.component.ts | 6 +- .../cloud/configurator-cloud.component.ts | 6 +- .../docker/configurator-docker.component.ts | 10 +- .../configure-custom-adapters.component.ts | 4 +- .../edit-network-configuration.component.ts | 6 +- .../configurator-ethernet-switch.component.ts | 6 +- .../configurator-ethernet-hub.component.ts | 6 +- .../ios/configurator-ios.component.ts | 6 +- .../iou/configurator-iou.component.ts | 6 +- .../nat/configurator-nat.component.ts | 6 +- .../qemu/configurator-qemu.component.ts | 12 +- .../qemu-image-creator.component.ts | 4 +- .../switch/configurator-switch.component.ts | 6 +- .../configurator-virtualbox.component.ts | 6 +- .../vmware/configurator-vmware.component.ts | 6 +- .../vpcs/configurator-vpcs.component.ts | 6 +- .../nodes-menu/nodes-menu.component.ts | 15 +- .../packet-filters.component.ts | 10 +- .../start-capture/start-capture.component.ts | 6 +- .../project-map-menu.component.html | 2 +- .../project-map-menu.component.ts | 6 +- .../project-map/project-map.component.html | 40 ++--- .../project-map/project-map.component.spec.ts | 36 ++--- .../project-map/project-map.component.ts | 80 +++++----- .../project-readme.component.ts | 4 +- .../web-console/web-console.component.ts | 4 +- ...add-blank-project-dialog.component.spec.ts | 10 +- .../add-blank-project-dialog.component.ts | 14 +- .../choose-name-dialog.component.ts | 4 +- .../edit-project-dialog.component.html | 6 +- .../edit-project-dialog.component.ts | 6 +- .../readme-editor/readme-editor.component.ts | 4 +- .../import-project-dialog.component.spec.ts | 18 +-- .../import-project-dialog.component.ts | 12 +- .../projects/projects.component.html | 2 +- .../projects/projects.component.spec.ts | 16 +- .../components/projects/projects.component.ts | 30 ++-- .../save-project-dialog.component.ts | 6 +- .../settings/console/console.component.html | 2 +- .../create-snapshot-dialog.component.html | 2 +- .../create-snapshot-dialog.component.ts | 6 +- .../list-of-snaphshots.component.spec.ts | 10 +- .../list-of-snapshots.component.ts | 10 +- .../snapshot-menu-item.component.ts | 6 +- .../status-info/status-info.component.ts | 8 +- .../system-status/system-status.component.ts | 4 +- .../template-list-dialog.component.ts | 14 +- .../components/template/template.component.ts | 14 +- .../topology-summary.component.spec.ts | 2 +- .../topology-summary.component.ts | 8 +- .../logged-user/logged-user.component.ts | 12 +- .../web-console-full-window.component.ts | 14 +- src/app/filters/authImageFilter.ts | 4 +- src/app/guards/login-guard.ts | 10 +- .../default-layout.component.html | 4 +- .../default-layout.component.ts | 32 ++-- src/app/services/appliances.service.ts | 16 +- .../built-in-templates.service.spec.ts | 16 +- .../services/built-in-templates.service.ts | 16 +- src/app/services/compute.service.ts | 12 +- src/app/services/docker.service.ts | 20 +-- src/app/services/drawing.service.spec.ts | 18 +-- src/app/services/drawing.service.ts | 28 ++-- src/app/services/http-server.service.spec.ts | 30 ++-- src/app/services/http-server.service.ts | 50 +++--- .../services/image-manager.service.spec.ts | 8 +- src/app/services/image-manager.service.ts | 20 +-- src/app/services/info.service.ts | 6 +- src/app/services/ios.service.ts | 24 +-- src/app/services/iou.service.ts | 24 +-- src/app/services/link.service.spec.ts | 6 +- src/app/services/link.service.ts | 44 +++--- src/app/services/login.service.ts | 12 +- src/app/services/node.service.spec.ts | 34 ++--- src/app/services/node.service.ts | 115 +++++++------- src/app/services/nodeConsole.service.ts | 6 +- src/app/services/notification.service.ts | 12 +- src/app/services/packet-capture.service.ts | 4 +- src/app/services/project.service.spec.ts | 38 ++--- src/app/services/project.service.ts | 74 ++++----- src/app/services/qemu.service.spec.ts | 8 +- src/app/services/qemu.service.ts | 32 ++-- .../services/recentlyOpenedProject.service.ts | 22 +-- .../server-management.service.spec.ts | 20 +-- src/app/services/server-management.service.ts | 12 +- .../services/server-settings.service.spec.ts | 4 +- src/app/services/server-settings.service.ts | 16 +- src/app/services/server.database.ts | 18 +-- src/app/services/server.service.spec.ts | 22 +-- src/app/services/server.service.ts | 68 ++++----- src/app/services/snapshot.service.spec.ts | 8 +- src/app/services/snapshot.service.ts | 16 +- src/app/services/symbol.service.spec.ts | 8 +- src/app/services/symbol.service.ts | 24 +-- src/app/services/template.service.spec.ts | 10 +- src/app/services/template.service.ts | 8 +- src/app/services/user.service.ts | 4 +- src/app/services/version.service.spec.ts | 8 +- src/app/services/version.service.ts | 4 +- src/app/services/virtual-box.service.spec.ts | 10 +- src/app/services/virtual-box.service.ts | 20 +-- src/app/services/vmware.service.spec.ts | 10 +- src/app/services/vmware.service.ts | 20 +-- src/app/services/vpcs.service.spec.ts | 8 +- src/app/services/vpcs.service.ts | 16 +- .../project-name-async-validator.ts | 4 +- .../template-name-async-validator.ts | 4 +- 295 files changed, 1713 insertions(+), 1710 deletions(-) diff --git a/e2e/helpers/server.po.ts b/e2e/helpers/server.po.ts index d706ae49..808aa630 100644 --- a/e2e/helpers/server.po.ts +++ b/e2e/helpers/server.po.ts @@ -17,25 +17,25 @@ export class ServersPage { } async clickAddServer() { - let serversTable = await this.checkServersTable(); - if (serversTable.length === 0) { + let controllerTable = await this.checkControllersTable(); + if (controllerTable.length === 0) { let buttons = await browser.driver.findElements(by.className('mat-button mat-button-base')); await buttons[3].click(); } } - checkServersTable() { + checkControllersTable() { return browser.driver.findElements(by.css('mat-cell')); } async navigateToServerProjects() { this.helper.sleep(2000); let hyperlinks = await browser.driver.findElements(by.css('a.table-link')); - let serverLink; + let controllerLink; await this.helper.asyncForEach(hyperlinks, async (element) => { let text = await element.getText(); - if (text === '127.0.0.1') serverLink = element; + if (text === '127.0.0.1') controllerLink = element; }); - await serverLink.click(); + await controllerLink.click(); } } diff --git a/e2e/project-map.e2e-spec.ts b/e2e/project-map.e2e-spec.ts index 8986d97a..249325aa 100644 --- a/e2e/project-map.e2e-spec.ts +++ b/e2e/project-map.e2e-spec.ts @@ -4,21 +4,21 @@ import { ProjectsPage } from './helpers/project.po'; import { ServersPage } from './helpers/server.po'; describe('Project map page', () => { - let serversPage: ServersPage; + let controllersPage: ServersPage; let projectsPage: ProjectsPage; let projectMapPage: ProjectMapPage; let helper: TestHelper; beforeEach(async () => { - serversPage = new ServersPage(); + controllersPage = new ServersPage(); projectsPage = new ProjectsPage(); projectMapPage = new ProjectMapPage(); helper = new TestHelper(); - serversPage.maximizeWindow(); - await serversPage.navigateToServersPage(); - await serversPage.clickAddServer(); - await serversPage.navigateToServerProjects(); + controllersPage.maximizeWindow(); + await controllersPage.navigateToServersPage(); + await controllersPage.clickAddServer(); + await controllersPage.navigateToServerProjects(); await projectsPage.openAddProjectDialog(); helper.sleep(2000); await projectsPage.createProject(); diff --git a/e2e/projects.e2e-spec.ts b/e2e/projects.e2e-spec.ts index 3ec7dcb2..d05394f9 100644 --- a/e2e/projects.e2e-spec.ts +++ b/e2e/projects.e2e-spec.ts @@ -3,22 +3,22 @@ import { ProjectsPage } from './helpers/project.po'; import { ServersPage } from './helpers/server.po'; describe('Projects page', () => { - let serversPage: ServersPage; + let controllersPage: ServersPage; let projectsPage: ProjectsPage; let helper: TestHelper; beforeEach(() => { - serversPage = new ServersPage(); + controllersPage = new ServersPage(); projectsPage = new ProjectsPage(); helper = new TestHelper(); }); it('user should have possibility to create new project', async () => { // arrange - serversPage.maximizeWindow(); - await serversPage.navigateToServersPage(); - await serversPage.clickAddServer(); - await serversPage.navigateToServerProjects(); + controllersPage.maximizeWindow(); + await controllersPage.navigateToServersPage(); + await controllersPage.clickAddServer(); + await controllersPage.navigateToServerProjects(); helper.sleep(2000); //act diff --git a/e2e/servers.e2e-spec.ts b/e2e/servers.e2e-spec.ts index 45da0436..95b3b780 100644 --- a/e2e/servers.e2e-spec.ts +++ b/e2e/servers.e2e-spec.ts @@ -10,7 +10,7 @@ describe('Servers page', () => { helper = new TestHelper(); }); - xit('user should have possibility to add server', async () => { + xit('user should have possibility to add controller', async () => { // arrange page.maximizeWindow(); await page.navigateToServersPage(); @@ -19,10 +19,10 @@ describe('Servers page', () => { let text = await page.getAddServerNotificationText(); // assert - expect(text).toBe("We've discovered GNS3 server on 127.0.0.1:3080, would you like to add to the list?"); + expect(text).toBe("We've discovered GNS3 controller on 127.0.0.1:3080, would you like to add to the list?"); }); - it('user should see added server in the list', async () => { + it('user should see added controller in the list', async () => { // arrange page.maximizeWindow(); await page.navigateToServersPage(); @@ -30,7 +30,7 @@ describe('Servers page', () => { helper.sleep(1000); // act - let firstRowOfServersTable = await page.checkServersTable(); + let firstRowOfServersTable = await page.checkControllersTable(); let serverData = []; await helper.asyncForEach(firstRowOfServersTable, async (element) => { serverData.push(await element.getText()); diff --git a/local-server.js b/local-server.js index a8948c30..79e7de03 100644 --- a/local-server.js +++ b/local-server.js @@ -8,9 +8,9 @@ const { app } = require('electron') const isWin = /^win/.test(process.platform); -let runningServers = {}; +let runningControllers = {}; -exports.getLocalServerPath = async () => { +exports.getLocalControllerPath = async () => { let binary = isWin ? 'gns3server.exe': 'gns3server'; return findBinary('exe.', binary); } @@ -20,21 +20,21 @@ exports.getUbridgePath = async () => { return findBinary('ubridge', binary); } -exports.startLocalServer = async (server) => { - return await run(server, { +exports.startLocalController = async (controller) => { + return await run(controller, { logStdout: true }); } -exports.stopLocalServer = async (server) => { - return await stop(server.name); +exports.stopLocalServer = async (controller) => { + return await stop(controller.name); } -exports.getRunningServers = () => { - return Object.keys(runningServers); +exports.getrunningControllers = () => { + return Object.keys(runningControllers); } -exports.stopAllLocalServers = async () => { +exports.stopAllLocalControllers = async () => { return await stopAll(); } @@ -77,33 +77,33 @@ async function findBinaryInDirectory(baseDirectory, binaryDirectory, filename) { } -function getServerArguments(server, overrides, configPath) { - let serverArguments = []; - if(server.host) { - serverArguments.push('--host'); - serverArguments.push(server.host); +function getControllerArguments(controller, overrides, configPath) { + let controllerArguments = []; + if(controller.host) { + controllerArguments.push('--host'); + controllerArguments.push(controller.host); } - if(server.port) { - serverArguments.push('--port'); - serverArguments.push(server.port); + if(controller.port) { + controllerArguments.push('--port'); + controllerArguments.push(controller.port); } - serverArguments.push('--local'); + controllerArguments.push('--local'); if(configPath) { - serverArguments.push('--config'); - serverArguments.push(configPath); + controllerArguments.push('--config'); + controllerArguments.push(configPath); } - return serverArguments; + return controllerArguments; } -function getChannelForServer(server) { - return `local-server-run-${server.name}`; +function getChannelForController(controller) { + return `local-controller-run-${controller.name}`; } function notifyStatus(status) { - ipcMain.emit('local-server-status-events', status); + ipcMain.emit('local-controller-status-events', status); } function filterOutput(line) { @@ -120,44 +120,44 @@ function filterOutput(line) { } async function stopAll() { - for(var serverName in runningServers) { - let result, error = await stop(serverName); + for(var controllerName in runningControllers) { + let result, error = await stop(controllerName); } - console.log(`Stopped all servers`); + console.log(`Stopped all controllers`); } -async function stop(serverName) { +async function stop(controllerName) { let pid = undefined; - const runningServer = runningServers[serverName]; + const runningServer = runningControllers[controllerName]; if(runningServer !== undefined && runningServer.process) { pid = runningServer.process.pid; } - console.log(`Stopping '${serverName}' with PID='${pid}'`); + console.log(`Stopping '${controllerName}' with PID='${pid}'`); const stopped = new Promise((resolve, reject) => { if(pid === undefined) { - resolve(`Server '${serverName} is already stopped`); - delete runningServers[serverName]; + resolve(`Controller '${controllerName} is already stopped`); + delete runningControllers[controllerName]; return; } kill(pid, (error) => { if(error) { - console.error(`Error occured during stopping '${serverName}' with PID='${pid}'`); + console.error(`Error occured during stopping '${controllerName}' with PID='${pid}'`); reject(error); } else { - delete runningServers[serverName]; - console.log(`Stopped '${serverName}' with PID='${pid}'`); - resolve(`Stopped '${serverName}' with PID='${pid}'`); + delete runningControllers[controllerName]; + console.log(`Stopped '${controllerName}' with PID='${pid}'`); + resolve(`Stopped '${controllerName}' with PID='${pid}'`); notifyStatus({ - serverName: serverName, + controllerName: controllerName, status: 'stopped', - message: `Server '${serverName}' stopped'` + message: `Controller '${controllerName}' stopped'` }); } }); @@ -166,11 +166,11 @@ async function stop(serverName) { return stopped; } -async function getIniFile(server) { - return path.join(app.getPath('userData'), `gns3_server_${server.id}.ini`); +async function getIniFile(controller) { + return path.join(app.getPath('userData'), `gns3_controller_${controller.id}.ini`); } -async function configure(configPath, server) { +async function configure(configPath, controller) { if(!fs.existsSync(configPath)) { fs.closeSync(fs.openSync(configPath, 'w')); console.log(`Configuration file '${configPath}' has been created.`); @@ -178,20 +178,20 @@ async function configure(configPath, server) { var config = ini.parse(fs.readFileSync(configPath, 'utf-8')); - if(server.path) { - config.path = server.path; + if(controller.path) { + config.path = controller.path; } - if(server.host) { - config.host = server.host; + if(controller.host) { + config.host = controller.host; } - if(server.port) { - config.port = server.port; + if(controller.port) { + config.port = controller.port; } - if(server.ubridge_path) { - config.ubridge_path = server.ubridge_path; + if(controller.ubridge_path) { + config.ubridge_path = controller.ubridge_path; } - fs.writeFileSync(configPath, ini.stringify(config, { section: 'Server' })); + fs.writeFileSync(configPath, ini.stringify(config, { section: 'Controller' })); } async function setPATHEnv() { @@ -216,7 +216,7 @@ async function setPATHEnv() { process.env.PATH = extra.join(";"); } -async function run(server, options) { +async function run(controller, options) { if(!options) { options = {}; } @@ -226,34 +226,34 @@ async function run(server, options) { console.log(`Configuring`); - const configPath = await getIniFile(server); - await configure(configPath, server); + const configPath = await getIniFile(controller); + await configure(configPath, controller); console.log(`Setting up PATH`); await setPATHEnv(); - console.log(`Running '${server.path}'`); + console.log(`Running '${controller.path}'`); - let serverProcess = spawn(server.path, getServerArguments(server, {}, configPath)); + let controllerProcess = spawn(controller.path, getControllerArguments(controller, {}, configPath)); notifyStatus({ - serverName: server.name, + controllerName: controller.name, status: 'started', - message: `Server '${server.name}' started'` + message: `Controller '${controller.name}' started'` }); - runningServers[server.name] = { - process: serverProcess + runningControllers[controller.name] = { + process: controllerProcess }; - serverProcess.stdout.on('data', function(data) { + controllerProcess.stdout.on('data', function(data) { const line = data.toString(); const { isCritical, errorMessage } = filterOutput(line); if(isCritical) { notifyStatus({ - serverName: server.name, + controllerName: controller.name, status: 'stderr', - message: `Server reported error: '${errorMessage}` + message: `Controller reported error: '${errorMessage}` }); } @@ -262,25 +262,25 @@ async function run(server, options) { } }); - serverProcess.stderr.on('data', function(data) { + controllerProcess.stderr.on('data', function(data) { if(logSterr) { console.log(data.toString()); } }); - serverProcess.on('exit', (code, signal) => { + controllerProcess.on('exit', (code, signal) => { notifyStatus({ - serverName: server.name, + controllerName: controller.name, status: 'errored', - message: `Server '${server.name}' has exited with status='${code}'` + message: `controller '${controller.name}' has exited with status='${code}'` }); }); - serverProcess.on('error', (err) => { + controllerProcess.on('error', (err) => { notifyStatus({ - serverName: server.name, + controllerName: controller.name, status: 'errored', - message: `Server errored: '${err}` + message: `Controller errored: '${err}` }); }); @@ -297,9 +297,9 @@ async function main() { } if(ipcMain) { - ipcMain.on('local-server-run', async function (event, server) { - const responseChannel = getChannelForServer(); - await run(server); + ipcMain.on('local-controller-run', async function (event, controller) { + const responseChannel = getChannelForController(); + await run(controller); event.sender.send(responseChannel, { success: true }); diff --git a/src/ReleaseNotes.txt b/src/ReleaseNotes.txt index 17a32fc2..62fdf18d 100644 --- a/src/ReleaseNotes.txt +++ b/src/ReleaseNotes.txt @@ -11,7 +11,7 @@ Bug Fixes & enhancements - symbol is not properly selected in change symbol dialog - issue when using the scroll wheel on the web console - missing settings for Docker nodes -- error on servers page +- error on controllers page What's new - double click nodes to open the console @@ -127,7 +127,7 @@ Bug Fixes - Fix for return command in console - Fix for deleting links - Fix for duplicating any node type -- Fix for console errors on servers page +- Fix for console errors on controllers page - Fix for console errors on projects page GNS3 Web UI 2019.2.0 v10 @@ -140,12 +140,12 @@ What's New - Filtering devices with packet filters on topology summary - Filtering devices with captures on topology summary - View options taken from map configuration -- Servers summary widget +- Controllers summary widget - Ability to lock single item on the map - Editing & import & export config files - Context menu for inserted drawings -- Ability to drag topology summary & servers summary & console widgets -- Ability to resize topology summary & servers summary & console widgets +- Ability to drag topology summary & controllers summary & console widgets +- Ability to resize topology summary & controllers summary & console widgets - Option to show the grid - Option to snap to grid - Usage instructions available from context menu diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 895a674b..ad50ec3d 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -73,7 +73,7 @@ const routes: Routes = [ path: 'controller/:controller_id/projects', component: ProjectsComponent, canActivate: [LoginGuard], - resolve: { server: ServerResolve }, + resolve: { controller: ServerResolve }, }, { path: 'help', component: HelpComponent }, { path: 'settings', component: SettingsComponent }, @@ -86,7 +86,7 @@ const routes: Routes = [ path: 'controller/:controller_id/project/:project_id/snapshots', component: ListOfSnapshotsComponent, canActivate: [LoginGuard], - resolve: { server: ServerResolve }, + resolve: { controller: ServerResolve }, }, { path: 'controller/:controller_id/preferences', component: PreferencesComponent, canActivate: [LoginGuard] }, // { path: 'controller/:controller_id/preferences/general', component: GeneralPreferencesComponent }, diff --git a/src/app/cartography/components/d3-map/d3-map.component.html b/src/app/cartography/components/d3-map/d3-map.component.html index c066bb4a..ee3a26dd 100644 --- a/src/app/cartography/components/d3-map/d3-map.component.html +++ b/src/app/cartography/components/d3-map/d3-map.component.html @@ -44,6 +44,6 @@ - + diff --git a/src/app/cartography/components/d3-map/d3-map.component.ts b/src/app/cartography/components/d3-map/d3-map.component.ts index b79b3bbe..44599034 100644 --- a/src/app/cartography/components/d3-map/d3-map.component.ts +++ b/src/app/cartography/components/d3-map/d3-map.component.ts @@ -43,7 +43,7 @@ export class D3MapComponent implements OnInit, OnChanges, OnDestroy { @Input() drawings: Drawing[] = []; @Input() symbols: Symbol[] = []; @Input() project: Project; - @Input() server: Server; + @Input() controller: Server; @Input() width = 1500; @Input() height = 600; diff --git a/src/app/cartography/components/text-editor/text-editor.component.ts b/src/app/cartography/components/text-editor/text-editor.component.ts index 70f690a5..2aed35d4 100644 --- a/src/app/cartography/components/text-editor/text-editor.component.ts +++ b/src/app/cartography/components/text-editor/text-editor.component.ts @@ -37,7 +37,7 @@ import { Node } from '../../models/node'; export class TextEditorComponent implements OnInit, OnDestroy { @ViewChild('temporaryTextElement') temporaryTextElement: ElementRef; @Input('svg') svg: SVGSVGElement; - @Input('server') server: Server; + @Input('controller') controller: Server; leftPosition: string = '0px'; topPosition: string = '0px'; @@ -185,7 +185,7 @@ export class TextEditorComponent implements OnInit, OnDestroy { let link: Link = this.linksDataSource.get(this.editedLink.linkId); link.nodes.find((n) => n.node_id === this.editedNode.node_id).label.text = innerText; - this.linkService.updateLink(this.server, link).subscribe((link: Link) => { + this.linkService.updateLink(this.controller, link).subscribe((link: Link) => { rootElement .selectAll('text.editingMode') .attr('visibility', 'visible') diff --git a/src/app/cartography/models/map/map-link.ts b/src/app/cartography/models/map/map-link.ts index 339f165d..aebfac0d 100644 --- a/src/app/cartography/models/map/map-link.ts +++ b/src/app/cartography/models/map/map-link.ts @@ -16,13 +16,13 @@ export class MapLink implements Indexed { suspend: boolean; link_style?: LinkStyle; - distance: number; // this is not from server - length: number; // this is not from server - source: MapNode; // this is not from server - target: MapNode; // this is not from server + distance: number; // this is not from controller + length: number; // this is not from controller + source: MapNode; // this is not from controller + target: MapNode; // this is not from controller - isSelected = false; // this is not from server - isMultiplied = false; // this is not from server - x: number; // this is not from server - y: number; // this is not from server + isSelected = false; // this is not from controller + isMultiplied = false; // this is not from controller + x: number; // this is not from controller + y: number; // this is not from controller } diff --git a/src/app/components/bundled-server-finder/bundled-server-finder.component.spec.ts b/src/app/components/bundled-server-finder/bundled-server-finder.component.spec.ts index 11ec0e49..92a8301a 100644 --- a/src/app/components/bundled-server-finder/bundled-server-finder.component.spec.ts +++ b/src/app/components/bundled-server-finder/bundled-server-finder.component.spec.ts @@ -16,7 +16,7 @@ describe('BundledServerFinderComponent', () => { let router: any; let service: ServerService; let progressService: MockedProgressService = new MockedProgressService(); - let serverServiceMock: jasmine.SpyObj; + let controllerServiceMock: jasmine.SpyObj; beforeEach(async () => { @@ -26,7 +26,7 @@ describe('BundledServerFinderComponent', () => { - serverServiceMock = jasmine.createSpyObj([ + controllerServiceMock = jasmine.createSpyObj([ "getLocalServer" ]); @@ -37,7 +37,7 @@ describe('BundledServerFinderComponent', () => { await TestBed.configureTestingModule({ providers: [ { provide: Router, useValue: router }, - { provide: ServerService, useValue: serverServiceMock }, + { provide: ServerService, useValue: controllerServiceMock }, { provide: ProgressService, useValue: progressService }, ], declarations: [BundledServerFinderComponent], @@ -49,17 +49,17 @@ describe('BundledServerFinderComponent', () => { fixture.detectChanges(); }); - it('should create and redirect to server', fakeAsync(() => { - const server = new Server(); - server.id = 99; - serverServiceMock.getLocalServer.and.returnValue( - Promise.resolve(server) + it('should create and redirect to controller', fakeAsync(() => { + const controller = new Server(); + controller.id = 99; + controllerServiceMock.getLocalServer.and.returnValue( + Promise.resolve(controller) ); expect(component).toBeTruthy(); tick(101) fixture.detectChanges() fixture.whenStable().then(() => { - expect(serverServiceMock.getLocalServer).toHaveBeenCalledWith('vps3.gns3.net',3000); + expect(controllerServiceMock.getLocalServer).toHaveBeenCalledWith('vps3.gns3.net',3000); expect(router.navigate).toHaveBeenCalledWith(['/controller', 99, 'projects']); }) service = TestBed.inject(ServerService); diff --git a/src/app/components/bundled-server-finder/bundled-server-finder.component.ts b/src/app/components/bundled-server-finder/bundled-server-finder.component.ts index 86bf33af..c55dbe8d 100644 --- a/src/app/components/bundled-server-finder/bundled-server-finder.component.ts +++ b/src/app/components/bundled-server-finder/bundled-server-finder.component.ts @@ -31,8 +31,8 @@ export class BundledServerFinderComponent implements OnInit { port = 80; } - this.serverService.getLocalServer(this.document.location.hostname, port).then((server: Server) => { - this.router.navigate(['/controller', server.id, 'projects']); + this.serverService.getLocalServer(this.document.location.hostname, port).then((controller: Server) => { + this.router.navigate(['/controller', controller.id, 'projects']); this.progressService.deactivate(); }); }, 100); diff --git a/src/app/components/controllers/add-controller-dialog/add-controller-dialog.component.html b/src/app/components/controllers/add-controller-dialog/add-controller-dialog.component.html index 970b470f..7c806c01 100644 --- a/src/app/components/controllers/add-controller-dialog/add-controller-dialog.component.html +++ b/src/app/components/controllers/add-controller-dialog/add-controller-dialog.component.html @@ -1,9 +1,9 @@

Add controller

-
+
- You must enter a value + You must enter a value - diff --git a/src/app/components/controllers/add-controller-dialog/add-controller-dialog.component.ts b/src/app/components/controllers/add-controller-dialog/add-controller-dialog.component.ts index 2f4266ae..6faaf9b8 100644 --- a/src/app/components/controllers/add-controller-dialog/add-controller-dialog.component.ts +++ b/src/app/components/controllers/add-controller-dialog/add-controller-dialog.component.ts @@ -17,7 +17,7 @@ export class AddControllerDialogComponent implements OnInit { ]; locations = []; - serverForm = new FormGroup({ + controllerForm = new FormGroup({ name: new FormControl('', [Validators.required]), location: new FormControl(''), path: new FormControl(''), @@ -57,7 +57,7 @@ export class AddControllerDialogComponent implements OnInit { async numberOfLocalServers() { const servers = await this.serverService.findAll(); - return servers.filter((server) => server.location === 'local').length; + return servers.filter((controller) => controller.location === 'local').length; } getDefaultHost() { @@ -88,9 +88,9 @@ export class AddControllerDialogComponent implements OnInit { const defaultLocalServerPath = await this.getDefaultLocalServerPath(); const defaultUbridgePath = await this.getDefaultUbridgePath(); - this.serverForm.get('location').valueChanges.subscribe((location: string) => { - const pathControl = this.serverForm.get('path'); - const ubridgePathControl = this.serverForm.get('ubridge_path'); + this.controllerForm.get('location').valueChanges.subscribe((location: string) => { + const pathControl = this.controllerForm.get('path'); + const ubridgePathControl = this.controllerForm.get('ubridge_path'); if (location === 'local') { pathControl.setValue(defaultLocalServerPath); @@ -114,29 +114,29 @@ export class AddControllerDialogComponent implements OnInit { }); const defaultLocation = await this.getDefaultLocation(); - this.serverForm.get('location').setValue(defaultLocation); - this.serverForm.get('host').setValue(this.getDefaultHost()); - this.serverForm.get('port').setValue(this.getDefaultPort()); + this.controllerForm.get('location').setValue(defaultLocation); + this.controllerForm.get('host').setValue(this.getDefaultHost()); + this.controllerForm.get('port').setValue(this.getDefaultPort()); } onAddClick(): void { - if (!this.serverForm.valid) { + if (!this.controllerForm.valid) { return; } - const server: Server = Object.assign({}, this.serverForm.value); - this.serverService.checkServerVersion(server).subscribe( + const controller: Server = Object.assign({}, this.controllerForm.value); + this.serverService.checkServerVersion(controller).subscribe( (serverInfo) => { if (serverInfo.version.split('.')[0] >= 3) { - this.dialogRef.close(server); - this.toasterService.success(`Server ${server.name} added.`); + this.dialogRef.close(controller); + this.toasterService.success(`Server ${controller.name} added.`); } else { this.dialogRef.close(); this.toasterService.error(`Server version is not supported.`); } }, (error) => { - this.toasterService.error('Cannot connect to the server: ' + error); + this.toasterService.error('Cannot connect to the controller: ' + error); } ); } diff --git a/src/app/components/controllers/controller-discovery/controller-discovery.component.html b/src/app/components/controllers/controller-discovery/controller-discovery.component.html index d0fbbc9a..a395b204 100644 --- a/src/app/components/controllers/controller-discovery/controller-discovery.component.html +++ b/src/app/components/controllers/controller-discovery/controller-discovery.component.html @@ -1,6 +1,6 @@ - We've discovered GNS3 server on {{ discoveredServer?.host }}:{{ discoveredServer?.port }}{{ discoveredServer?.host }}:{{ discoveredServer?.port }}, would you like to add to the list? diff --git a/src/app/components/controllers/controller-discovery/controller-discovery.component.spec.ts b/src/app/components/controllers/controller-discovery/controller-discovery.component.spec.ts index 7fdf4a50..92a812af 100644 --- a/src/app/components/controllers/controller-discovery/controller-discovery.component.spec.ts +++ b/src/app/components/controllers/controller-discovery/controller-discovery.component.spec.ts @@ -47,7 +47,7 @@ it('should create', () => { }); describe('isAvailable', () => { - it('should return server object when server is available', () => { + it('should return controller object when controller is available', () => { const version = new Version(); version.version = '2.1.8'; @@ -58,20 +58,20 @@ describe('isAvailable', () => { expect(s.port).toEqual(3080); }); - const server = new Server(); - server.host = '127.0.0.1'; - server.port = 3080; + const controller = new Server(); + controller.host = '127.0.0.1'; + controller.port = 3080; - expect(getVersionSpy).toHaveBeenCalledWith(server); + expect(getVersionSpy).toHaveBeenCalledWith(controller); }); - it('should throw error once server is not available', () => { - const server = new Server(); - server.host = '127.0.0.1'; - server.port = 3080; + it('should throw error once controller is not available', () => { + const controller = new Server(); + controller.host = '127.0.0.1'; + controller.port = 3080; const getVersionSpy = spyOn(mockedVersionService, 'get').and.returnValue( - Observable.throwError(new Error('server is unavailable')) + Observable.throwError(new Error('controller is unavailable')) ); let hasExecuted = false; @@ -79,11 +79,11 @@ describe('isAvailable', () => { (ver) => { }, (err) => { hasExecuted = true; - expect(err.toString()).toEqual('Error: server is unavailable'); + expect(err.toString()).toEqual('Error: controller is unavailable'); } ); - expect(getVersionSpy).toHaveBeenCalledWith(server); + expect(getVersionSpy).toHaveBeenCalledWith(controller); expect(hasExecuted).toBeTruthy(); }); }); @@ -94,10 +94,10 @@ describe('discovery', () => { version.version = '2.1.8'; spyOn(component, 'isServerAvailable').and.callFake((ip, port) => { - const server = new Server(); - server.host = ip; - server.port = port; - return Observable.of(server); + const controller = new Server(); + controller.host = ip; + controller.port = port; + return Observable.of(controller); }); component.discovery().subscribe((discovered) => { @@ -112,18 +112,18 @@ describe('discovery', () => { }); describe('discoverFirstAvailableServer', () => { - let server: Server; + let controller: Server; beforeEach(function () { - server = new Server(); - (server.host = '199.111.111.1'), (server.port = 3333); + controller = new Server(); + (controller.host = '199.111.111.1'), (controller.port = 3333); spyOn(component, 'discovery').and.callFake(() => { - return Observable.of([server]); + return Observable.of([controller]); }); }); - it('should get first server from discovered and with no added before', fakeAsync(() => { + it('should get first controller from discovered and with no added before', fakeAsync(() => { expect(component.discoveredServer).toBeUndefined(); component.discoverFirstAvailableServer(); tick(); @@ -131,8 +131,8 @@ describe('discoverFirstAvailableServer', () => { expect(component.discoveredServer.port).toEqual(3333); })); - it('should get first server from discovered and with already added', fakeAsync(() => { - mockedServerService.servers.push(server); + it('should get first controller from discovered and with already added', fakeAsync(() => { + mockedServerService.servers.push(controller); expect(component.discoveredServer).toBeUndefined(); component.discoverFirstAvailableServer(); @@ -141,17 +141,17 @@ describe('discoverFirstAvailableServer', () => { })); }); -describe('accepting and ignoring found server', () => { - let server: Server; +describe('accepting and ignoring found controller', () => { + let controller: Server; beforeEach(() => { - server = new Server(); - (server.host = '199.111.111.1'), (server.port = 3333); - component.discoveredServer = server; + controller = new Server(); + (controller.host = '199.111.111.1'), (controller.port = 3333); + component.discoveredServer = controller; }); describe('accept', () => { - it('should add new server', fakeAsync(() => { - component.accept(server); + it('should add new controller', fakeAsync(() => { + component.accept(controller); tick(); expect(component.discoveredServer).toBeNull(); expect(mockedServerService.servers[0].host).toEqual('199.111.111.1'); @@ -161,8 +161,8 @@ describe('accepting and ignoring found server', () => { }); describe('ignore', () => { - it('should reject server', fakeAsync(() => { - component.ignore(server); + it('should reject controller', fakeAsync(() => { + component.ignore(controller); tick(); expect(component.discoveredServer).toBeNull(); })); diff --git a/src/app/components/controllers/controller-discovery/controller-discovery.component.ts b/src/app/components/controllers/controller-discovery/controller-discovery.component.ts index da06a07d..124e21f8 100644 --- a/src/app/components/controllers/controller-discovery/controller-discovery.component.ts +++ b/src/app/components/controllers/controller-discovery/controller-discovery.component.ts @@ -45,8 +45,8 @@ export class ControllerDiscoveryComponent implements OnInit { let local = await this.serverService.findAll(); local.forEach((added) => { - discovered = discovered.filter((server) => { - return !(server.host == added.host && server.port == added.port); + discovered = discovered.filter((controller) => { + return !(controller.host == added.host && controller.port == added.port); }); }); @@ -58,14 +58,14 @@ export class ControllerDiscoveryComponent implements OnInit { async discoverServers() { let discoveredServers: Server[] = []; this.defaultServers.forEach(async (testServer) => { - const server = new Server(); - server.host = testServer.host; - server.port = testServer.port; + const controller = new Server(); + controller.host = testServer.host; + controller.port = testServer.port; let version = await this.versionService - .get(server) + .get(controller) .toPromise() .catch((error) => null); - if (version) discoveredServers.push(server); + if (version) discoveredServers.push(controller); }); return discoveredServers; } @@ -74,8 +74,8 @@ export class ControllerDiscoveryComponent implements OnInit { forkJoin([from(this.serverService.findAll()).pipe(map((s: Server[]) => s)), this.discovery()]).subscribe( ([local, discovered]) => { local.forEach((added) => { - discovered = discovered.filter((server) => { - return !(server.host == added.host && server.port == added.port); + discovered = discovered.filter((controller) => { + return !(controller.host == added.host && controller.port == added.port); }); }); if (discovered.length > 0) { @@ -106,25 +106,25 @@ export class ControllerDiscoveryComponent implements OnInit { } isServerAvailable(ip: string, port: number): Observable { - const server = new Server(); - server.host = ip; - server.port = port; - return this.versionService.get(server).flatMap((version: Version) => Observable.of(server)); + const controller = new Server(); + controller.host = ip; + controller.port = port; + return this.versionService.get(controller).flatMap((version: Version) => Observable.of(controller)); } - ignore(server: Server) { + ignore(controller: Server) { this.discoveredServer = null; } - accept(server: Server) { - if (server.name == null) { - server.name = server.host; + accept(controller: Server) { + if (controller.name == null) { + controller.name = controller.host; } - server.location = 'remote'; - server.protocol = location.protocol as ServerProtocol; + controller.location = 'remote'; + controller.protocol = location.protocol as ServerProtocol; - this.serverService.create(server).then((created: Server) => { + this.serverService.create(controller).then((created: Server) => { this.serverDatabase.addServer(created); this.discoveredServer = null; }); diff --git a/src/app/components/controllers/controllers.component.html b/src/app/components/controllers/controllers.component.html index 7fa1edb3..0bf017ae 100644 --- a/src/app/components/controllers/controllers.component.html +++ b/src/app/components/controllers/controllers.component.html @@ -53,22 +53,22 @@
diff --git a/src/app/components/controllers/controllers.component.ts b/src/app/components/controllers/controllers.component.ts index c47c6731..2c2481c5 100644 --- a/src/app/components/controllers/controllers.component.ts +++ b/src/app/components/controllers/controllers.component.ts @@ -38,23 +38,23 @@ export class ControllersComponent implements OnInit, OnDestroy { private router: Router ) { } - getServers() { + getControllers() { const runningServersNames = this.serverManagement.getRunningServers(); - this.serverService.findAll().then((servers: Server[]) => { - servers.forEach((server) => { - const serverIndex = runningServersNames.findIndex((serverName) => server.name === serverName); + this.serverService.findAll().then((controllers: Server[]) => { + controllers.forEach((controller) => { + const serverIndex = runningServersNames.findIndex((controllerName) => controller.name === controllerName); if (serverIndex >= 0) { - server.status = 'running'; + controller.status = 'running'; } }); - servers.forEach((server) => { - this.serverService.checkServerVersion(server).subscribe( + controllers.forEach((controller) => { + this.serverService.checkServerVersion(controller).subscribe( (serverInfo) => { if (serverInfo.version.split('.')[0] >= 3) { - if (!server.protocol) server.protocol = location.protocol as ServerProtocol; - if (!this.serverDatabase.find(server.name)) this.serverDatabase.addServer(server); + if (!controller.protocol) controller.protocol = location.protocol as ServerProtocol; + if (!this.serverDatabase.find(controller.name)) this.serverDatabase.addServer(controller); } }, (error) => { } @@ -66,12 +66,12 @@ export class ControllersComponent implements OnInit, OnDestroy { ngOnInit() { this.isElectronApp = this.electronService.isElectronApp; - if (this.serverService && this.serverService.isServiceInitialized) this.getServers(); + if (this.serverService && this.serverService.isServiceInitialized) this.getControllers(); if (this.serverService && this.serverService.isServiceInitialized) { this.serverService.serviceInitialized.subscribe(async (value: boolean) => { if (value) { - this.getServers(); + this.getControllers(); } }); } @@ -79,23 +79,23 @@ export class ControllersComponent implements OnInit, OnDestroy { this.dataSource = new ServerDataSource(this.serverDatabase); this.serverStatusSubscription = this.serverManagement.serverStatusChanged.subscribe((serverStatus) => { - const server = this.serverDatabase.find(serverStatus.serverName); - if (!server) { + const controller = this.serverDatabase.find(serverStatus.serverName); + if (!controller) { return; } if (serverStatus.status === 'starting') { - server.status = 'starting'; + controller.status = 'starting'; } if (serverStatus.status === 'stopped') { - server.status = 'stopped'; + controller.status = 'stopped'; } if (serverStatus.status === 'errored') { - server.status = 'stopped'; + controller.status = 'stopped'; } if (serverStatus.status === 'started') { - server.status = 'running'; + controller.status = 'running'; } - this.serverDatabase.update(server); + this.serverDatabase.update(controller); this.changeDetector.detectChanges(); }); } @@ -105,12 +105,12 @@ export class ControllersComponent implements OnInit, OnDestroy { } startLocalServer() { - const server = this.serverDatabase.data.find((n) => n.location === 'bundled' || 'local'); - this.startServer(server); + const controller = this.serverDatabase.data.find((n) => n.location === 'bundled' || 'local'); + this.startServer(controller); } - openProjects(server) { - this.router.navigate(['/controller', server.id, 'projects']); + openProjects(controller) { + this.router.navigate(['/controller', controller.id, 'projects']); } createModal() { @@ -120,43 +120,43 @@ export class ControllersComponent implements OnInit, OnDestroy { disableClose: true, }); - dialogRef.afterClosed().subscribe((server) => { - if (server) { - this.serverService.create(server).then((created: Server) => { + dialogRef.afterClosed().subscribe((controller) => { + if (controller) { + this.serverService.create(controller).then((created: Server) => { this.serverDatabase.addServer(created); }); } }); } - getServerStatus(server: Server) { - if (server.location === 'local') { - if (server.status === undefined) { + getServerStatus(controller: Server) { + if (controller.location === 'local') { + if (controller.status === undefined) { return 'stopped'; } - return server.status; + return controller.status; } } - deleteServer(server: Server) { + deleteServer(controller: Server) { this.bottomSheet.open(ConfirmationBottomSheetComponent); let bottomSheetRef = this.bottomSheet._openedBottomSheetRef; - bottomSheetRef.instance.message = 'Do you want to delete the server?'; + bottomSheetRef.instance.message = 'Do you want to delete the controller?'; const bottomSheetSubscription = bottomSheetRef.afterDismissed().subscribe((result: boolean) => { if (result) { - this.serverService.delete(server).then(() => { - this.serverDatabase.remove(server); + this.serverService.delete(controller).then(() => { + this.serverDatabase.remove(controller); }); } }); } - async startServer(server: Server) { - await this.serverManagement.start(server); + async startServer(controller: Server) { + await this.serverManagement.start(controller); } - async stopServer(server: Server) { - await this.serverManagement.stop(server); + async stopServer(controller: Server) { + await this.serverManagement.stop(controller); } } diff --git a/src/app/components/direct-link/direct-link.component.html b/src/app/components/direct-link/direct-link.component.html index 20eca142..23ce15bb 100644 --- a/src/app/components/direct-link/direct-link.component.html +++ b/src/app/components/direct-link/direct-link.component.html @@ -1,7 +1,7 @@ -
+
-

Add new server

+

Add new controller

@@ -26,7 +26,7 @@
- +
diff --git a/src/app/components/direct-link/direct-link.component.ts b/src/app/components/direct-link/direct-link.component.ts index 8559f3e2..f5f51ef6 100644 --- a/src/app/components/direct-link/direct-link.component.ts +++ b/src/app/components/direct-link/direct-link.component.ts @@ -13,9 +13,9 @@ import { ToasterService } from '../../services/toaster.service'; encapsulation: ViewEncapsulation.None, }) export class DirectLinkComponent implements OnInit { - public serverOptionsVisibility = false; - public serverIp; - public serverPort; + public controllerOptionsVisibility = false; + public controllerIp; + public controllerPort; public projectId; protocols = [ @@ -42,27 +42,27 @@ export class DirectLinkComponent implements OnInit { ) {} async ngOnInit() { - if (this.serverService.isServiceInitialized) this.getServers(); + if (this.serverService.isServiceInitialized) this.getControllers(); this.serverService.serviceInitialized.subscribe(async (value: boolean) => { if (value) { - this.getServers(); + this.getControllers(); } }); } - private async getServers() { - this.serverIp = this.route.snapshot.paramMap.get('server_ip'); - this.serverPort = +this.route.snapshot.paramMap.get('server_port'); + private async getControllers() { + this.controllerIp = this.route.snapshot.paramMap.get('server_ip'); + this.controllerPort = +this.route.snapshot.paramMap.get('server_port'); this.projectId = this.route.snapshot.paramMap.get('project_id'); - const servers = await this.serverService.findAll(); - const server = servers.filter((server) => server.host === this.serverIp && server.port === this.serverPort)[0]; + const controllers = await this.serverService.findAll(); + const controller = controllers.filter((controller) => controller.host === this.controllerIp && controller.port === this.controllerPort)[0]; - if (server) { - this.router.navigate(['/controller', server.id, 'project', this.projectId]); + if (controller) { + this.router.navigate(['/controller', controller.id, 'project', this.projectId]); } else { - this.serverOptionsVisibility = true; + this.controllerOptionsVisibility = true; } } @@ -73,8 +73,8 @@ export class DirectLinkComponent implements OnInit { } let serverToAdd: Server = new Server(); - serverToAdd.host = this.serverIp; - serverToAdd.port = this.serverPort; + serverToAdd.host = this.controllerIp; + serverToAdd.port = this.controllerPort; serverToAdd.name = this.serverForm.get('name').value; serverToAdd.location = this.serverForm.get('location').value; diff --git a/src/app/components/drawings-listeners/drawing-added/drawing-added.component.ts b/src/app/components/drawings-listeners/drawing-added/drawing-added.component.ts index f43c825f..8dd98067 100644 --- a/src/app/components/drawings-listeners/drawing-added/drawing-added.component.ts +++ b/src/app/components/drawings-listeners/drawing-added/drawing-added.component.ts @@ -16,7 +16,7 @@ import { DrawingService } from '../../../services/drawing.service'; styleUrls: ['./drawing-added.component.scss'], }) export class DrawingAddedComponent implements OnInit, OnDestroy { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Input() selectedDrawing: string; @Output() drawingSaved = new EventEmitter(); @@ -49,7 +49,7 @@ export class DrawingAddedComponent implements OnInit, OnDestroy { let svgText = this.mapDrawingToSvgConverter.convert(drawing); this.drawingService - .add(this.server, this.project.project_id, evt.x, evt.y, svgText) + .add(this.controller, this.project.project_id, evt.x, evt.y, svgText) .subscribe((serverDrawing: Drawing) => { this.drawingsDataSource.add(serverDrawing); this.drawingSaved.emit(true); diff --git a/src/app/components/drawings-listeners/drawing-dragged/drawing-dragged.component.ts b/src/app/components/drawings-listeners/drawing-dragged/drawing-dragged.component.ts index dc33b8fa..9f5e1e7d 100644 --- a/src/app/components/drawings-listeners/drawing-dragged/drawing-dragged.component.ts +++ b/src/app/components/drawings-listeners/drawing-dragged/drawing-dragged.component.ts @@ -15,7 +15,7 @@ import { DrawingService } from '../../../services/drawing.service'; styleUrls: ['./drawing-dragged.component.scss'], }) export class DrawingDraggedComponent implements OnInit, OnDestroy { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; private drawingDragged: Subscription; @@ -35,7 +35,7 @@ export class DrawingDraggedComponent implements OnInit, OnDestroy { drawing.y += draggedEvent.dy; this.drawingService - .updatePosition(this.server, this.project, drawing, drawing.x, drawing.y) + .updatePosition(this.controller, this.project, drawing, drawing.x, drawing.y) .subscribe((serverDrawing: Drawing) => { this.drawingsDataSource.update(serverDrawing); }); diff --git a/src/app/components/drawings-listeners/drawing-resized/drawing-resized.component.ts b/src/app/components/drawings-listeners/drawing-resized/drawing-resized.component.ts index ef8fc203..266f5d2b 100644 --- a/src/app/components/drawings-listeners/drawing-resized/drawing-resized.component.ts +++ b/src/app/components/drawings-listeners/drawing-resized/drawing-resized.component.ts @@ -15,7 +15,7 @@ import { DrawingService } from '../../../services/drawing.service'; styleUrls: ['./drawing-resized.component.scss'], }) export class DrawingResizedComponent implements OnInit, OnDestroy { - @Input() server: Server; + @Input() controller: Server; private drawingResized: Subscription; constructor( @@ -34,7 +34,7 @@ export class DrawingResizedComponent implements OnInit, OnDestroy { let svgString = this.mapDrawingToSvgConverter.convert(resizedEvent.datum); this.drawingService - .updateSizeAndPosition(this.server, drawing, resizedEvent.x, resizedEvent.y, svgString) + .updateSizeAndPosition(this.controller, drawing, resizedEvent.x, resizedEvent.y, svgString) .subscribe((serverDrawing: Drawing) => { this.drawingsDataSource.update(serverDrawing); }); diff --git a/src/app/components/drawings-listeners/interface-label-dragged/interface-label-dragged.component.ts b/src/app/components/drawings-listeners/interface-label-dragged/interface-label-dragged.component.ts index 124674ea..83a5e1e4 100644 --- a/src/app/components/drawings-listeners/interface-label-dragged/interface-label-dragged.component.ts +++ b/src/app/components/drawings-listeners/interface-label-dragged/interface-label-dragged.component.ts @@ -14,7 +14,7 @@ import { LinkService } from '../../../services/link.service'; styleUrls: ['./interface-label-dragged.component.scss'], }) export class InterfaceLabelDraggedComponent { - @Input() server: Server; + @Input() controller: Server; private interfaceDragged: Subscription; constructor( @@ -40,7 +40,7 @@ export class InterfaceLabelDraggedComponent { link.nodes[1].label.y += draggedEvent.dy; } - this.linkService.updateNodes(this.server, link, link.nodes).subscribe((serverLink: Link) => { + this.linkService.updateNodes(this.controller, link, link.nodes).subscribe((serverLink: Link) => { this.linksDataSource.update(serverLink); }); } diff --git a/src/app/components/drawings-listeners/link-created/link-created.component.ts b/src/app/components/drawings-listeners/link-created/link-created.component.ts index f115ca90..33972355 100644 --- a/src/app/components/drawings-listeners/link-created/link-created.component.ts +++ b/src/app/components/drawings-listeners/link-created/link-created.component.ts @@ -17,7 +17,7 @@ import { ProjectService } from '../../../services/project.service'; styleUrls: ['./link-created.component.scss'], }) export class LinkCreatedComponent implements OnInit, OnDestroy { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; private linkCreated: Subscription; @@ -87,7 +87,7 @@ export class LinkCreatedComponent implements OnInit, OnDestroy { this.linkService .createLink( - this.server, + this.controller, sourceNode, sourcePort, targetNode, @@ -98,7 +98,7 @@ export class LinkCreatedComponent implements OnInit, OnDestroy { yLabelTargetNode ) .subscribe(() => { - this.projectService.links(this.server, this.project.project_id).subscribe((links: Link[]) => { + this.projectService.links(this.controller, this.project.project_id).subscribe((links: Link[]) => { this.linksDataSource.set(links); }); }); diff --git a/src/app/components/drawings-listeners/node-dragged/node-dragged.component.ts b/src/app/components/drawings-listeners/node-dragged/node-dragged.component.ts index 7730d4b2..0aed5c12 100644 --- a/src/app/components/drawings-listeners/node-dragged/node-dragged.component.ts +++ b/src/app/components/drawings-listeners/node-dragged/node-dragged.component.ts @@ -15,7 +15,7 @@ import { NodeService } from '../../../services/node.service'; styleUrls: ['./node-dragged.component.scss'], }) export class NodeDraggedComponent implements OnInit, OnDestroy { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; private nodeDragged: Subscription; @@ -34,7 +34,7 @@ export class NodeDraggedComponent implements OnInit, OnDestroy { node.x += draggedEvent.dx; node.y += draggedEvent.dy; - this.nodeService.updatePosition(this.server, this.project, node, node.x, node.y).subscribe((serverNode: Node) => { + this.nodeService.updatePosition(this.controller, this.project, node, node.x, node.y).subscribe((serverNode: Node) => { this.nodesDataSource.update(serverNode); }); } diff --git a/src/app/components/drawings-listeners/node-label-dragged/node-label-dragged.component.ts b/src/app/components/drawings-listeners/node-label-dragged/node-label-dragged.component.ts index 9a3bcc47..286b7f55 100644 --- a/src/app/components/drawings-listeners/node-label-dragged/node-label-dragged.component.ts +++ b/src/app/components/drawings-listeners/node-label-dragged/node-label-dragged.component.ts @@ -15,7 +15,7 @@ import { NodeService } from '../../../services/node.service'; styleUrls: ['./node-label-dragged.component.scss'], }) export class NodeLabelDraggedComponent implements OnInit, OnDestroy { - @Input() server: Server; + @Input() controller: Server; private nodeLabelDragged: Subscription; constructor( @@ -38,7 +38,7 @@ export class NodeLabelDraggedComponent implements OnInit, OnDestroy { const label = this.mapLabelToLabel.convert(mapLabel); node.label = label; - this.nodeService.updateLabel(this.server, node, node.label).subscribe((serverNode: Node) => { + this.nodeService.updateLabel(this.controller, node, node.label).subscribe((serverNode: Node) => { this.nodesDataSource.update(serverNode); }); } diff --git a/src/app/components/drawings-listeners/text-added/text-added.component.ts b/src/app/components/drawings-listeners/text-added/text-added.component.ts index d14311ee..a3c770e6 100644 --- a/src/app/components/drawings-listeners/text-added/text-added.component.ts +++ b/src/app/components/drawings-listeners/text-added/text-added.component.ts @@ -18,7 +18,7 @@ import { DrawingService } from '../../../services/drawing.service'; styleUrls: ['./text-added.component.scss'], }) export class TextAddedComponent implements OnInit, OnDestroy { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Output() drawingSaved = new EventEmitter(); private textAdded: Subscription; @@ -43,7 +43,7 @@ export class TextAddedComponent implements OnInit, OnDestroy { this.drawingService .add( - this.server, + this.controller, this.project.project_id, (evt.x - (this.context.getZeroZeroTransformationPoint().x + this.context.transformation.x)) / this.context.transformation.k, diff --git a/src/app/components/drawings-listeners/text-edited/text-edited.component.ts b/src/app/components/drawings-listeners/text-edited/text-edited.component.ts index d5d5eaec..424711da 100644 --- a/src/app/components/drawings-listeners/text-edited/text-edited.component.ts +++ b/src/app/components/drawings-listeners/text-edited/text-edited.component.ts @@ -16,7 +16,7 @@ import { DrawingService } from '../../../services/drawing.service'; styleUrls: ['./text-edited.component.scss'], }) export class TextEditedComponent implements OnInit, OnDestroy { - @Input() server: Server; + @Input() controller: Server; private textEdited: Subscription; constructor( @@ -38,7 +38,7 @@ export class TextEditedComponent implements OnInit, OnDestroy { let drawing = this.drawingsDataSource.get(evt.textDrawingId); - this.drawingService.updateText(this.server, drawing, svgString).subscribe((serverDrawing: Drawing) => { + this.drawingService.updateText(this.controller, drawing, svgString).subscribe((serverDrawing: Drawing) => { this.drawingsDataSource.update(serverDrawing); this.drawingsEventSource.textSaved.emit(true); }); diff --git a/src/app/components/export-portable-project/export-portable-project.component.ts b/src/app/components/export-portable-project/export-portable-project.component.ts index b4f05311..540574ed 100644 --- a/src/app/components/export-portable-project/export-portable-project.component.ts +++ b/src/app/components/export-portable-project/export-portable-project.component.ts @@ -16,7 +16,7 @@ export class ExportPortableProjectComponent implements OnInit { compression_methods: any = []; compression_level: any = []; compression_filter_value: any = []; - server: Server; + controller: Server; project: Project; index: number = 4; fileName: string; @@ -30,7 +30,7 @@ export class ExportPortableProjectComponent implements OnInit { ) {} async ngOnInit() { - this.server = this.data.serverDetails; + this.controller = this.data.serverDetails; this.project = this.data.projectDetails; this.fileName = this.project.name + '.gns3project'; await this.formControls(); @@ -65,7 +65,7 @@ export class ExportPortableProjectComponent implements OnInit { exportPortableProject() { this.isExport = true; this.export_project_form.value.compression = this.export_project_form.value.compression.value ?? 'zstd'; - window.location.assign(this.projectService.getexportPortableProjectPath(this.server, this.project.project_id, this.export_project_form.value)) + window.location.assign(this.projectService.getexportPortableProjectPath(this.controller, this.project.project_id, this.export_project_form.value)) this.dialogRef.close(); } } diff --git a/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.spec.ts b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.spec.ts index d56eb2d5..7fc34798 100644 --- a/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.spec.ts +++ b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.spec.ts @@ -17,7 +17,7 @@ import { MockedToasterService } from 'app/services/toaster.service.spec'; import { MatSnackBarModule } from '@angular/material/snack-bar'; export class MockedImageManagerService { - public getImages(server: Server) { + public getImages(controller: Server) { return of(); } diff --git a/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.ts b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.ts index 60099892..2f5bb5b4 100644 --- a/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.ts +++ b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.ts @@ -20,7 +20,7 @@ import { ToasterService } from '../../../services/toaster.service'; ], }) export class AddImageDialogComponent implements OnInit { - server: Server; + controller: Server; isInstallAppliance: boolean = false; install_appliance: boolean = false; selectFile: any = []; @@ -36,7 +36,7 @@ export class AddImageDialogComponent implements OnInit { ) {} public ngOnInit() { - this.server = this.data; + this.controller =this.data; this.uploaderImage = new FileUploader({}); this.uploaderImage.onAfterAddingFile = (file) => { @@ -98,11 +98,11 @@ export class AddImageDialogComponent implements OnInit { let file = event; let fileReader: FileReader = new FileReader(); fileReader.onloadend = () => { - const url = this.imageService.getImagePath(this.server, this.install_appliance, fileName); + const url = this.imageService.getImagePath(this.controller, this.install_appliance, fileName); const itemToUpload = this.uploaderImage.queue[i]; itemToUpload.url = url; if ((itemToUpload as any).options) (itemToUpload as any).options.disableMultipart = true; - (itemToUpload as any).options.headers = [{ name: 'Authorization', value: 'Bearer ' + this.server.authToken }]; + (itemToUpload as any).options.headers = [{ name: 'Authorization', value: 'Bearer ' + this.controller.authToken }]; this.uploaderImage.uploadItem(itemToUpload); }; fileReader.readAsText(file); diff --git a/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.spec.ts b/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.spec.ts index 43aea89c..99a96b83 100644 --- a/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.spec.ts +++ b/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.spec.ts @@ -17,7 +17,7 @@ import { ImageManagerComponent } from '../image-manager.component'; import { DeleteAllImageFilesDialogComponent } from './deleteallfiles-dialog.component'; export class MockedImageManagerService { - public deleteALLFile(server: Server, image_path) { + public deleteALLFile(controller: Server, image_path) { return of(); } } diff --git a/src/app/components/image-manager/image-manager.component.spec.ts b/src/app/components/image-manager/image-manager.component.spec.ts index bdba7db1..e8f2af81 100644 --- a/src/app/components/image-manager/image-manager.component.spec.ts +++ b/src/app/components/image-manager/image-manager.component.spec.ts @@ -23,11 +23,11 @@ import { ToasterService } from 'app/services/toaster.service'; import { MockedToasterService } from 'app/services/toaster.service.spec'; export class MockedImageManagerService { - public getImages(server: Server) { + public getImages(controller: Server) { return of(); } - public deleteFile(server: Server, image_path) { + public deleteFile(controller: Server, image_path) { return of(); } diff --git a/src/app/components/image-manager/image-manager.component.ts b/src/app/components/image-manager/image-manager.component.ts index 233538eb..bfacad47 100644 --- a/src/app/components/image-manager/image-manager.component.ts +++ b/src/app/components/image-manager/image-manager.component.ts @@ -19,7 +19,7 @@ import { imageDataSource, imageDatabase } from "./image-database-file"; styleUrls: ['./image-manager.component.scss'] }) export class ImageManagerComponent implements OnInit { - server: Server; + controller: Server; public version: string; dataSource: imageDataSource; imageDatabase = new imageDatabase(); @@ -41,12 +41,12 @@ export class ImageManagerComponent implements OnInit { ngOnInit(): void { let controller_id = parseInt(this.route.snapshot.paramMap.get('controller_id')); - this.serverService.get(controller_id).then((server: Server) => { - this.server = server; - if (server.authToken) { + this.serverService.get(controller_id).then((controller: Server) => { + this.controller = controller; + if (controller.authToken) { this.getImages() } - // this.versionService.get(this.server).subscribe((version: Version) => { + // this.versionService.get(this.controller).subscribe((version: Version) => { // this.version = version.version; // }); }); @@ -54,7 +54,7 @@ export class ImageManagerComponent implements OnInit { } getImages() { - this.imageService.getImages(this.server).subscribe( + this.imageService.getImages(this.controller).subscribe( (images: Image[]) => { this.imageDatabase.addImages(images) }, @@ -66,7 +66,7 @@ export class ImageManagerComponent implements OnInit { } deleteFile(path) { - this.imageService.deleteFile(this.server, path).subscribe( + this.imageService.deleteFile(this.controller, path).subscribe( (res) => { this.getImages() this.unChecked() @@ -106,7 +106,7 @@ export class ImageManagerComponent implements OnInit { maxHeight: '550px', autoFocus: false, disableClose: true, - data: this.server + data: this.controller }); dialogRef.afterClosed().subscribe((isAddes: boolean) => { @@ -128,7 +128,7 @@ export class ImageManagerComponent implements OnInit { autoFocus: false, disableClose: true, data: { - server: this.server, + controller: this.controller, deleteFilesPaths: this.selection.selected } }); diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts index 8abc9833..50a31707 100644 --- a/src/app/components/login/login.component.ts +++ b/src/app/components/login/login.component.ts @@ -18,7 +18,7 @@ import { VersionService } from '../../services/version.service'; encapsulation: ViewEncapsulation.None, }) export class LoginComponent implements OnInit, DoCheck { - private server: Server; + private controller: Server; public version: string; public isLightThemeEnabled: boolean = false; public loginError: boolean = false; @@ -45,14 +45,14 @@ export class LoginComponent implements OnInit, DoCheck { async ngOnInit() { const controller_id = this.route.snapshot.paramMap.get('controller_id'); this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/'; - this.serverService.get(parseInt(controller_id, 10)).then((server: Server) => { - this.server = server; + this.serverService.get(parseInt(controller_id, 10)).then((controller: Server) => { + this.controller = controller; - if (server.authToken) { - this.router.navigate(['/controller', this.server.id, 'projects']); + if (controller.authToken) { + this.router.navigate(['/controller', this.controller.id, 'projects']); } - this.versionService.get(this.server).subscribe((version: Version) => { + this.versionService.get(this.controller).subscribe((version: Version) => { this.version = version.version; }); }); @@ -78,17 +78,17 @@ export class LoginComponent implements OnInit, DoCheck { let username = this.loginForm.get('username').value; let password = this.loginForm.get('password').value; - this.loginService.login(this.server, username, password).subscribe( + this.loginService.login(this.controller, username, password).subscribe( async (response: AuthResponse) => { - let server = this.server; - server.authToken = response.access_token; - server.username = username; - server.password = password; - server.tokenExpired = false; - await this.serverService.update(server); + let controller = this.controller; + controller.authToken = response.access_token; + controller.username = username; + controller.password = password; + controller.tokenExpired = false; + await this.serverService.update(controller); if (this.returnUrl.length <= 1) { - this.router.navigate(['/controller', this.server.id, 'projects']); + this.router.navigate(['/controller', this.controller.id, 'projects']); } else { this.router.navigateByUrl(this.returnUrl); } diff --git a/src/app/components/preferences/built-in/built-in-preferences.component.html b/src/app/components/preferences/built-in/built-in-preferences.component.html index 03ec3f78..c914afb5 100644 --- a/src/app/components/preferences/built-in/built-in-preferences.component.html +++ b/src/app/components/preferences/built-in/built-in-preferences.component.html @@ -2,7 +2,7 @@

Built-in preferences

-
@@ -10,13 +10,13 @@
- + Ethernet hubs - + Ethernet switches - Cloud nodes + Cloud nodes
diff --git a/src/app/components/preferences/built-in/built-in-preferences.component.spec.ts b/src/app/components/preferences/built-in/built-in-preferences.component.spec.ts index 40f09c82..99b9e8da 100644 --- a/src/app/components/preferences/built-in/built-in-preferences.component.spec.ts +++ b/src/app/components/preferences/built-in/built-in-preferences.component.spec.ts @@ -48,7 +48,7 @@ describe('BuiltInPreferencesComponent', () => { expect(component).toBeTruthy(); }); - it('should set correct server id', () => { - expect(component.serverId).toBe('1'); + it('should set correct controller id', () => { + expect(component.controllerId).toBe('1'); }); }); diff --git a/src/app/components/preferences/built-in/built-in-preferences.component.ts b/src/app/components/preferences/built-in/built-in-preferences.component.ts index a622c9e8..145b3a3e 100644 --- a/src/app/components/preferences/built-in/built-in-preferences.component.ts +++ b/src/app/components/preferences/built-in/built-in-preferences.component.ts @@ -7,11 +7,11 @@ import { ActivatedRoute } from '@angular/router'; styleUrls: ['./built-in-preferences.component.scss', '../preferences.component.scss'], }) export class BuiltInPreferencesComponent implements OnInit { - public serverId: string = ''; + public controllerId: string = ''; constructor(private route: ActivatedRoute) {} ngOnInit() { - this.serverId = this.route.snapshot.paramMap.get('controller_id'); + this.controllerId = this.route.snapshot.paramMap.get('controller_id'); } } diff --git a/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-add-template/cloud-nodes-add-template.component.spec.ts b/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-add-template/cloud-nodes-add-template.component.spec.ts index 5a20b5ca..d8467cf1 100644 --- a/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-add-template/cloud-nodes-add-template.component.spec.ts +++ b/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-add-template/cloud-nodes-add-template.component.spec.ts @@ -24,7 +24,7 @@ import { MockedActivatedRoute } from '../../../preferences.component.spec'; import { CloudNodesAddTemplateComponent } from './cloud-nodes-add-template.component'; export class MockedBuiltInTemplatesService { - public addTemplate(server: Server, cloudTemplate: CloudTemplate) { + public addTemplate(controller: Server, cloudTemplate: CloudTemplate) { return of(cloudTemplate); } } @@ -80,7 +80,7 @@ describe('CloudNodesAddTemplateComponent', () => { it('should call add template', () => { spyOn(mockedBuiltInTemplatesService, 'addTemplate').and.returnValue(of({} as CloudTemplate)); component.templateName = 'sample name'; - component.server = { id: 1 } as Server; + component.controller = { id: 1 } as Server; component.formGroup.controls['templateName'].setValue('template name'); component.addTemplate(); @@ -92,7 +92,7 @@ describe('CloudNodesAddTemplateComponent', () => { spyOn(mockedBuiltInTemplatesService, 'addTemplate').and.returnValue(of({} as CloudTemplate)); spyOn(mockedToasterService, 'error'); component.templateName = ''; - component.server = { id: 1 } as Server; + component.controller = { id: 1 } as Server; component.addTemplate(); diff --git a/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-add-template/cloud-nodes-add-template.component.ts b/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-add-template/cloud-nodes-add-template.component.ts index 81e080e7..04c499b9 100644 --- a/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-add-template/cloud-nodes-add-template.component.ts +++ b/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-add-template/cloud-nodes-add-template.component.ts @@ -17,7 +17,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; styleUrls: ['./cloud-nodes-add-template.component.scss', '../../../preferences.component.scss'], }) export class CloudNodesAddTemplateComponent implements OnInit { - server: Server; + controller: Server; templateName: string = ''; formGroup: FormGroup; isLocalComputerChosen: boolean = true; @@ -39,8 +39,8 @@ export class CloudNodesAddTemplateComponent implements OnInit { ngOnInit() { const controller_id = this.route.snapshot.paramMap.get('controller_id'); - this.serverService.get(parseInt(controller_id, 10)).then((server: Server) => { - this.server = server; + this.serverService.get(parseInt(controller_id, 10)).then((controller: Server) => { + this.controller = controller; }); } @@ -51,7 +51,7 @@ export class CloudNodesAddTemplateComponent implements OnInit { } goBack() { - this.router.navigate(['/controller', this.server.id, 'preferences', 'builtin', 'cloud-nodes']); + this.router.navigate(['/controller', this.controller.id, 'preferences', 'builtin', 'cloud-nodes']); } addTemplate() { @@ -66,7 +66,7 @@ export class CloudNodesAddTemplateComponent implements OnInit { cloudTemplate.name = this.formGroup.get('templateName').value; cloudTemplate.compute_id = 'local'; - this.builtInTemplatesService.addTemplate(this.server, cloudTemplate).subscribe((cloudNodeTemplate) => { + this.builtInTemplatesService.addTemplate(this.controller, cloudTemplate).subscribe((cloudNodeTemplate) => { this.goBack(); }); } else { diff --git a/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-template-details/cloud-nodes-template-details.component.spec.ts b/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-template-details/cloud-nodes-template-details.component.spec.ts index cb888516..32e425c7 100644 --- a/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-template-details/cloud-nodes-template-details.component.spec.ts +++ b/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-template-details/cloud-nodes-template-details.component.spec.ts @@ -23,11 +23,11 @@ import { MockedActivatedRoute } from '../../../preferences.component.spec'; import { CloudNodesTemplateDetailsComponent } from './cloud-nodes-template-details.component'; export class MockedBuiltInTemplatesService { - public getTemplate(server: Server, template_id: string) { + public getTemplate(controller: Server, template_id: string) { return of({ ports_mapping: [] } as CloudTemplate); } - public saveTemplate(server: Server, cloudTemplate: CloudTemplate) { + public saveTemplate(controller: Server, cloudTemplate: CloudTemplate) { return of(cloudTemplate); } } diff --git a/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-template-details/cloud-nodes-template-details.component.ts b/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-template-details/cloud-nodes-template-details.component.ts index 1e996c7f..646d9b20 100644 --- a/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-template-details/cloud-nodes-template-details.component.ts +++ b/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-template-details/cloud-nodes-template-details.component.ts @@ -14,7 +14,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; styleUrls: ['./cloud-nodes-template-details.component.scss', '../../../preferences.component.scss'], }) export class CloudNodesTemplateDetailsComponent implements OnInit { - server: Server; + controller: Server; cloudNodeTemplate: CloudTemplate; isSymbolSelectionOpened: boolean = false; @@ -49,12 +49,12 @@ export class CloudNodesTemplateDetailsComponent implements OnInit { ngOnInit() { const controller_id = this.route.snapshot.paramMap.get('controller_id'); const template_id = this.route.snapshot.paramMap.get('template_id'); - this.serverService.get(parseInt(controller_id, 10)).then((server: Server) => { - this.server = server; + this.serverService.get(parseInt(controller_id, 10)).then((controller: Server) => { + this.controller = controller; this.getConfiguration(); this.builtInTemplatesService - .getTemplate(this.server, template_id) + .getTemplate(this.controller, template_id) .subscribe((cloudNodeTemplate: CloudTemplate) => { this.cloudNodeTemplate = cloudNodeTemplate; @@ -70,7 +70,7 @@ export class CloudNodesTemplateDetailsComponent implements OnInit { } goBack() { - this.router.navigate(['/controller', this.server.id, 'preferences', 'builtin', 'cloud-nodes']); + this.router.navigate(['/controller', this.controller.id, 'preferences', 'builtin', 'cloud-nodes']); } getConfiguration() { @@ -114,7 +114,7 @@ export class CloudNodesTemplateDetailsComponent implements OnInit { this.cloudNodeTemplate.ports_mapping = [...this.portsMappingEthernet, ...this.portsMappingTap]; this.builtInTemplatesService - .saveTemplate(this.server, this.cloudNodeTemplate) + .saveTemplate(this.controller, this.cloudNodeTemplate) .subscribe((cloudNodeTemplate: CloudTemplate) => { this.toasterService.success('Changes saved'); }); diff --git a/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-templates/cloud-nodes-templates.component.html b/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-templates/cloud-nodes-templates.component.html index d8f29312..88aa3267 100644 --- a/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-templates/cloud-nodes-templates.component.html +++ b/src/app/components/preferences/built-in/cloud-nodes/cloud-nodes-templates/cloud-nodes-templates.component.html @@ -3,18 +3,18 @@

Cloud nodes templates

- +
diff --git a/src/app/components/preferences/common/symbols-menu/symbols-menu.component.ts b/src/app/components/preferences/common/symbols-menu/symbols-menu.component.ts index 15e6024b..c19cca68 100644 --- a/src/app/components/preferences/common/symbols-menu/symbols-menu.component.ts +++ b/src/app/components/preferences/common/symbols-menu/symbols-menu.component.ts @@ -7,7 +7,7 @@ import { Server } from '../../../../models/server'; styleUrls: ['./symbols-menu.component.scss', '../../preferences.component.scss'], }) export class SymbolsMenuComponent { - @Input() server: Server; + @Input() controller: Server; @Input() symbol: string; @Output() symbolChangedEmitter = new EventEmitter(); diff --git a/src/app/components/preferences/common/symbols/symbols.component.ts b/src/app/components/preferences/common/symbols/symbols.component.ts index 965cc9a2..3738bd9e 100644 --- a/src/app/components/preferences/common/symbols/symbols.component.ts +++ b/src/app/components/preferences/common/symbols/symbols.component.ts @@ -10,7 +10,7 @@ import { SymbolService } from '../../../../services/symbol.service'; styleUrls: ['./symbols.component.scss'], }) export class SymbolsComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() symbol: string; @Output() symbolChanged = new EventEmitter(); @@ -42,7 +42,7 @@ export class SymbolsComponent implements OnInit { } loadSymbols() { - this.symbolService.list(this.server).subscribe((symbols: Symbol[]) => { + this.symbolService.list(this.controller).subscribe((symbols: Symbol[]) => { this.symbols = symbols; this.filteredSymbols = symbols; }); @@ -61,7 +61,7 @@ export class SymbolsComponent implements OnInit { fileReader.onloadend = () => { let image = fileReader.result; let svg = this.createSvgFileForImage(image, imageToUpload); - this.symbolService.add(this.server, fileName, svg).subscribe(() => { + this.symbolService.add(this.controller, fileName, svg).subscribe(() => { this.loadSymbols(); }); }; @@ -78,6 +78,6 @@ export class SymbolsComponent implements OnInit { } getImageSourceForTemplate(symbol: string) { - return `${this.server.protocol}//${this.server.host}:${this.server.port}/${environment.current_version}/symbols/${symbol}/raw`; + return `${this.controller.protocol}//${this.controller.host}:${this.controller.port}/${environment.current_version}/symbols/${symbol}/raw`; } } diff --git a/src/app/components/preferences/docker/add-docker-template/add-docker-template.component.spec.ts b/src/app/components/preferences/docker/add-docker-template/add-docker-template.component.spec.ts index 9afbc46e..09e6c04b 100644 --- a/src/app/components/preferences/docker/add-docker-template/add-docker-template.component.spec.ts +++ b/src/app/components/preferences/docker/add-docker-template/add-docker-template.component.spec.ts @@ -31,7 +31,7 @@ import { MockedActivatedRoute } from '../../preferences.component.spec'; import { AddDockerTemplateComponent } from './add-docker-template.component'; export class MockedDockerService { - public addTemplate(server: Server, dockerTemplate: DockerTemplate) { + public addTemplate(controller: Server, dockerTemplate: DockerTemplate) { return of(dockerTemplate); } } diff --git a/src/app/components/preferences/docker/add-docker-template/add-docker-template.component.ts b/src/app/components/preferences/docker/add-docker-template/add-docker-template.component.ts index 63b13c7d..3c852646 100644 --- a/src/app/components/preferences/docker/add-docker-template/add-docker-template.component.ts +++ b/src/app/components/preferences/docker/add-docker-template/add-docker-template.component.ts @@ -19,7 +19,7 @@ import { ToasterService } from '../../../../services/toaster.service'; styleUrls: ['./add-docker-template.component.scss', '../../preferences.component.scss'], }) export class AddDockerTemplateComponent implements OnInit { - server: Server; + controller: Server; dockerTemplate: DockerTemplate; consoleTypes: string[] = []; isRemoteComputerChosen: boolean = false; @@ -60,8 +60,8 @@ export class AddDockerTemplateComponent implements OnInit { ngOnInit() { const controller_id = this.route.snapshot.paramMap.get('controller_id'); - this.serverService.get(parseInt(controller_id, 10)).then((server: Server) => { - this.server = server; + this.serverService.get(parseInt(controller_id, 10)).then((controller: Server) => { + this.controller = controller; this.consoleTypes = this.configurationService.getConsoleTypes(); @@ -69,7 +69,7 @@ export class AddDockerTemplateComponent implements OnInit { this.dockerTemplate = dockerTemplate; }); - this.dockerService.getImages(server).subscribe((images) => { + this.dockerService.getImages(controller).subscribe((images) => { this.dockerImages = images; }); }); @@ -86,7 +86,7 @@ export class AddDockerTemplateComponent implements OnInit { } goBack() { - this.router.navigate(['/controller', this.server.id, 'preferences', 'docker', 'templates']); + this.router.navigate(['/controller', this.controller.id, 'preferences', 'docker', 'templates']); } addTemplate() { @@ -107,7 +107,7 @@ export class AddDockerTemplateComponent implements OnInit { this.dockerTemplate.adapters = +this.networkAdaptersForm.get('adapters').value; this.dockerTemplate.compute_id = 'local'; - this.dockerService.addTemplate(this.server, this.dockerTemplate).subscribe((template: DockerTemplate) => { + this.dockerService.addTemplate(this.controller, this.dockerTemplate).subscribe((template: DockerTemplate) => { this.goBack(); }); } else { diff --git a/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.ts b/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.ts index 4f460bd0..6a244d8b 100644 --- a/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.ts +++ b/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.ts @@ -14,7 +14,7 @@ import { ToasterService } from '../../../../services/toaster.service'; styleUrls: ['./copy-docker-template.component.scss', '../../preferences.component.scss'], }) export class CopyDockerTemplateComponent implements OnInit { - server: Server; + controller: Server; templateName: string = ''; dockerTemplate: DockerTemplate; templateNameForm: FormGroup; @@ -35,10 +35,10 @@ export class CopyDockerTemplateComponent implements OnInit { ngOnInit() { const controller_id = this.route.snapshot.paramMap.get('controller_id'); const template_id = this.route.snapshot.paramMap.get('template_id'); - this.serverService.get(parseInt(controller_id, 10)).then((server: Server) => { - this.server = server; + this.serverService.get(parseInt(controller_id, 10)).then((controller: Server) => { + this.controller = controller; - this.dockerService.getTemplate(this.server, template_id).subscribe((dockerTemplate: DockerTemplate) => { + this.dockerService.getTemplate(this.controller, template_id).subscribe((dockerTemplate: DockerTemplate) => { this.dockerTemplate = dockerTemplate; this.templateName = `Copy of ${this.dockerTemplate.name}`; }); @@ -46,7 +46,7 @@ export class CopyDockerTemplateComponent implements OnInit { } goBack() { - this.router.navigate(['/controller', this.server.id, 'preferences', 'docker', 'templates']); + this.router.navigate(['/controller', this.controller.id, 'preferences', 'docker', 'templates']); } addTemplate() { @@ -54,7 +54,7 @@ export class CopyDockerTemplateComponent implements OnInit { this.dockerTemplate.template_id = uuid(); this.dockerTemplate.name = this.templateName; - this.dockerService.addTemplate(this.server, this.dockerTemplate).subscribe((template: DockerTemplate) => { + this.dockerService.addTemplate(this.controller, this.dockerTemplate).subscribe((template: DockerTemplate) => { this.goBack(); }); } else { diff --git a/src/app/components/preferences/docker/docker-template-details/docker-template-details.component.spec.ts b/src/app/components/preferences/docker/docker-template-details/docker-template-details.component.spec.ts index 4e0c4e4a..8c39f9ba 100644 --- a/src/app/components/preferences/docker/docker-template-details/docker-template-details.component.spec.ts +++ b/src/app/components/preferences/docker/docker-template-details/docker-template-details.component.spec.ts @@ -22,11 +22,11 @@ import { MockedActivatedRoute } from '../../preferences.component.spec'; import { DockerTemplateDetailsComponent } from './docker-template-details.component'; export class MockedDockerService { - public getTemplate(server: Server, template_id: string) { + public getTemplate(controller: Server, template_id: string) { return of({} as DockerTemplate); } - public saveTemplate(server: Server, dockerTemplate: DockerTemplate) { + public saveTemplate(controller: Server, dockerTemplate: DockerTemplate) { return of(dockerTemplate); } } diff --git a/src/app/components/preferences/docker/docker-template-details/docker-template-details.component.ts b/src/app/components/preferences/docker/docker-template-details/docker-template-details.component.ts index f4b2203f..522fbec4 100644 --- a/src/app/components/preferences/docker/docker-template-details/docker-template-details.component.ts +++ b/src/app/components/preferences/docker/docker-template-details/docker-template-details.component.ts @@ -15,7 +15,7 @@ import { ToasterService } from '../../../../services/toaster.service'; styleUrls: ['./docker-template-details.component.scss', '../../preferences.component.scss'], }) export class DockerTemplateDetailsComponent implements OnInit { - server: Server; + controller: Server; dockerTemplate: DockerTemplate; isSymbolSelectionOpened: boolean = false; @@ -48,11 +48,11 @@ export class DockerTemplateDetailsComponent implements OnInit { ngOnInit() { const controller_id = this.route.snapshot.paramMap.get('controller_id'); const template_id = this.route.snapshot.paramMap.get('template_id'); - this.serverService.get(parseInt(controller_id, 10)).then((server: Server) => { - this.server = server; + this.serverService.get(parseInt(controller_id, 10)).then((controller: Server) => { + this.controller = controller; this.getConfiguration(); - this.dockerService.getTemplate(this.server, template_id).subscribe((dockerTemplate: DockerTemplate) => { + this.dockerService.getTemplate(this.controller, template_id).subscribe((dockerTemplate: DockerTemplate) => { this.dockerTemplate = dockerTemplate; }); }); @@ -65,14 +65,14 @@ export class DockerTemplateDetailsComponent implements OnInit { } goBack() { - this.router.navigate(['/controller', this.server.id, 'preferences', 'docker', 'templates']); + this.router.navigate(['/controller', this.controller.id, 'preferences', 'docker', 'templates']); } onSave() { if (this.generalSettingsForm.invalid) { this.toasterService.error(`Fill all required fields`); } else { - this.dockerService.saveTemplate(this.server, this.dockerTemplate).subscribe((savedTemplate: DockerTemplate) => { + this.dockerService.saveTemplate(this.controller, this.dockerTemplate).subscribe((savedTemplate: DockerTemplate) => { this.toasterService.success('Changes saved'); }); } diff --git a/src/app/components/preferences/docker/docker-templates/docker-templates.component.html b/src/app/components/preferences/docker/docker-templates/docker-templates.component.html index f44bddc9..3ffbf3a5 100644 --- a/src/app/components/preferences/docker/docker-templates/docker-templates.component.html +++ b/src/app/components/preferences/docker/docker-templates/docker-templates.component.html @@ -3,18 +3,18 @@

Docker container templates

- +
- +
\ No newline at end of file diff --git a/src/app/components/project-map/console-wrapper/console-wrapper.component.ts b/src/app/components/project-map/console-wrapper/console-wrapper.component.ts index fd92b262..5091fa75 100644 --- a/src/app/components/project-map/console-wrapper/console-wrapper.component.ts +++ b/src/app/components/project-map/console-wrapper/console-wrapper.component.ts @@ -14,11 +14,11 @@ import { ThemeService } from '../../../services/theme.service'; styleUrls: ['./console-wrapper.component.scss'], }) export class ConsoleWrapperComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Output() closeConsole = new EventEmitter(); - filters: string[] = ['all', 'errors', 'warnings', 'info', 'map updates', 'server requests']; + filters: string[] = ['all', 'errors', 'warnings', 'info', 'map updates', 'controller requests']; selectedFilter: string = 'all'; public style: object = {}; diff --git a/src/app/components/project-map/context-console-menu/context-console-menu.component.spec.ts b/src/app/components/project-map/context-console-menu/context-console-menu.component.spec.ts index ddd1f4fe..895b0679 100644 --- a/src/app/components/project-map/context-console-menu/context-console-menu.component.spec.ts +++ b/src/app/components/project-map/context-console-menu/context-console-menu.component.spec.ts @@ -62,7 +62,7 @@ describe('ContextConsoleMenuComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(ContextConsoleMenuComponent); component = fixture.componentInstance; - component.server = { location: 'local' } as Server; + component.controller = { location: 'local' } as Server; fixture.detectChanges(); }); diff --git a/src/app/components/project-map/context-console-menu/context-console-menu.component.ts b/src/app/components/project-map/context-console-menu/context-console-menu.component.ts index d90d940d..efc96731 100644 --- a/src/app/components/project-map/context-console-menu/context-console-menu.component.ts +++ b/src/app/components/project-map/context-console-menu/context-console-menu.component.ts @@ -29,7 +29,7 @@ import { ConsoleDeviceActionComponent } from '../context-menu/actions/console-de }) export class ContextConsoleMenuComponent implements OnInit { @Input() project: Project; - @Input() server: Server; + @Input() controller: Server; @ViewChild(MatMenuTrigger) contextConsoleMenu: MatMenuTrigger; @ViewChild('container', { read: ViewContainerRef }) container; componentRef: ComponentRef; @@ -86,7 +86,7 @@ export class ContextConsoleMenuComponent implements OnInit { ConsoleDeviceActionComponent ); this.componentRef = this.container.createComponent(factory); - this.componentRef.instance.server = this.server; + this.componentRef.instance.controller = this.controller; this.componentRef.instance.nodes = [this.node]; this.componentRef.instance.console(); @@ -95,7 +95,7 @@ export class ContextConsoleMenuComponent implements OnInit { ConsoleDeviceActionBrowserComponent ); this.componentBrowserRef = this.container.createComponent(factory); - this.componentBrowserRef.instance.server = this.server; + this.componentBrowserRef.instance.controller = this.controller; this.componentBrowserRef.instance.node = this.node; this.componentBrowserRef.instance.openConsole(); diff --git a/src/app/components/project-map/context-menu/actions/align-horizontally/align-horizontally.component.ts b/src/app/components/project-map/context-menu/actions/align-horizontally/align-horizontally.component.ts index bab33ea4..85928e3c 100644 --- a/src/app/components/project-map/context-menu/actions/align-horizontally/align-horizontally.component.ts +++ b/src/app/components/project-map/context-menu/actions/align-horizontally/align-horizontally.component.ts @@ -9,7 +9,7 @@ import { NodeService } from '../../../../../services/node.service'; templateUrl: './align-horizontally.component.html', }) export class AlignHorizontallyActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; constructor(private nodesDataSource: NodesDataSource, private nodeService: NodeService) {} @@ -27,7 +27,7 @@ export class AlignHorizontallyActionComponent implements OnInit { node.y = averageY; this.nodesDataSource.update(node); - this.nodeService.update(this.server, node).subscribe((node: Node) => {}); + this.nodeService.update(this.controller, node).subscribe((node: Node) => {}); }); } } diff --git a/src/app/components/project-map/context-menu/actions/align_vertically/align-vertically.component.ts b/src/app/components/project-map/context-menu/actions/align_vertically/align-vertically.component.ts index 771a2ac9..6c411e07 100644 --- a/src/app/components/project-map/context-menu/actions/align_vertically/align-vertically.component.ts +++ b/src/app/components/project-map/context-menu/actions/align_vertically/align-vertically.component.ts @@ -9,7 +9,7 @@ import { NodeService } from '../../../../../services/node.service'; templateUrl: './align-vertically.component.html', }) export class AlignVerticallyActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; constructor(private nodesDataSource: NodesDataSource, private nodeService: NodeService) {} @@ -27,7 +27,7 @@ export class AlignVerticallyActionComponent implements OnInit { node.x = averageX; this.nodesDataSource.update(node); - this.nodeService.update(this.server, node).subscribe((node: Node) => {}); + this.nodeService.update(this.controller, node).subscribe((node: Node) => {}); }); } } diff --git a/src/app/components/project-map/context-menu/actions/bring-to-front-action/bring-to-front-action.component.ts b/src/app/components/project-map/context-menu/actions/bring-to-front-action/bring-to-front-action.component.ts index 95fc56f7..effb1213 100644 --- a/src/app/components/project-map/context-menu/actions/bring-to-front-action/bring-to-front-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/bring-to-front-action/bring-to-front-action.component.ts @@ -12,7 +12,7 @@ import { NodeService } from '../../../../../services/node.service'; templateUrl: './bring-to-front-action.component.html', }) export class BringToFrontActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; @Input() drawings: Drawing[]; @@ -35,14 +35,14 @@ export class BringToFrontActionComponent implements OnInit { node.z = maxZValue; this.nodesDataSource.update(node); - this.nodeService.update(this.server, node).subscribe((node: Node) => {}); + this.nodeService.update(this.controller, node).subscribe((node: Node) => {}); }); this.drawings.forEach((drawing) => { drawing.z = maxZValue; this.drawingsDataSource.update(drawing); - this.drawingService.update(this.server, drawing).subscribe((drawing: Drawing) => {}); + this.drawingService.update(this.controller, drawing).subscribe((drawing: Drawing) => {}); }); } } diff --git a/src/app/components/project-map/context-menu/actions/change-hostname/change-hostname-action.component.ts b/src/app/components/project-map/context-menu/actions/change-hostname/change-hostname-action.component.ts index cef0973e..886d4ebf 100644 --- a/src/app/components/project-map/context-menu/actions/change-hostname/change-hostname-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/change-hostname/change-hostname-action.component.ts @@ -9,7 +9,7 @@ import { ChangeHostnameDialogComponent } from '../../../change-hostname-dialog/c templateUrl: './change-hostname-action.component.html', }) export class ChangeHostnameActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() node: Node; constructor(private dialog: MatDialog) {} @@ -22,7 +22,7 @@ export class ChangeHostnameActionComponent implements OnInit { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.node = this.node; } } diff --git a/src/app/components/project-map/context-menu/actions/change-symbol/change-symbol-action.component.ts b/src/app/components/project-map/context-menu/actions/change-symbol/change-symbol-action.component.ts index cb568fce..f1298392 100644 --- a/src/app/components/project-map/context-menu/actions/change-symbol/change-symbol-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/change-symbol/change-symbol-action.component.ts @@ -9,7 +9,7 @@ import { ChangeSymbolDialogComponent } from '../../../change-symbol-dialog/chang templateUrl: './change-symbol-action.component.html', }) export class ChangeSymbolActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() node: Node; constructor(private dialog: MatDialog) {} @@ -24,7 +24,7 @@ export class ChangeSymbolActionComponent implements OnInit { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.node = this.node; } } diff --git a/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts b/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts index e85d8f65..36b521ff 100644 --- a/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts @@ -21,7 +21,7 @@ import { ConfiguratorDialogVpcsComponent } from '../../../node-editors/configura templateUrl: './config-action.component.html', }) export class ConfigActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() node: Node; private conf = { autoFocus: false, @@ -62,7 +62,7 @@ export class ConfigActionComponent { } let instance = this.dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.node = this.node; } } diff --git a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts index f822d129..18fc2a29 100644 --- a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts +++ b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts @@ -9,13 +9,13 @@ import { ToasterService } from '../../../../../services/toaster.service'; templateUrl: './console-device-action-browser.component.html', }) export class ConsoleDeviceActionBrowserComponent { - @Input() server: Server; + @Input() controller: Server; @Input() node: Node; constructor(private toasterService: ToasterService, private nodeService: NodeService) {} openConsole() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.startConsole(); }); @@ -30,7 +30,7 @@ export class ConsoleDeviceActionBrowserComponent { this.node.console_host === '0:0:0:0:0:0:0:0' || this.node.console_host === '::' ) { - this.node.console_host = this.server.host; + this.node.console_host = this.controller.host; } if ( diff --git a/src/app/components/project-map/context-menu/actions/console-device-action/console-device-action.component.spec.ts b/src/app/components/project-map/context-menu/actions/console-device-action/console-device-action.component.spec.ts index 81064dcd..ffefb674 100644 --- a/src/app/components/project-map/context-menu/actions/console-device-action/console-device-action.component.spec.ts +++ b/src/app/components/project-map/context-menu/actions/console-device-action/console-device-action.component.spec.ts @@ -16,7 +16,7 @@ describe('ConsoleDeviceActionComponent', () => { let component: ConsoleDeviceActionComponent; let fixture: ComponentFixture; let electronService; - let server: Server; + let controller: Server; let settingsService: SettingsService; let mockedServerService: MockedServerService; let mockedToaster: MockedToasterService; @@ -37,7 +37,7 @@ describe('ConsoleDeviceActionComponent', () => { mockedServerService = new MockedServerService(); mockedToaster = new MockedToasterService(); - server = { host: 'localhost', port: 222 } as Server; + controller = { host: 'localhost', port: 222 } as Server; }); beforeEach(async() => { @@ -83,7 +83,7 @@ describe('ConsoleDeviceActionComponent', () => { ]; component.nodes = nodes; - component.server = server; + component.controller = controller; settingsService.setConsoleSettings('command'); spyOn(component, 'openConsole'); diff --git a/src/app/components/project-map/context-menu/actions/console-device-action/console-device-action.component.ts b/src/app/components/project-map/context-menu/actions/console-device-action/console-device-action.component.ts index f826a59a..f133ce4c 100644 --- a/src/app/components/project-map/context-menu/actions/console-device-action/console-device-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/console-device-action/console-device-action.component.ts @@ -12,7 +12,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; templateUrl: './console-device-action.component.html', }) export class ConsoleDeviceActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; constructor( @@ -49,7 +49,7 @@ export class ConsoleDeviceActionComponent implements OnInit { name: node.name, project_id: node.project_id, node_id: node.node_id, - server_url: this.serverService.getServerUrl(this.server), + server_url: this.serverService.getServerUrl(this.controller), }; await this.openConsole(consoleRequest); } diff --git a/src/app/components/project-map/context-menu/actions/delete-action/delete-action.component.ts b/src/app/components/project-map/context-menu/actions/delete-action/delete-action.component.ts index 693cb21a..ffc5ff29 100644 --- a/src/app/components/project-map/context-menu/actions/delete-action/delete-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/delete-action/delete-action.component.ts @@ -17,7 +17,7 @@ import { NodeService } from '../../../../../services/node.service'; templateUrl: './delete-action.component.html', }) export class DeleteActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; @Input() drawings: Drawing[]; @Input() links: Link[]; @@ -49,19 +49,19 @@ export class DeleteActionComponent implements OnInit { this.nodes.forEach((node) => { this.nodesDataSource.remove(node); - this.nodeService.delete(this.server, node).subscribe((node: Node) => {}); + this.nodeService.delete(this.controller, node).subscribe((node: Node) => {}); }); this.drawings.forEach((drawing) => { this.drawingsDataSource.remove(drawing); - this.drawingService.delete(this.server, drawing).subscribe((drawing: Drawing) => {}); + this.drawingService.delete(this.controller, drawing).subscribe((drawing: Drawing) => {}); }); this.links.forEach((link) => { this.linksDataSource.remove(link); - this.linkService.deleteLink(this.server, link).subscribe(() => {}); + this.linkService.deleteLink(this.controller, link).subscribe(() => {}); }); } } diff --git a/src/app/components/project-map/context-menu/actions/duplicate-action/duplicate-action.component.ts b/src/app/components/project-map/context-menu/actions/duplicate-action/duplicate-action.component.ts index a2cf43a3..1d7dba38 100644 --- a/src/app/components/project-map/context-menu/actions/duplicate-action/duplicate-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/duplicate-action/duplicate-action.component.ts @@ -14,7 +14,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; templateUrl: './duplicate-action.component.html', }) export class DuplicateActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Input() drawings: Drawing[]; @Input() nodes: Node[]; @@ -31,7 +31,7 @@ export class DuplicateActionComponent { let runningNodes: string = ''; for (let node of this.nodes) { if (node.status === 'stopped') { - this.nodeService.duplicate(this.server, node).subscribe((node: Node) => { + this.nodeService.duplicate(this.controller, node).subscribe((node: Node) => { this.nodesDataSource.add(node); }); } else { @@ -40,7 +40,7 @@ export class DuplicateActionComponent { } for (let drawing of this.drawings) { - this.drawingService.duplicate(this.server, drawing.project_id, drawing).subscribe((drawing: Drawing) => { + this.drawingService.duplicate(this.controller, drawing.project_id, drawing).subscribe((drawing: Drawing) => { this.drawingsDataSource.add(drawing); }); } diff --git a/src/app/components/project-map/context-menu/actions/edit-config/edit-config-action.component.ts b/src/app/components/project-map/context-menu/actions/edit-config/edit-config-action.component.ts index e172382a..1b0ea670 100644 --- a/src/app/components/project-map/context-menu/actions/edit-config/edit-config-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/edit-config/edit-config-action.component.ts @@ -10,7 +10,7 @@ import { ConfigEditorDialogComponent } from '../../../node-editors/config-editor templateUrl: './edit-config-action.component.html', }) export class EditConfigActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Input() node: Node; @@ -24,7 +24,7 @@ export class EditConfigActionComponent { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.project = this.project; instance.node = this.node; } diff --git a/src/app/components/project-map/context-menu/actions/edit-link-style-action/edit-link-style-action.component.ts b/src/app/components/project-map/context-menu/actions/edit-link-style-action/edit-link-style-action.component.ts index de5ea91b..b7aca5fa 100644 --- a/src/app/components/project-map/context-menu/actions/edit-link-style-action/edit-link-style-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/edit-link-style-action/edit-link-style-action.component.ts @@ -11,7 +11,7 @@ import { LinkStyleEditorDialogComponent } from '../../../drawings-editors/link-s templateUrl: './edit-link-style-action.component.html', }) export class EditLinkStyleActionComponent implements OnChanges { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Input() link: Link; @@ -26,7 +26,7 @@ export class EditLinkStyleActionComponent implements OnChanges { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.project = this.project; instance.link = this.link; } diff --git a/src/app/components/project-map/context-menu/actions/edit-style-action/edit-style-action.component.ts b/src/app/components/project-map/context-menu/actions/edit-style-action/edit-style-action.component.ts index 37e89e4e..e58dd36a 100644 --- a/src/app/components/project-map/context-menu/actions/edit-style-action/edit-style-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/edit-style-action/edit-style-action.component.ts @@ -11,7 +11,7 @@ import { StyleEditorDialogComponent } from '../../../drawings-editors/style-edit templateUrl: './edit-style-action.component.html', }) export class EditStyleActionComponent implements OnChanges { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Input() drawing: Drawing; isImageDrawing: boolean = false; @@ -29,7 +29,7 @@ export class EditStyleActionComponent implements OnChanges { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.project = this.project; instance.drawing = this.drawing; } diff --git a/src/app/components/project-map/context-menu/actions/edit-text-action/edit-text-action.component.ts b/src/app/components/project-map/context-menu/actions/edit-text-action/edit-text-action.component.ts index ee847219..bd4f3b34 100644 --- a/src/app/components/project-map/context-menu/actions/edit-text-action/edit-text-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/edit-text-action/edit-text-action.component.ts @@ -14,7 +14,7 @@ import { TextEditorDialogComponent } from '../../../drawings-editors/text-editor templateUrl: './edit-text-action.component.html', }) export class EditTextActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Input() drawing: Drawing; @Input() node: Node; @@ -33,7 +33,7 @@ export class EditTextActionComponent implements OnInit { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.project = this.project; instance.drawing = this.drawing; instance.node = this.node; diff --git a/src/app/components/project-map/context-menu/actions/export-config/export-config-action.component.ts b/src/app/components/project-map/context-menu/actions/export-config/export-config-action.component.ts index 84e8396a..278ed363 100644 --- a/src/app/components/project-map/context-menu/actions/export-config/export-config-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/export-config/export-config-action.component.ts @@ -10,14 +10,14 @@ import { ConfigDialogComponent } from '../../dialogs/config-dialog/config-dialog templateUrl: './export-config-action.component.html', }) export class ExportConfigActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() node: Node; constructor(private nodeService: NodeService, private dialog: MatDialog) {} exportConfig() { if (this.node.node_type === 'vpcs') { - this.nodeService.getStartupConfiguration(this.server, this.node).subscribe((config: any) => { + this.nodeService.getStartupConfiguration(this.controller, this.node).subscribe((config: any) => { this.downloadByHtmlTag(config); }); } else { @@ -29,11 +29,11 @@ export class ExportConfigActionComponent { let instance = dialogRef.componentInstance; dialogRef.afterClosed().subscribe((configType: string) => { if (configType === 'startup-config') { - this.nodeService.getStartupConfiguration(this.server, this.node).subscribe((config: any) => { + this.nodeService.getStartupConfiguration(this.controller, this.node).subscribe((config: any) => { this.downloadByHtmlTag(config); }); } else if (configType === 'private-config') { - this.nodeService.getPrivateConfiguration(this.server, this.node).subscribe((config: any) => { + this.nodeService.getPrivateConfiguration(this.controller, this.node).subscribe((config: any) => { this.downloadByHtmlTag(config); }); } diff --git a/src/app/components/project-map/context-menu/actions/http-console-new-tab/http-console-new-tab-action.component.ts b/src/app/components/project-map/context-menu/actions/http-console-new-tab/http-console-new-tab-action.component.ts index 73cf9ddd..c73f5983 100644 --- a/src/app/components/project-map/context-menu/actions/http-console-new-tab/http-console-new-tab-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/http-console-new-tab/http-console-new-tab-action.component.ts @@ -8,7 +8,7 @@ import { Server } from '../../../../../models/server'; templateUrl: './http-console-new-tab-action.component.html', }) export class HttpConsoleNewTabActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; constructor(private nodeConsoleService: NodeConsoleService) {} diff --git a/src/app/components/project-map/context-menu/actions/http-console/http-console-action.component.ts b/src/app/components/project-map/context-menu/actions/http-console/http-console-action.component.ts index 523cdb4c..c79022c6 100644 --- a/src/app/components/project-map/context-menu/actions/http-console/http-console-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/http-console/http-console-action.component.ts @@ -8,7 +8,7 @@ import { NodeConsoleService } from '../../../../../services/nodeConsole.service' templateUrl: './http-console-action.component.html', }) export class HttpConsoleActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; constructor(private nodeConsoleService: NodeConsoleService) {} diff --git a/src/app/components/project-map/context-menu/actions/import-config/import-config-action.component.ts b/src/app/components/project-map/context-menu/actions/import-config/import-config-action.component.ts index 524e74ba..c3c1e136 100644 --- a/src/app/components/project-map/context-menu/actions/import-config/import-config-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/import-config/import-config-action.component.ts @@ -12,7 +12,7 @@ import { ConfigDialogComponent } from '../../dialogs/config-dialog/config-dialog styleUrls: ['./import-config-action.component.scss'], }) export class ImportConfigActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() node: Node; @ViewChild('fileInput') fileInput: ElementRef; configType: string; @@ -47,11 +47,11 @@ export class ImportConfigActionComponent { } if (this.configType === 'startup-config') { - this.nodeService.saveConfiguration(this.server, this.node, content).subscribe(() => { + this.nodeService.saveConfiguration(this.controller, this.node, content).subscribe(() => { this.toasterService.success(`Configuration for node ${this.node.name} imported.`); }); } else if (this.configType === 'private-config') { - this.nodeService.savePrivateConfiguration(this.server, this.node, content).subscribe(() => { + this.nodeService.savePrivateConfiguration(this.controller, this.node, content).subscribe(() => { this.toasterService.success(`Configuration for node ${this.node.name} imported.`); }); } diff --git a/src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.ts b/src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.ts index 5f6808e1..a3fbe0cf 100644 --- a/src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.ts @@ -9,7 +9,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; templateUrl: './isolate-node-action.component.html', }) export class IsolateNodeActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() node: Node; constructor(private nodeService: NodeService, private toasterService: ToasterService) {} @@ -17,7 +17,7 @@ export class IsolateNodeActionComponent implements OnInit { ngOnInit() {} isolate() { - this.nodeService.isolate(this.server, this.node).subscribe( + this.nodeService.isolate(this.controller, this.node).subscribe( (n: Node) => {}, (error) => { this.toasterService.error(error.error.message); diff --git a/src/app/components/project-map/context-menu/actions/lock-action/lock-action.component.ts b/src/app/components/project-map/context-menu/actions/lock-action/lock-action.component.ts index 3c227633..3c003b1d 100644 --- a/src/app/components/project-map/context-menu/actions/lock-action/lock-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/lock-action/lock-action.component.ts @@ -12,7 +12,7 @@ import { NodeService } from '../../../../../services/node.service'; templateUrl: './lock-action.component.html', }) export class LockActionComponent implements OnChanges { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; @Input() drawings: Drawing[]; command: string; @@ -37,14 +37,14 @@ export class LockActionComponent implements OnChanges { lock() { this.nodes.forEach((node) => { node.locked = !node.locked; - this.nodeService.updateNode(this.server, node).subscribe((node) => { + this.nodeService.updateNode(this.controller, node).subscribe((node) => { this.nodesDataSource.update(node); }); }); this.drawings.forEach((drawing) => { drawing.locked = !drawing.locked; - this.drawingService.update(this.server, drawing).subscribe((drawing) => { + this.drawingService.update(this.controller, drawing).subscribe((drawing) => { this.drawingsDataSource.update(drawing); }); }); diff --git a/src/app/components/project-map/context-menu/actions/move-layer-down-action/move-layer-down-action.component.ts b/src/app/components/project-map/context-menu/actions/move-layer-down-action/move-layer-down-action.component.ts index 306cf028..8d7518e2 100644 --- a/src/app/components/project-map/context-menu/actions/move-layer-down-action/move-layer-down-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/move-layer-down-action/move-layer-down-action.component.ts @@ -12,7 +12,7 @@ import { NodeService } from '../../../../../services/node.service'; templateUrl: './move-layer-down-action.component.html', }) export class MoveLayerDownActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; @Input() drawings: Drawing[]; @@ -30,14 +30,14 @@ export class MoveLayerDownActionComponent implements OnInit { node.z--; this.nodesDataSource.update(node); - this.nodeService.update(this.server, node).subscribe((node: Node) => {}); + this.nodeService.update(this.controller, node).subscribe((node: Node) => {}); }); this.drawings.forEach((drawing) => { drawing.z--; this.drawingsDataSource.update(drawing); - this.drawingService.update(this.server, drawing).subscribe((drawing: Drawing) => {}); + this.drawingService.update(this.controller, drawing).subscribe((drawing: Drawing) => {}); }); } } diff --git a/src/app/components/project-map/context-menu/actions/move-layer-up-action/move-layer-up-action.component.ts b/src/app/components/project-map/context-menu/actions/move-layer-up-action/move-layer-up-action.component.ts index b8901271..4eb86a80 100644 --- a/src/app/components/project-map/context-menu/actions/move-layer-up-action/move-layer-up-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/move-layer-up-action/move-layer-up-action.component.ts @@ -12,7 +12,7 @@ import { NodeService } from '../../../../../services/node.service'; templateUrl: './move-layer-up-action.component.html', }) export class MoveLayerUpActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; @Input() drawings: Drawing[]; @@ -30,14 +30,14 @@ export class MoveLayerUpActionComponent implements OnInit { node.z++; this.nodesDataSource.update(node); - this.nodeService.update(this.server, node).subscribe((node: Node) => {}); + this.nodeService.update(this.controller, node).subscribe((node: Node) => {}); }); this.drawings.forEach((drawing) => { drawing.z++; this.drawingsDataSource.update(drawing); - this.drawingService.update(this.server, drawing).subscribe((drawing: Drawing) => {}); + this.drawingService.update(this.controller, drawing).subscribe((drawing: Drawing) => {}); }); } } diff --git a/src/app/components/project-map/context-menu/actions/open-file-explorer/open-file-explorer-action.component.ts b/src/app/components/project-map/context-menu/actions/open-file-explorer/open-file-explorer-action.component.ts index fc032a09..8678eef7 100644 --- a/src/app/components/project-map/context-menu/actions/open-file-explorer/open-file-explorer-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/open-file-explorer/open-file-explorer-action.component.ts @@ -8,7 +8,7 @@ import { Server } from '../../../../../models/server'; templateUrl: './open-file-explorer-action.component.html', }) export class OpenFileExplorerActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() node: Node; constructor(private electronService: ElectronService) {} diff --git a/src/app/components/project-map/context-menu/actions/packet-filters-action/packet-filters-action.component.ts b/src/app/components/project-map/context-menu/actions/packet-filters-action/packet-filters-action.component.ts index 953aafd2..c9e8629e 100644 --- a/src/app/components/project-map/context-menu/actions/packet-filters-action/packet-filters-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/packet-filters-action/packet-filters-action.component.ts @@ -10,7 +10,7 @@ import { PacketFiltersDialogComponent } from '../../../packet-capturing/packet-f templateUrl: './packet-filters-action.component.html', }) export class PacketFiltersActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Input() link: Link; @@ -24,7 +24,7 @@ export class PacketFiltersActionComponent { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.project = this.project; instance.link = this.link; } diff --git a/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.ts b/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.ts index 90fcf687..59ce63b4 100644 --- a/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.ts @@ -8,7 +8,7 @@ import { NodeService } from '../../../../../services/node.service'; templateUrl: './reload-node-action.component.html', }) export class ReloadNodeActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; filteredNodes: Node[] = []; @@ -30,7 +30,7 @@ export class ReloadNodeActionComponent implements OnInit { reloadNodes() { this.filteredNodes.forEach((node) => { - this.nodeService.reload(this.server, node).subscribe((n: Node) => {}); + this.nodeService.reload(this.controller, node).subscribe((n: Node) => {}); }); } } diff --git a/src/app/components/project-map/context-menu/actions/reset-link/reset-link-action.component.ts b/src/app/components/project-map/context-menu/actions/reset-link/reset-link-action.component.ts index 085e8896..eae3c147 100644 --- a/src/app/components/project-map/context-menu/actions/reset-link/reset-link-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/reset-link/reset-link-action.component.ts @@ -8,7 +8,7 @@ import { LinkService } from '../../../../../services/link.service'; templateUrl: './reset-link-action.component.html' }) export class ResetLinkActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() link: Link; constructor( @@ -16,6 +16,6 @@ export class ResetLinkActionComponent { ) {} resetLink() { - this.linkService.resetLink(this.server, this.link).subscribe(() => {}); + this.linkService.resetLink(this.controller, this.link).subscribe(() => {}); } } diff --git a/src/app/components/project-map/context-menu/actions/resume-link-action/resume-link-action.component.ts b/src/app/components/project-map/context-menu/actions/resume-link-action/resume-link-action.component.ts index 356c933a..3a1e93f7 100644 --- a/src/app/components/project-map/context-menu/actions/resume-link-action/resume-link-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/resume-link-action/resume-link-action.component.ts @@ -8,13 +8,13 @@ import { LinkService } from '../../../../../services/link.service'; templateUrl: './resume-link-action.component.html', }) export class ResumeLinkActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() link: Link; constructor(private linkService: LinkService) {} resumeLink() { this.link.suspend = false; - this.linkService.updateLink(this.server, this.link).subscribe(() => {}); + this.linkService.updateLink(this.controller, this.link).subscribe(() => {}); } } diff --git a/src/app/components/project-map/context-menu/actions/show-node-action/show-node-action.component.ts b/src/app/components/project-map/context-menu/actions/show-node-action/show-node-action.component.ts index 3a10e6cf..de6b9280 100644 --- a/src/app/components/project-map/context-menu/actions/show-node-action/show-node-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/show-node-action/show-node-action.component.ts @@ -10,7 +10,7 @@ import { InfoDialogComponent } from '../../../info-dialog/info-dialog.component' }) export class ShowNodeActionComponent { @Input() node: Node; - @Input() server: Server; + @Input() controller: Server; constructor(private dialog: MatDialog) {} @@ -23,6 +23,6 @@ export class ShowNodeActionComponent { }); let instance = dialogRef.componentInstance; instance.node = this.node; - instance.server = this.server; + instance.controller = this.controller; } } diff --git a/src/app/components/project-map/context-menu/actions/start-capture-on-started-link/start-capture-on-started-link.component.ts b/src/app/components/project-map/context-menu/actions/start-capture-on-started-link/start-capture-on-started-link.component.ts index ca7e8a71..16f15b61 100644 --- a/src/app/components/project-map/context-menu/actions/start-capture-on-started-link/start-capture-on-started-link.component.ts +++ b/src/app/components/project-map/context-menu/actions/start-capture-on-started-link/start-capture-on-started-link.component.ts @@ -9,7 +9,7 @@ import { PacketCaptureService } from '../../../../../services/packet-capture.ser templateUrl: './start-capture-on-started-link.component.html', }) export class StartCaptureOnStartedLinkActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Input() link: Link; @@ -17,6 +17,6 @@ export class StartCaptureOnStartedLinkActionComponent { startCapture() { var splittedFileName = this.link.capture_file_name.split('.'); - this.packetCaptureService.startCapture(this.server, this.project, this.link, splittedFileName[0]); + this.packetCaptureService.startCapture(this.controller, this.project, this.link, splittedFileName[0]); } } diff --git a/src/app/components/project-map/context-menu/actions/start-capture/start-capture-action.component.ts b/src/app/components/project-map/context-menu/actions/start-capture/start-capture-action.component.ts index 6a1a13e7..547fd0d8 100644 --- a/src/app/components/project-map/context-menu/actions/start-capture/start-capture-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/start-capture/start-capture-action.component.ts @@ -10,7 +10,7 @@ import { StartCaptureDialogComponent } from '../../../packet-capturing/start-cap templateUrl: './start-capture-action.component.html', }) export class StartCaptureActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Input() link: Link; @@ -23,7 +23,7 @@ export class StartCaptureActionComponent { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.project = this.project; instance.link = this.link; } diff --git a/src/app/components/project-map/context-menu/actions/start-node-action/start-node-action.component.ts b/src/app/components/project-map/context-menu/actions/start-node-action/start-node-action.component.ts index 11c886ad..7386b6fb 100644 --- a/src/app/components/project-map/context-menu/actions/start-node-action/start-node-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/start-node-action/start-node-action.component.ts @@ -9,7 +9,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; templateUrl: './start-node-action.component.html', }) export class StartNodeActionComponent implements OnInit, OnChanges { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; isNodeWithStoppedStatus: boolean; @@ -29,8 +29,9 @@ export class StartNodeActionComponent implements OnInit, OnChanges { } startNodes() { + debugger this.nodes.forEach((node) => { - this.nodeService.start(this.server, node).subscribe( + this.nodeService.start(this.controller, node).subscribe( (n: Node) => {}, (error) => { this.toasterService.error(error.error.message); diff --git a/src/app/components/project-map/context-menu/actions/stop-capture/stop-capture-action.component.ts b/src/app/components/project-map/context-menu/actions/stop-capture/stop-capture-action.component.ts index 4b875d20..e4d72adc 100644 --- a/src/app/components/project-map/context-menu/actions/stop-capture/stop-capture-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/stop-capture/stop-capture-action.component.ts @@ -8,12 +8,12 @@ import { LinkService } from '../../../../../services/link.service'; templateUrl: './stop-capture-action.component.html', }) export class StopCaptureActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() link: Link; constructor(private linkService: LinkService) {} stopCapture() { - this.linkService.stopCaptureOnLink(this.server, this.link).subscribe(() => {}); + this.linkService.stopCaptureOnLink(this.controller, this.link).subscribe(() => {}); } } diff --git a/src/app/components/project-map/context-menu/actions/stop-node-action/stop-node-action.component.ts b/src/app/components/project-map/context-menu/actions/stop-node-action/stop-node-action.component.ts index 8e1e24b6..c1a4c0af 100644 --- a/src/app/components/project-map/context-menu/actions/stop-node-action/stop-node-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/stop-node-action/stop-node-action.component.ts @@ -8,7 +8,7 @@ import { NodeService } from '../../../../../services/node.service'; templateUrl: './stop-node-action.component.html', }) export class StopNodeActionComponent implements OnInit, OnChanges { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; isNodeWithStartedStatus: boolean; @@ -29,7 +29,7 @@ export class StopNodeActionComponent implements OnInit, OnChanges { stopNodes() { this.nodes.forEach((node) => { - this.nodeService.stop(this.server, node).subscribe((n: Node) => {}); + this.nodeService.stop(this.controller, node).subscribe((n: Node) => {}); }); } } diff --git a/src/app/components/project-map/context-menu/actions/suspend-link/suspend-link-action.component.ts b/src/app/components/project-map/context-menu/actions/suspend-link/suspend-link-action.component.ts index e0049122..347b1bb3 100644 --- a/src/app/components/project-map/context-menu/actions/suspend-link/suspend-link-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/suspend-link/suspend-link-action.component.ts @@ -8,13 +8,13 @@ import { LinkService } from '../../../../../services/link.service'; templateUrl: './suspend-link-action.component.html', }) export class SuspendLinkActionComponent { - @Input() server: Server; + @Input() controller: Server; @Input() link: Link; constructor(private linkService: LinkService) {} suspendLink() { this.link.suspend = true; - this.linkService.updateLink(this.server, this.link).subscribe(() => {}); + this.linkService.updateLink(this.controller, this.link).subscribe(() => {}); } } diff --git a/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.ts b/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.ts index 375959e7..f8a8a2ab 100644 --- a/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.ts @@ -8,7 +8,7 @@ import { NodeService } from '../../../../../services/node.service'; templateUrl: './suspend-node-action.component.html', }) export class SuspendNodeActionComponent implements OnInit, OnChanges { - @Input() server: Server; + @Input() controller: Server; @Input() nodes: Node[]; isNodeWithStartedStatus: boolean; @@ -29,7 +29,7 @@ export class SuspendNodeActionComponent implements OnInit, OnChanges { suspendNodes() { this.nodes.forEach((node) => { - this.nodeService.suspend(this.server, node).subscribe((n: Node) => {}); + this.nodeService.suspend(this.controller, node).subscribe((n: Node) => {}); }); } } diff --git a/src/app/components/project-map/context-menu/actions/unisolate-node-action/unisolate-node-action.component.ts b/src/app/components/project-map/context-menu/actions/unisolate-node-action/unisolate-node-action.component.ts index a8226e4c..278137e3 100644 --- a/src/app/components/project-map/context-menu/actions/unisolate-node-action/unisolate-node-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/unisolate-node-action/unisolate-node-action.component.ts @@ -9,7 +9,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; templateUrl: './unisolate-node-action.component.html', }) export class UnisolateNodeActionComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() node: Node; constructor(private nodeService: NodeService, private toasterService: ToasterService) {} @@ -17,7 +17,7 @@ export class UnisolateNodeActionComponent implements OnInit { ngOnInit() {} unisolate() { - this.nodeService.unisolate(this.server, this.node).subscribe( + this.nodeService.unisolate(this.controller, this.node).subscribe( (n: Node) => {}, (error) => { this.toasterService.error(error.error.message); diff --git a/src/app/components/project-map/context-menu/context-menu.component.html b/src/app/components/project-map/context-menu/context-menu.component.html index 85f6fec9..5d51d8b2 100644 --- a/src/app/components/project-map/context-menu/context-menu.component.html +++ b/src/app/components/project-map/context-menu/context-menu.component.html @@ -1,59 +1,59 @@
- - - - - - + + + + + + - - + + @@ -64,7 +64,7 @@ (labels.length === 1 && linkNodes.length === 0 && drawings.length === 0) || (linkNodes.length === 1 && labels.length === 0 && drawings.length === 0)) " - [server]="server" + [controller]="controller" [project]="project" [drawing]="drawings[0]" [node]="nodes[0]" @@ -74,7 +74,7 @@ > @@ -83,7 +83,7 @@ nodes.length === 1 && (nodes[0].node_type === 'vpcs' || nodes[0].node_type === 'iou' || nodes[0].node_type === 'dynamips') " - [server]="server" + [controller]="controller" [node]="nodes[0]" > @@ -126,7 +126,7 @@ links.length === 1 && linkNodes.length === 0 " - [server]="server" + [controller]="controller" [link]="links[0]" > @@ -149,7 +149,7 @@ links.length === 1 && linkNodes.length === 0 " - [server]="server" + [controller]="controller" [project]="project" [link]="links[0]" > @@ -161,7 +161,7 @@ links.length === 1 && linkNodes.length === 0 " - [server]="server" + [controller]="controller" [link]="links[0]" > @@ -204,19 +204,19 @@ (drawings.length > 0 || nodes.length > 0 || links.length > 0) && linkNodes.length === 0 " - [server]="server" + [controller]="controller" [nodes]="nodes" [drawings]="drawings" [links]="links" > diff --git a/src/app/components/project-map/context-menu/context-menu.component.spec.ts b/src/app/components/project-map/context-menu/context-menu.component.spec.ts index 6e41f76b..5d91b674 100644 --- a/src/app/components/project-map/context-menu/context-menu.component.spec.ts +++ b/src/app/components/project-map/context-menu/context-menu.component.spec.ts @@ -35,7 +35,7 @@ describe('ContextMenuComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(ContextMenuComponent); component = fixture.componentInstance; - component.server = { location: 'local' } as Server; + component.controller = { location: 'local' } as Server; fixture.detectChanges(); }); diff --git a/src/app/components/project-map/context-menu/context-menu.component.ts b/src/app/components/project-map/context-menu/context-menu.component.ts index 6f3d7053..c00c1259 100644 --- a/src/app/components/project-map/context-menu/context-menu.component.ts +++ b/src/app/components/project-map/context-menu/context-menu.component.ts @@ -19,7 +19,7 @@ import { ProjectService } from '../../../services/project.service'; }) export class ContextMenuComponent implements OnInit { @Input() project: Project; - @Input() server: Server; + @Input() controller: Server; @ViewChild(MatMenuTrigger) contextMenu: MatMenuTrigger; @@ -47,7 +47,7 @@ export class ContextMenuComponent implements OnInit { this.setPosition(0, 0); this.isElectronApp = this.electronService.isElectronApp; - this.isBundledServer = this.server.location === 'bundled'; + this.isBundledServer = this.controller.location === 'bundled'; } public setPosition(top: number, left: number) { diff --git a/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.ts b/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.ts index fca658ea..897a7ccc 100644 --- a/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.ts +++ b/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.ts @@ -17,7 +17,7 @@ import { LinkToMapLinkConverter } from '../../../../cartography/converters/map/l styleUrls: ['./link-style-editor.component.scss'], }) export class LinkStyleEditorDialogComponent implements OnInit { - server: Server; + controller: Server; project: Project; link: Link; formGroup: FormGroup; @@ -68,7 +68,7 @@ export class LinkStyleEditorDialogComponent implements OnInit { let type = this.borderTypes.indexOf(this.formGroup.get('type').value); this.link.link_style.type = type; - this.linkService.updateLinkStyle(this.server, this.link).subscribe((link) => { + this.linkService.updateLinkStyle(this.controller, this.link).subscribe((link) => { this.linksDataSource.update(link); this.linksEventSource.edited.next(this.linkToMapLink.convert(link)); location.reload() diff --git a/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts b/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts index e216ab40..33c439a3 100644 --- a/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts +++ b/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts @@ -21,7 +21,7 @@ import { RotationValidator } from '../../../../validators/rotation-validator'; styleUrls: ['./style-editor.component.scss'], }) export class StyleEditorDialogComponent implements OnInit { - server: Server; + controller: Server; project: Project; drawing: Drawing; element: ElementData; @@ -88,7 +88,7 @@ export class StyleEditorDialogComponent implements OnInit { this.drawing.svg = this.mapDrawingToSvgConverter.convert(mapDrawing); - this.drawingService.update(this.server, this.drawing).subscribe((serverDrawing: Drawing) => { + this.drawingService.update(this.controller, this.drawing).subscribe((serverDrawing: Drawing) => { this.drawingsDataSource.update(serverDrawing); this.dialogRef.close(); }); diff --git a/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.ts b/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.ts index 8440f5b0..c094779d 100644 --- a/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.ts +++ b/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.ts @@ -30,7 +30,7 @@ import { RotationValidator } from '../../../../validators/rotation-validator'; export class TextEditorDialogComponent implements OnInit { @ViewChild('textArea', { static: true }) textArea: ElementRef; - server: Server; + controller: Server; project: Project; drawing: Drawing; node: Node; @@ -140,7 +140,7 @@ export class TextEditorDialogComponent implements OnInit { this.node.label.style = this.getStyleFromTextElement(); this.node.label.rotation = +this.rotation; - this.nodeService.updateLabel(this.server, this.node, this.node.label).subscribe((node: Node) => { + this.nodeService.updateLabel(this.controller, this.node, this.node.label).subscribe((node: Node) => { this.nodesDataSource.update(node); this.dialogRef.close(); }); @@ -149,7 +149,7 @@ export class TextEditorDialogComponent implements OnInit { this.label.rotation = +this.rotation; this.label.text = this.element.text; - this.linkService.updateLink(this.server, this.link).subscribe((link: Link) => { + this.linkService.updateLink(this.controller, this.link).subscribe((link: Link) => { this.linksDataSource.update(link); this.dialogRef.close(); }); @@ -162,7 +162,7 @@ export class TextEditorDialogComponent implements OnInit { this.drawing.svg = this.mapDrawingToSvgConverter.convert(mapDrawing); - this.drawingService.update(this.server, this.drawing).subscribe((serverDrawing: Drawing) => { + this.drawingService.update(this.controller, this.drawing).subscribe((serverDrawing: Drawing) => { this.drawingsDataSource.update(serverDrawing); this.dialogRef.close(); }); diff --git a/src/app/components/project-map/import-appliance/import-appliance.component.ts b/src/app/components/project-map/import-appliance/import-appliance.component.ts index 95f04332..c7d6baf4 100644 --- a/src/app/components/project-map/import-appliance/import-appliance.component.ts +++ b/src/app/components/project-map/import-appliance/import-appliance.component.ts @@ -20,7 +20,7 @@ import { ToasterService } from '../../../services/toaster.service'; }) export class ImportApplianceComponent implements OnInit { @Input('project') project: Project; - @Input('server') server: Server; + @Input('controller') controller: Server; uploader: FileUploader; template; @@ -49,13 +49,13 @@ export class ImportApplianceComponent implements OnInit { headers: ParsedResponseHeaders ) => { if (this.template.template_type === 'qemu') { - this.qemuService.addTemplate(this.server, this.template).subscribe(() => this.onUploadComplete()); + this.qemuService.addTemplate(this.controller, this.template).subscribe(() => this.onUploadComplete()); } else if (this.template.template_type === 'iou') { - this.iouService.addTemplate(this.server, this.template).subscribe(() => this.onUploadComplete()); + this.iouService.addTemplate(this.controller, this.template).subscribe(() => this.onUploadComplete()); } else if (this.template.template_type === 'dynamips') { - this.iosService.addTemplate(this.server, this.template).subscribe(() => this.onUploadComplete()); + this.iosService.addTemplate(this.controller, this.template).subscribe(() => this.onUploadComplete()); } else if (this.template.template_type === 'docker') { - this.dockerService.addTemplate(this.server, this.template).subscribe(() => this.onUploadComplete()); + this.dockerService.addTemplate(this.controller, this.template).subscribe(() => this.onUploadComplete()); } }; } @@ -130,8 +130,8 @@ export class ImportApplianceComponent implements OnInit { template.default_name_format = '{name}-{0}'; template.compute_id = 'vm'; // qemu - VM - // iou - VM + main server - // dynamips - vm + main server + // iou - VM + main controller + // dynamips - vm + main controller // docker - vm if (template.category === 'guest') { @@ -141,7 +141,7 @@ export class ImportApplianceComponent implements OnInit { } this.template = template; - const url = this.getUploadPath(this.server, template.template_type, name); + const url = this.getUploadPath(this.controller, template.template_type, name); this.uploader.queue.forEach((elem) => (elem.url = url)); const itemToUpload = this.uploader.queue[0]; this.uploader.uploadItem(itemToUpload); @@ -149,7 +149,7 @@ export class ImportApplianceComponent implements OnInit { fileReader.readAsText(file); } - private getUploadPath(server: Server, emulator: string, filename: string) { - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/${emulator}/images/${filename}`; + private getUploadPath(controller: Server, emulator: string, filename: string) { + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/${emulator}/images/${filename}`; } } diff --git a/src/app/components/project-map/info-dialog/info-dialog.component.ts b/src/app/components/project-map/info-dialog/info-dialog.component.ts index 296132b6..a741fa6f 100644 --- a/src/app/components/project-map/info-dialog/info-dialog.component.ts +++ b/src/app/components/project-map/info-dialog/info-dialog.component.ts @@ -10,7 +10,7 @@ import { InfoService } from '../../../services/info.service'; styleUrls: ['./info-dialog.component.scss'], }) export class InfoDialogComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() node: Node; infoList: string[] = []; usage: string = ''; @@ -19,7 +19,7 @@ export class InfoDialogComponent implements OnInit { constructor(public dialogRef: MatDialogRef, private infoService: InfoService) {} ngOnInit() { - this.infoList = this.infoService.getInfoAboutNode(this.node, this.server); + this.infoList = this.infoService.getInfoAboutNode(this.node, this.controller); this.commandLine = this.infoService.getCommandLine(this.node); this.usage = this.node.usage ? this.node.usage : `No usage information has been provided for this node.`; } diff --git a/src/app/components/project-map/log-console/log-console.component.spec.ts b/src/app/components/project-map/log-console/log-console.component.spec.ts index a7c01728..43fb77d8 100644 --- a/src/app/components/project-map/log-console/log-console.component.spec.ts +++ b/src/app/components/project-map/log-console/log-console.component.spec.ts @@ -66,7 +66,7 @@ describe('LogConsoleComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(LogConsoleComponent); component = fixture.componentInstance; - component.server = { location: 'local' } as Server; + component.controller = { location: 'local' } as Server; fixture.detectChanges(); }); diff --git a/src/app/components/project-map/log-console/log-console.component.ts b/src/app/components/project-map/log-console/log-console.component.ts index 1c5209d7..216bec9a 100644 --- a/src/app/components/project-map/log-console/log-console.component.ts +++ b/src/app/components/project-map/log-console/log-console.component.ts @@ -34,7 +34,7 @@ import { LogEventsDataSource } from './log-events-datasource'; styleUrls: ['./log-console.component.scss'], }) export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @ViewChild('console') console: ElementRef; @@ -49,7 +49,7 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { private infoSubscription: Subscription; public command: string = ''; - public filters: string[] = ['all', 'errors', 'warnings', 'info', 'map updates', 'server requests']; + public filters: string[] = ['all', 'errors', 'warnings', 'info', 'map updates', 'controller requests']; public selectedFilter: string = 'all'; public filteredEvents: LogEvent[] = []; @@ -121,7 +121,7 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { }); this.serverRequestsSubscription = this.httpService.requestsNotificationEmitter.subscribe((message) => { this.showMessage({ - type: 'server request', + type: 'controller request', message: message, }); }); @@ -180,22 +180,22 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { this.showCommand('Current version: ' + this.version); } else if (this.command === 'start all') { this.showCommand('Starting all nodes...'); - this.nodeService.startAll(this.server, this.project).subscribe(() => { + this.nodeService.startAll(this.controller, this.project).subscribe(() => { this.showCommand('All nodes started.'); }); } else if (this.command === 'stop all') { this.showCommand('Stopping all nodes...'); - this.nodeService.stopAll(this.server, this.project).subscribe(() => { + this.nodeService.stopAll(this.controller, this.project).subscribe(() => { this.showCommand('All nodes stopped.'); }); } else if (this.command === 'suspend all') { this.showCommand('Suspending all nodes...'); - this.nodeService.suspendAll(this.server, this.project).subscribe(() => { + this.nodeService.suspendAll(this.controller, this.project).subscribe(() => { this.showCommand('All nodes suspended.'); }); } else if (this.command === 'reload all') { this.showCommand('Reloading all nodes...'); - this.nodeService.reloadAll(this.server, this.project).subscribe(() => { + this.nodeService.reloadAll(this.controller, this.project).subscribe(() => { this.showCommand('All nodes reloaded.'); }); } else if ( @@ -211,16 +211,16 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { if (node) { if (this.regexStart.test(this.command)) { this.showCommand(`Starting node ${splittedCommand[1]}...`); - this.nodeService.start(this.server, node).subscribe(() => this.showCommand(`Node ${node.name} started.`)); + this.nodeService.start(this.controller, node).subscribe(() => this.showCommand(`Node ${node.name} started.`)); } else if (this.regexStop.test(this.command)) { this.showCommand(`Stopping node ${splittedCommand[1]}...`); - this.nodeService.stop(this.server, node).subscribe(() => this.showCommand(`Node ${node.name} stopped.`)); + this.nodeService.stop(this.controller, node).subscribe(() => this.showCommand(`Node ${node.name} stopped.`)); } else if (this.regexSuspend.test(this.command)) { this.showCommand(`Suspending node ${splittedCommand[1]}...`); - this.nodeService.suspend(this.server, node).subscribe(() => this.showCommand(`Node ${node.name} suspended.`)); + this.nodeService.suspend(this.controller, node).subscribe(() => this.showCommand(`Node ${node.name} suspended.`)); } else if (this.regexReload.test(this.command)) { this.showCommand(`Reloading node ${splittedCommand[1]}...`); - this.nodeService.reload(this.server, node).subscribe(() => this.showCommand(`Node ${node.name} reloaded.`)); + this.nodeService.reload(this.controller, node).subscribe(() => this.showCommand(`Node ${node.name} reloaded.`)); } else if (this.regexConsole.test(this.command)) { if (node.status === 'started') { this.showCommand(`Launching console for node ${splittedCommand[1]}...`); @@ -280,8 +280,8 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { } getFilteredEvents(): LogEvent[] { - if (this.selectedFilter === 'server requests') { - return this.logEventsDataSource.getItems().filter((n) => n.type === 'server request'); + if (this.selectedFilter === 'controller requests') { + return this.logEventsDataSource.getItems().filter((n) => n.type === 'controller request'); } else if (this.selectedFilter === 'errors') { return this.logEventsDataSource.getItems().filter((n) => n.type === 'error'); } else if (this.selectedFilter === 'warnings') { diff --git a/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts b/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts index e5405da1..98e22f00 100644 --- a/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts +++ b/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts @@ -47,14 +47,14 @@ import { environment } from 'environments/environment'; ], }) export class NewTemplateDialogComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; uploader: FileUploader; uploaderImage: FileUploader; public action: string = 'install'; - public actionTitle: string = 'Install appliance from server'; + public actionTitle: string = 'Install appliance from controller'; public secondActionTitle: string = 'Appliance settings'; public searchText: string = ''; @@ -103,7 +103,7 @@ export class NewTemplateDialogComponent implements OnInit { ) { } ngOnInit() { - this.applianceService.getAppliances(this.server).subscribe((appliances) => { + this.applianceService.getAppliances(this.controller).subscribe((appliances) => { this.appliances = appliances; this.appliances.forEach((appliance) => { if (appliance.docker) appliance.emulator = 'Docker'; @@ -116,33 +116,33 @@ export class NewTemplateDialogComponent implements OnInit { this.dataSource.paginator = this.paginator; }); - this.templateService.list(this.server).subscribe((templates) => { + this.templateService.list(this.controller).subscribe((templates) => { this.templates = templates; }); - this.computeService.getComputes(this.server).subscribe((computes) => { + this.computeService.getComputes(this.controller).subscribe((computes) => { computes.forEach((compute) => { if (compute.capabilities.platform === 'linux') this.isLinuxPlatform = true; }); }); - this.qemuService.getBinaries(this.server).subscribe((binaries) => { + this.qemuService.getBinaries(this.controller).subscribe((binaries) => { this.qemuBinaries = binaries; }); - this.qemuService.getImages(this.server).subscribe((qemuImages) => { + this.qemuService.getImages(this.controller).subscribe((qemuImages) => { this.qemuImages = qemuImages; }); - this.iosService.getImages(this.server).subscribe((iosImages) => { + this.iosService.getImages(this.controller).subscribe((iosImages) => { this.iosImages = iosImages; }); - this.iouService.getImages(this.server).subscribe((iouImages) => { + this.iouService.getImages(this.controller).subscribe((iouImages) => { this.iouImages = iouImages; }); - this.applianceService.getAppliances(this.server).subscribe((appliances) => { + this.applianceService.getAppliances(this.controller).subscribe((appliances) => { this.appliances = appliances; this.appliances.forEach((appliance) => { if (appliance.docker) appliance.emulator = 'Docker'; @@ -218,7 +218,7 @@ export class NewTemplateDialogComponent implements OnInit { updateAppliances() { this.progressService.activate(); - this.applianceService.updateAppliances(this.server).subscribe( + this.applianceService.updateAppliances(this.controller).subscribe( (appliances) => { this.appliances = appliances; this.progressService.deactivate(); @@ -232,15 +232,15 @@ export class NewTemplateDialogComponent implements OnInit { } refreshImages() { - this.qemuService.getImages(this.server).subscribe((qemuImages) => { + this.qemuService.getImages(this.controller).subscribe((qemuImages) => { this.qemuImages = qemuImages; }); - this.iosService.getImages(this.server).subscribe((iosImages) => { + this.iosService.getImages(this.controller).subscribe((iosImages) => { this.iosImages = iosImages; }); - this.iouService.getImages(this.server).subscribe((iouImages) => { + this.iouService.getImages(this.controller).subscribe((iouImages) => { this.iouImages = iouImages; }); @@ -249,7 +249,7 @@ export class NewTemplateDialogComponent implements OnInit { getAppliance(url: string) { let str = url.split(`/${environment.current_version}`); let appliancePath = str[str.length - 1]; - this.applianceService.getAppliance(this.server, appliancePath).subscribe((appliance: Appliance) => { + this.applianceService.getAppliance(this.controller, appliancePath).subscribe((appliance: Appliance) => { this.applianceToInstall = appliance; setTimeout(() => { this.stepper.next(); @@ -272,11 +272,11 @@ export class NewTemplateDialogComponent implements OnInit { if (appliance.iou) emulator = 'iou'; if (appliance.qemu) emulator = 'qemu'; - const url = this.applianceService.getUploadPath(this.server, emulator, fileName); + const url = this.applianceService.getUploadPath(this.controller, emulator, fileName); this.uploader.queue.forEach((elem) => (elem.url = url)); const itemToUpload = this.uploader.queue[0]; - if ((itemToUpload as any).options) (itemToUpload as any).options.disableMultipart = true; ((itemToUpload as any).options.headers = [{ name: 'Authorization', value: 'Bearer ' + this.server.authToken }]) + if ((itemToUpload as any).options) (itemToUpload as any).options.disableMultipart = true; ((itemToUpload as any).options.headers = [{ name: 'Authorization', value: 'Bearer ' + this.controller.authToken }]) this.uploader.uploadItem(itemToUpload); }; @@ -302,7 +302,7 @@ export class NewTemplateDialogComponent implements OnInit { setAction(action: string) { this.action = action; if (action === 'install') { - this.actionTitle = 'Install appliance from server'; + this.actionTitle = 'Install appliance from controller'; } else if (action === 'import') { this.actionTitle = 'Import an appliance file'; } @@ -414,11 +414,11 @@ export class NewTemplateDialogComponent implements OnInit { if (this.applianceToInstall.dynamips) emulator = 'dynamips'; if (this.applianceToInstall.iou) emulator = 'iou'; - const url = this.applianceService.getUploadPath(this.server, emulator, fileName); + const url = this.applianceService.getUploadPath(this.controller, emulator, fileName); this.uploaderImage.queue.forEach((elem) => (elem.url = url)); const itemToUpload = this.uploaderImage.queue[0]; - if ((itemToUpload as any).options) (itemToUpload as any).options.disableMultipart = true; ((itemToUpload as any).options.headers = [{ name: 'Authorization', value: 'Bearer ' + this.server.authToken }]) + if ((itemToUpload as any).options) (itemToUpload as any).options.disableMultipart = true; ((itemToUpload as any).options.headers = [{ name: 'Authorization', value: 'Bearer ' + this.controller.authToken }]) this.uploaderImage.uploadItem(itemToUpload); }; @@ -534,11 +534,11 @@ export class NewTemplateDialogComponent implements OnInit { name: this.applianceToInstall.name, }, }); - dialogRef.componentInstance.server = this.server; + dialogRef.componentInstance.controller = this.controller; dialogRef.afterClosed().subscribe((answer: string) => { if (answer) { iouTemplate.name = answer; - this.iouService.addTemplate(this.server, iouTemplate).subscribe((template) => { + this.iouService.addTemplate(this.controller, iouTemplate).subscribe((template) => { this.templateService.newTemplateCreated.next(template); this.toasterService.success('Template added'); this.dialogRef.close(); @@ -582,12 +582,12 @@ export class NewTemplateDialogComponent implements OnInit { name: this.applianceToInstall.name, }, }); - dialogRef.componentInstance.server = this.server; + dialogRef.componentInstance.controller = this.controller; dialogRef.afterClosed().subscribe((answer: string) => { if (answer) { iosTemplate.name = answer; - this.iosService.addTemplate(this.server, iosTemplate).subscribe((template) => { + this.iosService.addTemplate(this.controller, iosTemplate).subscribe((template) => { this.templateService.newTemplateCreated.next((template as any) as Template); this.toasterService.success('Template added'); this.dialogRef.close(); @@ -620,12 +620,12 @@ export class NewTemplateDialogComponent implements OnInit { name: this.applianceToInstall.name, }, }); - dialogRef.componentInstance.server = this.server; + dialogRef.componentInstance.controller = this.controller; dialogRef.afterClosed().subscribe((answer: string) => { if (answer) { dockerTemplate.name = answer; - this.dockerService.addTemplate(this.server, dockerTemplate).subscribe((template) => { + this.dockerService.addTemplate(this.controller, dockerTemplate).subscribe((template) => { this.templateService.newTemplateCreated.next((template as any) as Template); this.toasterService.success('Template added'); this.dialogRef.close(); @@ -679,12 +679,12 @@ export class NewTemplateDialogComponent implements OnInit { name: this.applianceToInstall.name, }, }); - dialogRef.componentInstance.server = this.server; + dialogRef.componentInstance.controller = this.controller; dialogRef.afterClosed().subscribe((answer: string) => { if (answer) { qemuTemplate.name = answer; - this.qemuService.addTemplate(this.server, qemuTemplate).subscribe((template) => { + this.qemuService.addTemplate(this.controller, qemuTemplate).subscribe((template) => { this.templateService.newTemplateCreated.next((template as any) as Template); this.toasterService.success('Template added'); this.dialogRef.close(); diff --git a/src/app/components/project-map/new-template-dialog/template-name-dialog/template-name-dialog.component.ts b/src/app/components/project-map/new-template-dialog/template-name-dialog/template-name-dialog.component.ts index 6d100673..f5308135 100644 --- a/src/app/components/project-map/new-template-dialog/template-name-dialog/template-name-dialog.component.ts +++ b/src/app/components/project-map/new-template-dialog/template-name-dialog/template-name-dialog.component.ts @@ -16,7 +16,7 @@ import { ProjectNameValidator } from '../../../projects/models/projectNameValida providers: [ProjectNameValidator], }) export class TemplateNameDialogComponent implements OnInit { - server: Server; + controller: Server; templateNameForm: FormGroup; constructor( @@ -36,7 +36,7 @@ export class TemplateNameDialogComponent implements OnInit { templateName: new FormControl( name, [Validators.required, this.templateNameValidator.get], - [templateNameAsyncValidator(this.server, this.templateService)] + [templateNameAsyncValidator(this.controller, this.templateService)] ), }); @@ -54,7 +54,7 @@ export class TemplateNameDialogComponent implements OnInit { this.toasterService.error('Please enter correct name for new template'); return; } - this.templateService.list(this.server).subscribe((templates: Template[]) => { + this.templateService.list(this.controller).subscribe((templates: Template[]) => { const templateName = this.templateNameForm.controls['templateName'].value; let existingProject = templates.find((t) => t.name === templateName); diff --git a/src/app/components/project-map/node-editors/config-editor/config-editor.component.spec.ts b/src/app/components/project-map/node-editors/config-editor/config-editor.component.spec.ts index b3b47295..626a69fb 100644 --- a/src/app/components/project-map/node-editors/config-editor/config-editor.component.spec.ts +++ b/src/app/components/project-map/node-editors/config-editor/config-editor.component.spec.ts @@ -16,7 +16,7 @@ import { ConfigEditorDialogComponent } from './config-editor.component'; describe('ConfigEditorDialogComponent', () => { let component: ConfigEditorDialogComponent; let fixture: ComponentFixture; - let server: Server; + let controller: Server; let node: Node; let toaster = { success: jasmine.createSpy('success'), @@ -45,9 +45,9 @@ describe('ConfigEditorDialogComponent', () => { declarations: [ConfigEditorDialogComponent], }).compileComponents(); - server = new Server(); - server.host = 'localhost'; - server.port = 80; + controller = new Server(); + controller.host = 'localhost'; + controller.port = 80; node = new Node(); node.name = 'sample name'; @@ -56,7 +56,7 @@ describe('ConfigEditorDialogComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(ConfigEditorDialogComponent); component = fixture.componentInstance; - component.server = server; + component.controller = controller; component.node = node; fixture.detectChanges(); }); diff --git a/src/app/components/project-map/node-editors/config-editor/config-editor.component.ts b/src/app/components/project-map/node-editors/config-editor/config-editor.component.ts index e624d8ef..527288b2 100644 --- a/src/app/components/project-map/node-editors/config-editor/config-editor.component.ts +++ b/src/app/components/project-map/node-editors/config-editor/config-editor.component.ts @@ -12,7 +12,7 @@ import { ToasterService } from '../../../../services/toaster.service'; styleUrls: ['./config-editor.component.scss'], }) export class ConfigEditorDialogComponent implements OnInit { - server: Server; + controller: Server; project: Project; node: Node; @@ -26,21 +26,21 @@ export class ConfigEditorDialogComponent implements OnInit { ) {} ngOnInit() { - this.nodeService.getStartupConfiguration(this.server, this.node).subscribe((config: any) => { + this.nodeService.getStartupConfiguration(this.controller, this.node).subscribe((config: any) => { this.config = config; }); if (this.node.node_type === 'iou' || this.node.node_type === 'dynamips') { - this.nodeService.getPrivateConfiguration(this.server, this.node).subscribe((privateConfig: any) => { + this.nodeService.getPrivateConfiguration(this.controller, this.node).subscribe((privateConfig: any) => { this.privateConfig = privateConfig; }); } } onSaveClick() { - this.nodeService.saveConfiguration(this.server, this.node, this.config).subscribe((response) => { + this.nodeService.saveConfiguration(this.controller, this.node, this.config).subscribe((response) => { if (this.node.node_type === 'iou' || this.node.node_type === 'dynamips') { - this.nodeService.savePrivateConfiguration(this.server, this.node, this.privateConfig).subscribe((resp) => { + this.nodeService.savePrivateConfiguration(this.controller, this.node, this.privateConfig).subscribe((resp) => { this.dialogRef.close(); this.toasterService.success(`Configuration for node ${this.node.name} saved.`); }); diff --git a/src/app/components/project-map/node-editors/configurator/atm_switch/configurator-atm-switch.component.ts b/src/app/components/project-map/node-editors/configurator/atm_switch/configurator-atm-switch.component.ts index cd98de04..c25d738e 100644 --- a/src/app/components/project-map/node-editors/configurator/atm_switch/configurator-atm-switch.component.ts +++ b/src/app/components/project-map/node-editors/configurator/atm_switch/configurator-atm-switch.component.ts @@ -12,7 +12,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; styleUrls: ['../configurator.component.scss', '../../../../preferences/preferences.component.scss'], }) export class ConfiguratorDialogAtmSwitchComponent implements OnInit { - server: Server; + controller: Server; node: Node; name: string; nameForm: FormGroup; @@ -58,7 +58,7 @@ export class ConfiguratorDialogAtmSwitchComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = node.name; @@ -146,7 +146,7 @@ export class ConfiguratorDialogAtmSwitchComponent implements OnInit { {} ); - this.nodeService.updateNode(this.server, this.node).subscribe(() => { + this.nodeService.updateNode(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.ts b/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.ts index fd34de07..e5415dd8 100644 --- a/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.ts +++ b/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.ts @@ -16,7 +16,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; styleUrls: ['../configurator.component.scss'], }) export class ConfiguratorDialogCloudComponent implements OnInit { - server: Server; + controller: Server; node: Node; name: string; generalSettingsForm: FormGroup; @@ -51,7 +51,7 @@ export class ConfiguratorDialogCloudComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = node.name; this.getConfiguration(); @@ -98,7 +98,7 @@ export class ConfiguratorDialogCloudComponent implements OnInit { .concat(this.portsMappingEthernet) .concat(this.portsMappingTap); - this.nodeService.updateNode(this.server, this.node).subscribe(() => { + this.nodeService.updateNode(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.ts b/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.ts index d962c5d8..8a4963f6 100644 --- a/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.ts +++ b/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.ts @@ -16,7 +16,7 @@ import { NonNegativeValidator } from '../../../../../validators/non-negative-val styleUrls: ['../configurator.component.scss'], }) export class ConfiguratorDialogDockerComponent implements OnInit { - server: Server; + controller: Server; node: Node; name: string; generalSettingsForm: FormGroup; @@ -50,7 +50,7 @@ export class ConfiguratorDialogDockerComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = node.name; this.getConfiguration(); @@ -65,20 +65,20 @@ export class ConfiguratorDialogDockerComponent implements OnInit { configureCustomAdapters() { this.dialogRef = this.dialog.open(ConfigureCustomAdaptersDialogComponent, this.conf); let instance = this.dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.node = this.node; } editNetworkConfiguration() { this.dialogRef = this.dialog.open(EditNetworkConfigurationDialogComponent, this.conf); let instance = this.dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.node = this.node; } onSaveClick() { if (this.generalSettingsForm.valid) { - this.nodeService.updateNode(this.server, this.node).subscribe(() => { + this.nodeService.updateNode(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/docker/configure-custom-adapters/configure-custom-adapters.component.ts b/src/app/components/project-map/node-editors/configurator/docker/configure-custom-adapters/configure-custom-adapters.component.ts index 2441fc82..7d331188 100644 --- a/src/app/components/project-map/node-editors/configurator/docker/configure-custom-adapters/configure-custom-adapters.component.ts +++ b/src/app/components/project-map/node-editors/configurator/docker/configure-custom-adapters/configure-custom-adapters.component.ts @@ -13,7 +13,7 @@ import { ToasterService } from '../../../../../../services/toaster.service'; styleUrls: ['./configure-custom-adapters.component.scss'], }) export class ConfigureCustomAdaptersDialogComponent implements OnInit { - server: Server; + controller: Server; node: Node; displayedColumns: string[] = ['adapter_number', 'port_name']; adapters: CustomAdapter[] = []; @@ -42,7 +42,7 @@ export class ConfigureCustomAdaptersDialogComponent implements OnInit { onSaveClick() { this.node.custom_adapters = this.adapters; - this.nodeService.updateNodeWithCustomAdapters(this.server, this.node).subscribe(() => { + this.nodeService.updateNodeWithCustomAdapters(this.controller, this.node).subscribe(() => { this.onCancelClick(); this.toasterService.success(`Configuration saved for node ${this.node.name}`); }); diff --git a/src/app/components/project-map/node-editors/configurator/docker/edit-network-configuration/edit-network-configuration.component.ts b/src/app/components/project-map/node-editors/configurator/docker/edit-network-configuration/edit-network-configuration.component.ts index 2f298783..096219c1 100644 --- a/src/app/components/project-map/node-editors/configurator/docker/edit-network-configuration/edit-network-configuration.component.ts +++ b/src/app/components/project-map/node-editors/configurator/docker/edit-network-configuration/edit-network-configuration.component.ts @@ -11,7 +11,7 @@ import { ToasterService } from '../../../../../../services/toaster.service'; styleUrls: ['./edit-network-configuration.component.scss'], }) export class EditNetworkConfigurationDialogComponent implements OnInit { - server: Server; + controller: Server; node: Node; configuration: string; @@ -22,14 +22,14 @@ export class EditNetworkConfigurationDialogComponent implements OnInit { ) {} ngOnInit() { - this.nodeService.getNetworkConfiguration(this.server, this.node).subscribe((response: string) => { + this.nodeService.getNetworkConfiguration(this.controller, this.node).subscribe((response: string) => { this.configuration = response; }); } onSaveClick() { this.nodeService - .saveNetworkConfiguration(this.server, this.node, this.configuration) + .saveNetworkConfiguration(this.controller, this.node, this.configuration) .subscribe((response: string) => { this.onCancelClick(); this.toasterService.success(`Configuration for node ${this.node.name} saved.`); diff --git a/src/app/components/project-map/node-editors/configurator/ethernet-switch/configurator-ethernet-switch.component.ts b/src/app/components/project-map/node-editors/configurator/ethernet-switch/configurator-ethernet-switch.component.ts index 296182c0..6018ad4c 100644 --- a/src/app/components/project-map/node-editors/configurator/ethernet-switch/configurator-ethernet-switch.component.ts +++ b/src/app/components/project-map/node-editors/configurator/ethernet-switch/configurator-ethernet-switch.component.ts @@ -15,7 +15,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; }) export class ConfiguratorDialogEthernetSwitchComponent implements OnInit { @ViewChild(PortsComponent) portsComponent: PortsComponent; - server: Server; + controller: Server; node: Node; name: string; inputForm: FormGroup; @@ -34,7 +34,7 @@ export class ConfiguratorDialogEthernetSwitchComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = this.node.name; this.getConfiguration(); @@ -48,7 +48,7 @@ export class ConfiguratorDialogEthernetSwitchComponent implements OnInit { onSaveClick() { if (this.inputForm.valid) { this.node.properties.ports_mapping = this.portsComponent.ethernetPorts; - this.nodeService.updateNode(this.server, this.node).subscribe(() => { + this.nodeService.updateNode(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/ethernet_hub/configurator-ethernet-hub.component.ts b/src/app/components/project-map/node-editors/configurator/ethernet_hub/configurator-ethernet-hub.component.ts index 4b4e2e47..6e62bd50 100644 --- a/src/app/components/project-map/node-editors/configurator/ethernet_hub/configurator-ethernet-hub.component.ts +++ b/src/app/components/project-map/node-editors/configurator/ethernet_hub/configurator-ethernet-hub.component.ts @@ -13,7 +13,7 @@ import { VpcsConfigurationService } from '../../../../../services/vpcs-configura styleUrls: ['../configurator.component.scss'], }) export class ConfiguratorDialogEthernetHubComponent implements OnInit { - server: Server; + controller: Server; node: Node; numberOfPorts: number; inputForm: FormGroup; @@ -34,7 +34,7 @@ export class ConfiguratorDialogEthernetHubComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = this.node.name; this.numberOfPorts = this.node.ports.length; @@ -57,7 +57,7 @@ export class ConfiguratorDialogEthernetHubComponent implements OnInit { }); } - this.nodeService.updateNode(this.server, this.node).subscribe(() => { + this.nodeService.updateNode(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.ts b/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.ts index 9090e1f5..2a436f65 100644 --- a/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.ts +++ b/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.ts @@ -13,7 +13,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; styleUrls: ['../configurator.component.scss'], }) export class ConfiguratorDialogIosComponent implements OnInit { - server: Server; + controller: Server; node: Node; name: string; generalSettingsForm: FormGroup; @@ -38,7 +38,7 @@ export class ConfiguratorDialogIosComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = node.name; this.getConfiguration(); @@ -51,7 +51,7 @@ export class ConfiguratorDialogIosComponent implements OnInit { onSaveClick() { if (this.generalSettingsForm.valid && this.memoryForm.valid) { - this.nodeService.updateNode(this.server, this.node).subscribe(() => { + this.nodeService.updateNode(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/iou/configurator-iou.component.ts b/src/app/components/project-map/node-editors/configurator/iou/configurator-iou.component.ts index b336bcc6..7d544857 100644 --- a/src/app/components/project-map/node-editors/configurator/iou/configurator-iou.component.ts +++ b/src/app/components/project-map/node-editors/configurator/iou/configurator-iou.component.ts @@ -13,7 +13,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; styleUrls: ['../configurator.component.scss'], }) export class ConfiguratorDialogIouComponent implements OnInit { - server: Server; + controller: Server; node: Node; name: string; generalSettingsForm: FormGroup; @@ -38,7 +38,7 @@ export class ConfiguratorDialogIouComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = node.name; this.getConfiguration(); @@ -51,7 +51,7 @@ export class ConfiguratorDialogIouComponent implements OnInit { onSaveClick() { if (this.generalSettingsForm.valid && this.networkForm.valid) { - this.nodeService.updateNode(this.server, this.node).subscribe(() => { + this.nodeService.updateNode(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/nat/configurator-nat.component.ts b/src/app/components/project-map/node-editors/configurator/nat/configurator-nat.component.ts index c42da4d1..610ca170 100644 --- a/src/app/components/project-map/node-editors/configurator/nat/configurator-nat.component.ts +++ b/src/app/components/project-map/node-editors/configurator/nat/configurator-nat.component.ts @@ -12,7 +12,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; styleUrls: ['../configurator.component.scss'], }) export class ConfiguratorDialogNatComponent implements OnInit { - server: Server; + controller: Server; node: Node; name: string; generalSettingsForm: FormGroup; @@ -29,7 +29,7 @@ export class ConfiguratorDialogNatComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = node.name; }); @@ -37,7 +37,7 @@ export class ConfiguratorDialogNatComponent implements OnInit { onSaveClick() { if (this.generalSettingsForm.valid) { - this.nodeService.updateNode(this.server, this.node).subscribe(() => { + this.nodeService.updateNode(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/qemu/configurator-qemu.component.ts b/src/app/components/project-map/node-editors/configurator/qemu/configurator-qemu.component.ts index e03d477c..3a6016a5 100644 --- a/src/app/components/project-map/node-editors/configurator/qemu/configurator-qemu.component.ts +++ b/src/app/components/project-map/node-editors/configurator/qemu/configurator-qemu.component.ts @@ -18,7 +18,7 @@ import { QemuImageCreatorComponent } from './qemu-image-creator/qemu-image-creat styleUrls: ['../configurator.component.scss'], }) export class ConfiguratorDialogQemuComponent implements OnInit { - server: Server; + controller: Server; node: Node; name: string; generalSettingsForm: FormGroup; @@ -57,17 +57,17 @@ export class ConfiguratorDialogQemuComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = node.name; this.getConfiguration(); }); - this.qemuService.getBinaries(this.server).subscribe((qemuBinaries: QemuBinary[]) => { + this.qemuService.getBinaries(this.controller).subscribe((qemuBinaries: QemuBinary[]) => { this.binaries = qemuBinaries; }); - this.qemuService.getImages(this.server).subscribe((qemuImages: QemuImage[]) => { + this.qemuService.getImages(this.controller).subscribe((qemuImages: QemuImage[]) => { this.qemuImages = qemuImages; }); } @@ -75,7 +75,7 @@ export class ConfiguratorDialogQemuComponent implements OnInit { openQemuImageCreator() { this.dialogRefQemuImageCreator = this.dialog.open(QemuImageCreatorComponent, this.conf); let instance = this.dialogRefQemuImageCreator.componentInstance; - instance.server = this.server; + instance.controller = this.controller; } uploadCdromImageFile(event) { @@ -116,7 +116,7 @@ export class ConfiguratorDialogQemuComponent implements OnInit { this.node.properties.adapters = this.node.custom_adapters.length; - this.nodeService.updateNodeWithCustomAdapters(this.server, this.node).subscribe(() => { + this.nodeService.updateNodeWithCustomAdapters(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/qemu/qemu-image-creator/qemu-image-creator.component.ts b/src/app/components/project-map/node-editors/configurator/qemu/qemu-image-creator/qemu-image-creator.component.ts index 5287f987..5bd624e4 100644 --- a/src/app/components/project-map/node-editors/configurator/qemu/qemu-image-creator/qemu-image-creator.component.ts +++ b/src/app/components/project-map/node-editors/configurator/qemu/qemu-image-creator/qemu-image-creator.component.ts @@ -13,7 +13,7 @@ import { ToasterService } from '../../../../../../services/toaster.service'; styleUrls: ['../../configurator.component.scss'], }) export class QemuImageCreatorComponent implements OnInit { - server: Server; + controller: Server; qemuImg: QemuImg; formatOptions: string[] = ['qcow2', 'qcow', 'vhd', 'vdi', 'vmdk', 'raw']; @@ -101,7 +101,7 @@ export class QemuImageCreatorComponent implements OnInit { onSaveClick() { if (this.inputForm.valid && this.qemuImg.format) { - this.qemuService.addImage(this.server, this.qemuImg).subscribe(() => { + this.qemuService.addImage(this.controller, this.qemuImg).subscribe(() => { this.dialogRef.close(); }); } else { diff --git a/src/app/components/project-map/node-editors/configurator/switch/configurator-switch.component.ts b/src/app/components/project-map/node-editors/configurator/switch/configurator-switch.component.ts index ada8e204..2b0e4667 100644 --- a/src/app/components/project-map/node-editors/configurator/switch/configurator-switch.component.ts +++ b/src/app/components/project-map/node-editors/configurator/switch/configurator-switch.component.ts @@ -12,7 +12,7 @@ import { ToasterService } from '../../../../../services/toaster.service'; styleUrls: ['../configurator.component.scss', '../../../../preferences/preferences.component.scss'], }) export class ConfiguratorDialogSwitchComponent implements OnInit { - server: Server; + controller: Server; node: Node; name: string; nameForm: FormGroup; @@ -48,7 +48,7 @@ export class ConfiguratorDialogSwitchComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = node.name; @@ -115,7 +115,7 @@ export class ConfiguratorDialogSwitchComponent implements OnInit { {} ); - this.nodeService.updateNode(this.server, this.node).subscribe(() => { + this.nodeService.updateNode(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/virtualbox/configurator-virtualbox.component.ts b/src/app/components/project-map/node-editors/configurator/virtualbox/configurator-virtualbox.component.ts index 629f2aed..40655f85 100644 --- a/src/app/components/project-map/node-editors/configurator/virtualbox/configurator-virtualbox.component.ts +++ b/src/app/components/project-map/node-editors/configurator/virtualbox/configurator-virtualbox.component.ts @@ -14,7 +14,7 @@ import { VirtualBoxConfigurationService } from '../../../../../services/virtual- styleUrls: ['../configurator.component.scss'], }) export class ConfiguratorDialogVirtualBoxComponent implements OnInit { - server: Server; + controller: Server; node: Node; name: string; generalSettingsForm: FormGroup; @@ -40,7 +40,7 @@ export class ConfiguratorDialogVirtualBoxComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = node.name; this.getConfiguration(); @@ -65,7 +65,7 @@ export class ConfiguratorDialogVirtualBoxComponent implements OnInit { this.node.properties.adapters = this.node.custom_adapters.length; - this.nodeService.updateNodeWithCustomAdapters(this.server, this.node).subscribe(() => { + this.nodeService.updateNodeWithCustomAdapters(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/vmware/configurator-vmware.component.ts b/src/app/components/project-map/node-editors/configurator/vmware/configurator-vmware.component.ts index 854021cd..daac3c2f 100644 --- a/src/app/components/project-map/node-editors/configurator/vmware/configurator-vmware.component.ts +++ b/src/app/components/project-map/node-editors/configurator/vmware/configurator-vmware.component.ts @@ -14,7 +14,7 @@ import { VmwareConfigurationService } from '../../../../../services/vmware-confi styleUrls: ['../configurator.component.scss'], }) export class ConfiguratorDialogVmwareComponent implements OnInit { - server: Server; + controller: Server; node: Node; name: string; generalSettingsForm: FormGroup; @@ -39,7 +39,7 @@ export class ConfiguratorDialogVmwareComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = node.name; this.getConfiguration(); @@ -64,7 +64,7 @@ export class ConfiguratorDialogVmwareComponent implements OnInit { this.node.properties.adapters = this.node.custom_adapters.length; - this.nodeService.updateNodeWithCustomAdapters(this.server, this.node).subscribe(() => { + this.nodeService.updateNodeWithCustomAdapters(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/node-editors/configurator/vpcs/configurator-vpcs.component.ts b/src/app/components/project-map/node-editors/configurator/vpcs/configurator-vpcs.component.ts index 920e94c9..041108a4 100644 --- a/src/app/components/project-map/node-editors/configurator/vpcs/configurator-vpcs.component.ts +++ b/src/app/components/project-map/node-editors/configurator/vpcs/configurator-vpcs.component.ts @@ -13,7 +13,7 @@ import { VpcsConfigurationService } from '../../../../../services/vpcs-configura styleUrls: ['../configurator.component.scss'], }) export class ConfiguratorDialogVpcsComponent implements OnInit { - server: Server; + controller: Server; node: Node; name: string; inputForm: FormGroup; @@ -32,7 +32,7 @@ export class ConfiguratorDialogVpcsComponent implements OnInit { } ngOnInit() { - this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => { this.node = node; this.name = node.name; this.getConfiguration(); @@ -45,7 +45,7 @@ export class ConfiguratorDialogVpcsComponent implements OnInit { onSaveClick() { if (this.inputForm.valid) { - this.nodeService.updateNode(this.server, this.node).subscribe(() => { + this.nodeService.updateNode(this.controller, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/components/project-map/nodes-menu/nodes-menu.component.ts b/src/app/components/project-map/nodes-menu/nodes-menu.component.ts index f19dda53..a7e543a6 100644 --- a/src/app/components/project-map/nodes-menu/nodes-menu.component.ts +++ b/src/app/components/project-map/nodes-menu/nodes-menu.component.ts @@ -20,7 +20,7 @@ import { NodesMenuConfirmationDialogComponent } from './nodes-menu-confirmation- }) export class NodesMenuComponent { @Input('project') project: Project; - @Input('server') server: Server; + @Input('controller') controller: Server; constructor( private nodeService: NodeService, @@ -50,7 +50,7 @@ export class NodesMenuComponent { name: node.name, project_id: node.project_id, node_id: node.node_id, - server_url: this.serverService.getServerUrl(this.server), + server_url: this.serverService.getServerUrl(this.controller), }; await this.electronService.remote.require('./console-executor.js').openConsole(request); } @@ -64,31 +64,32 @@ export class NodesMenuComponent { } startNodes() { - this.nodeService.startAll(this.server, this.project).subscribe(() => { + this.nodeService.startAll(this.controller, this.project).subscribe(() => { this.toasterService.success('All nodes successfully started'); }); } stopNodes() { - this.nodeService.stopAll(this.server, this.project).subscribe(() => { + this.nodeService.stopAll(this.controller, this.project).subscribe(() => { this.toasterService.success('All nodes successfully stopped'); }); } suspendNodes() { - this.nodeService.suspendAll(this.server, this.project).subscribe(() => { + this.nodeService.suspendAll(this.controller, this.project).subscribe(() => { this.toasterService.success('All nodes successfully suspended'); }); } reloadNodes() { - this.nodeService.reloadAll(this.server, this.project).subscribe(() => { + this.nodeService.reloadAll(this.controller, this.project).subscribe(() => { this.toasterService.success('All nodes successfully reloaded'); }); } resetNodes() { - this.nodeService.resetAllNodes(this.server, this.project).subscribe(() => { + debugger + this.nodeService.resetAllNodes(this.controller, this.project).subscribe(() => { this.toasterService.success('Successfully reset all console connections'); }); } diff --git a/src/app/components/project-map/packet-capturing/packet-filters/packet-filters.component.ts b/src/app/components/project-map/packet-capturing/packet-filters/packet-filters.component.ts index 3b22edef..03dd1b36 100644 --- a/src/app/components/project-map/packet-capturing/packet-filters/packet-filters.component.ts +++ b/src/app/components/project-map/packet-capturing/packet-filters/packet-filters.component.ts @@ -15,7 +15,7 @@ import { HelpDialogComponent } from '../../help-dialog/help-dialog.component'; styleUrls: ['./packet-filters.component.scss'], }) export class PacketFiltersDialogComponent implements OnInit { - server: Server; + controller: Server; project: Project; link: Link; filters: Filter; @@ -28,7 +28,7 @@ export class PacketFiltersDialogComponent implements OnInit { ) {} ngOnInit() { - this.linkService.getLink(this.server, this.link.project_id, this.link.link_id).subscribe((link: Link) => { + this.linkService.getLink(this.controller, this.link.project_id, this.link.link_id).subscribe((link: Link) => { this.link = link; this.filters = { bpf: [], @@ -47,7 +47,7 @@ export class PacketFiltersDialogComponent implements OnInit { } }); - this.linkService.getAvailableFilters(this.server, this.link).subscribe((availableFilters: FilterDescription[]) => { + this.linkService.getAvailableFilters(this.controller, this.link).subscribe((availableFilters: FilterDescription[]) => { this.availableFilters = availableFilters; }); } @@ -65,14 +65,14 @@ export class PacketFiltersDialogComponent implements OnInit { packet_loss: [0], }; - this.linkService.updateLink(this.server, this.link).subscribe((link: Link) => { + this.linkService.updateLink(this.controller, this.link).subscribe((link: Link) => { this.dialogRef.close(); }); } onYesClick() { this.link.filters = this.filters; - this.linkService.updateLink(this.server, this.link).subscribe((link: Link) => { + this.linkService.updateLink(this.controller, this.link).subscribe((link: Link) => { this.dialogRef.close(); }); } diff --git a/src/app/components/project-map/packet-capturing/start-capture/start-capture.component.ts b/src/app/components/project-map/packet-capturing/start-capture/start-capture.component.ts index bd568c10..967ad236 100644 --- a/src/app/components/project-map/packet-capturing/start-capture/start-capture.component.ts +++ b/src/app/components/project-map/packet-capturing/start-capture/start-capture.component.ts @@ -18,7 +18,7 @@ import { PacketFiltersDialogComponent } from '../packet-filters/packet-filters.c styleUrls: ['./start-capture.component.scss'], }) export class StartCaptureDialogComponent implements OnInit { - server: Server; + controller: Server; project: Project; link: Link; linkTypes = []; @@ -78,10 +78,10 @@ export class StartCaptureDialogComponent implements OnInit { }; if (this.startProgram) { - this.packetCaptureService.startCapture(this.server, this.project, this.link, captureSettings.capture_file_name); + this.packetCaptureService.startCapture(this.controller, this.project, this.link, captureSettings.capture_file_name); } - this.linkService.startCaptureOnLink(this.server, this.link, captureSettings).subscribe(() => { + this.linkService.startCaptureOnLink(this.controller, this.link, captureSettings).subscribe(() => { this.dialogRef.close(); }); } diff --git a/src/app/components/project-map/project-map-menu/project-map-menu.component.html b/src/app/components/project-map/project-map-menu/project-map-menu.component.html index 81f0fc0f..30495dc1 100644 --- a/src/app/components/project-map/project-map-menu/project-map-menu.component.html +++ b/src/app/components/project-map/project-map-menu/project-map-menu.component.html @@ -98,7 +98,7 @@ photo_camera '); splittedSvg[i] = splittedElement[1].substring(2); i += 2; @@ -175,7 +175,7 @@ export class ProjectMapMenuComponent implements OnInit, OnDestroy { let image = fileReader.result; let svg = this.createSvgFileForImage(image, imageToUpload); this.drawingService - .add(this.server, this.project.project_id, -(imageToUpload.width / 2), -(imageToUpload.height / 2), svg) + .add(this.controller, this.project.project_id, -(imageToUpload.width / 2), -(imageToUpload.height / 2), svg) .subscribe(() => {}); }; diff --git a/src/app/components/project-map/project-map.component.html b/src/app/components/project-map/project-map.component.html index 58b480d0..cda57e4a 100644 --- a/src/app/components/project-map/project-map.component.html +++ b/src/app/components/project-map/project-map.component.html @@ -1,7 +1,7 @@
@@ -83,7 +83,7 @@ - @@ -91,11 +91,11 @@ developer_board Go to controllers - - @@ -103,7 +103,7 @@ settings Go to settings - @@ -111,7 +111,7 @@ control_point New template - +
- +
- +
- - - - - - - - + + + + + + + +
diff --git a/src/app/components/project-map/project-map.component.spec.ts b/src/app/components/project-map/project-map.component.spec.ts index 686e0f34..e5fd0c17 100644 --- a/src/app/components/project-map/project-map.component.spec.ts +++ b/src/app/components/project-map/project-map.component.spec.ts @@ -89,55 +89,55 @@ export class MockedNodeService { return of(this.node); } - delete(server: Server, node: Node) { + delete(controller: Server, node: Node) { return of(); } - startAll(server: Server, project: Project) { + startAll(controller: Server, project: Project) { return of(); } - stopAll(server: Server, project: Project) { + stopAll(controller: Server, project: Project) { return of(); } - suspendAll(server: Server, project: Project) { + suspendAll(controller: Server, project: Project) { return of(); } - reloadAll(server: Server, project: Project) { + reloadAll(controller: Server, project: Project) { return of(); } - start(server: Server, node: Node) { + start(controller: Server, node: Node) { return of(); } - stop(server: Server, node: Node) { + stop(controller: Server, node: Node) { return of(); } - suspend(server: Server, node: Node) { + suspend(controller: Server, node: Node) { return of(); } - reload(server: Server, node: Node) { + reload(controller: Server, node: Node) { return of(); } - duplicate(server: Server, node: Node) { + duplicate(controller: Server, node: Node) { return of(node); } - getStartupConfiguration(server: Server, node: Node) { + getStartupConfiguration(controller: Server, node: Node) { return of('sample config'); } - saveConfiguration(server: Server, node: Node, configuration: string) { + saveConfiguration(controller: Server, node: Node, configuration: string) { return of(configuration); } - update(server: Server, node: Node) { + update(controller: Server, node: Node) { return of(node); } } @@ -150,7 +150,7 @@ export class MockedDrawingService { return of(this.drawing); } - duplicate(server: Server, project_id: string, drawing: Drawing) { + duplicate(controller: Server, project_id: string, drawing: Drawing) { return of(drawing); } @@ -178,7 +178,7 @@ export class MockedDrawingService { export class MockedLinkService { constructor() {} - getLink(server: Server, projectId: string, linkId: string) { + getLink(controller: Server, projectId: string, linkId: string) { return of({}); } @@ -186,7 +186,7 @@ export class MockedLinkService { return of({}); } - updateLink(server: Server, link: Link) { + updateLink(controller: Server, link: Link) { return of({}); } @@ -198,11 +198,11 @@ export class MockedLinkService { return of({}); } - startCaptureOnLink(server: Server, link: Link, settings: CapturingSettings) { + startCaptureOnLink(controller: Server, link: Link, settings: CapturingSettings) { return of({}); } - getAvailableFilters(server: Server, link: Link) { + getAvailableFilters(controller: Server, link: Link) { return of({}); } } diff --git a/src/app/components/project-map/project-map.component.ts b/src/app/components/project-map/project-map.component.ts index 61cee01a..41430293 100644 --- a/src/app/components/project-map/project-map.component.ts +++ b/src/app/components/project-map/project-map.component.ts @@ -104,7 +104,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { public drawings: Drawing[] = []; public symbols: Symbol[] = []; public project: Project; - public server: Server; + public controller: Server; public projectws: WebSocket; public ws: WebSocket; public isProjectMapMenuVisible: boolean = false; @@ -241,7 +241,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { // const componentFactory = this.cfr.resolveComponentFactory(TopologySummaryComponent); // this.instance = this.topologySummaryContainer.createComponent(componentFactory, null, this.injector); - this.instance.instance.server = this.server; + this.instance.instance.controller = this.controller; this.instance.instance.project = this.project; } else if (this.instance) { if (this.instance.instance) { @@ -267,12 +267,12 @@ export class ProjectMapComponent implements OnInit, OnDestroy { this.projectMapSubscription.add( this.nodesDataSource.changes.subscribe((nodes: Node[]) => { - if (!this.server) return; + if (!this.controller) return; nodes.forEach(async (node: Node) => { - node.symbol_url = `${this.server.protocol}//${this.server.host}:${this.server.port}/${environment.current_version}/symbols/${node.symbol}/raw`; + node.symbol_url = `${this.controller.protocol}//${this.controller.host}:${this.controller.port}/${environment.current_version}/symbols/${node.symbol}/raw`; if (node.width == 0 && node.height == 0) { - let symbolDimensions = await this.symbolService.getDimensions(this.server, node.symbol).toPromise(); + let symbolDimensions = await this.symbolService.getDimensions(this.controller, node.symbol).toPromise(); node.width = symbolDimensions.width; node.height = symbolDimensions.height; } @@ -333,10 +333,10 @@ export class ProjectMapComponent implements OnInit, OnDestroy { from(this.serverService.get(controller_id)) .pipe( - mergeMap((server: Server) => { - if (!server) this.router.navigate(['/controllers']); - this.server = server; - return this.projectService.get(server, paramMap.get('project_id')).pipe( + mergeMap((controller: Server) => { + if (!controller) this.router.navigate(['/controllers']); + this.controller = controller; + return this.projectService.get(controller, paramMap.get('project_id')).pipe( map((project) => { return project; }) @@ -346,19 +346,19 @@ export class ProjectMapComponent implements OnInit, OnDestroy { this.project = project; if (!project) this.router.navigate(['/controllers']); - this.projectService.open(this.server, this.project.project_id); + this.projectService.open(this.controller, this.project.project_id); this.title.setTitle(this.project.name); this.isInterfaceLabelVisible = this.mapSettingsService.showInterfaceLabels; this.toggleShowTopologySummary(this.mapSettingsService.isTopologySummaryVisible); - this.recentlyOpenedProjectService.setServerId(this.server.id.toString()); + this.recentlyOpenedProjectService.setcontrollerId(this.controller.id.toString()); if (this.project.status === 'opened') { return new Observable((observer) => { observer.next(this.project); }); } else { - return this.projectService.open(this.server, this.project.project_id); + return this.projectService.open(this.controller, this.project.project_id); } }) ) @@ -416,7 +416,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { Mousetrap.bind('ctrl+shift+s', (event: Event) => { event.preventDefault(); - this.router.navigate(['/controller', this.server.id, 'preferences']); + this.router.navigate(['/controller', this.controller.id, 'preferences']); }); Mousetrap.bind('del', (event: Event) => { @@ -437,7 +437,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { .filter((item) => item instanceof MapNode) .forEach((item: MapNode) => { const node = this.mapNodeToNode.convert(item); - this.nodeService.delete(this.server, node).subscribe((data) => { + this.nodeService.delete(this.controller, node).subscribe((data) => { this.toasterService.success('Node has been deleted'); }); }); @@ -446,7 +446,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { .filter((item) => item instanceof MapDrawing) .forEach((item: MapDrawing) => { const drawing = this.mapDrawingToDrawing.convert(item); - this.drawingService.delete(this.server, drawing).subscribe((data) => { + this.drawingService.delete(this.controller, drawing).subscribe((data) => { this.toasterService.success('Drawing has been deleted'); }); }); @@ -459,15 +459,15 @@ export class ProjectMapComponent implements OnInit, OnDestroy { this.recentlyOpenedProjectService.setProjectId(this.project.project_id); const subscription = this.projectService - .nodes(this.server, project.project_id) + .nodes(this.controller, project.project_id) .pipe( mergeMap((nodes: Node[]) => { this.nodesDataSource.set(nodes); - return this.projectService.links(this.server, project.project_id); + return this.projectService.links(this.controller, project.project_id); }), mergeMap((links: Link[]) => { this.linksDataSource.set(links); - return this.projectService.drawings(this.server, project.project_id); + return this.projectService.drawings(this.controller, project.project_id); }) ) .subscribe((drawings: Drawing[]) => { @@ -482,7 +482,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { } setUpProjectWS(project: Project) { - this.projectws = new WebSocket(this.notificationService.projectNotificationsPath(this.server, project.project_id)); + this.projectws = new WebSocket(this.notificationService.projectNotificationsPath(this.controller, project.project_id)); this.projectws.onmessage = (event: MessageEvent) => { this.projectWebServiceHandler.handleMessage(JSON.parse(event.data)); @@ -494,7 +494,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { } setUpWS() { - this.ws = new WebSocket(this.notificationService.notificationsPath(this.server)); + this.ws = new WebSocket(this.notificationService.notificationsPath(this.controller)); } setUpMapCallbacks() { @@ -592,25 +592,25 @@ export class ProjectMapComponent implements OnInit, OnDestroy { this.progressService.activate(); this.nodeService .createFromTemplate( - this.server, + this.controller, this.project, nodeAddedEvent.template, nodeAddedEvent.x, nodeAddedEvent.y, - nodeAddedEvent.server + nodeAddedEvent.controller ) .subscribe( (node: Node) => { // if (nodeAddedEvent.name !== nodeAddedEvent.template.name) { // node.name = nodeAddedEvent.name; - // this.nodeService.updateNode(this.server, node).subscribe(()=>{}); + // this.nodeService.updateNode(this.controller, node).subscribe(()=>{}); // } - this.projectService.nodes(this.server, this.project.project_id).subscribe((nodes: Node[]) => { + this.projectService.nodes(this.controller, this.project.project_id).subscribe((nodes: Node[]) => { nodes .filter((node) => node.label.style === null) .forEach((node) => { const fixedNode = this.nodeCreatedLabelStylesFixer.fix(node); - this.nodeService.updateLabel(this.server, node, fixedNode.label).subscribe(); + this.nodeService.updateLabel(this.controller, node, fixedNode.label).subscribe(); }); this.nodesDataSource.set(nodes); @@ -925,7 +925,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; } saveProject() { @@ -935,7 +935,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.project = this.project; } @@ -946,7 +946,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.project = this.project; } @@ -959,7 +959,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; const subscription = dialogRef.componentInstance.onImportProject.subscribe((projectId: string) => { uuid = projectId; }); @@ -973,8 +973,8 @@ export class ProjectMapComponent implements OnInit, OnDestroy { const bottomSheetSubscription = bottomSheetRef.afterDismissed().subscribe((result: boolean) => { if (result) { - this.projectService.open(this.server, uuid).subscribe(() => { - this.router.navigate(['/controller', this.server.id, 'project', uuid]); + this.projectService.open(this.controller, uuid).subscribe(() => { + this.router.navigate(['/controller', this.controller.id, 'project', uuid]); }); } }); @@ -995,7 +995,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { ) { this.toasterService.error('Project with running nodes cannot be exported.'); } else { - // location.assign(this.projectService.getExportPath(this.server, this.project)); + // location.assign(this.projectService.getExportPath(this.controller, this.project)); this.exportPortableProjectDialog(); } } @@ -1005,7 +1005,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { maxHeight: '850px', autoFocus: false, disableClose: true, - data: {serverDetails:this.server,projectDetails:this.project}, + data: {serverDetails:this.controller,projectDetails:this.project}, }); dialogRef.afterClosed().subscribe((isAddes: boolean) => {}); @@ -1026,7 +1026,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { height=\"${imageToUpload.height}\" width=\"${imageToUpload.width}\">\n\n`; this.drawingService - .add(this.server, this.project.project_id, -(imageToUpload.width / 2), -(imageToUpload.height / 2), svg) + .add(this.controller, this.project.project_id, -(imageToUpload.width / 2), -(imageToUpload.height / 2), svg) .subscribe(() => {}); }; @@ -1042,8 +1042,8 @@ export class ProjectMapComponent implements OnInit, OnDestroy { bottomSheetRef.instance.message = 'Do you want to close the project?'; const bottomSheetSubscription = bottomSheetRef.afterDismissed().subscribe((result: boolean) => { if (result) { - this.projectService.close(this.server, this.project.project_id).subscribe(() => { - this.router.navigate(['/controller', this.server.id, 'projects']); + this.projectService.close(this.controller, this.project.project_id).subscribe(() => { + this.router.navigate(['/controller', this.controller.id, 'projects']); }); } }); @@ -1055,8 +1055,8 @@ export class ProjectMapComponent implements OnInit, OnDestroy { bottomSheetRef.instance.message = 'Do you want to delete the project?'; const bottomSheetSubscription = bottomSheetRef.afterDismissed().subscribe((result: boolean) => { if (result) { - this.projectService.delete(this.server, this.project.project_id).subscribe(() => { - this.router.navigate(['/controller', this.server.id, 'projects']); + this.projectService.delete(this.controller, this.project.project_id).subscribe(() => { + this.router.navigate(['/controller', this.controller.id, 'projects']); }); } }); @@ -1070,7 +1070,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.project = this.project; } @@ -1082,7 +1082,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.project = this.project; } diff --git a/src/app/components/project-map/project-readme/project-readme.component.ts b/src/app/components/project-map/project-readme/project-readme.component.ts index ba3bdb5e..bc6a1afc 100644 --- a/src/app/components/project-map/project-readme/project-readme.component.ts +++ b/src/app/components/project-map/project-readme/project-readme.component.ts @@ -14,7 +14,7 @@ import { ViewChild } from '@angular/core'; styleUrls: ['./project-readme.component.scss'] }) export class ProjectReadmeComponent implements AfterViewInit { - server: Server; + controller: Server; project: Project; @ViewChild('text', {static: false}) text: ElementRef; @@ -28,7 +28,7 @@ export class ProjectReadmeComponent implements AfterViewInit { ngAfterViewInit() { let markdown = ``; - this.projectService.getReadmeFile(this.server, this.project.project_id).subscribe(file => { + this.projectService.getReadmeFile(this.controller, this.project.project_id).subscribe(file => { if (file) { markdown = file; setTimeout(function(){ diff --git a/src/app/components/project-map/web-console/web-console.component.ts b/src/app/components/project-map/web-console/web-console.component.ts index c3a6a89a..b43e3e44 100644 --- a/src/app/components/project-map/web-console/web-console.component.ts +++ b/src/app/components/project-map/web-console/web-console.component.ts @@ -15,7 +15,7 @@ import { ThemeService } from '../../../services/theme.service'; styleUrls: ['../../../../../node_modules/xterm/css/xterm.css', './web-console.component.scss'], }) export class WebConsoleComponent implements OnInit, AfterViewInit { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Input() node: Node; @@ -53,7 +53,7 @@ export class WebConsoleComponent implements OnInit, AfterViewInit { if (this.isLightThemeEnabled) this.term.setOption('theme', { background: 'white', foreground: 'black', cursor: 'black' }); - const socket = new WebSocket(this.consoleService.getUrl(this.server, this.node)); + const socket = new WebSocket(this.consoleService.getUrl(this.controller, this.node)); socket.onerror = (event) => { this.term.write('Connection lost'); diff --git a/src/app/components/projects/add-blank-project-dialog/add-blank-project-dialog.component.spec.ts b/src/app/components/projects/add-blank-project-dialog/add-blank-project-dialog.component.spec.ts index d3f66f49..70a38a44 100644 --- a/src/app/components/projects/add-blank-project-dialog/add-blank-project-dialog.component.spec.ts +++ b/src/app/components/projects/add-blank-project-dialog/add-blank-project-dialog.component.spec.ts @@ -53,7 +53,7 @@ export class MockedProjectService { describe('AddBlankProjectDialogComponent', () => { let component: AddBlankProjectDialogComponent; let fixture: ComponentFixture; - let server: Server; + let controller: Server; let router = { navigate: jasmine.createSpy('navigate'), }; @@ -85,15 +85,15 @@ describe('AddBlankProjectDialogComponent', () => { declarations: [AddBlankProjectDialogComponent], }).compileComponents(); - server = new Server(); - server.host = 'localhost'; - server.port = 80; + controller = new Server(); + controller.host = 'localhost'; + controller.port = 80; }); beforeEach(() => { fixture = TestBed.createComponent(AddBlankProjectDialogComponent); component = fixture.componentInstance; - component.server = server; + component.controller = controller; fixture.detectChanges(); }); diff --git a/src/app/components/projects/add-blank-project-dialog/add-blank-project-dialog.component.ts b/src/app/components/projects/add-blank-project-dialog/add-blank-project-dialog.component.ts index 1d187daa..280f5652 100644 --- a/src/app/components/projects/add-blank-project-dialog/add-blank-project-dialog.component.ts +++ b/src/app/components/projects/add-blank-project-dialog/add-blank-project-dialog.component.ts @@ -18,7 +18,7 @@ import { ProjectNameValidator } from '../models/projectNameValidator'; providers: [ProjectNameValidator], }) export class AddBlankProjectDialogComponent implements OnInit { - server: Server; + controller: Server; projectNameForm: FormGroup; uuid: string; onAddProject = new EventEmitter(); @@ -38,7 +38,7 @@ export class AddBlankProjectDialogComponent implements OnInit { projectName: new FormControl( null, [Validators.required, this.projectNameValidator.get], - [projectNameAsyncValidator(this.server, this.projectService)] + [projectNameAsyncValidator(this.controller, this.projectService)] ), }); } @@ -51,7 +51,7 @@ export class AddBlankProjectDialogComponent implements OnInit { if (this.projectNameForm.invalid) { return; } - this.projectService.list(this.server).subscribe((projects: Project[]) => { + this.projectService.list(this.controller).subscribe((projects: Project[]) => { const projectName = this.projectNameForm.controls['projectName'].value; let existingProject = projects.find((project) => project.name === projectName); @@ -70,11 +70,11 @@ export class AddBlankProjectDialogComponent implements OnInit { addProject(): void { this.uuid = uuid(); this.projectService - .add(this.server, this.projectNameForm.controls['projectName'].value, this.uuid) + .add(this.controller, this.projectNameForm.controls['projectName'].value, this.uuid) .subscribe((project: Project) => { this.dialogRef.close(); this.toasterService.success(`Project ${project.name} added`); - this.router.navigate(['/controller', this.server.id, 'project', project.project_id]); + this.router.navigate(['/controller', this.controller.id, 'project', project.project_id]); }); } @@ -97,8 +97,8 @@ export class AddBlankProjectDialogComponent implements OnInit { dialogRef.afterClosed().subscribe((answer: boolean) => { if (answer) { - this.projectService.close(this.server, existingProject.project_id).subscribe(() => { - this.projectService.delete(this.server, existingProject.project_id).subscribe(() => { + this.projectService.close(this.controller, existingProject.project_id).subscribe(() => { + this.projectService.delete(this.controller, existingProject.project_id).subscribe(() => { this.addProject(); }); }); diff --git a/src/app/components/projects/choose-name-dialog/choose-name-dialog.component.ts b/src/app/components/projects/choose-name-dialog/choose-name-dialog.component.ts index 3a0c6b9b..91d32664 100644 --- a/src/app/components/projects/choose-name-dialog/choose-name-dialog.component.ts +++ b/src/app/components/projects/choose-name-dialog/choose-name-dialog.component.ts @@ -10,7 +10,7 @@ import { ProjectService } from '../../../services/project.service'; styleUrls: ['./choose-name-dialog.component.scss'], }) export class ChooseNameDialogComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; name: string; @@ -25,7 +25,7 @@ export class ChooseNameDialogComponent implements OnInit { } onSaveClick() { - this.projectService.duplicate(this.server, this.project.project_id, this.name).subscribe(() => { + this.projectService.duplicate(this.controller, this.project.project_id, this.name).subscribe(() => { this.dialogRef.close(); }); } diff --git a/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.html b/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.html index 2acfd347..e87a2e4d 100644 --- a/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.html +++ b/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.html @@ -26,7 +26,7 @@ - Open this project in the background when GNS3 server starts + Open this project in the background when GNS3 controller starts @@ -42,8 +42,8 @@ - - + + diff --git a/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.ts b/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.ts index 9afb5311..166b9fb6 100644 --- a/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.ts +++ b/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.ts @@ -16,7 +16,7 @@ import { ReadmeEditorComponent } from './readme-editor/readme-editor.component'; export class EditProjectDialogComponent implements OnInit { @ViewChild('editor') editor: ReadmeEditorComponent; - server: Server; + controller: Server; project: Project; formGroup: FormGroup; variableFormGroup: FormGroup; @@ -91,8 +91,8 @@ export class EditProjectDialogComponent implements OnInit { this.project.auto_close = !this.auto_close; - this.projectService.update(this.server, this.project).subscribe((project: Project) => { - this.projectService.postReadmeFile(this.server, this.project.project_id, this.editor.markdown).subscribe((response) => { + this.projectService.update(this.controller, this.project).subscribe((project: Project) => { + this.projectService.postReadmeFile(this.controller, this.project.project_id, this.editor.markdown).subscribe((response) => { this.toasterService.success(`Project ${project.name} updated.`); this.onNoClick(); }); diff --git a/src/app/components/projects/edit-project-dialog/readme-editor/readme-editor.component.ts b/src/app/components/projects/edit-project-dialog/readme-editor/readme-editor.component.ts index 6edf5950..56cb74f9 100644 --- a/src/app/components/projects/edit-project-dialog/readme-editor/readme-editor.component.ts +++ b/src/app/components/projects/edit-project-dialog/readme-editor/readme-editor.component.ts @@ -11,7 +11,7 @@ import { Project } from '../../../../models/project'; styleUrls: ['./readme-editor.component.scss'] }) export class ReadmeEditorComponent implements OnInit { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; public markdown = ``; @@ -21,7 +21,7 @@ export class ReadmeEditorComponent implements OnInit { ) {} ngOnInit() { - this.projectService.getReadmeFile(this.server, this.project.project_id).subscribe(file => { + this.projectService.getReadmeFile(this.controller, this.project.project_id).subscribe(file => { if (file) this.markdown = file; }); } diff --git a/src/app/components/projects/import-project-dialog/import-project-dialog.component.spec.ts b/src/app/components/projects/import-project-dialog/import-project-dialog.component.spec.ts index 634e2536..907b882d 100644 --- a/src/app/components/projects/import-project-dialog/import-project-dialog.component.spec.ts +++ b/src/app/components/projects/import-project-dialog/import-project-dialog.component.spec.ts @@ -51,19 +51,19 @@ export class MockedProjectService { return of(this.projects); } - getUploadPath(server: Server, uuid: string, project_name: string) { - return `http://${server.host}:${server.port}/${environment.current_version}/projects/${uuid}/import?name=${project_name}`; + getUploadPath(controller: Server, uuid: string, project_name: string) { + return `http://${controller.host}:${controller.port}/${environment.current_version}/projects/${uuid}/import?name=${project_name}`; } - getExportPath(server: Server, project: Project) { - return `http://${server.host}:${server.port}/${environment.current_version}/projects/${project.project_id}/export`; + getExportPath(controller: Server, project: Project) { + return `http://${controller.host}:${controller.port}/${environment.current_version}/projects/${project.project_id}/export`; } } describe('ImportProjectDialogComponent', () => { let component: ImportProjectDialogComponent; let fixture: ComponentFixture; - let server: Server; + let controller: Server; let debugElement: DebugElement; let fileSelectDirective: FileSelectDirective; let mockedToasterService = new MockedToasterService() @@ -99,16 +99,16 @@ describe('ImportProjectDialogComponent', () => { declarations: [ImportProjectDialogComponent], }).compileComponents(); - server = new Server(); - server.host = 'localhost'; - server.port = 80; + controller = new Server(); + controller.host = 'localhost'; + controller.port = 80; }); beforeEach(() => { fixture = TestBed.createComponent(ImportProjectDialogComponent); debugElement = fixture.debugElement; component = fixture.componentInstance; - component.server = server; + component.controller = controller; component.projectNameForm.controls['projectName'].setValue('ValidName'); fixture.detectChanges(); diff --git a/src/app/components/projects/import-project-dialog/import-project-dialog.component.ts b/src/app/components/projects/import-project-dialog/import-project-dialog.component.ts index b3ffe291..f05edc2c 100644 --- a/src/app/components/projects/import-project-dialog/import-project-dialog.component.ts +++ b/src/app/components/projects/import-project-dialog/import-project-dialog.component.ts @@ -23,7 +23,7 @@ import { MatSnackBar } from '@angular/material/snack-bar'; export class ImportProjectDialogComponent implements OnInit { uploader: FileUploader; uploadProgress: number = 0; - server: Server; + controller: Server; isImportEnabled: boolean = false; isFinishEnabled: boolean = false; isDeleteVisible: boolean = false; @@ -99,7 +99,7 @@ export class ImportProjectDialogComponent implements OnInit { if (this.projectNameForm.invalid) { this.submitted = true; } else { - this.projectService.list(this.server).subscribe((projects: Project[]) => { + this.projectService.list(this.controller).subscribe((projects: Project[]) => { const projectName = this.projectNameForm.controls['projectName'].value; let existingProject = projects.find((project) => project.name === projectName); @@ -115,7 +115,7 @@ export class ImportProjectDialogComponent implements OnInit { importProject() { const url = this.prepareUploadPath(); this.uploader.queue.forEach((elem) => (elem.url = url)); - this.uploader.authToken = `Bearer ${this.server.authToken}` + this.uploader.authToken = `Bearer ${this.controller.authToken}` this.isFirstStepCompleted = true; const itemToUpload = this.uploader.queue[0]; this.uploader.uploadItem(itemToUpload); @@ -136,8 +136,8 @@ export class ImportProjectDialogComponent implements OnInit { dialogRef.afterClosed().subscribe((answer: boolean) => { if (answer) { - this.projectService.close(this.server, existingProject.project_id).subscribe(() => { - this.projectService.delete(this.server, existingProject.project_id).subscribe(() => { + this.projectService.close(this.controller, existingProject.project_id).subscribe(() => { + this.projectService.delete(this.controller, existingProject.project_id).subscribe(() => { this.importProject(); }); }); @@ -164,7 +164,7 @@ export class ImportProjectDialogComponent implements OnInit { prepareUploadPath(): string { this.uuid = uuid(); const projectName = this.projectNameForm.controls['projectName'].value; - return this.projectService.getUploadPath(this.server, this.uuid, projectName); + return this.projectService.getUploadPath(this.controller, this.uuid, projectName); } cancelUploading() { diff --git a/src/app/components/projects/projects.component.html b/src/app/components/projects/projects.component.html index e8d880fe..9bda66c7 100644 --- a/src/app/components/projects/projects.component.html +++ b/src/app/components/projects/projects.component.html @@ -25,7 +25,7 @@ Name - {{ row.name }} + {{ row.name }} diff --git a/src/app/components/projects/projects.component.spec.ts b/src/app/components/projects/projects.component.spec.ts index 37e00e09..f9fc9d77 100644 --- a/src/app/components/projects/projects.component.spec.ts +++ b/src/app/components/projects/projects.component.spec.ts @@ -33,7 +33,7 @@ xdescribe('ProjectsComponent', () => { let settingsService: SettingsService; let projectService: ProjectService; let serverService: ServerService; - let server: Server; + let controller: Server; let progressService: ProgressService; let mockedProjectService: MockedProjectService = new MockedProjectService(); let electronService; @@ -86,12 +86,12 @@ xdescribe('ProjectsComponent', () => { projectService = TestBed.inject(ProjectService); progressService = TestBed.inject(ProgressService); - server = new Server(); - server.id = 99; + controller = new Server(); + controller.id = 99; const settings = {} as Settings; - spyOn(serverService, 'get').and.returnValue(Promise.resolve(server)); + spyOn(serverService, 'get').and.returnValue(Promise.resolve(controller)); spyOn(settingsService, 'getAll').and.returnValue(settings); spyOn(projectService, 'list').and.returnValue(of([])); @@ -136,12 +136,12 @@ describe('ProjectComponent open', () => { spyOn(projectService, 'open').and.returnValue(of(project)); - component.server = server; + component.controller = controller; }); it('should open project', () => { component.open(project); - expect(projectService.open).toHaveBeenCalledWith(server, project.project_id); + expect(projectService.open).toHaveBeenCalledWith(controller, project.project_id); expect(progressService.activate).toHaveBeenCalled(); expect(progressService.deactivate).toHaveBeenCalled(); @@ -157,12 +157,12 @@ describe('ProjectComponent close', () => { spyOn(projectService, 'close').and.returnValue(of(project)); - component.server = server; + component.controller = controller; }); xit('should close project', () => { component.close(project); - expect(projectService.close).toHaveBeenCalledWith(server, project.project_id); + expect(projectService.close).toHaveBeenCalledWith(controller, project.project_id); expect(progressService.activate).toHaveBeenCalled(); expect(progressService.deactivate).toHaveBeenCalled(); diff --git a/src/app/components/projects/projects.component.ts b/src/app/components/projects/projects.component.ts index 09244f4f..28fa208e 100644 --- a/src/app/components/projects/projects.component.ts +++ b/src/app/components/projects/projects.component.ts @@ -26,7 +26,7 @@ import { NavigationDialogComponent } from './navigation-dialog/navigation-dialog styleUrls: ['./projects.component.scss'], }) export class ProjectsComponent implements OnInit { - server: Server; + controller: Server; projectDatabase = new ProjectDatabase(); dataSource: ProjectDataSource; displayedColumns = ['name', 'actions']; @@ -50,9 +50,9 @@ export class ProjectsComponent implements OnInit { ) {} ngOnInit() { - this.server = this.route.snapshot.data['server']; - if (!this.server) this.router.navigate(['/controllers']); - this.recentlyOpenedProjectService.setServerIdProjectList(this.server.id.toString()); + this.controller = this.route.snapshot.data['controller']; + if (!this.controller) this.router.navigate(['/controllers']); + this.recentlyOpenedProjectService.setcontrollerIdProjectList(this.controller.id.toString()); this.refresh(); this.sort.sort({ @@ -67,18 +67,18 @@ export class ProjectsComponent implements OnInit { goToPreferences() { this.router - .navigate(['/controller', this.server.id, 'preferences']) + .navigate(['/controller', this.controller.id, 'preferences']) .catch((error) => this.toasterService.error('Cannot navigate to the preferences')); } goToSystemStatus() { this.router - .navigate(['/controller', this.server.id, 'systemstatus']) + .navigate(['/controller', this.controller.id, 'systemstatus']) .catch((error) => this.toasterService.error('Cannot navigate to the system status')); } refresh() { - this.projectService.list(this.server).subscribe( + this.projectService.list(this.controller).subscribe( (projects: Project[]) => { this.projectDatabase.addProjects(projects); }, @@ -94,7 +94,7 @@ export class ProjectsComponent implements OnInit { bottomSheetRef.instance.message = 'Do you want to delete the project?'; const bottomSheetSubscription = bottomSheetRef.afterDismissed().subscribe((result: boolean) => { if (result) { - this.projectService.delete(this.server, project.project_id).subscribe(() => { + this.projectService.delete(this.controller, project.project_id).subscribe(() => { this.refresh(); }); } @@ -104,7 +104,7 @@ export class ProjectsComponent implements OnInit { open(project: Project) { this.progressService.activate(); - this.projectService.open(this.server, project.project_id).subscribe( + this.projectService.open(this.controller, project.project_id).subscribe( () => { this.refresh(); }, @@ -125,7 +125,7 @@ export class ProjectsComponent implements OnInit { bottomSheetRef.instance.message = 'Do you want to close the project?'; const bottomSheetSubscription = bottomSheetRef.afterDismissed().subscribe((result: boolean) => { if (result) { - this.projectService.close(this.server, project.project_id).subscribe(() => { + this.projectService.close(this.controller, project.project_id).subscribe(() => { this.refresh(); this.progressService.deactivate(); }); @@ -140,7 +140,7 @@ export class ProjectsComponent implements OnInit { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; instance.project = project; dialogRef.afterClosed().subscribe(() => { this.refresh(); @@ -154,7 +154,7 @@ export class ProjectsComponent implements OnInit { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; } importProject() { @@ -165,7 +165,7 @@ export class ProjectsComponent implements OnInit { disableClose: true, }); let instance = dialogRef.componentInstance; - instance.server = this.server; + instance.controller = this.controller; const subscription = dialogRef.componentInstance.onImportProject.subscribe((projectId: string) => { uuid = projectId; }); @@ -180,8 +180,8 @@ export class ProjectsComponent implements OnInit { const bottomSheetSubscription = bottomSheetRef.afterDismissed().subscribe((result: boolean) => { if (result) { - this.projectService.open(this.server, uuid).subscribe(() => { - this.router.navigate(['/controller', this.server.id, 'project', uuid]); + this.projectService.open(this.controller, uuid).subscribe(() => { + this.router.navigate(['/controller', this.controller.id, 'project', uuid]); }); } }); diff --git a/src/app/components/projects/save-project-dialog/save-project-dialog.component.ts b/src/app/components/projects/save-project-dialog/save-project-dialog.component.ts index 3128dfb5..f188101c 100644 --- a/src/app/components/projects/save-project-dialog/save-project-dialog.component.ts +++ b/src/app/components/projects/save-project-dialog/save-project-dialog.component.ts @@ -15,7 +15,7 @@ import { ProjectNameValidator } from '../models/projectNameValidator'; providers: [ProjectNameValidator], }) export class SaveProjectDialogComponent implements OnInit { - server: Server; + controller: Server; project: Project; projectNameForm: FormGroup; onAddProject = new EventEmitter(); @@ -43,7 +43,7 @@ export class SaveProjectDialogComponent implements OnInit { if (this.projectNameForm.invalid) { return; } - this.projectService.list(this.server).subscribe((projects: Project[]) => { + this.projectService.list(this.controller).subscribe((projects: Project[]) => { const projectName = this.projectNameForm.controls['projectName'].value; let existingProject = projects.find((project) => project.name === projectName); @@ -72,7 +72,7 @@ export class SaveProjectDialogComponent implements OnInit { addProject(): void { this.projectService - .duplicate(this.server, this.project.project_id, this.projectNameForm.controls['projectName'].value) + .duplicate(this.controller, this.project.project_id, this.projectNameForm.controls['projectName'].value) .subscribe((project: Project) => { this.dialogRef.close(); this.toasterService.success(`Project ${project.name} added`); diff --git a/src/app/components/settings/console/console.component.html b/src/app/components/settings/console/console.component.html index 185b553e..71fcac48 100644 --- a/src/app/components/settings/console/console.component.html +++ b/src/app/components/settings/console/console.component.html @@ -17,7 +17,7 @@ %s: path of the serial connection
%d: title of the console
%i: Project UUID
- %c: server URL (http://user:password@server:port) + %c: server URL (http://user:password@controller:port)
diff --git a/src/app/components/snapshots/create-snapshot-dialog/create-snapshot-dialog.component.html b/src/app/components/snapshots/create-snapshot-dialog/create-snapshot-dialog.component.html index dbdc41b9..bcd91f6c 100644 --- a/src/app/components/snapshots/create-snapshot-dialog/create-snapshot-dialog.component.html +++ b/src/app/components/snapshots/create-snapshot-dialog/create-snapshot-dialog.component.html @@ -5,7 +5,7 @@ class="top-button" color="accent" (click)="onNoClick()" - routerLink="/controller/{{ server?.id }}/project/{{ project?.project_id }}/snapshots" + routerLink="/controller/{{ controller?.id }}/project/{{ project?.project_id }}/snapshots" > Go to snapshots diff --git a/src/app/components/snapshots/create-snapshot-dialog/create-snapshot-dialog.component.ts b/src/app/components/snapshots/create-snapshot-dialog/create-snapshot-dialog.component.ts index f5b99a8e..ad617cb5 100644 --- a/src/app/components/snapshots/create-snapshot-dialog/create-snapshot-dialog.component.ts +++ b/src/app/components/snapshots/create-snapshot-dialog/create-snapshot-dialog.component.ts @@ -15,7 +15,7 @@ import { ToasterService } from '../../../services/toaster.service'; styleUrls: ['./create-snapshot-dialog.component.scss'], }) export class CreateSnapshotDialogComponent { - server: Server; + controller: Server; project: Project; snapshot: Snapshot = new Snapshot(); inputForm: FormGroup; @@ -30,7 +30,7 @@ export class CreateSnapshotDialogComponent { private nodesDataSource: NodesDataSource, @Inject(MAT_DIALOG_DATA) public data: any ) { - this.server = data['server']; + this.controller = data['controller']; this.project = data['project']; this.inputForm = this.formBuilder.group({ @@ -38,7 +38,7 @@ export class CreateSnapshotDialogComponent { }); if (this.project && this.project.project_id) { - this.snapshotService.list(this.server, this.project.project_id).subscribe((snapshots: Snapshot[]) => { + this.snapshotService.list(this.controller, this.project.project_id).subscribe((snapshots: Snapshot[]) => { snapshots.forEach((snapshot: Snapshot) => { this.snapshots.push(snapshot.name); }); diff --git a/src/app/components/snapshots/list-of-snapshots/list-of-snaphshots.component.spec.ts b/src/app/components/snapshots/list-of-snapshots/list-of-snaphshots.component.spec.ts index 139317ff..223df286 100644 --- a/src/app/components/snapshots/list-of-snapshots/list-of-snaphshots.component.spec.ts +++ b/src/app/components/snapshots/list-of-snapshots/list-of-snaphshots.component.spec.ts @@ -39,7 +39,7 @@ export class MockedActivatedRoute { }, }, data: { - server: new Server(), + controller: new Server(), }, }, }; @@ -47,15 +47,15 @@ export class MockedActivatedRoute { } export class MockedSnapshotService { - public list(server: Server, project_id: string) { + public list(controller: Server, project_id: string) { return of([]); } - public delete(server: Server, project_id: string, snapshot_id: string) { + public delete(controller: Server, project_id: string, snapshot_id: string) { return of({}); } - public restore(server: Server, project_id: string, snapshot_id: string) { + public restore(controller: Server, project_id: string, snapshot_id: string) { return of({}); } } @@ -82,7 +82,7 @@ describe('ListOfSnapshotsComponent', () => { { path: 'controller/:controller_id/project/:project_id/snapshots', component: ListOfSnapshotsComponent, - resolve: { server: ServerResolve }, + resolve: { controller: ServerResolve }, }, ]), ], diff --git a/src/app/components/snapshots/list-of-snapshots/list-of-snapshots.component.ts b/src/app/components/snapshots/list-of-snapshots/list-of-snapshots.component.ts index 274fa223..bff62be1 100644 --- a/src/app/components/snapshots/list-of-snapshots/list-of-snapshots.component.ts +++ b/src/app/components/snapshots/list-of-snapshots/list-of-snapshots.component.ts @@ -15,7 +15,7 @@ import { ToasterService } from '../../../services/toaster.service'; styleUrls: ['./list-of-snapshots.component.scss'], }) export class ListOfSnapshotsComponent implements OnInit { - server: Server; + controller: Server; projectId: string; snapshots: Snapshot[]; displayedColumns = ['name', 'creationDate', 'actions']; @@ -30,18 +30,18 @@ export class ListOfSnapshotsComponent implements OnInit { ngOnInit() { this.projectId = this.route.snapshot.paramMap.get('project_id'); - this.server = this.route.snapshot.data['server']; + this.controller = this.route.snapshot.data['controller']; this.getSnapshots(); } getSnapshots() { - this.snapshotService.list(this.server, this.projectId).subscribe((snapshots: Snapshot[]) => { + this.snapshotService.list(this.controller, this.projectId).subscribe((snapshots: Snapshot[]) => { this.snapshots = snapshots; }); } restoreSnapshot(snapshot: Snapshot) { - const restoring = this.snapshotService.restore(this.server, this.projectId, snapshot.snapshot_id.toString()); + const restoring = this.snapshotService.restore(this.controller, this.projectId, snapshot.snapshot_id.toString()); const progress = this.progressDialogService.open(); const subscription = restoring.subscribe((project: Project) => { this.toaster.success(`Snapshot ${snapshot.name} has been restored.`); @@ -56,7 +56,7 @@ export class ListOfSnapshotsComponent implements OnInit { } deleteSnapshot(snapshot: Snapshot) { - this.snapshotService.delete(this.server, this.projectId, snapshot.snapshot_id.toString()).subscribe(() => { + this.snapshotService.delete(this.controller, this.projectId, snapshot.snapshot_id.toString()).subscribe(() => { this.getSnapshots(); this.toaster.success(`Snapshot ${snapshot.name} has been deleted.`); }); diff --git a/src/app/components/snapshots/snapshot-menu-item/snapshot-menu-item.component.ts b/src/app/components/snapshots/snapshot-menu-item/snapshot-menu-item.component.ts index 2c676594..6e9ffa57 100644 --- a/src/app/components/snapshots/snapshot-menu-item/snapshot-menu-item.component.ts +++ b/src/app/components/snapshots/snapshot-menu-item/snapshot-menu-item.component.ts @@ -16,7 +16,7 @@ import { CreateSnapshotDialogComponent } from '../create-snapshot-dialog/create- }) export class SnapshotMenuItemComponent implements OnInit { @Input('project') project: Project; - @Input('server') server: Server; + @Input('controller') controller: Server; constructor( private dialog: MatDialog, @@ -31,7 +31,7 @@ export class SnapshotMenuItemComponent implements OnInit { const dialogRef = this.dialog.open(CreateSnapshotDialogComponent, { width: '450px', data: { - server: this.server, + controller: this.controller, project: this.project, }, autoFocus: false, @@ -40,7 +40,7 @@ export class SnapshotMenuItemComponent implements OnInit { dialogRef.afterClosed().subscribe((snapshot) => { if (snapshot && this.project.project_id) { - const creation = this.snapshotService.create(this.server, this.project.project_id, snapshot); + const creation = this.snapshotService.create(this.controller, this.project.project_id, snapshot); const progress = this.progressDialogService.open(); diff --git a/src/app/components/system-status/status-info/status-info.component.ts b/src/app/components/system-status/status-info/status-info.component.ts index f704520d..8a432a49 100644 --- a/src/app/components/system-status/status-info/status-info.component.ts +++ b/src/app/components/system-status/status-info/status-info.component.ts @@ -12,7 +12,7 @@ import { ToasterService } from '../../../services/toaster.service'; styleUrls: ['./status-info.component.scss'], }) export class StatusInfoComponent implements OnInit { - public serverId: string = ''; + public controllerId: string = ''; public computeStatistics: ComputeStatistics[] = []; public connectionFailed: boolean; @@ -24,13 +24,13 @@ export class StatusInfoComponent implements OnInit { ) {} ngOnInit() { - this.serverId = this.route.snapshot.paramMap.get('controller_id'); + this.controllerId = this.route.snapshot.paramMap.get('controller_id'); this.getStatistics(); } getStatistics() { - this.serverService.get(Number(this.serverId)).then((server: Server) => { - this.computeService.getStatistics(server).subscribe((statistics: ComputeStatistics[]) => { + this.serverService.get(Number(this.controllerId)).then((controller: Server) => { + this.computeService.getStatistics(controller).subscribe((statistics: ComputeStatistics[]) => { this.computeStatistics = statistics; setTimeout(() => { this.getStatistics(); diff --git a/src/app/components/system-status/system-status.component.ts b/src/app/components/system-status/system-status.component.ts index 2eb65771..9b1ab80c 100644 --- a/src/app/components/system-status/system-status.component.ts +++ b/src/app/components/system-status/system-status.component.ts @@ -7,11 +7,11 @@ import { ActivatedRoute } from '@angular/router'; styleUrls: ['./system-status.component.scss'], }) export class SystemStatusComponent implements OnInit { - public serverId: string = ''; + public controllerId: string = ''; constructor(private route: ActivatedRoute) {} ngOnInit() { - this.serverId = this.route.snapshot.paramMap.get('controller_id'); + this.controllerId = this.route.snapshot.paramMap.get('controller_id'); } } diff --git a/src/app/components/template/template-list-dialog/template-list-dialog.component.ts b/src/app/components/template/template-list-dialog/template-list-dialog.component.ts index a6347fb4..77b4b68d 100644 --- a/src/app/components/template/template-list-dialog/template-list-dialog.component.ts +++ b/src/app/components/template/template-list-dialog/template-list-dialog.component.ts @@ -17,7 +17,7 @@ import { NonNegativeValidator } from '../../../validators/non-negative-validator styleUrls: ['./template-list-dialog.component.scss'], }) export class TemplateListDialogComponent implements OnInit { - server: Server; + controller: Server; project: Project; templateTypes: string[] = [ 'cloud', @@ -49,7 +49,7 @@ export class TemplateListDialogComponent implements OnInit { private toasterService: ToasterService, private nonNegativeValidator: NonNegativeValidator ) { - this.server = data['server']; + this.controller = data['controller']; this.project = data['project']; this.configurationForm = this.formBuilder.group({ numberOfNodes: new FormControl(1, [ Validators.compose([Validators.required, nonNegativeValidator.get])]), @@ -61,7 +61,7 @@ export class TemplateListDialogComponent implements OnInit { } ngOnInit() { - this.templateService.list(this.server).subscribe((listOfTemplates: Template[]) => { + this.templateService.list(this.controller).subscribe((listOfTemplates: Template[]) => { this.filteredTemplates = listOfTemplates; this.templates = listOfTemplates; }); @@ -108,7 +108,7 @@ export class TemplateListDialogComponent implements OnInit { } else { let event: NodeAddedEvent = { template: this.selectedTemplate, - server: this.selectedTemplate.compute_id, + controller: this.selectedTemplate.compute_id, // name: this.configurationForm.get('name').value, numberOfNodes: this.configurationForm.get('numberOfNodes').value, x: x, @@ -122,7 +122,7 @@ export class TemplateListDialogComponent implements OnInit { export interface NodeAddedEvent { template: Template; - server: string; + controller: string; name?: string; numberOfNodes: number; x: number; @@ -136,8 +136,8 @@ export class TemplateDatabase { return this.dataChange.value; } - constructor(private server: Server, private templateService: TemplateService) { - this.templateService.list(this.server).subscribe((templates) => { + constructor(private controller: Server, private templateService: TemplateService) { + this.templateService.list(this.controller).subscribe((templates) => { this.dataChange.next(templates); }); } diff --git a/src/app/components/template/template.component.ts b/src/app/components/template/template.component.ts index abd19ff1..f4bcf0d7 100644 --- a/src/app/components/template/template.component.ts +++ b/src/app/components/template/template.component.ts @@ -18,7 +18,7 @@ import { DomSanitizer } from '@angular/platform-browser'; styleUrls: ['./template.component.scss'], }) export class TemplateComponent implements OnInit, OnDestroy { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Output() onNodeCreation = new EventEmitter(); overlay; @@ -67,12 +67,12 @@ export class TemplateComponent implements OnInit, OnDestroy { this.templates.push(template); }); - this.templateService.list(this.server).subscribe((listOfTemplates: Template[]) => { + this.templateService.list(this.controller).subscribe((listOfTemplates: Template[]) => { this.filteredTemplates = listOfTemplates; this.sortTemplates(); this.templates = listOfTemplates; }); - this.symbolService.list(this.server); + this.symbolService.list(this.controller); if (this.themeService.getActualTheme() === 'light') this.isLightThemeEnabled = true; this.themeSubscription = this.themeService.themeChanged.subscribe((value: string) => { if (value === 'light-theme') this.isLightThemeEnabled = true; @@ -120,13 +120,13 @@ export class TemplateComponent implements OnInit, OnDestroy { } dragEnd(ev, template: Template) { - this.symbolService.raw(this.server, template.symbol.substring(1)).subscribe((symbolSvg: string) => { + this.symbolService.raw(this.controller, template.symbol.substring(1)).subscribe((symbolSvg: string) => { let width = +symbolSvg.split('width="')[1].split('"')[0] ? +symbolSvg.split('width="')[1].split('"')[0] : 0; let scale = this.scaleService.getScale(); let nodeAddedEvent: NodeAddedEvent = { template: template, - server: 'local', + controller: 'local', numberOfNodes: 1, x: (this.startX + ev.x - this.project.scene_width / 2 - width / 2) * scale + window.scrollX, y: (this.startY + ev.y - this.project.scene_height / 2) * scale + window.scrollY, @@ -139,7 +139,7 @@ export class TemplateComponent implements OnInit, OnDestroy { const dialogRef = this.dialog.open(TemplateListDialogComponent, { width: '600px', data: { - server: this.server, + controller: this.controller, project: this.project, }, autoFocus: false, @@ -154,7 +154,7 @@ export class TemplateComponent implements OnInit, OnDestroy { } getImageSourceForTemplate(template: Template) { - return this.symbolService.getSymbolFromTemplate(this.server, template); + return this.symbolService.getSymbolFromTemplate(this.controller, template); // let symbol = this.symbolService.getSymbolFromTemplate(template); // if (symbol) return this.domSanitizer.bypassSecurityTrustUrl(`data:image/svg+xml;base64,${btoa(symbol.raw)}`); // return this.domSanitizer.bypassSecurityTrustUrl('data:image/svg+xml;base64,'); diff --git a/src/app/components/topology-summary/topology-summary.component.spec.ts b/src/app/components/topology-summary/topology-summary.component.spec.ts index c8f099cc..913cdec0 100644 --- a/src/app/components/topology-summary/topology-summary.component.spec.ts +++ b/src/app/components/topology-summary/topology-summary.component.spec.ts @@ -20,7 +20,7 @@ import { MockedLinksDataSource, MockedNodesDataSource } from '../project-map/pro import { TopologySummaryComponent } from './topology-summary.component'; export class MockedComputeService { - getComputes(server: Server) { + getComputes(controller: Server) { return of([]); } } diff --git a/src/app/components/topology-summary/topology-summary.component.ts b/src/app/components/topology-summary/topology-summary.component.ts index 1a98464a..f3202095 100644 --- a/src/app/components/topology-summary/topology-summary.component.ts +++ b/src/app/components/topology-summary/topology-summary.component.ts @@ -19,7 +19,7 @@ import { ThemeService } from '../../services/theme.service'; changeDetection: ChangeDetectionStrategy.Default, }) export class TopologySummaryComponent implements OnInit, OnDestroy { - @Input() server: Server; + @Input() controller: Server; @Input() project: Project; @Output() closeTopologySummary = new EventEmitter(); @@ -59,7 +59,7 @@ export class TopologySummaryComponent implements OnInit, OnDestroy { this.nodes = nodes; this.nodes.forEach((n) => { if (n.console_host === '0.0.0.0' || n.console_host === '0:0:0:0:0:0:0:0' || n.console_host === '::') { - n.console_host = this.server.host; + n.console_host = this.controller.host; } }); if (this.sortingOrder === 'asc') { @@ -70,11 +70,11 @@ export class TopologySummaryComponent implements OnInit, OnDestroy { }) ); - this.projectService.getStatistics(this.server, this.project.project_id).subscribe((stats) => { + this.projectService.getStatistics(this.controller, this.project.project_id).subscribe((stats) => { this.projectsStatistics = stats; }); - this.computeService.getComputes(this.server).subscribe((computes) => { + this.computeService.getComputes(this.controller).subscribe((computes) => { this.computes = computes; }); diff --git a/src/app/components/users/logged-user/logged-user.component.ts b/src/app/components/users/logged-user/logged-user.component.ts index 0c02ad43..d79659e2 100644 --- a/src/app/components/users/logged-user/logged-user.component.ts +++ b/src/app/components/users/logged-user/logged-user.component.ts @@ -13,7 +13,7 @@ import { Server } from '../../../models/server'; }) export class LoggedUserComponent implements OnInit { public user: User; - public server: Server; + public controller: Server; constructor( private route: ActivatedRoute, @@ -23,10 +23,10 @@ export class LoggedUserComponent implements OnInit { ) {} ngOnInit() { - let serverId = this.route.snapshot.paramMap.get('controller_id'); - this.serverService.get(+serverId).then((server: Server) => { - this.server = server; - this.userService.getInformationAboutLoggedUser(server).subscribe((response: any) => { + let controllerId = this.route.snapshot.paramMap.get('controller_id'); + this.serverService.get(+controllerId).then((controller: Server) => { + this.controller = controller; + this.userService.getInformationAboutLoggedUser(controller).subscribe((response: any) => { this.user = response; }); }); @@ -38,7 +38,7 @@ export class LoggedUserComponent implements OnInit { selBox.style.left = '0'; selBox.style.top = '0'; selBox.style.opacity = '0'; - selBox.value = this.server.authToken; + selBox.value = this.controller.authToken; document.body.appendChild(selBox); selBox.focus(); selBox.select(); diff --git a/src/app/components/web-console-full-window/web-console-full-window.component.ts b/src/app/components/web-console-full-window/web-console-full-window.component.ts index 554b3aa5..eb22b0a8 100644 --- a/src/app/components/web-console-full-window/web-console-full-window.component.ts +++ b/src/app/components/web-console-full-window/web-console-full-window.component.ts @@ -18,11 +18,11 @@ import { ServerService } from '../../services/server.service'; styleUrls: ['../../../../node_modules/xterm/css/xterm.css'], }) export class WebConsoleFullWindowComponent implements OnInit { - private serverId: string; + private controllerId: string; private projectId: string; private nodeId: string; private subscriptions: Subscription = new Subscription(); - private server: Server; + private controller: Server; private node: Node; public term: Terminal = new Terminal(); @@ -51,7 +51,7 @@ export class WebConsoleFullWindowComponent implements OnInit { } getData() { - this.serverId = this.route.snapshot.paramMap.get('controller_id'); + this.controllerId = this.route.snapshot.paramMap.get('controller_id'); this.projectId = this.route.snapshot.paramMap.get('project_id'); this.nodeId = this.route.snapshot.paramMap.get('node_id'); @@ -59,9 +59,9 @@ export class WebConsoleFullWindowComponent implements OnInit { this.fitAddon.fit(); }); - this.serverService.get(+this.serverId).then((server: Server) => { - this.server = server; - this.nodeService.getNodeById(this.server, this.projectId, this.nodeId).subscribe((node: Node) => { + this.serverService.get(+this.controllerId).then((controller: Server) => { + this.controller = controller; + this.nodeService.getNodeById(this.controller, this.projectId, this.nodeId).subscribe((node: Node) => { this.node = node; this.title.setTitle(this.node.name); this.openTerminal(); @@ -72,7 +72,7 @@ export class WebConsoleFullWindowComponent implements OnInit { openTerminal() { setTimeout(() => { this.term.open(this.terminal.nativeElement); - const socket = new WebSocket(this.consoleService.getUrl(this.server, this.node)); + const socket = new WebSocket(this.consoleService.getUrl(this.controller, this.node)); socket.onerror = (event) => { this.term.write('Connection lost' + '\r\n'); diff --git a/src/app/filters/authImageFilter.ts b/src/app/filters/authImageFilter.ts index 72f6cbe8..80f2c8d6 100644 --- a/src/app/filters/authImageFilter.ts +++ b/src/app/filters/authImageFilter.ts @@ -15,9 +15,9 @@ export class AuthImageFilter implements PipeTransform { private domSanitizer: DomSanitizer ) { } - async transform(src: string, server: Server) { + async transform(src: string, controller: Server) { let url = src.split(`${environment.current_version}`)[1]; - const imageBlob: Blob = await this.httpServer.getBlob(server, url).toPromise(); + const imageBlob: Blob = await this.httpServer.getBlob(controller, url).toPromise(); const reader = new FileReader(); return new Promise((resolve, reject) => { reader.onloadend = () => resolve(this.domSanitizer.bypassSecurityTrustUrl(reader.result as string)); diff --git a/src/app/guards/login-guard.ts b/src/app/guards/login-guard.ts index e1d56d27..6c92f430 100644 --- a/src/app/guards/login-guard.ts +++ b/src/app/guards/login-guard.ts @@ -11,15 +11,15 @@ export class LoginGuard implements CanActivate { async canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) { const controller_id = next.paramMap.get('controller_id'); this.loginService.controller_id = controller_id; - let server = await this.serverService.get(parseInt(controller_id, 10)); + let controller = await this.serverService.get(parseInt(controller_id, 10)); try { - await this.loginService.getLoggedUser(server); + await this.loginService.getLoggedUser(controller); } catch (e) {} - return this.serverService.get(parseInt(controller_id, 10)).then((server: Server) => { - if (server.authToken && !server.tokenExpired) { + return this.serverService.get(parseInt(controller_id, 10)).then((controller: Server) => { + if (controller.authToken && !controller.tokenExpired) { return true; } - this.router.navigate(['/controller', server.id, 'login'], { queryParams: { returnUrl: state.url } }); + this.router.navigate(['/controller', controller.id, 'login'], { queryParams: { returnUrl: state.url } }); }); } } diff --git a/src/app/layouts/default-layout/default-layout.component.html b/src/app/layouts/default-layout/default-layout.component.html index e1106f2f..0eb6c2e1 100644 --- a/src/app/layouts/default-layout/default-layout.component.html +++ b/src/app/layouts/default-layout/default-layout.component.html @@ -4,11 +4,11 @@ - - diff --git a/src/app/layouts/default-layout/default-layout.component.ts b/src/app/layouts/default-layout/default-layout.component.ts index 18f215f8..2073b94c 100644 --- a/src/app/layouts/default-layout/default-layout.component.ts +++ b/src/app/layouts/default-layout/default-layout.component.ts @@ -26,9 +26,9 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy { serverStatusSubscription: Subscription; shouldStopServersOnClosing = true; - recentlyOpenedServerId: string; + recentlyOpenedcontrollerId: string; recentlyOpenedProjectId: string; - serverIdProjectList: string; + controllerIdProjectList: string; constructor( private electronService: ElectronService, @@ -47,9 +47,9 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy { if (val instanceof NavigationEnd) this.checkIfUserIsLoginPage(); }); - this.recentlyOpenedServerId = this.recentlyOpenedProjectService.getServerId(); + this.recentlyOpenedcontrollerId = this.recentlyOpenedProjectService.getcontrollerId(); this.recentlyOpenedProjectId = this.recentlyOpenedProjectService.getProjectId(); - this.serverIdProjectList = this.recentlyOpenedProjectService.getServerIdProjectList(); + this.controllerIdProjectList = this.recentlyOpenedProjectService.getcontrollerIdProjectList(); this.isInstalledSoftwareAvailable = this.electronService.isElectronApp; @@ -70,16 +70,16 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy { } goToUserInfo() { - let serverId = this.router.url.split("/controller/")[1].split("/")[0]; - this.serverService.get(+serverId).then((server: Server) => { - this.router.navigate(['/controller', server.id, 'loggeduser']); + let controllerId = this.router.url.split("/controller/")[1].split("/")[0]; + this.serverService.get(+controllerId).then((controller: Server) => { + this.router.navigate(['/controller', controller.id, 'loggeduser']); }); } goToDocumentation() { - let serverId = this.router.url.split("/controller/")[1].split("/")[0]; - this.serverService.get(+serverId).then((server: Server) => { - (window as any).open(`http://${server.host}:${server.port}/docs`); + let controllerId = this.router.url.split("/controller/")[1].split("/")[0]; + this.serverService.get(+controllerId).then((controller: Server) => { + (window as any).open(`http://${controller.host}:${controller.port}/docs`); }); } @@ -92,22 +92,22 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy { } logout() { - let serverId = this.router.url.split("/controller/")[1].split("/")[0]; - this.serverService.get(+serverId).then((server: Server) => { - server.authToken = null; - this.serverService.update(server).then(val => this.router.navigate(['/controller', server.id, 'login'])); + let controllerId = this.router.url.split("/controller/")[1].split("/")[0]; + this.serverService.get(+controllerId).then((controller: Server) => { + controller.authToken = null; + this.serverService.update(controller).then(val => this.router.navigate(['/controller', controller.id, 'login'])); }); } listProjects() { this.router - .navigate(['/controller', this.serverIdProjectList, 'projects']) + .navigate(['/controller', this.controllerIdProjectList, 'projects']) .catch((error) => this.toasterService.error('Cannot list projects')); } backToProject() { this.router - .navigate(['/controller', this.recentlyOpenedServerId, 'project', this.recentlyOpenedProjectId]) + .navigate(['/controller', this.recentlyOpenedcontrollerId, 'project', this.recentlyOpenedProjectId]) .catch((error) => this.toasterService.error('Cannot navigate to the last opened project')); } diff --git a/src/app/services/appliances.service.ts b/src/app/services/appliances.service.ts index 96d573fc..4204d332 100644 --- a/src/app/services/appliances.service.ts +++ b/src/app/services/appliances.service.ts @@ -9,19 +9,19 @@ import { HttpServer } from './http-server.service'; export class ApplianceService { constructor(private httpServer: HttpServer) {} - getAppliances(server: Server): Observable { - return this.httpServer.get(server, '/appliances') as Observable; + getAppliances(controller: Server): Observable { + return this.httpServer.get(controller, '/appliances') as Observable; } - getAppliance(server: Server, url): Observable { - return this.httpServer.get(server, url) as Observable; + getAppliance(controller: Server, url): Observable { + return this.httpServer.get(controller, url) as Observable; } - getUploadPath(server: Server, emulator: string, filename: string) { - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/images/upload/${filename}`; + getUploadPath(controller: Server, emulator: string, filename: string) { + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/images/upload/${filename}`; } - updateAppliances(server: Server): Observable { - return this.httpServer.get(server, '/appliances?update=yes') as Observable; + updateAppliances(controller: Server): Observable { + return this.httpServer.get(controller, '/appliances?update=yes') as Observable; } } diff --git a/src/app/services/built-in-templates.service.spec.ts b/src/app/services/built-in-templates.service.spec.ts index 86cd0938..e29b04be 100644 --- a/src/app/services/built-in-templates.service.spec.ts +++ b/src/app/services/built-in-templates.service.spec.ts @@ -14,7 +14,7 @@ describe('BuiltInTemplatesService', () => { let httpClient: HttpClient; let httpTestingController: HttpTestingController; let httpServer: HttpServer; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -25,7 +25,7 @@ describe('BuiltInTemplatesService', () => { httpClient = TestBed.get(HttpClient); httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -50,7 +50,7 @@ describe('BuiltInTemplatesService', () => { template_type: 'cloud', } as CloudTemplate; - service.saveTemplate(server, cloudtemplate).subscribe(); + service.saveTemplate(controller, cloudtemplate).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/1`); expect(req.request.method).toEqual('PUT'); @@ -70,7 +70,7 @@ describe('BuiltInTemplatesService', () => { template_type: 'ethernet_hub', }; - service.saveTemplate(server, ethernethubtemplate).subscribe(); + service.saveTemplate(controller, ethernethubtemplate).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/2`); expect(req.request.method).toEqual('PUT'); @@ -90,7 +90,7 @@ describe('BuiltInTemplatesService', () => { template_type: 'ethernet_hub', }; - service.saveTemplate(server, ethernetswitchtemplate).subscribe(); + service.saveTemplate(controller, ethernetswitchtemplate).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/3`); expect(req.request.method).toEqual('PUT'); @@ -111,7 +111,7 @@ describe('BuiltInTemplatesService', () => { template_type: 'cloud', } as CloudTemplate; - service.addTemplate(server, cloudtemplate).subscribe(); + service.addTemplate(controller, cloudtemplate).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`) expect(req.request.method).toEqual('POST'); @@ -131,7 +131,7 @@ describe('BuiltInTemplatesService', () => { template_type: 'ethernet_hub', }; - service.addTemplate(server, ethernethubtemplate).subscribe(); + service.addTemplate(controller, ethernethubtemplate).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`) expect(req.request.method).toEqual('POST'); @@ -151,7 +151,7 @@ describe('BuiltInTemplatesService', () => { template_type: 'ethernet_hub', }; - service.addTemplate(server, ethernetswitchtemplate).subscribe(); + service.addTemplate(controller, ethernetswitchtemplate).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`) expect(req.request.method).toEqual('POST'); diff --git a/src/app/services/built-in-templates.service.ts b/src/app/services/built-in-templates.service.ts index 56d3a696..b3a6fb8f 100644 --- a/src/app/services/built-in-templates.service.ts +++ b/src/app/services/built-in-templates.service.ts @@ -7,21 +7,21 @@ import { HttpServer } from './http-server.service'; export class BuiltInTemplatesService { constructor(private httpServer: HttpServer) {} - getTemplates(server: Server): Observable { - return this.httpServer.get(server, '/templates') as Observable; + getTemplates(controller: Server): Observable { + return this.httpServer.get(controller, '/templates') as Observable; } - getTemplate(server: Server, template_id: string): Observable { - return this.httpServer.get(server, `/templates/${template_id}`) as Observable; + getTemplate(controller: Server, template_id: string): Observable { + return this.httpServer.get(controller, `/templates/${template_id}`) as Observable; } - addTemplate(server: Server, builtInTemplate: any): Observable { - return this.httpServer.post(server, `/templates`, builtInTemplate) as Observable; + addTemplate(controller: Server, builtInTemplate: any): Observable { + return this.httpServer.post(controller, `/templates`, builtInTemplate) as Observable; } - saveTemplate(server: Server, builtInTemplate: any): Observable { + saveTemplate(controller: Server, builtInTemplate: any): Observable { return this.httpServer.put( - server, + controller, `/templates/${builtInTemplate.template_id}`, builtInTemplate ) as Observable; diff --git a/src/app/services/compute.service.ts b/src/app/services/compute.service.ts index b8234b6d..962a9ca1 100644 --- a/src/app/services/compute.service.ts +++ b/src/app/services/compute.service.ts @@ -10,15 +10,15 @@ import { HttpServer } from './http-server.service'; export class ComputeService { constructor(private httpServer: HttpServer) {} - getComputes(server: Server): Observable { - return this.httpServer.get(server, '/computes') as Observable; + getComputes(controller: Server): Observable { + return this.httpServer.get(controller, '/computes') as Observable; } - getUploadPath(server: Server, emulator: string, filename: string) { - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/${emulator}/images/${filename}`; + getUploadPath(controller: Server, emulator: string, filename: string) { + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/${emulator}/images/${filename}`; } - getStatistics(server: Server): Observable { - return this.httpServer.get(server, `/statistics`); + getStatistics(controller: Server): Observable { + return this.httpServer.get(controller, `/statistics`); } } diff --git a/src/app/services/docker.service.ts b/src/app/services/docker.service.ts index eaf9b26d..0f782bb2 100644 --- a/src/app/services/docker.service.ts +++ b/src/app/services/docker.service.ts @@ -10,25 +10,25 @@ import { HttpServer } from './http-server.service'; export class DockerService { constructor(private httpServer: HttpServer) {} - getTemplates(server: Server): Observable { - return this.httpServer.get(server, '/templates') as Observable; + getTemplates(controller: Server): Observable { + return this.httpServer.get(controller, '/templates') as Observable; } - getTemplate(server: Server, template_id: string): Observable { - return this.httpServer.get(server, `/templates/${template_id}`) as Observable; + getTemplate(controller: Server, template_id: string): Observable { + return this.httpServer.get(controller, `/templates/${template_id}`) as Observable; } - getImages(server: Server): Observable { - return this.httpServer.get(server, `/computes/${environment.compute_id}/docker/images`) as Observable; + getImages(controller: Server): Observable { + return this.httpServer.get(controller, `/computes/${environment.compute_id}/docker/images`) as Observable; } - addTemplate(server: Server, dockerTemplate: any): Observable { - return this.httpServer.post(server, `/templates`, dockerTemplate) as Observable; + addTemplate(controller: Server, dockerTemplate: any): Observable { + return this.httpServer.post(controller, `/templates`, dockerTemplate) as Observable; } - saveTemplate(server: Server, dockerTemplate: any): Observable { + saveTemplate(controller: Server, dockerTemplate: any): Observable { return this.httpServer.put( - server, + controller, `/templates/${dockerTemplate.template_id}`, dockerTemplate ) as Observable; diff --git a/src/app/services/drawing.service.spec.ts b/src/app/services/drawing.service.spec.ts index d470a6a4..b6bc27c8 100644 --- a/src/app/services/drawing.service.spec.ts +++ b/src/app/services/drawing.service.spec.ts @@ -15,7 +15,7 @@ describe('DrawingService', () => { let httpClient: HttpClient; let httpTestingController: HttpTestingController; let httpServer: HttpServer; - let server: Server; + let controller: Server; let project: Project = new Project(); beforeEach(() => { @@ -27,7 +27,7 @@ describe('DrawingService', () => { httpClient = TestBed.get(HttpClient); httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -43,7 +43,7 @@ describe('DrawingService', () => { drawing.project_id = 'myproject'; drawing.drawing_id = 'id'; - service.updatePosition(server, project, drawing, 10, 20).subscribe(); + service.updatePosition(controller, project, drawing, 10, 20).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('PUT'); @@ -58,7 +58,7 @@ describe('DrawingService', () => { drawing.project_id = 'myproject'; drawing.drawing_id = 'id'; - service.updatePosition(server, project, drawing, 10.1, 20.6).subscribe(); + service.updatePosition(controller, project, drawing, 10.1, 20.6).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('PUT'); @@ -74,7 +74,7 @@ describe('DrawingService', () => { drawing.drawing_id = 'id'; let svgSample = ''; - service.updateSizeAndPosition(server, drawing, 100, 100, svgSample).subscribe(); + service.updateSizeAndPosition(controller, drawing, 100, 100, svgSample).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('PUT'); @@ -93,7 +93,7 @@ describe('DrawingService', () => { drawing.drawing_id = 'id'; let svgSample = ''; - service.updateSizeAndPosition(server, drawing, 100.1, 100.6, svgSample).subscribe(); + service.updateSizeAndPosition(controller, drawing, 100.1, 100.6, svgSample).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('PUT'); @@ -116,7 +116,7 @@ describe('DrawingService', () => { drawing.svg = ''; drawing.locked = false; - service.update(server, drawing).subscribe(); + service.update(controller, drawing).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('PUT'); @@ -135,7 +135,7 @@ describe('DrawingService', () => { drawing.project_id = 'myproject'; drawing.drawing_id = 'id'; - service.delete(server, drawing).subscribe(); + service.delete(controller, drawing).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('DELETE'); @@ -152,7 +152,7 @@ describe('DrawingService', () => { drawing.svg = ''; - service.duplicate(server, drawing.project_id, drawing).subscribe(); + service.duplicate(controller, drawing.project_id, drawing).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/${drawing.project_id}/drawings`); expect(req.request.method).toEqual('POST'); diff --git a/src/app/services/drawing.service.ts b/src/app/services/drawing.service.ts index 8a422996..bfef6a05 100644 --- a/src/app/services/drawing.service.ts +++ b/src/app/services/drawing.service.ts @@ -11,8 +11,8 @@ import { HttpServer } from './http-server.service'; export class DrawingService { constructor(private httpServer: HttpServer, private svgToDrawingConverter: SvgToDrawingConverter) {} - add(server: Server, project_id: string, x: number, y: number, svg: string) { - return this.httpServer.post(server, `/projects/${project_id}/drawings`, { + add(controller: Server, project_id: string, x: number, y: number, svg: string) { + return this.httpServer.post(controller, `/projects/${project_id}/drawings`, { svg: svg, x: Math.round(x), y: Math.round(y), @@ -20,8 +20,8 @@ export class DrawingService { }); } - duplicate(server: Server, project_id: string, drawing: Drawing) { - return this.httpServer.post(server, `/projects/${project_id}/drawings`, { + duplicate(controller: Server, project_id: string, drawing: Drawing) { + return this.httpServer.post(controller, `/projects/${project_id}/drawings`, { svg: drawing.svg, rotation: drawing.rotation, x: drawing.x + 10, @@ -30,7 +30,7 @@ export class DrawingService { }); } - updatePosition(server: Server, project: Project, drawing: Drawing, x: number, y: number): Observable { + updatePosition(controller: Server, project: Project, drawing: Drawing, x: number, y: number): Observable { let xPosition: number = Math.round(x); let yPosition: number = Math.round(y); @@ -46,22 +46,22 @@ export class DrawingService { yPosition = Math.round(yPosition - drawing.element.height / 2); } - return this.httpServer.put(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, { + return this.httpServer.put(controller, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, { x: xPosition, y: yPosition, }); } - updateSizeAndPosition(server: Server, drawing: Drawing, x: number, y: number, svg: string): Observable { - return this.httpServer.put(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, { + updateSizeAndPosition(controller: Server, drawing: Drawing, x: number, y: number, svg: string): Observable { + return this.httpServer.put(controller, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, { svg: svg, x: Math.round(x), y: Math.round(y), }); } - updateText(server: Server, drawing: Drawing, svg: string): Observable { - return this.httpServer.put(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, { + updateText(controller: Server, drawing: Drawing, svg: string): Observable { + return this.httpServer.put(controller, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, { svg: svg, x: Math.round(drawing.x), y: Math.round(drawing.y), @@ -69,8 +69,8 @@ export class DrawingService { }); } - update(server: Server, drawing: Drawing): Observable { - return this.httpServer.put(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, { + update(controller: Server, drawing: Drawing): Observable { + return this.httpServer.put(controller, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, { locked: drawing.locked, svg: drawing.svg, rotation: drawing.rotation, @@ -80,7 +80,7 @@ export class DrawingService { }); } - delete(server: Server, drawing: Drawing) { - return this.httpServer.delete(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`); + delete(controller: Server, drawing: Drawing) { + return this.httpServer.delete(controller, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`); } } diff --git a/src/app/services/http-server.service.spec.ts b/src/app/services/http-server.service.spec.ts index 12d17859..6b76da90 100644 --- a/src/app/services/http-server.service.spec.ts +++ b/src/app/services/http-server.service.spec.ts @@ -55,7 +55,7 @@ describe('HttpServer', () => { let httpClient: HttpClient; let httpTestingController: HttpTestingController; let service: HttpServer; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -67,7 +67,7 @@ describe('HttpServer', () => { httpTestingController = TestBed.get(HttpTestingController); service = TestBed.get(HttpServer); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -75,7 +75,7 @@ describe('HttpServer', () => { }); it('should make GET query for get method', () => { - service.get(server, '/test').subscribe(); + service.get(controller, '/test').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('GET'); @@ -85,7 +85,7 @@ describe('HttpServer', () => { it('should make GET query for get method and return instance of type', () => { const testData: MyType = { id: 3 }; - service.get(server, '/test').subscribe((data) => { + service.get(controller, '/test').subscribe((data) => { expect(data instanceof MyType).toBeFalsy(); expect(data).toEqual(testData); }); @@ -114,7 +114,7 @@ describe('HttpServer', () => { }); it('should make GET query for getText method', () => { - service.getText(server, '/test').subscribe(); + service.getText(controller, '/test').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('GET'); @@ -123,7 +123,7 @@ describe('HttpServer', () => { it('should make GET query for getText method and preserve options', () => { service - .getText(server, '/test', { + .getText(controller, '/test', { headers: { CustomHeader: 'value', }, @@ -137,7 +137,7 @@ describe('HttpServer', () => { }); it('should make POST query for post method', () => { - service.post(server, '/test', { test: '1' }).subscribe(); + service.post(controller, '/test', { test: '1' }).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('POST'); @@ -145,7 +145,7 @@ describe('HttpServer', () => { }); it('should make PUT query for put method', () => { - service.put(server, '/test', { test: '1' }).subscribe(); + service.put(controller, '/test', { test: '1' }).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('PUT'); @@ -153,7 +153,7 @@ describe('HttpServer', () => { }); it('should make DELETE query for delete method', () => { - service.delete(server, '/test').subscribe(); + service.delete(controller, '/test').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('DELETE'); @@ -161,7 +161,7 @@ describe('HttpServer', () => { }); it('should make PATCH query for patch method', () => { - service.patch(server, '/test', { test: '1' }).subscribe(); + service.patch(controller, '/test', { test: '1' }).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('PATCH'); @@ -169,7 +169,7 @@ describe('HttpServer', () => { }); it('should make HEAD query for head method', () => { - service.head(server, '/test').subscribe(); + service.head(controller, '/test').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('HEAD'); @@ -177,7 +177,7 @@ describe('HttpServer', () => { }); it('should make OPTIONS query for options method', () => { - service.options(server, '/test').subscribe(); + service.options(controller, '/test').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('OPTIONS'); @@ -185,11 +185,11 @@ describe('HttpServer', () => { }); it('should make local call when ip and port is not defined', () => { - server.host = null; - server.port = null; + controller.host = null; + controller.port = null; service - .get(server, '/test', { + .get(controller, '/test', { headers: { CustomHeader: 'value', }, diff --git a/src/app/services/http-server.service.ts b/src/app/services/http-server.service.ts index 5668c286..9d32f259 100644 --- a/src/app/services/http-server.service.ts +++ b/src/app/services/http-server.service.ts @@ -103,9 +103,9 @@ export class HttpServer { constructor(private http: HttpClient, private errorHandler: ServerErrorHandler) {} - get(server: Server, url: string, options?: JsonOptions): Observable { + get(controller: Server, url: string, options?: JsonOptions): Observable { options = this.getJsonOptions(options); - const intercepted = this.getOptionsForServer(server, url, options); + const intercepted = this.getOptionsForServer(controller, url, options); this.requestsNotificationEmitter.emit(`GET ${intercepted.url}`); return this.http @@ -113,9 +113,9 @@ export class HttpServer { .pipe(catchError(this.errorHandler.handleError)) as Observable; } - getText(server: Server, url: string, options?: TextOptions): Observable { + getText(controller: Server, url: string, options?: TextOptions): Observable { options = this.getTextOptions(options); - const intercepted = this.getOptionsForServer(server, url, options); + const intercepted = this.getOptionsForServer(controller, url, options); this.requestsNotificationEmitter.emit(`GET ${intercepted.url}`); return this.http @@ -123,9 +123,9 @@ export class HttpServer { .pipe(catchError(this.errorHandler.handleError)); } - getBlob(server: Server, url: string, options?: BlobOptions): Observable { + getBlob(controller: Server, url: string, options?: BlobOptions): Observable { options = this.getBlobOptions(options); - const intercepted = this.getOptionsForServer(server, url, options); + const intercepted = this.getOptionsForServer(controller, url, options); this.requestsNotificationEmitter.emit(`GET ${intercepted.url}`); return this.http @@ -133,9 +133,9 @@ export class HttpServer { .pipe(catchError(this.errorHandler.handleError)); } - post(server: Server, url: string, body: any | null, options?: JsonOptions): Observable { + post(controller: Server, url: string, body: any | null, options?: JsonOptions): Observable { options = this.getJsonOptions(options); - const intercepted = this.getOptionsForServer(server, url, options); + const intercepted = this.getOptionsForServer(controller, url, options); this.requestsNotificationEmitter.emit(`POST ${intercepted.url}`); return this.http @@ -143,9 +143,9 @@ export class HttpServer { .pipe(catchError(this.errorHandler.handleError)) as Observable; } - put(server: Server, url: string, body: any, options?: JsonOptions): Observable { + put(controller: Server, url: string, body: any, options?: JsonOptions): Observable { options = this.getJsonOptions(options); - const intercepted = this.getOptionsForServer(server, url, options); + const intercepted = this.getOptionsForServer(controller, url, options); this.requestsNotificationEmitter.emit(`PUT ${intercepted.url}`); return this.http @@ -153,9 +153,9 @@ export class HttpServer { .pipe(catchError(this.errorHandler.handleError)) as Observable; } - delete(server: Server, url: string, options?: JsonOptions): Observable { + delete(controller: Server, url: string, options?: JsonOptions): Observable { options = this.getJsonOptions(options); - const intercepted = this.getOptionsForServer(server, url, options); + const intercepted = this.getOptionsForServer(controller, url, options); this.requestsNotificationEmitter.emit(`DELETE ${intercepted.url}`); return this.http @@ -163,25 +163,25 @@ export class HttpServer { .pipe(catchError(this.errorHandler.handleError)) as Observable; } - patch(server: Server, url: string, body: any, options?: JsonOptions): Observable { + patch(controller: Server, url: string, body: any, options?: JsonOptions): Observable { options = this.getJsonOptions(options); - const intercepted = this.getOptionsForServer(server, url, options); + const intercepted = this.getOptionsForServer(controller, url, options); return this.http .patch(intercepted.url, body, intercepted.options) .pipe(catchError(this.errorHandler.handleError)) as Observable; } - head(server: Server, url: string, options?: JsonOptions): Observable { + head(controller: Server, url: string, options?: JsonOptions): Observable { options = this.getJsonOptions(options); - const intercepted = this.getOptionsForServer(server, url, options); + const intercepted = this.getOptionsForServer(controller, url, options); return this.http .head(intercepted.url, intercepted.options) .pipe(catchError(this.errorHandler.handleError)) as Observable; } - options(server: Server, url: string, options?: JsonOptions): Observable { + options(controller: Server, url: string, options?: JsonOptions): Observable { options = this.getJsonOptions(options); - const intercepted = this.getOptionsForServer(server, url, options); + const intercepted = this.getOptionsForServer(controller, url, options); return this.http .options(intercepted.url, intercepted.options) .pipe(catchError(this.errorHandler.handleError)) as Observable; @@ -214,12 +214,12 @@ export class HttpServer { return options; } - private getOptionsForServer(server: Server, url: string, options: T) { - if (server && server.host && server.port) { - if (!server.protocol) { - server.protocol = location.protocol as ServerProtocol; + private getOptionsForServer(controller: Server, url: string, options: T) { + if (controller && controller.host && controller.port) { + if (!controller.protocol) { + controller.protocol = location.protocol as ServerProtocol; } - url = `${server.protocol}//${server.host}:${server.port}/${environment.current_version}${url}`; + url = `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}${url}`; } else { url = `/${environment.current_version}${url}`; } @@ -228,8 +228,8 @@ export class HttpServer { options.headers = {}; } - if (server && server.authToken && !server.tokenExpired) { - options.headers['Authorization'] = `Bearer ${server.authToken}`; + if (controller && controller.authToken && !controller.tokenExpired) { + options.headers['Authorization'] = `Bearer ${controller.authToken}`; } return { diff --git a/src/app/services/image-manager.service.spec.ts b/src/app/services/image-manager.service.spec.ts index 4b02887d..4f59d9f0 100644 --- a/src/app/services/image-manager.service.spec.ts +++ b/src/app/services/image-manager.service.spec.ts @@ -14,7 +14,7 @@ describe('ImageManagerService', () => { let httpClient: HttpClient; let httpTestingController: HttpTestingController; let httpServer: HttpServer; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -25,7 +25,7 @@ describe('ImageManagerService', () => { httpClient = TestBed.get(HttpClient); httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); - server = getTestServer(); + controller = getTestServer(); // service = TestBed.inject(ImageManagerService); }); afterEach(() => { @@ -34,7 +34,7 @@ describe('ImageManagerService', () => { it('should be get Images', inject([ImageManagerService], (service: ImageManagerService) => { - service.getImages(server).subscribe(); + service.getImages(controller).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/images`); expect(req.request.method).toEqual('GET'); expect(service).toBeTruthy(); @@ -53,7 +53,7 @@ describe('ImageManagerService', () => { updated_at: '', }; - service.uploadedImage(server, install_appliance, image.filename, image).subscribe(); + service.uploadedImage(controller, install_appliance, image.filename, image).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/images/upload/?install_appliances=true`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual(image); diff --git a/src/app/services/image-manager.service.ts b/src/app/services/image-manager.service.ts index 9c210b6f..242fba68 100644 --- a/src/app/services/image-manager.service.ts +++ b/src/app/services/image-manager.service.ts @@ -12,22 +12,22 @@ export class ImageManagerService { constructor(private httpServer: HttpServer) { } - getImages(server: Server) { - return this.httpServer.get(server, '/images') as Observable; + getImages(controller: Server) { + return this.httpServer.get(controller, '/images') as Observable; } - getImagePath(server:Server, install_appliance, image_path){ - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/images/upload/${image_path}?install_appliances=${install_appliance}`; + getImagePath(controller:Server, install_appliance, image_path){ + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/images/upload/${image_path}?install_appliances=${install_appliance}`; } - getUploadPath(server: Server, emulator: string, filename: string) { - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/images/upload/${filename}`; + getUploadPath(controller: Server, emulator: string, filename: string) { + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/images/upload/${filename}`; } - uploadedImage(server:Server, install_appliance, image_path, flie){ - return this.httpServer.post(server, `/images/upload/${image_path}?install_appliances=${install_appliance}`,flie) as Observable; + uploadedImage(controller:Server, install_appliance, image_path, flie){ + return this.httpServer.post(controller, `/images/upload/${image_path}?install_appliances=${install_appliance}`,flie) as Observable; } - deleteFile(server:Server, image_path){ - return this.httpServer.delete(server, `/images/${image_path}`) as Observable; + deleteFile(controller:Server, image_path){ + return this.httpServer.delete(controller, `/images/${image_path}`) as Observable; } } diff --git a/src/app/services/info.service.ts b/src/app/services/info.service.ts index 4ebb966c..38713e0c 100644 --- a/src/app/services/info.service.ts +++ b/src/app/services/info.service.ts @@ -5,7 +5,7 @@ import { Server } from '../models/server'; @Injectable() export class InfoService { - getInfoAboutNode(node: Node, server: Server): string[] { + getInfoAboutNode(node: Node, controller: Server): string[] { let infoList: string[] = []; if (node.node_type === 'cloud') { infoList.push(`Cloud ${node.name} is always on.`); @@ -34,8 +34,8 @@ export class InfoService { } else if (node.node_type === 'vpcs') { infoList.push(`Node ${node.name} is ${node.status}.`); } - infoList.push(`Running on server ${server.name} with port ${server.port}.`); - infoList.push(`Server ID is ${server.id}.`); + infoList.push(`Running on controller ${controller.name} with port ${controller.port}.`); + infoList.push(`Server ID is ${controller.id}.`); if (node.console_type !== 'none' && node.console_type !== 'null') { infoList.push(`Console is on port ${node.console} and type is ${node.console_type}.`); } diff --git a/src/app/services/ios.service.ts b/src/app/services/ios.service.ts index 1d6e8e58..364d7ec9 100644 --- a/src/app/services/ios.service.ts +++ b/src/app/services/ios.service.ts @@ -10,29 +10,29 @@ import { HttpServer } from './http-server.service'; export class IosService { constructor(private httpServer: HttpServer) {} - getImages(server: Server): Observable { - return this.httpServer.get(server, '/images?image_type=ios') as Observable; + getImages(controller: Server): Observable { + return this.httpServer.get(controller, '/images?image_type=ios') as Observable; } - getImagePath(server: Server, filename: string): string { - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/images/upload/${filename}`; + getImagePath(controller: Server, filename: string): string { + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/images/upload/${filename}`; } - getTemplates(server: Server): Observable { - return this.httpServer.get(server, '/templates') as Observable; + getTemplates(controller: Server): Observable { + return this.httpServer.get(controller, '/templates') as Observable; } - getTemplate(server: Server, template_id: string): Observable { - return this.httpServer.get(server, `/templates/${template_id}`) as Observable; + getTemplate(controller: Server, template_id: string): Observable { + return this.httpServer.get(controller, `/templates/${template_id}`) as Observable; } - addTemplate(server: Server, iosTemplate: IosTemplate): Observable { - return this.httpServer.post(server, `/templates`, iosTemplate) as Observable; + addTemplate(controller: Server, iosTemplate: IosTemplate): Observable { + return this.httpServer.post(controller, `/templates`, iosTemplate) as Observable; } - saveTemplate(server: Server, iosTemplate: IosTemplate): Observable { + saveTemplate(controller: Server, iosTemplate: IosTemplate): Observable { return this.httpServer.put( - server, + controller, `/templates/${iosTemplate.template_id}`, iosTemplate ) as Observable; diff --git a/src/app/services/iou.service.ts b/src/app/services/iou.service.ts index b1675e22..9e87ec50 100644 --- a/src/app/services/iou.service.ts +++ b/src/app/services/iou.service.ts @@ -10,29 +10,29 @@ import { HttpServer } from './http-server.service'; export class IouService { constructor(private httpServer: HttpServer) {} - getTemplates(server: Server): Observable { - return this.httpServer.get(server, '/templates') as Observable; + getTemplates(controller: Server): Observable { + return this.httpServer.get(controller, '/templates') as Observable; } - getTemplate(server: Server, template_id: string): Observable { - return this.httpServer.get(server, `/templates/${template_id}`) as Observable; + getTemplate(controller: Server, template_id: string): Observable { + return this.httpServer.get(controller, `/templates/${template_id}`) as Observable; } - getImages(server: Server): Observable { - return this.httpServer.get(server, '/images?image_type=iou') as Observable; + getImages(controller: Server): Observable { + return this.httpServer.get(controller, '/images?image_type=iou') as Observable; } - getImagePath(server: Server, filename: string): string { - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/images/upload/${filename}`; + getImagePath(controller: Server, filename: string): string { + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/images/upload/${filename}`; } - addTemplate(server: Server, iouTemplate: any): Observable { - return this.httpServer.post(server, `/templates`, iouTemplate) as Observable; + addTemplate(controller: Server, iouTemplate: any): Observable { + return this.httpServer.post(controller, `/templates`, iouTemplate) as Observable; } - saveTemplate(server: Server, iouTemplate: any): Observable { + saveTemplate(controller: Server, iouTemplate: any): Observable { return this.httpServer.put( - server, + controller, `/templates/${iouTemplate.template_id}`, iouTemplate ) as Observable; diff --git a/src/app/services/link.service.spec.ts b/src/app/services/link.service.spec.ts index a4cc5e8d..17e2bd27 100644 --- a/src/app/services/link.service.spec.ts +++ b/src/app/services/link.service.spec.ts @@ -14,7 +14,7 @@ describe('LinkService', () => { let httpClient: HttpClient; let httpTestingController: HttpTestingController; let httpServer: HttpServer; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -25,7 +25,7 @@ describe('LinkService', () => { httpClient = TestBed.get(HttpClient); httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -52,7 +52,7 @@ describe('LinkService', () => { targetPort.port_number = 3; targetPort.adapter_number = 4; - service.createLink(server, sourceNode, sourcePort, targetNode, targetPort, 0, 0, 10, 10).subscribe(); + service.createLink(controller, sourceNode, sourcePort, targetNode, targetPort, 0, 0, 10, 10).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/links`); expect(req.request.method).toEqual('POST'); diff --git a/src/app/services/link.service.ts b/src/app/services/link.service.ts index 17e722b9..a0590b59 100644 --- a/src/app/services/link.service.ts +++ b/src/app/services/link.service.ts @@ -14,7 +14,7 @@ export class LinkService { constructor(private httpServer: HttpServer) {} createLink( - server: Server, + controller: Server, source_node: Node, source_port: Port, target_node: Node, @@ -24,7 +24,7 @@ export class LinkService { xLabelTargetNode: number, yLabelTargetNode: number ) { - return this.httpServer.post(server, `/projects/${source_node.project_id}/links`, { + return this.httpServer.post(controller, `/projects/${source_node.project_id}/links`, { nodes: [ { node_id: source_node.node_id, @@ -54,33 +54,33 @@ export class LinkService { }); } - getLink(server: Server, projectId: string, linkId: string) { - return this.httpServer.get(server, `/projects/${projectId}/links/${linkId}`); + getLink(controller: Server, projectId: string, linkId: string) { + return this.httpServer.get(controller, `/projects/${projectId}/links/${linkId}`); } - deleteLink(server: Server, link: Link) { - return this.httpServer.delete(server, `/projects/${link.project_id}/links/${link.link_id}`); + deleteLink(controller: Server, link: Link) { + return this.httpServer.delete(controller, `/projects/${link.project_id}/links/${link.link_id}`); } - updateLink(server: Server, link: Link) { + updateLink(controller: Server, link: Link) { link.x = Math.round(link.x); link.y = Math.round(link.y); - return this.httpServer.put(server, `/projects/${link.project_id}/links/${link.link_id}`, link); + return this.httpServer.put(controller, `/projects/${link.project_id}/links/${link.link_id}`, link); } - updateLinkStyle(server: Server, link: Link) { - return this.httpServer.put(server, `/projects/${link.project_id}/links/${link.link_id}`, link); + updateLinkStyle(controller: Server, link: Link) { + return this.httpServer.put(controller, `/projects/${link.project_id}/links/${link.link_id}`, link); } - getAvailableFilters(server: Server, link: Link) { + getAvailableFilters(controller: Server, link: Link) { return this.httpServer.get( - server, + controller, `/projects/${link.project_id}/links/${link.link_id}/available_filters` ); } - updateNodes(server: Server, link: Link, nodes: LinkNode[]) { + updateNodes(controller: Server, link: Link, nodes: LinkNode[]) { const requestNodes = nodes.map((linkNode) => { return { node_id: linkNode.node_id, @@ -96,22 +96,22 @@ export class LinkService { }; }); - return this.httpServer.put(server, `/projects/${link.project_id}/links/${link.link_id}`, { nodes: requestNodes }); + return this.httpServer.put(controller, `/projects/${link.project_id}/links/${link.link_id}`, { nodes: requestNodes }); } - startCaptureOnLink(server: Server, link: Link, settings: CapturingSettings) { - return this.httpServer.post(server, `/projects/${link.project_id}/links/${link.link_id}/capture/start`, settings); + startCaptureOnLink(controller: Server, link: Link, settings: CapturingSettings) { + return this.httpServer.post(controller, `/projects/${link.project_id}/links/${link.link_id}/capture/start`, settings); } - stopCaptureOnLink(server: Server, link: Link) { - return this.httpServer.post(server, `/projects/${link.project_id}/links/${link.link_id}/capture/stop`, {}); + stopCaptureOnLink(controller: Server, link: Link) { + return this.httpServer.post(controller, `/projects/${link.project_id}/links/${link.link_id}/capture/stop`, {}); } - resetLink(server: Server, link: Link) { - return this.httpServer.post(server, `/projects/${link.project_id}/links/${link.link_id}/reset`, {}); + resetLink(controller: Server, link: Link) { + return this.httpServer.post(controller, `/projects/${link.project_id}/links/${link.link_id}/reset`, {}); } - streamPcap(server: Server, link: Link) { - return this.httpServer.get(server, `/projects/${link.project_id}/links/${link.link_id}/capture/stream`); + streamPcap(controller: Server, link: Link) { + return this.httpServer.get(controller, `/projects/${link.project_id}/links/${link.link_id}/capture/stream`); } } diff --git a/src/app/services/login.service.ts b/src/app/services/login.service.ts index c9a006f3..5ceb64bc 100644 --- a/src/app/services/login.service.ts +++ b/src/app/services/login.service.ts @@ -10,7 +10,7 @@ export class LoginService { controller_id:string ='' constructor(private httpServer: HttpServer) {} - login(server: Server, username: string, password: string) { + login(controller: Server, username: string, password: string) { const payload = new HttpParams() .set('username', username) .set('password', password); @@ -19,13 +19,13 @@ export class LoginService { headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded') }; - return this.httpServer.post(server, '/users/login', payload, options); + return this.httpServer.post(controller, '/users/login', payload, options); } - getLoggedUser(server: Server) { - return this.httpServer.get(server, "/users/me").toPromise() + getLoggedUser(controller: Server) { + return this.httpServer.get(controller, "/users/me").toPromise() } - async getLoggedUserRefToken(server: Server,current_user):Promise { - return await this.httpServer.post(server, "/users/authenticate", {"username":current_user.username,"password":current_user.password}).toPromise() + async getLoggedUserRefToken(controller: Server,current_user):Promise { + return await this.httpServer.post(controller, "/users/authenticate", {"username":current_user.username,"password":current_user.password}).toPromise() } } diff --git a/src/app/services/node.service.spec.ts b/src/app/services/node.service.spec.ts index 7760fc7b..d88f8034 100644 --- a/src/app/services/node.service.spec.ts +++ b/src/app/services/node.service.spec.ts @@ -17,7 +17,7 @@ describe('NodeService', () => { let httpTestingController: HttpTestingController; let httpServer: HttpServer; let service: NodeService; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -32,7 +32,7 @@ describe('NodeService', () => { httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); service = TestBed.get(NodeService); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -48,7 +48,7 @@ describe('NodeService', () => { node.project_id = 'myproject'; node.node_id = 'id'; - service.start(server, node).subscribe(); + service.start(controller, node).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id/start`); expect(req.request.method).toEqual('POST'); @@ -60,7 +60,7 @@ describe('NodeService', () => { node.project_id = 'myproject'; node.node_id = 'id'; - service.stop(server, node).subscribe(); + service.stop(controller, node).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id/stop`); expect(req.request.method).toEqual('POST'); @@ -72,7 +72,7 @@ describe('NodeService', () => { node.project_id = 'myproject'; node.node_id = 'id'; - service.suspend(server, node).subscribe(); + service.suspend(controller, node).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id/suspend`); expect(req.request.method).toEqual('POST'); @@ -84,7 +84,7 @@ describe('NodeService', () => { node.project_id = 'myproject'; node.node_id = 'id'; - service.reload(server, node).subscribe(); + service.reload(controller, node).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id/reload`); expect(req.request.method).toEqual('POST'); @@ -96,7 +96,7 @@ describe('NodeService', () => { project_id: '1', } as Project; - service.startAll(server, project).subscribe(); + service.startAll(controller, project).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/1/nodes/start`); expect(req.request.method).toEqual('POST'); @@ -108,7 +108,7 @@ describe('NodeService', () => { project_id: '1', } as Project; - service.stopAll(server, project).subscribe(); + service.stopAll(controller, project).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/1/nodes/stop`); expect(req.request.method).toEqual('POST'); @@ -120,7 +120,7 @@ describe('NodeService', () => { project_id: '1', } as Project; - service.suspendAll(server, project).subscribe(); + service.suspendAll(controller, project).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/1/nodes/suspend`); expect(req.request.method).toEqual('POST'); @@ -132,7 +132,7 @@ describe('NodeService', () => { project_id: '1', } as Project; - service.reloadAll(server, project).subscribe(); + service.reloadAll(controller, project).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/1/nodes/reload`); expect(req.request.method).toEqual('POST'); @@ -145,7 +145,7 @@ describe('NodeService', () => { const template = new Template(); template.template_id = 'mytemplate'; - service.createFromTemplate(server, project, template, 10, 20, 'compute').subscribe(); + service.createFromTemplate(controller, project, template, 10, 20, 'compute').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/templates/mytemplate`); expect(req.request.method).toEqual('POST'); @@ -164,7 +164,7 @@ describe('NodeService', () => { node.project_id = 'myproject'; node.node_id = 'id'; - service.updatePosition(server, project, node, 10, 20).subscribe(); + service.updatePosition(controller, project, node, 10, 20).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id`); expect(req.request.method).toEqual('PUT'); @@ -182,7 +182,7 @@ describe('NodeService', () => { node.project_id = 'myproject'; node.node_id = 'id'; - service.updatePosition(server, project, node, 10.1, 20.6).subscribe(); + service.updatePosition(controller, project, node, 10.1, 20.6).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id`); expect(req.request.method).toEqual('PUT'); @@ -204,7 +204,7 @@ describe('NodeService', () => { label.x = 10; label.y = 20; - service.updateLabel(server, node, label).subscribe(); + service.updateLabel(controller, node, label).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id`); expect(req.request.method).toEqual('PUT'); @@ -227,7 +227,7 @@ describe('NodeService', () => { node.y = 20; node.z = 30; - service.update(server, node).subscribe(); + service.update(controller, node).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id`); expect(req.request.method).toEqual('PUT'); @@ -243,7 +243,7 @@ describe('NodeService', () => { node.project_id = 'myproject'; node.node_id = 'id'; - service.delete(server, node).subscribe(); + service.delete(controller, node).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id`); expect(req.request.method).toEqual('DELETE'); @@ -254,7 +254,7 @@ describe('NodeService', () => { node.project_id = 'project_id_1'; node.node_id = 'node_id_1'; - service.duplicate(server, node).subscribe(); + service.duplicate(controller, node).subscribe(); const req = httpTestingController.expectOne( `http://127.0.0.1:3080/${environment.current_version}/projects/${node.project_id}/nodes/${node.node_id}/duplicate` diff --git a/src/app/services/node.service.ts b/src/app/services/node.service.ts index 3b70fadb..e96fa2e8 100644 --- a/src/app/services/node.service.ts +++ b/src/app/services/node.service.ts @@ -12,55 +12,56 @@ import { HttpServer } from './http-server.service'; export class NodeService { constructor(private httpServer: HttpServer) {} - getNodeById(server: Server, projectId: string, nodeId: string) { - return this.httpServer.get(server, `/projects/${projectId}/nodes/${nodeId}`); + getNodeById(controller: Server, projectId: string, nodeId: string) { + return this.httpServer.get(controller, `/projects/${projectId}/nodes/${nodeId}`); } - isolate(server: Server, node: Node) { - return this.httpServer.post(server, `/projects/${node.project_id}/nodes/${node.node_id}/isolate`, {}); + isolate(controller: Server, node: Node) { + return this.httpServer.post(controller, `/projects/${node.project_id}/nodes/${node.node_id}/isolate`, {}); } - unisolate(server: Server, node: Node) { - return this.httpServer.post(server, `/projects/${node.project_id}/nodes/${node.node_id}/unisolate`, {}); + unisolate(controller: Server, node: Node) { + return this.httpServer.post(controller, `/projects/${node.project_id}/nodes/${node.node_id}/unisolate`, {}); } - start(server: Server, node: Node) { - return this.httpServer.post(server, `/projects/${node.project_id}/nodes/${node.node_id}/start`, {}); + start(controller: Server, node: Node) { + debugger + return this.httpServer.post(controller, `/projects/${node.project_id}/nodes/${node.node_id}/start`, {}); } - startAll(server: Server, project: Project) { - return this.httpServer.post(server, `/projects/${project.project_id}/nodes/start`, {}); + startAll(controller: Server, project: Project) { + return this.httpServer.post(controller, `/projects/${project.project_id}/nodes/start`, {}); } - stop(server: Server, node: Node) { - return this.httpServer.post(server, `/projects/${node.project_id}/nodes/${node.node_id}/stop`, {}); + stop(controller: Server, node: Node) { + return this.httpServer.post(controller, `/projects/${node.project_id}/nodes/${node.node_id}/stop`, {}); } - stopAll(server: Server, project: Project) { - return this.httpServer.post(server, `/projects/${project.project_id}/nodes/stop`, {}); + stopAll(controller: Server, project: Project) { + return this.httpServer.post(controller, `/projects/${project.project_id}/nodes/stop`, {}); } - suspend(server: Server, node: Node) { - return this.httpServer.post(server, `/projects/${node.project_id}/nodes/${node.node_id}/suspend`, {}); + suspend(controller: Server, node: Node) { + return this.httpServer.post(controller, `/projects/${node.project_id}/nodes/${node.node_id}/suspend`, {}); } - suspendAll(server: Server, project: Project) { - return this.httpServer.post(server, `/projects/${project.project_id}/nodes/suspend`, {}); + suspendAll(controller: Server, project: Project) { + return this.httpServer.post(controller, `/projects/${project.project_id}/nodes/suspend`, {}); } - reload(server: Server, node: Node) { - return this.httpServer.post(server, `/projects/${node.project_id}/nodes/${node.node_id}/reload`, {}); + reload(controller: Server, node: Node) { + return this.httpServer.post(controller, `/projects/${node.project_id}/nodes/${node.node_id}/reload`, {}); } - reloadAll(server: Server, project: Project) { - return this.httpServer.post(server, `/projects/${project.project_id}/nodes/reload`, {}); + reloadAll(controller: Server, project: Project) { + return this.httpServer.post(controller, `/projects/${project.project_id}/nodes/reload`, {}); } - resetAllNodes(server: Server, project: Project) { - return this.httpServer.post(server, `/projects/${project.project_id}/nodes/console/reset`, {}); + resetAllNodes(controller: Server, project: Project) { + return this.httpServer.post(controller, `/projects/${project.project_id}/nodes/console/reset`, {}); } createFromTemplate( - server: Server, + controller: Server, project: Project, template: Template, x: number, @@ -68,20 +69,20 @@ export class NodeService { compute_id: string ): Observable { if (!compute_id) { - return this.httpServer.post(server, `/projects/${project.project_id}/templates/${template.template_id}`, { + return this.httpServer.post(controller, `/projects/${project.project_id}/templates/${template.template_id}`, { x: Math.round(x), y: Math.round(y), compute_id: 'local', }); } - return this.httpServer.post(server, `/projects/${project.project_id}/templates/${template.template_id}`, { + return this.httpServer.post(controller, `/projects/${project.project_id}/templates/${template.template_id}`, { x: Math.round(x), y: Math.round(y), compute_id: compute_id, }); } - updatePosition(server: Server, project: Project, node: Node, x: number, y: number): Observable { + updatePosition(controller: Server, project: Project, node: Node, x: number, y: number): Observable { let xPosition: number = Math.round(x); let yPosition: number = Math.round(y); @@ -93,14 +94,14 @@ export class NodeService { yPosition = Math.round(yPosition - node.height / 2); } - return this.httpServer.put(server, `/projects/${node.project_id}/nodes/${node.node_id}`, { + return this.httpServer.put(controller, `/projects/${node.project_id}/nodes/${node.node_id}`, { x: xPosition, y: yPosition, }); } - updateLabel(server: Server, node: Node, label: Label): Observable { - return this.httpServer.put(server, `/projects/${node.project_id}/nodes/${node.node_id}`, { + updateLabel(controller: Server, node: Node, label: Label): Observable { + return this.httpServer.put(controller, `/projects/${node.project_id}/nodes/${node.node_id}`, { label: { rotation: label.rotation, style: label.style, @@ -111,22 +112,22 @@ export class NodeService { }); } - updateSymbol(server: Server, node: Node, changedSymbol: string): Observable { - return this.httpServer.put(server, `/projects/${node.project_id}/nodes/${node.node_id}`, { + updateSymbol(controller: Server, node: Node, changedSymbol: string): Observable { + return this.httpServer.put(controller, `/projects/${node.project_id}/nodes/${node.node_id}`, { symbol: changedSymbol, }); } - update(server: Server, node: Node): Observable { - return this.httpServer.put(server, `/projects/${node.project_id}/nodes/${node.node_id}`, { + update(controller: Server, node: Node): Observable { + return this.httpServer.put(controller, `/projects/${node.project_id}/nodes/${node.node_id}`, { x: Math.round(node.x), y: Math.round(node.y), z: node.z, }); } - updateNode(server: Server, node: Node): Observable { - return this.httpServer.put(server, `/projects/${node.project_id}/nodes/${node.node_id}`, { + updateNode(controller: Server, node: Node): Observable { + return this.httpServer.put(controller, `/projects/${node.project_id}/nodes/${node.node_id}`, { console_type: node.console_type, console_auto_start: node.console_auto_start, locked: node.locked, @@ -135,8 +136,8 @@ export class NodeService { }); } - updateNodeWithCustomAdapters(server: Server, node: Node): Observable { - return this.httpServer.put(server, `/projects/${node.project_id}/nodes/${node.node_id}`, { + updateNodeWithCustomAdapters(controller: Server, node: Node): Observable { + return this.httpServer.put(controller, `/projects/${node.project_id}/nodes/${node.node_id}`, { console_type: node.console_type, console_auto_start: node.console_auto_start, custom_adapters: node.custom_adapters, @@ -145,43 +146,43 @@ export class NodeService { }); } - delete(server: Server, node: Node) { - return this.httpServer.delete(server, `/projects/${node.project_id}/nodes/${node.node_id}`); + delete(controller: Server, node: Node) { + return this.httpServer.delete(controller, `/projects/${node.project_id}/nodes/${node.node_id}`); } - duplicate(server: Server, node: Node) { - return this.httpServer.post(server, `/projects/${node.project_id}/nodes/${node.node_id}/duplicate`, { + duplicate(controller: Server, node: Node) { + return this.httpServer.post(controller, `/projects/${node.project_id}/nodes/${node.node_id}/duplicate`, { x: node.x + 10, y: node.y + 10, z: node.z, }); } - getNode(server: Server, node: Node) { - return this.httpServer.get(server, `/projects/${node.project_id}/nodes/${node.node_id}`); + getNode(controller: Server, node: Node) { + return this.httpServer.get(controller, `/projects/${node.project_id}/nodes/${node.node_id}`); } getDefaultCommand(): string { return `putty.exe -telnet \%h \%p -wt \"\%d\" -gns3 5 -skin 4`; } - getNetworkConfiguration(server: Server, node: Node) { + getNetworkConfiguration(controller: Server, node: Node) { return this.httpServer.get( - server, + controller, `/projects/${node.project_id}/nodes/${node.node_id}/files/etc/network/interfaces`, { responseType: 'text' as 'json' } ); } - saveNetworkConfiguration(server: Server, node: Node, configuration: string) { + saveNetworkConfiguration(controller: Server, node: Node, configuration: string) { return this.httpServer.post( - server, + controller, `/projects/${node.project_id}/nodes/${node.node_id}/files/etc/network/interfaces`, configuration ); } - getStartupConfiguration(server: Server, node: Node) { + getStartupConfiguration(controller: Server, node: Node) { let urlPath: string = `/projects/${node.project_id}/nodes/${node.node_id}`; if (node.node_type === 'vpcs') { @@ -192,10 +193,10 @@ export class NodeService { urlPath += `/files/configs/i${node.node_id}_startup-config.cfg`; } - return this.httpServer.get(server, urlPath, { responseType: 'text' as 'json' }); + return this.httpServer.get(controller, urlPath, { responseType: 'text' as 'json' }); } - getPrivateConfiguration(server: Server, node: Node) { + getPrivateConfiguration(controller: Server, node: Node) { let urlPath: string = `/projects/${node.project_id}/nodes/${node.node_id}`; if (node.node_type === 'iou') { @@ -204,10 +205,10 @@ export class NodeService { urlPath += `/files/configs/i${node.node_id}_private-config.cfg`; } - return this.httpServer.get(server, urlPath, { responseType: 'text' as 'json' }); + return this.httpServer.get(controller, urlPath, { responseType: 'text' as 'json' }); } - saveConfiguration(server: Server, node: Node, configuration: string) { + saveConfiguration(controller: Server, node: Node, configuration: string) { let urlPath: string = `/projects/${node.project_id}/nodes/${node.node_id}`; if (node.node_type === 'vpcs') { @@ -218,10 +219,10 @@ export class NodeService { urlPath += `/files/configs/i${node.node_id}_startup-config.cfg`; } - return this.httpServer.post(server, urlPath, configuration); + return this.httpServer.post(controller, urlPath, configuration); } - savePrivateConfiguration(server: Server, node: Node, configuration: string) { + savePrivateConfiguration(controller: Server, node: Node, configuration: string) { let urlPath: string = `/projects/${node.project_id}/nodes/${node.node_id}`; if (node.node_type === 'iou') { @@ -230,6 +231,6 @@ export class NodeService { urlPath += `/files/configs/i${node.node_id}_private-config.cfg`; } - return this.httpServer.post(server, urlPath, configuration); + return this.httpServer.post(controller, urlPath, configuration); } } diff --git a/src/app/services/nodeConsole.service.ts b/src/app/services/nodeConsole.service.ts index e38e4617..b4bf656e 100644 --- a/src/app/services/nodeConsole.service.ts +++ b/src/app/services/nodeConsole.service.ts @@ -66,13 +66,13 @@ export class NodeConsoleService { return this.defaultConsoleHeight / this.defaultNumberOfRows; } - getUrl(server: Server, node: Node) { + getUrl(controller: Server, node: Node) { let protocol:string = "ws" - if (server.protocol === "https:") { + if (controller.protocol === "https:") { protocol = "wss" } - return `${protocol}://${server.host}:${server.port}/${environment.current_version}/projects/${node.project_id}/nodes/${node.node_id}/console/ws` + return `${protocol}://${controller.host}:${controller.port}/${environment.current_version}/projects/${node.project_id}/nodes/${node.node_id}/console/ws` } openConsolesForAllNodesInWidget(nodes: Node[]) { diff --git a/src/app/services/notification.service.ts b/src/app/services/notification.service.ts index c159a83a..f5ed5d7e 100644 --- a/src/app/services/notification.service.ts +++ b/src/app/services/notification.service.ts @@ -4,22 +4,22 @@ import { Server } from '../models/server'; @Injectable() export class NotificationService { - notificationsPath(server: Server): string { + notificationsPath(controller: Server): string { let protocol:string = "ws" - if (server.protocol === "https:") { + if (controller.protocol === "https:") { protocol = "wss" } - return `${protocol}://${server.host}:${server.port}/${environment.current_version}/notifications/ws?token=${server.authToken}`; + return `${protocol}://${controller.host}:${controller.port}/${environment.current_version}/notifications/ws?token=${controller.authToken}`; } - projectNotificationsPath(server: Server, project_id: string): string { + projectNotificationsPath(controller: Server, project_id: string): string { let protocol:string = "ws" - if (server.protocol === "https:") { + if (controller.protocol === "https:") { protocol = "wss" } - return `${protocol}://${server.host}:${server.port}/${environment.current_version}/projects/${project_id}/notifications/ws?token=${server.authToken}`; + return `${protocol}://${controller.host}:${controller.port}/${environment.current_version}/projects/${project_id}/notifications/ws?token=${controller.authToken}`; } } diff --git a/src/app/services/packet-capture.service.ts b/src/app/services/packet-capture.service.ts index 890543e6..ad838ba3 100644 --- a/src/app/services/packet-capture.service.ts +++ b/src/app/services/packet-capture.service.ts @@ -7,9 +7,9 @@ import { Server } from '../models/server'; export class PacketCaptureService { constructor() {} - startCapture(server: Server, project: Project, link: Link, name: string) { + startCapture(controller: Server, project: Project, link: Link, name: string) { location.assign( - `gns3+pcap://${server.host}:${server.port}?project_id=${project.project_id}&link_id=${link.link_id}&name=${name}` + `gns3+pcap://${controller.host}:${controller.port}?project_id=${project.project_id}&link_id=${link.link_id}&name=${name}` ); } } diff --git a/src/app/services/project.service.spec.ts b/src/app/services/project.service.spec.ts index d3719f07..2cd46927 100644 --- a/src/app/services/project.service.spec.ts +++ b/src/app/services/project.service.spec.ts @@ -18,15 +18,15 @@ import { getTestServer } from './testing'; export class MockedProjectService { public projects: Project[] = []; - list(server: Server) { + list(controller: Server) { return of(this.projects); } - open(server: Server, project: Project) { + open(controller: Server, project: Project) { return of(project); } - close(server: Server, project: Project) { + close(controller: Server, project: Project) { return of(project); } @@ -34,22 +34,22 @@ export class MockedProjectService { return project.readonly; } - links(server: Server, project_id: string) { + links(controller: Server, project_id: string) { return of([]); } - delete(server: Server, project_id: string) { + delete(controller: Server, project_id: string) { return of(project_id); } - duplicate(server: Server, project_id: string) { + duplicate(controller: Server, project_id: string) { return of(project_id); } - getStatistics(server: Server, project_id: string) { + getStatistics(controller: Server, project_id: string) { return of({}); } - exportPortableProject(server: Server, formData:{}) { + exportPortableProject(controller: Server, formData:{}) { return of({}); } getCompression() { @@ -65,7 +65,7 @@ describe('ProjectService', () => { let httpTestingController: HttpTestingController; let httpServer: HttpServer; let service: ProjectService; - let server: Server; + let controller: Server; let settingsService: SettingsService; beforeEach(() => { @@ -85,7 +85,7 @@ describe('ProjectService', () => { service = TestBed.get(ProjectService); settingsService = TestBed.get(SettingsService); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -97,14 +97,14 @@ describe('ProjectService', () => { }); it('should get the project', () => { - service.get(server, 'myproject').subscribe(); + service.get(controller, 'myproject').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject`); expect(req.request.method).toEqual('GET'); }); it('should open the project', () => { - service.open(server, 'myproject').subscribe(); + service.open(controller, 'myproject').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/open`); expect(req.request.method).toEqual('POST'); @@ -112,7 +112,7 @@ describe('ProjectService', () => { }); it('should close the project', () => { - service.close(server, 'myproject').subscribe(); + service.close(controller, 'myproject').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/close`); expect(req.request.method).toEqual('POST'); @@ -120,42 +120,42 @@ describe('ProjectService', () => { }); it('should list projects', () => { - service.list(server).subscribe(); + service.list(controller).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects`); expect(req.request.method).toEqual('GET'); }); it('should get nodes of project', () => { - service.nodes(server, 'myproject').subscribe(); + service.nodes(controller, 'myproject').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes`); expect(req.request.method).toEqual('GET'); }); it('should get links of project', () => { - service.links(server, 'myproject').subscribe(); + service.links(controller, 'myproject').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/links`); expect(req.request.method).toEqual('GET'); }); it('should get drawings of project', () => { - service.drawings(server, 'myproject').subscribe(); + service.drawings(controller, 'myproject').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings`); expect(req.request.method).toEqual('GET'); }); it('should delete the project', () => { - service.delete(server, 'myproject').subscribe(); + service.delete(controller, 'myproject').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject`); expect(req.request.method).toEqual('DELETE'); }); it('should duplicate the project', () => { - service.duplicate(server, 'projectId', 'projectName').subscribe(); + service.duplicate(controller, 'projectId', 'projectName').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/projectId/duplicate`); expect(req.request.method).toEqual('POST'); diff --git a/src/app/services/project.service.ts b/src/app/services/project.service.ts index 9e356ad1..0a9e6e12 100644 --- a/src/app/services/project.service.ts +++ b/src/app/services/project.service.ts @@ -43,49 +43,49 @@ export class ProjectService { this.projectListSubject.next(true); } - getReadmeFile(server: Server, project_id: string) { - return this.httpServer.getText(server, `/projects/${project_id}/files/README.txt`); + getReadmeFile(controller: Server, project_id: string) { + return this.httpServer.getText(controller, `/projects/${project_id}/files/README.txt`); } - postReadmeFile(server: Server, project_id: string, readme: string) { - return this.httpServer.post(server, `/projects/${project_id}/files/README.txt`, readme); + postReadmeFile(controller: Server, project_id: string, readme: string) { + return this.httpServer.post(controller, `/projects/${project_id}/files/README.txt`, readme); } - get(server: Server, project_id: string) { - return this.httpServer.get(server, `/projects/${project_id}`); + get(controller: Server, project_id: string) { + return this.httpServer.get(controller, `/projects/${project_id}`); } - open(server: Server, project_id: string) { - return this.httpServer.post(server, `/projects/${project_id}/open`, {}); + open(controller: Server, project_id: string) { + return this.httpServer.post(controller, `/projects/${project_id}/open`, {}); } - close(server: Server, project_id: string) { + close(controller: Server, project_id: string) { this.recentlyOpenedProjectService.removeData(); - return this.httpServer.post(server, `/projects/${project_id}/close`, {}); + return this.httpServer.post(controller, `/projects/${project_id}/close`, {}); } - list(server: Server) { - return this.httpServer.get(server, '/projects'); + list(controller: Server) { + return this.httpServer.get(controller, '/projects'); } - nodes(server: Server, project_id: string) { - return this.httpServer.get(server, `/projects/${project_id}/nodes`); + nodes(controller: Server, project_id: string) { + return this.httpServer.get(controller, `/projects/${project_id}/nodes`); } - links(server: Server, project_id: string) { - return this.httpServer.get(server, `/projects/${project_id}/links`); + links(controller: Server, project_id: string) { + return this.httpServer.get(controller, `/projects/${project_id}/links`); } - drawings(server: Server, project_id: string) { - return this.httpServer.get(server, `/projects/${project_id}/drawings`); + drawings(controller: Server, project_id: string) { + return this.httpServer.get(controller, `/projects/${project_id}/drawings`); } - add(server: Server, project_name: string, project_id: string): Observable { - return this.httpServer.post(server, `/projects`, { name: project_name, project_id: project_id }); + add(controller: Server, project_name: string, project_id: string): Observable { + return this.httpServer.post(controller, `/projects`, { name: project_name, project_id: project_id }); } - update(server: Server, project: Project): Observable { - return this.httpServer.put(server, `/projects/${project.project_id}`, { + update(controller: Server, project: Project): Observable { + return this.httpServer.put(controller, `/projects/${project.project_id}`, { auto_close: project.auto_close, auto_open: project.auto_open, auto_start: project.auto_start, @@ -98,28 +98,28 @@ export class ProjectService { }); } - delete(server: Server, project_id: string): Observable { - return this.httpServer.delete(server, `/projects/${project_id}`); + delete(controller: Server, project_id: string): Observable { + return this.httpServer.delete(controller, `/projects/${project_id}`); } - getUploadPath(server: Server, uuid: string, project_name: string) { - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/projects/${uuid}/import?name=${project_name}`; + getUploadPath(controller: Server, uuid: string, project_name: string) { + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/projects/${uuid}/import?name=${project_name}`; } - getExportPath(server: Server, project: Project) { - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/projects/${project.project_id}/export`; + getExportPath(controller: Server, project: Project) { + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/projects/${project.project_id}/export`; } - export(server: Server, project_id: string): Observable { - return this.httpServer.get(server, `/projects/${project_id}/export`); + export(controller: Server, project_id: string): Observable { + return this.httpServer.get(controller, `/projects/${project_id}/export`); } - getStatistics(server: Server, project_id: string): Observable { - return this.httpServer.get(server, `/projects/${project_id}/stats`); + getStatistics(controller: Server, project_id: string): Observable { + return this.httpServer.get(controller, `/projects/${project_id}/stats`); } - duplicate(server: Server, project_id: string, project_name): Observable { - return this.httpServer.post(server, `/projects/${project_id}/duplicate`, { name: project_name }); + duplicate(controller: Server, project_id: string, project_name): Observable { + return this.httpServer.post(controller, `/projects/${project_id}/duplicate`, { name: project_name }); } isReadOnly(project: Project) { @@ -137,11 +137,11 @@ export class ProjectService { }; - getexportPortableProjectPath(server:Server, project_id: string,formData:any={}) { + getexportPortableProjectPath(controller:Server, project_id: string,formData:any={}) { if (formData.compression_level != null && formData.compression_level !='') { - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/projects/${project_id}/export?include_snapshots=${formData.include_snapshots}&include_images=${formData.include_base_image}&reset_mac_addresses=${formData.reset_mac_address}&compression=${formData.compression}&compression_level=${formData.compression_level}&token=${server.authToken}`; + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/projects/${project_id}/export?include_snapshots=${formData.include_snapshots}&include_images=${formData.include_base_image}&reset_mac_addresses=${formData.reset_mac_address}&compression=${formData.compression}&compression_level=${formData.compression_level}&token=${controller.authToken}`; } else { - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/projects/${project_id}/export?include_snapshots=${formData.include_snapshots}&include_images=${formData.include_base_image}&reset_mac_addresses=${formData.reset_mac_address}&compression=${formData.compression}&token=${server.authToken}`; + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/projects/${project_id}/export?include_snapshots=${formData.include_snapshots}&include_images=${formData.include_base_image}&reset_mac_addresses=${formData.reset_mac_address}&compression=${formData.compression}&token=${controller.authToken}`; } } diff --git a/src/app/services/qemu.service.spec.ts b/src/app/services/qemu.service.spec.ts index b2c80f11..fa22f24f 100644 --- a/src/app/services/qemu.service.spec.ts +++ b/src/app/services/qemu.service.spec.ts @@ -13,7 +13,7 @@ describe('QemuService', () => { let httpClient: HttpClient; let httpTestingController: HttpTestingController; let httpServer: HttpServer; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -24,7 +24,7 @@ describe('QemuService', () => { httpClient = TestBed.get(HttpClient); httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -80,7 +80,7 @@ describe('QemuService', () => { usage: '', }; - service.saveTemplate(server, template).subscribe(); + service.saveTemplate(controller, template).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/1`); expect(req.request.method).toEqual('PUT'); @@ -132,7 +132,7 @@ describe('QemuService', () => { usage: '', }; - service.addTemplate(server, template).subscribe(); + service.addTemplate(controller, template).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`); expect(req.request.method).toEqual('POST'); diff --git a/src/app/services/qemu.service.ts b/src/app/services/qemu.service.ts index 62b38c83..c2969eb5 100644 --- a/src/app/services/qemu.service.ts +++ b/src/app/services/qemu.service.ts @@ -11,37 +11,37 @@ import { HttpServer } from './http-server.service'; export class QemuService { constructor(private httpServer: HttpServer) {} - getTemplates(server: Server): Observable { - return this.httpServer.get(server, '/templates') as Observable; + getTemplates(controller: Server): Observable { + return this.httpServer.get(controller, '/templates') as Observable; } - getTemplate(server: Server, template_id: string): Observable { - return this.httpServer.get(server, `/templates/${template_id}`) as Observable; + getTemplate(controller: Server, template_id: string): Observable { + return this.httpServer.get(controller, `/templates/${template_id}`) as Observable; } - getImagePath(server: Server, filename: string): string { - return `${server.protocol}//${server.host}:${server.port}/images/upload/${filename}`; + getImagePath(controller: Server, filename: string): string { + return `${controller.protocol}//${controller.host}:${controller.port}/images/upload/${filename}`; } - getBinaries(server: Server): Observable { - return this.httpServer.get(server, '/computes/local/qemu/binaries') as Observable; + getBinaries(controller: Server): Observable { + return this.httpServer.get(controller, '/computes/local/qemu/binaries') as Observable; } - getImages(server: Server): Observable { - return this.httpServer.get(server, '/images?image_type=qemu') as Observable; + getImages(controller: Server): Observable { + return this.httpServer.get(controller, '/images?image_type=qemu') as Observable; } - addImage(server: Server, qemuImg: QemuImg): Observable { - return this.httpServer.post(server, '/images/upload', qemuImg) as Observable; + addImage(controller: Server, qemuImg: QemuImg): Observable { + return this.httpServer.post(controller, '/images/upload', qemuImg) as Observable; } - addTemplate(server: Server, qemuTemplate: QemuTemplate): Observable { - return this.httpServer.post(server, `/templates`, qemuTemplate) as Observable; + addTemplate(controller: Server, qemuTemplate: QemuTemplate): Observable { + return this.httpServer.post(controller, `/templates`, qemuTemplate) as Observable; } - saveTemplate(server: Server, qemuTemplate: QemuTemplate): Observable { + saveTemplate(controller: Server, qemuTemplate: QemuTemplate): Observable { return this.httpServer.put( - server, + controller, `/templates/${qemuTemplate.template_id}`, qemuTemplate ) as Observable; diff --git a/src/app/services/recentlyOpenedProject.service.ts b/src/app/services/recentlyOpenedProject.service.ts index d9753e96..610414d0 100644 --- a/src/app/services/recentlyOpenedProject.service.ts +++ b/src/app/services/recentlyOpenedProject.service.ts @@ -2,36 +2,36 @@ import { Injectable } from '@angular/core'; @Injectable() export class RecentlyOpenedProjectService { - private serverId: string; + private controllerId: string; private projectId: string; - private serverIdProjectList: string; + private controllerIdProjectList: string; - setServerId(serverId: string) { - this.serverId = serverId; + setcontrollerId(controllerId: string) { + this.controllerId = controllerId; } setProjectId(projectId: string) { this.projectId = projectId; } - setServerIdProjectList(serverId: string) { - this.serverIdProjectList = serverId; + setcontrollerIdProjectList(controllerId: string) { + this.controllerIdProjectList = controllerId; } - getServerId(): string { - return this.serverId; + getcontrollerId(): string { + return this.controllerId; } getProjectId(): string { return this.projectId; } - getServerIdProjectList(): string { - return this.serverIdProjectList; + getcontrollerIdProjectList(): string { + return this.controllerIdProjectList; } removeData() { - (this.serverId = ''), (this.projectId = ''); + (this.controllerId = ''), (this.projectId = ''); } } diff --git a/src/app/services/server-management.service.spec.ts b/src/app/services/server-management.service.spec.ts index 98aede75..9c1a4fcf 100644 --- a/src/app/services/server-management.service.spec.ts +++ b/src/app/services/server-management.service.spec.ts @@ -7,12 +7,12 @@ describe('ServerManagementService', () => { let electronService; let callbacks; let removed; - let server; + let controller; beforeEach(() => { callbacks = []; removed = []; - server = undefined; + controller = undefined; electronService = { isElectronApp: true, ipcRenderer: { @@ -30,10 +30,10 @@ describe('ServerManagementService', () => { require: (file) => { return { startLocalServer: (serv) => { - server = serv; + controller = serv; }, stopLocalServer: (serv) => { - server = serv; + controller = serv; }, }; }, @@ -58,7 +58,7 @@ describe('ServerManagementService', () => { it('should attach when running as electron app', () => { TestBed.get(ServerManagementService); expect(callbacks.length).toEqual(1); - expect(callbacks[0].channel).toEqual('local-server-status-events'); + expect(callbacks[0].channel).toEqual('local-controller-status-events'); }); it('should not attach when running as not electron app', () => { @@ -70,7 +70,7 @@ describe('ServerManagementService', () => { it('should deattach when running as electron app', () => { const service: ServerManagementService = TestBed.get(ServerManagementService); service.ngOnDestroy(); - expect(removed).toEqual(['local-server-status-events']); + expect(removed).toEqual(['local-controller-status-events']); }); it('should not deattach when running as not electron app', () => { @@ -80,15 +80,15 @@ describe('ServerManagementService', () => { expect(removed).toEqual([]); }); - it('should start local server', async () => { + it('should start local controller', async () => { const service: ServerManagementService = TestBed.get(ServerManagementService); await service.start({ name: 'test' } as Server); - expect(server).toEqual({ name: 'test' }); + expect(controller).toEqual({ name: 'test' }); }); - it('should stop local server', async () => { + it('should stop local controller', async () => { const service: ServerManagementService = TestBed.get(ServerManagementService); await service.stop({ name: 'test2' } as Server); - expect(server).toEqual({ name: 'test2' }); + expect(controller).toEqual({ name: 'test2' }); }); }); diff --git a/src/app/services/server-management.service.ts b/src/app/services/server-management.service.ts index 10376c07..b7f0257e 100644 --- a/src/app/services/server-management.service.ts +++ b/src/app/services/server-management.service.ts @@ -22,21 +22,21 @@ export class ServerManagementService implements OnDestroy { } get statusChannel() { - return 'local-server-status-events'; + return 'local-controller-status-events'; } - async start(server: Server) { + async start(controller: Server) { var startingEvent: ServerStateEvent = { - serverName: server.name, + serverName: controller.name, status: 'starting', message: '', }; this.serverStatusChanged.next(startingEvent); - return await this.electronService.remote.require('./local-server.js').startLocalServer(server); + return await this.electronService.remote.require('./local-server.js').startLocalServer(controller); } - async stop(server: Server) { - return await this.electronService.remote.require('./local-server.js').stopLocalServer(server); + async stop(controller: Server) { + return await this.electronService.remote.require('./local-server.js').stopLocalServer(controller); } async stopAll() { diff --git a/src/app/services/server-settings.service.spec.ts b/src/app/services/server-settings.service.spec.ts index 10274799..c3fea9d5 100644 --- a/src/app/services/server-settings.service.spec.ts +++ b/src/app/services/server-settings.service.spec.ts @@ -8,11 +8,11 @@ import { HttpServer } from './http-server.service'; import { ServerSettingsService } from './server-settings.service'; export class MockedServerSettingsService { - getSettingsForQemu(server: Server) { + getSettingsForQemu(controller: Server) { return of([]); } - updateSettingsForQemu(server: Server, qemuSettings: QemuSettings) { + updateSettingsForQemu(controller: Server, qemuSettings: QemuSettings) { return of([]); } } diff --git a/src/app/services/server-settings.service.ts b/src/app/services/server-settings.service.ts index dd25bafd..98f588cb 100644 --- a/src/app/services/server-settings.service.ts +++ b/src/app/services/server-settings.service.ts @@ -8,20 +8,20 @@ import { HttpServer } from './http-server.service'; export class ServerSettingsService { constructor(private httpServer: HttpServer) {} - get(server: Server) { - return this.httpServer.get(server, `/settings`); + get(controller: Server) { + return this.httpServer.get(controller, `/settings`); } - update(server: Server, serverSettings: ServerSettings) { - return this.httpServer.post(server, `/settings`, serverSettings); + update(controller: Server, serverSettings: ServerSettings) { + return this.httpServer.post(controller, `/settings`, serverSettings); } - getSettingsForQemu(server: Server) { - return this.httpServer.get(server, `/settings/qemu`); + getSettingsForQemu(controller: Server) { + return this.httpServer.get(controller, `/settings/qemu`); } - updateSettingsForQemu(server: Server, qemuSettings: QemuSettings) { - return this.httpServer.put(server, `/settings/qemu`, { + updateSettingsForQemu(controller: Server, qemuSettings: QemuSettings) { + return this.httpServer.put(controller, `/settings/qemu`, { enable_hardware_acceleration: qemuSettings.enable_hardware_acceleration, require_hardware_acceleration: qemuSettings.require_hardware_acceleration, }); diff --git a/src/app/services/server.database.ts b/src/app/services/server.database.ts index cd3abaea..b0b1ca03 100644 --- a/src/app/services/server.database.ts +++ b/src/app/services/server.database.ts @@ -12,9 +12,9 @@ export class ServerDatabase { return this.dataChange.value; } - public addServer(server: Server) { + public addServer(controller: Server) { const servers = this.data.slice(); - servers.push(server); + servers.push(controller); this.dataChange.next(servers); } @@ -22,8 +22,8 @@ export class ServerDatabase { this.dataChange.next(servers); } - public remove(server: Server) { - const index = this.data.indexOf(server); + public remove(controller: Server) { + const index = this.data.indexOf(controller); if (index >= 0) { this.data.splice(index, 1); this.dataChange.next(this.data.slice()); @@ -31,17 +31,17 @@ export class ServerDatabase { } public find(serverName: string) { - return this.data.find((server) => server.name === serverName); + return this.data.find((controller) => controller.name === serverName); } public findIndex(serverName: string) { - return this.data.findIndex((server) => server.name === serverName); + return this.data.findIndex((controller) => controller.name === serverName); } - public update(server: Server) { - const index = this.findIndex(server.name); + public update(controller: Server) { + const index = this.findIndex(controller.name); if (index >= 0) { - this.data[index] = server; + this.data[index] = controller; this.dataChange.next(this.data.slice()); } } diff --git a/src/app/services/server.service.spec.ts b/src/app/services/server.service.spec.ts index 1e21b3d1..c4904020 100644 --- a/src/app/services/server.service.spec.ts +++ b/src/app/services/server.service.spec.ts @@ -3,24 +3,24 @@ import { Server } from '../models/server'; export class MockedServerService { public servers: Server[] = []; - public create(server: Server) { + public create(controller: Server) { return new Promise((resolve, reject) => { - this.servers.push(server); - resolve(server); + this.servers.push(controller); + resolve(controller); }); } public get(controller_id: number) { - const server = new Server(); - server.id = controller_id; - return Promise.resolve(server); + const controller = new Server(); + controller.id = controller_id; + return Promise.resolve(controller); } public getLocalServer(hostname: string, port: number) { return new Promise((resolve, reject) => { - const server = new Server(); - server.id = 99; - resolve(server); + const controller = new Server(); + controller.id = 99; + resolve(controller); }); } @@ -30,7 +30,7 @@ export class MockedServerService { }); } - public getServerUrl(server: Server) { - return `${server.host}:${server.port}`; + public getServerUrl(controller: Server) { + return `${controller.host}:${controller.port}`; } } diff --git a/src/app/services/server.service.ts b/src/app/services/server.service.ts index 90e5a3bf..213eb9bc 100644 --- a/src/app/services/server.service.ts +++ b/src/app/services/server.service.ts @@ -10,12 +10,12 @@ export class ServerService { public isServiceInitialized: boolean; constructor(private httpServer: HttpServer) { - this.controllerIds = this.getServerIds(); + this.controllerIds = this.getcontrollerIds(); this.isServiceInitialized = true; this.serviceInitialized.next(this.isServiceInitialized); } - getServerIds() : string[]{ + getcontrollerIds() : string[]{ let str = localStorage.getItem("controllerIds"); if (str?.length > 0) { return str.split(","); @@ -23,38 +23,38 @@ export class ServerService { return []; } - updateServerIds() { + updatecontrollerIds() { localStorage.removeItem("controllerIds"); localStorage.setItem("controllerIds", this.controllerIds.toString()); } public get(id: number): Promise { - let server: Server = JSON.parse(localStorage.getItem(`controller-${id}`)); + let controller: Server = JSON.parse(localStorage.getItem(`controller-${id}`)); let promise = new Promise((resolve) => { - resolve(server); + resolve(controller); }); return promise; } - public create(server: Server) { - server.id = this.controllerIds.length + 1; - localStorage.setItem(`controller-${server.id}`, JSON.stringify(server)); + public create(controller: Server) { + controller.id = this.controllerIds.length + 1; + localStorage.setItem(`controller-${controller.id}`, JSON.stringify(controller)); - this.controllerIds.push(`controller-${server.id}`); - this.updateServerIds(); + this.controllerIds.push(`controller-${controller.id}`); + this.updatecontrollerIds(); let promise = new Promise((resolve) => { - resolve(server); + resolve(controller); }); return promise; } - public update(server: Server) { - localStorage.removeItem(`controller-${server.id}`); - localStorage.setItem(`controller-${server.id}`, JSON.stringify(server)); + public update(controller: Server) { + localStorage.removeItem(`controller-${controller.id}`); + localStorage.setItem(`controller-${controller.id}`, JSON.stringify(controller)); let promise = new Promise((resolve) => { - resolve(server); + resolve(controller); }); return promise; } @@ -63,37 +63,37 @@ export class ServerService { let promise = new Promise((resolve) => { let servers: Server[] = []; this.controllerIds.forEach((n) => { - let server: Server = JSON.parse(localStorage.getItem(n)); - servers.push(server); + let controller: Server = JSON.parse(localStorage.getItem(n)); + servers.push(controller); }); resolve(servers); }); return promise; } - public delete(server: Server) { - localStorage.removeItem(`controller-${server.id}`); - this.controllerIds = this.controllerIds.filter((n) => n !== `controller-${server.id}`); - this.updateServerIds(); + public delete(controller: Server) { + localStorage.removeItem(`controller-${controller.id}`); + this.controllerIds = this.controllerIds.filter((n) => n !== `controller-${controller.id}`); + this.updatecontrollerIds(); let promise = new Promise((resolve) => { - resolve(server.id); + resolve(controller.id); }); return promise; } - public getServerUrl(server: Server) { - return `${server.protocol}//${server.host}:${server.port}/`; + public getServerUrl(controller: Server) { + return `${controller.protocol}//${controller.host}:${controller.port}/`; } - public checkServerVersion(server: Server): Observable { - return this.httpServer.get(server, '/version'); + public checkServerVersion(controller: Server): Observable { + return this.httpServer.get(controller, '/version'); } public getLocalServer(host: string, port: number) { const promise = new Promise((resolve, reject) => { this.findAll().then((servers: Server[]) => { - const local = servers.find((server) => server.location === 'bundled'); + const local = servers.find((controller) => controller.location === 'bundled'); if (local) { local.host = host; local.port = port; @@ -102,13 +102,13 @@ export class ServerService { resolve(updated); }, reject); } else { - const server = new Server(); - server.name = 'local'; - server.host = host; - server.port = port; - server.location = 'bundled'; - server.protocol = location.protocol as ServerProtocol; - this.create(server).then((created) => { + const controller = new Server(); + controller.name = 'local'; + controller.host = host; + controller.port = port; + controller.location = 'bundled'; + controller.protocol = location.protocol as ServerProtocol; + this.create(controller).then((created) => { resolve(created); }, reject); } diff --git a/src/app/services/snapshot.service.spec.ts b/src/app/services/snapshot.service.spec.ts index 2c677c0b..749bacc2 100644 --- a/src/app/services/snapshot.service.spec.ts +++ b/src/app/services/snapshot.service.spec.ts @@ -14,7 +14,7 @@ describe('SnapshotService', () => { let httpTestingController: HttpTestingController; let httpServer: HttpServer; let service: SnapshotService; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -26,7 +26,7 @@ describe('SnapshotService', () => { httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); service = TestBed.get(SnapshotService); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -39,7 +39,7 @@ describe('SnapshotService', () => { it('should create snapshot', inject([SnapshotService], (service: SnapshotService) => { const snapshot = new Snapshot(); - service.create(server, 'myproject', snapshot).subscribe(); + service.create(controller, 'myproject', snapshot).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/snapshots`); expect(req.request.method).toEqual('POST'); @@ -47,7 +47,7 @@ describe('SnapshotService', () => { })); it('should list snapshots', inject([SnapshotService], (service: SnapshotService) => { - service.list(server, 'myproject').subscribe(); + service.list(controller, 'myproject').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/snapshots`); expect(req.request.method).toEqual('GET'); diff --git a/src/app/services/snapshot.service.ts b/src/app/services/snapshot.service.ts index e1973e81..4d7c3d28 100644 --- a/src/app/services/snapshot.service.ts +++ b/src/app/services/snapshot.service.ts @@ -7,19 +7,19 @@ import { HttpServer } from './http-server.service'; export class SnapshotService { constructor(private httpServer: HttpServer) {} - create(server: Server, project_id: string, snapshot: Snapshot) { - return this.httpServer.post(server, `/projects/${project_id}/snapshots`, snapshot); + create(controller: Server, project_id: string, snapshot: Snapshot) { + return this.httpServer.post(controller, `/projects/${project_id}/snapshots`, snapshot); } - delete(server: Server, project_id: string, snapshot_id: string) { - return this.httpServer.delete(server, `/projects/${project_id}/snapshots/${snapshot_id}`); + delete(controller: Server, project_id: string, snapshot_id: string) { + return this.httpServer.delete(controller, `/projects/${project_id}/snapshots/${snapshot_id}`); } - list(server: Server, project_id: string) { - return this.httpServer.get(server, `/projects/${project_id}/snapshots`); + list(controller: Server, project_id: string) { + return this.httpServer.get(controller, `/projects/${project_id}/snapshots`); } - restore(server: Server, project_id: string, snapshot_id: string) { - return this.httpServer.post(server, `/projects/${project_id}/snapshots/${snapshot_id}/restore`, {}); + restore(controller: Server, project_id: string, snapshot_id: string) { + return this.httpServer.post(controller, `/projects/${project_id}/snapshots/${snapshot_id}/restore`, {}); } } diff --git a/src/app/services/symbol.service.spec.ts b/src/app/services/symbol.service.spec.ts index 153aaee4..688c2c30 100644 --- a/src/app/services/symbol.service.spec.ts +++ b/src/app/services/symbol.service.spec.ts @@ -14,7 +14,7 @@ describe('SymbolService', () => { let httpClient: HttpClient; let httpTestingController: HttpTestingController; let httpServer: HttpServer; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -25,7 +25,7 @@ describe('SymbolService', () => { httpClient = TestBed.get(HttpClient); httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -37,14 +37,14 @@ describe('SymbolService', () => { })); it('should list symbols', inject([SymbolService], (service: SymbolService) => { - service.list(server).subscribe(); + service.list(controller).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/symbols`); expect(req.request.method).toEqual('GET'); })); it('should get raw symbol', inject([SymbolService], (service: SymbolService) => { - service.raw(server, ':my/tested.png').subscribe(); + service.raw(controller, ':my/tested.png').subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/symbols/:my/tested.png/raw`); expect(req.request.method).toEqual('GET'); diff --git a/src/app/services/symbol.service.ts b/src/app/services/symbol.service.ts index bf7eeb05..dc2d972d 100644 --- a/src/app/services/symbol.service.ts +++ b/src/app/services/symbol.service.ts @@ -26,9 +26,9 @@ export class SymbolService { return this.symbols.getValue().find((symbol: Symbol) => symbol.symbol_id === symbol_id); } - getDimensions(server: Server, symbol_id: string): Observable { + getDimensions(controller: Server, symbol_id: string): Observable { const encoded_uri = encodeURI(symbol_id); - return this.httpServer.get(server, `/symbols/${encoded_uri}/dimensions`); + return this.httpServer.get(controller, `/symbols/${encoded_uri}/dimensions`); } scaleDimensionsForNode(node: Node): SymbolDimension { @@ -43,30 +43,30 @@ export class SymbolService { return this.symbols.getValue().find((symbol: Symbol) => symbol.filename === symbol_filename); } - add(server: Server, symbolName: string, symbol: string) { + add(controller: Server, symbolName: string, symbol: string) { this.cache = null; - return this.httpServer.post(server, `/symbols/${symbolName}/raw`, symbol); + return this.httpServer.post(controller, `/symbols/${symbolName}/raw`, symbol); } - load(server: Server): Observable { - return this.httpServer.get(server, '/symbols'); + load(controller: Server): Observable { + return this.httpServer.get(controller, '/symbols'); } - list(server: Server) { + list(controller: Server) { if (!this.cache) { - this.cache = this.load(server).pipe(shareReplay(CACHE_SIZE)); + this.cache = this.load(controller).pipe(shareReplay(CACHE_SIZE)); } return this.cache; } - raw(server: Server, symbol_id: string) { + raw(controller: Server, symbol_id: string) { const encoded_uri = encodeURI(symbol_id); - return this.httpServer.getText(server, `/symbols/${encoded_uri}/raw`); + return this.httpServer.getText(controller, `/symbols/${encoded_uri}/raw`); } - getSymbolFromTemplate(server: Server, template: Template) { - return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/symbols/${template.symbol}/raw`; + getSymbolFromTemplate(controller: Server, template: Template) { + return `${controller.protocol}//${controller.host}:${controller.port}/${environment.current_version}/symbols/${template.symbol}/raw`; } } diff --git a/src/app/services/template.service.spec.ts b/src/app/services/template.service.spec.ts index 82cb9b64..5cbba60e 100644 --- a/src/app/services/template.service.spec.ts +++ b/src/app/services/template.service.spec.ts @@ -27,12 +27,12 @@ describe('TemplateService', () => { httpTestingController.verify(); }); - it('should ask for the list from server', () => { - const server = new Server(); - server.host = '127.0.0.1'; - server.port = 3080; + it('should ask for the list from controller', () => { + const controller = new Server(); + controller.host = '127.0.0.1'; + controller.port = 3080; - service.list(server).subscribe(() => {}); + service.list(controller).subscribe(() => {}); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`); expect(req.request.url).toBe(`http://127.0.0.1:3080/${environment.current_version}/templates`); diff --git a/src/app/services/template.service.ts b/src/app/services/template.service.ts index 9d1fca0b..e496e23d 100644 --- a/src/app/services/template.service.ts +++ b/src/app/services/template.service.ts @@ -11,11 +11,11 @@ export class TemplateService { constructor(private httpServer: HttpServer) {} - list(server: Server): Observable { - return this.httpServer.get(server, '/templates') as Observable; + list(controller: Server): Observable { + return this.httpServer.get(controller, '/templates') as Observable; } - deleteTemplate(server: Server, templateId: string): Observable { - return this.httpServer.delete(server, `/templates/${templateId}`, { observe: 'body' }); + deleteTemplate(controller: Server, templateId: string): Observable { + return this.httpServer.delete(controller, `/templates/${templateId}`, { observe: 'body' }); } } diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts index 8cd1d4e5..1de293c4 100644 --- a/src/app/services/user.service.ts +++ b/src/app/services/user.service.ts @@ -10,7 +10,7 @@ export class UserService { private httpServer: HttpServer ) {} - getInformationAboutLoggedUser(server: Server) { - return this.httpServer.get(server, '/users/me/'); + getInformationAboutLoggedUser(controller: Server) { + return this.httpServer.get(controller, '/users/me/'); } } diff --git a/src/app/services/version.service.spec.ts b/src/app/services/version.service.spec.ts index 6d8bad0e..6e83f327 100644 --- a/src/app/services/version.service.spec.ts +++ b/src/app/services/version.service.spec.ts @@ -12,7 +12,7 @@ import { VersionService } from './version.service'; export class MockedVersionService { public response: Observable; - public get(server: Server) { + public get(controller: Server) { return this.response; } } @@ -22,7 +22,7 @@ describe('VersionService', () => { let httpTestingController: HttpTestingController; let httpServer: HttpServer; let service: VersionService; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -34,7 +34,7 @@ describe('VersionService', () => { httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); service = TestBed.get(VersionService); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -46,7 +46,7 @@ describe('VersionService', () => { })); it('should get version', inject([VersionService], (service: VersionService) => { - service.get(server).subscribe(); + service.get(controller).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/version`); expect(req.request.method).toEqual('GET'); diff --git a/src/app/services/version.service.ts b/src/app/services/version.service.ts index eb834519..c688d4c2 100644 --- a/src/app/services/version.service.ts +++ b/src/app/services/version.service.ts @@ -8,7 +8,7 @@ import { HttpServer } from './http-server.service'; export class VersionService { constructor(private httpServer: HttpServer) {} - get(server: Server) { - return this.httpServer.get(server, '/version'); + get(controller: Server) { + return this.httpServer.get(controller, '/version'); } } diff --git a/src/app/services/virtual-box.service.spec.ts b/src/app/services/virtual-box.service.spec.ts index f06651a1..eddafbdb 100644 --- a/src/app/services/virtual-box.service.spec.ts +++ b/src/app/services/virtual-box.service.spec.ts @@ -13,7 +13,7 @@ describe('VirtualBoxService', () => { let httpClient: HttpClient; let httpTestingController: HttpTestingController; let httpServer: HttpServer; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -24,7 +24,7 @@ describe('VirtualBoxService', () => { httpClient = TestBed.get(HttpClient); httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -62,7 +62,7 @@ describe('VirtualBoxService', () => { vmname: '', }; - service.saveTemplate(server, template).subscribe(); + service.saveTemplate(controller, template).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/1`); expect(req.request.method).toEqual('PUT'); @@ -96,7 +96,7 @@ describe('VirtualBoxService', () => { vmname: '', }; - service.addTemplate(server, template).subscribe(); + service.addTemplate(controller, template).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`); expect(req.request.method).toEqual('POST'); @@ -104,7 +104,7 @@ describe('VirtualBoxService', () => { })); it('should get available virtual machines', inject([VirtualBoxService], (service: VirtualBoxService) => { - service.getVirtualMachines(server).subscribe(); + service.getVirtualMachines(controller).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/computes/${environment.compute_id}/virtualbox/vms`); expect(req.request.method).toEqual('GET'); diff --git a/src/app/services/virtual-box.service.ts b/src/app/services/virtual-box.service.ts index 878f4bbb..8c01ba2a 100644 --- a/src/app/services/virtual-box.service.ts +++ b/src/app/services/virtual-box.service.ts @@ -10,34 +10,34 @@ import { HttpServer } from './http-server.service'; export class VirtualBoxService { constructor(private httpServer: HttpServer) {} - getTemplates(server: Server): Observable { - return this.httpServer.get(server, '/templates') as Observable; + getTemplates(controller: Server): Observable { + return this.httpServer.get(controller, '/templates') as Observable; } - getTemplate(server: Server, template_id: string): Observable { + getTemplate(controller: Server, template_id: string): Observable { return this.httpServer.get( - server, + controller, `/templates/${template_id}` ) as Observable; } - addTemplate(server: Server, virtualBoxTemplate: VirtualBoxTemplate): Observable { + addTemplate(controller: Server, virtualBoxTemplate: VirtualBoxTemplate): Observable { return this.httpServer.post( - server, + controller, `/templates`, virtualBoxTemplate ) as Observable; } - saveTemplate(server: Server, virtualBoxTemplate: VirtualBoxTemplate): Observable { + saveTemplate(controller: Server, virtualBoxTemplate: VirtualBoxTemplate): Observable { return this.httpServer.put( - server, + controller, `/templates/${virtualBoxTemplate.template_id}`, virtualBoxTemplate ) as Observable; } - getVirtualMachines(server: Server): Observable { - return this.httpServer.get(server, `/computes/${environment.compute_id}/virtualbox/vms`) as Observable; + getVirtualMachines(controller: Server): Observable { + return this.httpServer.get(controller, `/computes/${environment.compute_id}/virtualbox/vms`) as Observable; } } diff --git a/src/app/services/vmware.service.spec.ts b/src/app/services/vmware.service.spec.ts index 9a1f38a0..2f3d3aa5 100644 --- a/src/app/services/vmware.service.spec.ts +++ b/src/app/services/vmware.service.spec.ts @@ -13,7 +13,7 @@ describe('VmwareService', () => { let httpClient: HttpClient; let httpTestingController: HttpTestingController; let httpServer: HttpServer; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -24,7 +24,7 @@ describe('VmwareService', () => { httpClient = TestBed.get(HttpClient); httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -61,7 +61,7 @@ describe('VmwareService', () => { vmx_path: '', }; - service.saveTemplate(server, template).subscribe(); + service.saveTemplate(controller, template).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/1`); expect(req.request.method).toEqual('PUT'); @@ -94,7 +94,7 @@ describe('VmwareService', () => { vmx_path: '', }; - service.addTemplate(server, template).subscribe(); + service.addTemplate(controller, template).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`); expect(req.request.method).toEqual('POST'); @@ -102,7 +102,7 @@ describe('VmwareService', () => { })); it('should get available virtual machines', inject([VmwareService], (service: VmwareService) => { - service.getVirtualMachines(server).subscribe(); + service.getVirtualMachines(controller).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/computes/${environment.compute_id}/vmware/vms`); expect(req.request.method).toEqual('GET'); diff --git a/src/app/services/vmware.service.ts b/src/app/services/vmware.service.ts index 6e051c80..a39f16f8 100644 --- a/src/app/services/vmware.service.ts +++ b/src/app/services/vmware.service.ts @@ -10,27 +10,27 @@ import { HttpServer } from './http-server.service'; export class VmwareService { constructor(private httpServer: HttpServer) {} - getTemplates(server: Server): Observable { - return this.httpServer.get(server, '/templates') as Observable; + getTemplates(controller: Server): Observable { + return this.httpServer.get(controller, '/templates') as Observable; } - getTemplate(server: Server, template_id: string): Observable { - return this.httpServer.get(server, `/templates/${template_id}`) as Observable; + getTemplate(controller: Server, template_id: string): Observable { + return this.httpServer.get(controller, `/templates/${template_id}`) as Observable; } - addTemplate(server: Server, vmwareTemplate: VmwareTemplate): Observable { - return this.httpServer.post(server, `/templates`, vmwareTemplate) as Observable; + addTemplate(controller: Server, vmwareTemplate: VmwareTemplate): Observable { + return this.httpServer.post(controller, `/templates`, vmwareTemplate) as Observable; } - saveTemplate(server: Server, vmwareTemplate: VmwareTemplate): Observable { + saveTemplate(controller: Server, vmwareTemplate: VmwareTemplate): Observable { return this.httpServer.put( - server, + controller, `/templates/${vmwareTemplate.template_id}`, vmwareTemplate ) as Observable; } - getVirtualMachines(server: Server): Observable { - return this.httpServer.get(server, `/computes/${environment.compute_id}/vmware/vms`) as Observable; + getVirtualMachines(controller: Server): Observable { + return this.httpServer.get(controller, `/computes/${environment.compute_id}/vmware/vms`) as Observable; } } diff --git a/src/app/services/vpcs.service.spec.ts b/src/app/services/vpcs.service.spec.ts index d3c351f0..ecf69078 100644 --- a/src/app/services/vpcs.service.spec.ts +++ b/src/app/services/vpcs.service.spec.ts @@ -13,7 +13,7 @@ describe('VpcsService', () => { let httpClient: HttpClient; let httpTestingController: HttpTestingController; let httpServer: HttpServer; - let server: Server; + let controller: Server; beforeEach(() => { TestBed.configureTestingModule({ @@ -24,7 +24,7 @@ describe('VpcsService', () => { httpClient = TestBed.get(HttpClient); httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); - server = getTestServer(); + controller = getTestServer(); }); afterEach(() => { @@ -50,7 +50,7 @@ describe('VpcsService', () => { template_type: 'vpcs', }; - service.saveTemplate(server, template).subscribe(); + service.saveTemplate(controller, template).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/1`); expect(req.request.method).toEqual('PUT'); @@ -72,7 +72,7 @@ describe('VpcsService', () => { template_type: 'vpcs', }; - service.addTemplate(server, template).subscribe(); + service.addTemplate(controller, template).subscribe(); const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`); expect(req.request.method).toEqual('POST'); diff --git a/src/app/services/vpcs.service.ts b/src/app/services/vpcs.service.ts index c07f781f..9e0f0862 100644 --- a/src/app/services/vpcs.service.ts +++ b/src/app/services/vpcs.service.ts @@ -8,21 +8,21 @@ import { HttpServer } from './http-server.service'; export class VpcsService { constructor(private httpServer: HttpServer) {} - getTemplates(server: Server): Observable { - return this.httpServer.get(server, '/templates') as Observable; + getTemplates(controller: Server): Observable { + return this.httpServer.get(controller, '/templates') as Observable; } - getTemplate(server: Server, template_id: string): Observable { - return this.httpServer.get(server, `/templates/${template_id}`) as Observable; + getTemplate(controller: Server, template_id: string): Observable { + return this.httpServer.get(controller, `/templates/${template_id}`) as Observable; } - addTemplate(server: Server, vpcsTemplate: VpcsTemplate): Observable { - return this.httpServer.post(server, `/templates`, vpcsTemplate) as Observable; + addTemplate(controller: Server, vpcsTemplate: VpcsTemplate): Observable { + return this.httpServer.post(controller, `/templates`, vpcsTemplate) as Observable; } - saveTemplate(server: Server, vpcsTemplate: VpcsTemplate): Observable { + saveTemplate(controller: Server, vpcsTemplate: VpcsTemplate): Observable { return this.httpServer.put( - server, + controller, `/templates/${vpcsTemplate.template_id}`, vpcsTemplate ) as Observable; diff --git a/src/app/validators/project-name-async-validator.ts b/src/app/validators/project-name-async-validator.ts index a18fa751..f766808f 100644 --- a/src/app/validators/project-name-async-validator.ts +++ b/src/app/validators/project-name-async-validator.ts @@ -4,10 +4,10 @@ import { map, switchMap } from 'rxjs/operators'; import { Server } from '../models/server'; import { ProjectService } from '../services/project.service'; -export const projectNameAsyncValidator = (server: Server, projectService: ProjectService) => { +export const projectNameAsyncValidator = (controller: Server, projectService: ProjectService) => { return (control: FormControl) => { return timer(500).pipe( - switchMap(() => projectService.list(server)), + switchMap(() => projectService.list(controller)), map((response) => (response.find((n) => n.name === control.value) ? { projectExist: true } : null)) ); }; diff --git a/src/app/validators/template-name-async-validator.ts b/src/app/validators/template-name-async-validator.ts index 3dd4e1b6..cbe35d7b 100644 --- a/src/app/validators/template-name-async-validator.ts +++ b/src/app/validators/template-name-async-validator.ts @@ -4,10 +4,10 @@ import { map, switchMap } from 'rxjs/operators'; import { Server } from '../models/server'; import { TemplateService } from '../services/template.service'; -export const templateNameAsyncValidator = (server: Server, templateService: TemplateService) => { +export const templateNameAsyncValidator = (controller: Server, templateService: TemplateService) => { return (control: FormControl) => { return timer(500).pipe( - switchMap(() => templateService.list(server)), + switchMap(() => templateService.list(controller)), map((response) => (response.find((n) => n.name === control.value) ? { templateExist: true } : null)) ); };