+ Computing Idle-PC values, please wait...
+
+
+
+
+
+
Choose an Idle-PC value
+
+
+ {{ idlepc.name }}
+
+
+
+
+
+
+
+
diff --git a/src/app/components/project-map/context-menu/dialogs/idle-pc-dialog/idle-pc-dialog.component.scss b/src/app/components/project-map/context-menu/dialogs/idle-pc-dialog/idle-pc-dialog.component.scss
new file mode 100644
index 00000000..add91a3f
--- /dev/null
+++ b/src/app/components/project-map/context-menu/dialogs/idle-pc-dialog/idle-pc-dialog.component.scss
@@ -0,0 +1,5 @@
+.container {
+ width: 100%;
+ display: flex;
+ justify-content: space-between;
+}
diff --git a/src/app/components/project-map/context-menu/dialogs/idle-pc-dialog/idle-pc-dialog.component.spec.ts b/src/app/components/project-map/context-menu/dialogs/idle-pc-dialog/idle-pc-dialog.component.spec.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/src/app/components/project-map/context-menu/dialogs/idle-pc-dialog/idle-pc-dialog.component.ts b/src/app/components/project-map/context-menu/dialogs/idle-pc-dialog/idle-pc-dialog.component.ts
new file mode 100644
index 00000000..c6b64968
--- /dev/null
+++ b/src/app/components/project-map/context-menu/dialogs/idle-pc-dialog/idle-pc-dialog.component.ts
@@ -0,0 +1,66 @@
+import {ChangeDetectorRef, Component, Inject, Input, OnInit} from '@angular/core';
+import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
+import {Controller} from "@models/controller";
+import {Node} from '../../../../../cartography/models/node';
+import {NodeService} from "@services/node.service";
+import {ToasterService} from "@services/toaster.service";
+
+@Component({
+ selector: 'app-idle-pc-dialog',
+ templateUrl: './idle-pc-dialog.component.html',
+ styleUrls: ['./idle-pc-dialog.component.scss'],
+})
+export class IdlePCDialogComponent implements OnInit {
+ @Input() controller: Controller;
+ @Input() node: Node;
+
+ idlepcs = [];
+ idlePC: string = '';
+ isComputing: boolean = false;
+
+ constructor(
+ private nodeService: NodeService,
+ public dialogRef: MatDialogRef,
+ private toasterService: ToasterService) {}
+
+ ngOnInit() {
+ this.onCompute();
+ }
+
+ onCompute() {
+ this.isComputing = true;
+ this.nodeService.getIdlePCProposals(this.controller, this.node).subscribe((idlepcs: any) => {
+ let idlepcs_values = [];
+ for (let value of idlepcs) {
+ // validate idle-pc format, e.g. 0x60c09aa0
+ const match = value.match(/^(0x[0-9a-f]{8})\s+\[(\d+)\]$/);
+ if (match) {
+ const idlepc = match[1];
+ const count = parseInt(match[2], 10);
+ if (50 <= count && count <= 60) {
+ value += "*";
+ }
+ idlepcs_values.push({'key': idlepc, 'name': value})
+ }
+ }
+ this.idlepcs = idlepcs_values;
+ if (this.idlepcs.length > 0) {
+ this.idlePC = this.idlepcs[0].key;
+ }
+ this.isComputing = false;
+ });
+ }
+
+ onClose() {
+ this.dialogRef.close();
+ }
+
+ onApply() {
+ if (this.idlePC && this.idlePC !== '0x0') {
+ this.node.properties.idlepc = this.idlePC;
+ this.nodeService.updateNode(this.controller, this.node).subscribe(() => {
+ this.toasterService.success(`Node ${this.node.name} updated with idle-PC value ${this.idlePC}`);
+ });
+ }
+ }
+}
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 cd80f331..cbdd8de5 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() controller:Controller ;
+ @Input() controller: Controller;
@Input() project: Project;
name: string;
diff --git a/src/app/services/node.service.ts b/src/app/services/node.service.ts
index 1ad20419..b5785baa 100644
--- a/src/app/services/node.service.ts
+++ b/src/app/services/node.service.ts
@@ -232,4 +232,12 @@ export class NodeService {
return this.httpController.post(controller, urlPath, configuration);
}
+
+ getIdlePCProposals(controller:Controller, node: Node) {
+ return this.httpController.get(controller, `/projects/${node.project_id}/nodes/${node.node_id}/dynamips/idlepc_proposals`);
+ }
+
+ getAutoIdlePC(controller:Controller, node: Node) {
+ return this.httpController.get(controller, `/projects/${node.project_id}/nodes/${node.node_id}/dynamips/auto_idlepc`);
+ }
}