-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
102 changed files
with
464 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...on/components/all-instances/instance-details/instance-tools/instance-tools.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<mat-card class="card"> | ||
<mat-card-header> | ||
<h3 mat-card-title> | ||
{{ 'Tools' | translate }} | ||
</h3> | ||
</mat-card-header> | ||
|
||
<mat-card-content> | ||
<div [matTooltip]="isInstanceStopped() ? ('Instance is not running' | translate) : ''"> | ||
<a | ||
mat-flat-button | ||
color="default" | ||
ixTest="open-shell" | ||
class="tool" | ||
[disabled]="isInstanceStopped()" | ||
[routerLink]="['/virtualization', 'view', instance().id, 'shell']" | ||
> | ||
<span>{{ 'Shell' | translate }}</span> | ||
|
||
<ix-icon name="mdi-console"></ix-icon> | ||
</a> | ||
</div> | ||
</mat-card-content> | ||
</mat-card> |
9 changes: 9 additions & 0 deletions
9
...on/components/all-instances/instance-details/instance-tools/instance-tools.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.tool { | ||
display: flex; | ||
margin: 0 -16px; | ||
|
||
::ng-deep .mdc-button__label { | ||
flex-grow: 1; | ||
justify-content: space-between; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...components/all-instances/instance-details/instance-tools/instance-tools.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { HarnessLoader } from '@angular/cdk/testing'; | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
import { MatButtonHarness } from '@angular/material/button/testing'; | ||
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest'; | ||
import { VirtualizationStatus } from 'app/enums/virtualization.enum'; | ||
import { VirtualizationInstance } from 'app/interfaces/virtualization.interface'; | ||
import { | ||
InstanceToolsComponent, | ||
} from 'app/pages/virtualization/components/all-instances/instance-details/instance-tools/instance-tools.component'; | ||
|
||
describe('InstanceToolsComponent', () => { | ||
let spectator: Spectator<InstanceToolsComponent>; | ||
let loader: HarnessLoader; | ||
const createComponent = createComponentFactory({ | ||
component: InstanceToolsComponent, | ||
}); | ||
|
||
beforeEach(() => { | ||
spectator = createComponent({ | ||
props: { | ||
instance: { | ||
id: 'my-instance', | ||
status: VirtualizationStatus.Running, | ||
} as VirtualizationInstance, | ||
}, | ||
}); | ||
|
||
loader = TestbedHarnessEnvironment.loader(spectator.fixture); | ||
}); | ||
|
||
describe('shell', () => { | ||
it('shows a link to shell', async () => { | ||
const shellLink = await loader.getHarness(MatButtonHarness.with({ text: 'Shell' })); | ||
|
||
expect(shellLink).toBeTruthy(); | ||
expect(await (await shellLink.host()).getAttribute('href')).toBe('/virtualization/view/my-instance/shell'); | ||
}); | ||
|
||
it('show shell link as disabled when instance is not running', async () => { | ||
spectator.setInput('instance', { | ||
id: 'my-instance', | ||
status: VirtualizationStatus.Stopped, | ||
} as VirtualizationInstance); | ||
|
||
const shellLink = await loader.getHarness(MatButtonHarness.with({ text: 'Shell' })); | ||
expect(await shellLink.isDisabled()).toBe(true); | ||
}); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
...tion/components/all-instances/instance-details/instance-tools/instance-tools.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
ChangeDetectionStrategy, Component, computed, input, | ||
} from '@angular/core'; | ||
import { MatAnchor, MatButton } from '@angular/material/button'; | ||
import { | ||
MatCard, MatCardContent, MatCardHeader, MatCardTitle, | ||
} from '@angular/material/card'; | ||
import { MatTooltip } from '@angular/material/tooltip'; | ||
import { RouterLink } from '@angular/router'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { VirtualizationStatus } from 'app/enums/virtualization.enum'; | ||
import { VirtualizationInstance } from 'app/interfaces/virtualization.interface'; | ||
import { IxIconComponent } from 'app/modules/ix-icon/ix-icon.component'; | ||
import { TestDirective } from 'app/modules/test-id/test.directive'; | ||
|
||
@Component({ | ||
selector: 'ix-instance-tools', | ||
templateUrl: './instance-tools.component.html', | ||
styleUrls: ['./instance-tools.component.scss'], | ||
standalone: true, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
imports: [ | ||
MatCardTitle, | ||
MatCardHeader, | ||
MatCard, | ||
MatCardContent, | ||
TranslateModule, | ||
MatButton, | ||
MatAnchor, | ||
TestDirective, | ||
IxIconComponent, | ||
MatTooltip, | ||
RouterLink, | ||
], | ||
}) | ||
export class InstanceToolsComponent { | ||
readonly instance = input.required<VirtualizationInstance>(); | ||
|
||
protected readonly isInstanceStopped = computed(() => this.instance().status !== VirtualizationStatus.Running); | ||
} |
37 changes: 37 additions & 0 deletions
37
src/app/pages/virtualization/components/instance-shell/instance-shell.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; | ||
import { Observable, Subscriber } from 'rxjs'; | ||
import { TerminalConfiguration, TerminalConnectionData } from 'app/interfaces/terminal.interface'; | ||
import { TerminalComponent } from 'app/modules/terminal/components/terminal/terminal.component'; | ||
|
||
@UntilDestroy() | ||
@Component({ | ||
selector: 'ix-instance-shell', | ||
template: '<ix-terminal [conf]="this"></ix-terminal>', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [TerminalComponent], | ||
}) | ||
export class InstanceShellComponent implements TerminalConfiguration { | ||
protected instanceId = signal(''); | ||
|
||
get connectionData(): TerminalConnectionData { | ||
return { | ||
virt_instance_id: this.instanceId(), | ||
}; | ||
} | ||
|
||
constructor( | ||
private aroute: ActivatedRoute, | ||
) {} | ||
|
||
preInit(): Observable<void> { | ||
return new Observable<void>((subscriber: Subscriber<void>) => { | ||
this.aroute.params.pipe(untilDestroyed(this)).subscribe((params) => { | ||
this.instanceId.set(params['id'] as string); | ||
subscriber.next(); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.