From fb9a6bfd4dbe6aeed739fcd90035cf89c94568e3 Mon Sep 17 00:00:00 2001 From: Andrew Schlackman <72105194+sei-aschlackman@users.noreply.github.com> Date: Wed, 24 Apr 2024 10:49:09 -0400 Subject: [PATCH] added menu toggle to manually enable read only mode --- .../components/console/console.component.html | 3 +- .../components/console/console.component.ts | 13 +++++- .../options-bar/options-bar.component.html | 22 +++++++++- .../options-bar/options-bar.component.ts | 32 ++++++++++++--- src/app/components/wmks/wmks.component.ts | 3 +- src/app/state/vm/vm.service.ts | 9 ++++- src/app/state/vsphere/vsphere.service.ts | 40 +++++++++++++------ 7 files changed, 97 insertions(+), 25 deletions(-) diff --git a/src/app/components/console/console.component.html b/src/app/components/console/console.component.html index 762cd61..e88f230 100644 --- a/src/app/components/console/console.component.html +++ b/src/app/components/console/console.component.html @@ -27,8 +27,9 @@ [readOnly]="readOnly" [vm]="vsphereVm$ | async" [vmId]="vmId" + (readOnlyChanged)="onReadOnlyChanged($event)" > - + } } } diff --git a/src/app/components/console/console.component.ts b/src/app/components/console/console.component.ts index 309c21d..aafd8eb 100644 --- a/src/app/components/console/console.component.ts +++ b/src/app/components/console/console.component.ts @@ -2,7 +2,7 @@ // Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information. import { Component, Input } from '@angular/core'; -import { Observable } from 'rxjs'; +import { BehaviorSubject, Observable } from 'rxjs'; import { Vm, VmType, VsphereVirtualMachine } from '../../generated/vm-api'; import { VmService } from '../../state/vm/vm.service'; import { VsphereQuery } from '../../state/vsphere/vsphere.query'; @@ -26,7 +26,7 @@ import { OptionsBar2Component } from '../options-bar2/options-bar2.component'; ], }) export class ConsoleComponent { - @Input() readOnly; + @Input() readOnly = false; @Input() set vmId(value: string) { this._vmId = value; @@ -47,8 +47,17 @@ export class ConsoleComponent { vsphereVm$: Observable; virtualMachine$: Observable; + readOnlyInternal = false; + readOnlySubject = new BehaviorSubject(this.readOnly); + readOnly$ = this.readOnlySubject.asObservable(); + constructor( private vsphereQuery: VsphereQuery, private vmService: VmService, ) {} + + onReadOnlyChanged(event: boolean) { + this.readOnlyInternal = event; + this.readOnlySubject.next(this.readOnlyInternal || this.readOnly); + } } diff --git a/src/app/components/options-bar/options-bar.component.html b/src/app/components/options-bar/options-bar.component.html index c481ba6..165cad7 100644 --- a/src/app/components/options-bar/options-bar.component.html +++ b/src/app/components/options-bar/options-bar.component.html @@ -9,7 +9,9 @@ - {{ vm?.name }} + {{ vm?.name }}{{ readOnlyInternal ? ' (Read Only)' : '' }}
@@ -20,6 +22,22 @@
@if (!readOnly) { + + } + + @if (!readOnlyInternal) {
@if (!vmService.model.isOwner) { @@ -253,7 +271,7 @@

{{ task.taskName }} ... {{ task.progress }}%

}
- @if (!readOnly) { + @if (!readOnlyInternal) {