Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

user follow enhancements #660

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
<!-- wait for readOnly http call to evaluate before initializing app-console -->
@if ({ value: readOnly$ | async }; as readOnly) {
@if (readOnly.value != null) {
<app-console [readOnly]="readOnly.value" [vmId]="vmId$ | async">
<app-console
[readOnly]="vmService.readOnly$ | async"
[allowReadOnlyToggle]="vmService.readOnlyToggleable$ | async"
[vmId]="vmId$ | async"
>
</app-console>
}
}
7 changes: 5 additions & 2 deletions src/app/components/console-page/console-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ export class ConsolePageComponent implements OnInit, OnDestroy {
private signalrRService: SignalRService,
private vmQuery: VmQuery,
private titleService: Title,
private vmService: VmService,
private authService: ComnAuthService,
public vmService: VmService,
) {}

ngOnInit() {
this.vmId = this.routerQuery.getParams('id');

this.signalrRService.startConnection().then(() => {
this.signalrRService.joinVm(this.vmId);

if (document.hasFocus()) {
this.signalrRService.setActiveVirtualMachine(this.vmId);
}
Expand All @@ -69,6 +70,8 @@ export class ConsolePageComponent implements OnInit, OnDestroy {
}

ngOnDestroy(): void {
this.signalrRService.leaveVm(this.vmId);

this.unsubscribe$.next(null);
this.unsubscribe$.complete();
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/console/console.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
) {
<app-options-bar
[readOnly]="readOnly"
[allowReadOnlyToggle]="allowReadOnlyToggle"
[vm]="vsphereVm$ | async"
[vmId]="vmId"
(readOnlyChanged)="onReadOnlyChanged($event)"
></app-options-bar>
<app-wmks [readOnly]="readOnlyInternal" [vmId]="vmId"></app-wmks>
<app-wmks [readOnly]="readOnly" [vmId]="vmId"></app-wmks>
}
}
}
Expand Down
11 changes: 1 addition & 10 deletions src/app/components/console/console.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { OptionsBar2Component } from '../options-bar2/options-bar2.component';
})
export class ConsoleComponent {
@Input({ required: true }) readOnly;
@Input({ required: true }) allowReadOnlyToggle;

@Input({ required: true }) set vmId(value: string) {
this._vmId = value;
Expand All @@ -47,18 +48,8 @@ export class ConsoleComponent {
vsphereVm$: Observable<VsphereVirtualMachine>;
virtualMachine$: Observable<Vm>;

readOnlyManual = false;

get readOnlyInternal() {
return this.readOnlyManual || this.readOnly;
}

constructor(
private vsphereQuery: VsphereQuery,
private vmService: VmService,
) {}

onReadOnlyChanged(event: boolean) {
this.readOnlyManual = event;
}
}
50 changes: 25 additions & 25 deletions src/app/components/options-bar/options-bar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<mat-icon svgIcon="gear" alt="Gear"></mat-icon>
</button>
<span class="ms-1"
>{{ vm?.name }}{{ readOnlyInternal ? ' (Read Only)' : '' }}</span
>{{ vm?.name }}{{ readOnly ? ' (Read Only)' : '' }}</span
>
<mat-menu #mainMenu="matMenu">
<div>
Expand All @@ -21,7 +21,7 @@
<button mat-menu-item (click)="reconnect()">Reconnect</button>
</div>

@if (!readOnly) {
@if (allowReadOnlyToggle) {
<button mat-menu-item (click)="$event.stopPropagation()">
<mat-slide-toggle
labelPosition="before"
Expand All @@ -37,10 +37,10 @@
</button>
}

@if (!readOnlyInternal) {
@if (!readOnly) {
<div>
<!-- Resolution -->
@if (!vmService.model.isOwner) {
@if (!vsphereService.model.isOwner) {
<button
mat-menu-item
[matMenuTriggerFor]="resolutionMenu"
Expand All @@ -49,10 +49,10 @@
>
<span
[matTooltip]="
vmService.model.vmToolsStatus ===
vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotInstalled
? 'VmWare Tools is not installed'
: vmService.model.vmToolsStatus ===
: vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotRunning
? 'VmWare Tools is not running'
: ''
Expand All @@ -67,9 +67,9 @@
<button
mat-menu-item
[disabled]="
vmService.model.vmToolsStatus ===
vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotRunning ||
vmService.model.vmToolsStatus ===
vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotInstalled
"
(click)="setResolution(currentVmContainerResolution)"
Expand All @@ -85,9 +85,9 @@
<button
mat-menu-item
[disabled]="
vmService.model.vmToolsStatus ===
vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotRunning ||
vmService.model.vmToolsStatus ===
vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotInstalled
"
(click)="setResolution(vmRes)"
Expand All @@ -108,10 +108,10 @@
<button mat-menu-item (click)="reboot()">Reboot</button>
<div
[matTooltip]="
vmService.model.vmToolsStatus ===
vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotInstalled
? 'VmWare Tools is not installed'
: vmService.model.vmToolsStatus ===
: vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotRunning
? 'VmWare Tools is not running'
: ''
Expand All @@ -121,9 +121,9 @@
<button
mat-menu-item
[disabled]="
vmService.model.vmToolsStatus ===
vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotRunning ||
vmService.model.vmToolsStatus ===
vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotInstalled
"
(click)="shutdownOS()"
Expand All @@ -148,10 +148,10 @@
<!-- send to VM -->
<div
[matTooltip]="
vmService.model.vmToolsStatus ===
vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotInstalled
? 'VmWare Tools is not installed'
: vmService.model.vmToolsStatus ===
: vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotRunning
? 'VmWare Tools is not running'
: ''
Expand All @@ -163,9 +163,9 @@
(click)="enableFileUpload('VM Send File Settings')"
[disabled]="
uploading ||
vmService.model.vmToolsStatus ===
vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotRunning ||
vmService.model.vmToolsStatus ===
vsphereService.model.vmToolsStatus ===
virtualMachineToolsStatus.toolsNotInstalled
"
aria-label="warning"
Expand Down Expand Up @@ -207,28 +207,28 @@
Send Text
</button>
</mat-menu>
@if (vmService.model.networkCards) {
@if (vsphereService.model.networkCards) {
<span>
@if (
vmService.model.canAccessNicConfiguration &&
vmService.model.networkCards.availableNetworks.length > 0
vsphereService.model.canAccessNicConfiguration &&
vsphereService.model.networkCards.availableNetworks.length > 0
) {
<button mat-menu-item [matMenuTriggerFor]="main_menu">
Network Cards
</button>
}
<mat-menu #main_menu="matMenu">
@for (
mainItem of vmService.model.networkCards.currentNetworks
| keys;
mainItem of vsphereService.model.networkCards
.currentNetworks | keys;
track mainItem
) {
<button mat-menu-item [matMenuTriggerFor]="sub_menu">
{{ mainItem.key }}
</button>
<mat-menu #sub_menu="matMenu">
@for (
subItem of vmService.model.networkCards
subItem of vsphereService.model.networkCards
.availableNetworks;
track subItem
) {
Expand Down Expand Up @@ -271,7 +271,7 @@ <h1 class="fs-6">{{ task.taskName }} ... {{ task.progress }}%</h1>
}
</div>

@if (!readOnlyInternal) {
@if (!readOnly) {
<div class="w-50 d-flex justify-content-center">
<button
mat-stroked-button
Expand Down
Loading