Skip to content

Commit

Permalink
Enable node communication mode editing
Browse files Browse the repository at this point in the history
This was only enabled in dev mode before. Now that we've updated to the latest API version, we can enable in production.
  • Loading branch information
dpwatrous committed Oct 16, 2023
1 parent cbd42c1 commit 75c8c8f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, isDevMode } from "@angular/core";
import { Component, Input } from "@angular/core";
import { autobind } from "@batch-flask/core";
import { SidebarManager } from "@batch-flask/ui/sidebar";
import { EditMetadataFormComponent } from "app/components/common/edit-metadata-form";
Expand Down Expand Up @@ -27,13 +27,25 @@ export class PoolConfigurationComponent {
}
public get pool() { return this._pool; }

public isDevMode: boolean = isDevMode();

public decorator: PoolDecorator;
public certificates: List<CertificateReference>;
public appPackages: List<ApplicationPackageReference>;
public metadata: List<Metadata> = List([]);

public get nodeCommSummary(): string {
const current = this._pool.currentNodeCommunicationMode;
const currentLabel = this.decorator.currentNodeCommunicationMode;

const target = this._pool.targetNodeCommunicationMode;
const targetLabel = this.decorator.targetNodeCommunicationMode;

if (target === "default" || current === target) {
return currentLabel;
} else {
return `${currentLabel} -> ${targetLabel}`;
}
}

private _pool: Pool;

constructor(private sidebarManager: SidebarManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@
</bl-no-item>
</bl-property-group>

<!-- TODO: Remove ngIf="isDevMode" (and the isDevMode property) when the API version is updated to support node communication mode -->
<bl-property-group *ngIf="isDevMode" label="Node communication" class="wide" [collapsed]="true" [edit]="editNodeComms">
<bl-property-group label="Node communication" class="wide" [collapsed]="true" [edit]="editNodeComms">
<div collapsed-preview>
<span>{{decorator.currentNodeCommunicationMode}}</span>
<span>{{nodeCommSummary}}</span>
</div>
<bl-text-property label="Current mode" value="{{decorator.currentNodeCommunicationMode || 'N/A'}}"></bl-text-property>
<bl-text-property label="Target mode" value="{{decorator.targetNodeCommunicationMode || 'Default'}}"></bl-text-property>
Expand Down
24 changes: 23 additions & 1 deletion desktop/src/app/decorators/pool-decorator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { StartTaskDecorator } from "app/decorators/start-task.decorator";
import {
ApplicationPackageReference, CertificateReference, Pool, UserAccount, UserAccountElevationLevel,
ApplicationPackageReference,
CertificateReference,
NodeCommunicationMode,
Pool,
UserAccount,
UserAccountElevationLevel,
} from "app/models";
import { PoolUtils } from "app/utils";
import { DecoratorBase } from "app/utils/decorators";
Expand Down Expand Up @@ -41,6 +46,8 @@ export class PoolDecorator extends DecoratorBase<Pool> {
public networkSubnetId: string;
public startTask: StartTaskDecorator;
public applicationLicenses: string;
public targetNodeCommunicationMode?: string;
public currentNodeCommunicationMode?: string;

public get routerLink() {
return this.pool.routerLink;
Expand Down Expand Up @@ -69,6 +76,8 @@ export class PoolDecorator extends DecoratorBase<Pool> {
this.startTask = pool.startTask && new StartTaskDecorator(pool.startTask);
this.lowPriorityNodes = PoolUtils.poolNodesStatus(pool,
pool.currentLowPriorityNodes, pool.targetLowPriorityNodes);
this.targetNodeCommunicationMode = this._nodeCommsField(pool.targetNodeCommunicationMode);
this.currentNodeCommunicationMode = this._nodeCommsField(pool.currentNodeCommunicationMode);

this.poolOs = this._computePoolOs();

Expand All @@ -94,4 +103,17 @@ export class PoolDecorator extends DecoratorBase<Pool> {
}
return user.name;
}

private _nodeCommsField(value: NodeCommunicationMode): string {
switch (value) {
case "default":
return "Default";
case "classic":
return "Classic";
case "simplified":
return "Simplified";
default:
return value;
}
}
}

0 comments on commit 75c8c8f

Please sign in to comment.