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

Verification checks against vm #171

Merged
merged 24 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f35acd0
add verification service and ui element
pprinzSVA Jun 16, 2023
5dcdd39
combine ui elements to one interactive element
pprinzSVA Jul 19, 2023
ea83f30
combine ui elements to one interactive element
pprinzSVA Jul 19, 2023
957cea0
only show task progress if scenario has tasks
pprinzSVA Jul 19, 2023
c5cb1a2
fix keeping old Task information
pprinzSVA Jul 20, 2023
24bb8f1
add markdown component to verify single Task
pprinzSVA Aug 18, 2023
007b0d8
adapt to support darkmode variables
pprinzSVA Aug 21, 2023
535c885
fix linting errors and warnings
pprinzSVA Aug 21, 2023
43c1278
fix formatting issues
pprinzSVA Aug 21, 2023
c352b2e
add animation to Button
pprinzSVA Sep 5, 2023
b250569
adapt to new angular version
pprinzSVA Oct 13, 2023
4472b11
adapt to new /verify response
pprinzSVA Feb 22, 2024
6f76bec
Display only relevant expected and actual Output/Returncode
pprinzSVA Feb 22, 2024
ecf35b7
fix infinite loading spinner if not all nodes have at least 1 Task
pprinzSVA Mar 21, 2024
dbc1ed1
DMerge master
jggoebel Apr 4, 2024
2465894
Run prettier & Dark mode fixes
jggoebel Apr 4, 2024
e89da0a
prettier
jggoebel Apr 4, 2024
0e72baa
Change verify endpoint to https to avoid browser stopping request
jggoebel Apr 5, 2024
afcc955
Improve design
jggoebel Apr 9, 2024
928d405
Improve design for tasklist
jggoebel Apr 9, 2024
8fac24d
Display checkmark if all tasks are successful
jggoebel Apr 9, 2024
feddc6a
Green circle if all tasks complete
jggoebel Apr 9, 2024
0ae382d
Show VM Name and fix icon position on task progress modal
pprinzSVA Apr 11, 2024
d803c46
Merge master
jggoebel Apr 15, 2024
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
3 changes: 2 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@
}
},
"cli": {
"schematicCollections": ["@angular-eslint/schematics"]
"schematicCollections": ["@angular-eslint/schematics"],
"analytics": false
},
"schematics": {
"@angular-eslint/schematics:application": {
Expand Down
24 changes: 23 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ import { GuacTerminalComponent } from './scenario/guacTerminal.component';
import { IdeWindowComponent } from './scenario/ideWindow.component';
import { ContextService } from './services/context.service';
import { TypedSettingsService } from './services/typedSettings.service';
import { VerificationService } from './services/verification.service';
import { TaskProgressComponent } from './scenario/task-progress/task-progress.component';
import { TaskModalComponent } from './scenario/task-modal/task-modal.component';
import { SingleTaskVerificationMarkdownComponent } from './hf-markdown/single-task-verification-markdown/single-task-verification-markdown.component';
import '@cds/core/icon/register.js';
import {
ClarityIcons,
Expand All @@ -69,6 +73,7 @@ import {
windowCloseIcon,
arrowIcon,
hostIcon,
syncIcon,
eyeIcon,
eyeHideIcon,
clockIcon,
Expand Down Expand Up @@ -99,6 +104,7 @@ ClarityIcons.addIcons(
windowCloseIcon,
arrowIcon,
hostIcon,
syncIcon,
eyeIcon,
eyeHideIcon,
clockIcon,
Expand All @@ -114,10 +120,21 @@ const appInitializerFn = (appConfig: AppConfigService) => {
};
};

export const jwtAllowedDomains = [
environment.server.replace(/(^\w+:|^)\/\//, ''),
];

export function addJwtAllowedDomain(domain: string) {
const newDomain = domain.replace(/(^\w+:|^)\/\//, '');
if (!jwtAllowedDomains.includes(newDomain)) {
jwtAllowedDomains.push(newDomain);
}
}

export function jwtOptionsFactory() {
return {
tokenGetter: tokenGetter,
allowedDomains: [environment.server.replace(/(^\w+:|^)\/\//, '')],
allowedDomains: jwtAllowedDomains,
disallowedRoutes: [
environment.server.replace(/(^\w+:|^)\/\//, '') + '/auth/authenticate',
],
Expand Down Expand Up @@ -147,6 +164,9 @@ export function jwtOptionsFactory() {
HfMarkdownComponent,
PrintableComponent,
IdeWindowComponent,
TaskProgressComponent,
TaskModalComponent,
SingleTaskVerificationMarkdownComponent,
],
imports: [
BrowserModule,
Expand All @@ -167,6 +187,7 @@ export function jwtOptionsFactory() {
},
globalParsers: [
{ component: CtrComponent },
{ component: SingleTaskVerificationMarkdownComponent },
{ component: QuizComponent },
],
}),
Expand All @@ -193,6 +214,7 @@ export function jwtOptionsFactory() {
ProgressService,
ContextService,
TypedSettingsService,
VerificationService,
{
provide: APP_INITIALIZER,
useFactory: appInitializerFn,
Expand Down
8 changes: 8 additions & 0 deletions src/app/hf-markdown/hf-markdown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ ${token}`;
>${this.renderHighlightedCode(code, language, filename)}</ctr>`;
},

verifyTask(code: string, target: string, taskName: string) {
return `<app-single-task-verification-markdown
target="${target}"
message="${code}"
taskName="${taskName}"
></app-single-task-verification-markdown>`;
},

mermaid(code: string) {
const n = 5;
const containerId = `mermaid-${this.uniqueString(n)}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<details
[ngClass]="task?.success ? 'greenBorder' : 'redBorder'"
(toggle)="detailsOpen = !detailsOpen"
>
<summary class="flex-container">
<div>
<cds-icon
shape="angle"
[ngClass]="detailsOpen ? 'down' : 'sideways'"
inverse
></cds-icon>
Verify: {{ taskName }} on {{ target }}
</div>
<div class="label-container">
<button
id="refreshButton"
(click)="elementClicked()"
class="label label-info"
label="Revalidate"
>
<cds-icon
[@rotatedState]="rotationState"
shape="sync"
inverse
></cds-icon>
</button>
<div *ngIf="task?.success" class="label label-status label-success">
<cds-icon shape="check" inverse></cds-icon>
</div>
<div *ngIf="!task?.success" class="label label-status label-danger">
<cds-icon shape="times" inverse></cds-icon>
</div>
</div>
</summary>

<ul class="list-group" *ngIf="task">
<li class="list-group-item">
<p>
Description: <b>{{ task.description }}</b>
</p>
<p>
Command: <code>{{ task.command }}</code>
</p>
</li>
<li class="list-group-item" *ngIf="isOfReturnType(task, ['Match_Regex'])">
<p>
Regular Expression: <code>{{ task.expected_output_value }}</code>
</p>
<p>
Actual Output: <code>{{ task.actual_output_value }}</code>
</p>
</li>
<li
class="list-group-item"
*ngIf="isOfReturnType(task, ['Return_Text', 'Return_Code_And_Text'])"
>
<p>
Expected Output: <code>{{ task.expected_output_value }}</code>
</p>
<p>
Actual Output: <code>{{ task.actual_output_value }}</code>
</p>
</li>
<li
class="list-group-item"
*ngIf="isOfReturnType(task, ['Return_Code', 'Return_Code_And_Text'])"
>
<p>
Expected Returncode: <code>{{ task.expected_return_code }}</code>
</p>
<p>
Actual Returncode: <code>{{ task.actual_return_code }}</code>
</p>
</li>
<li class="list-group-item" *ngIf="taskUnset()">
<button
id="refreshButton"
(click)="elementClicked()"
class="label label-info"
label="Revalidate"
>
<cds-icon
[@rotatedState]="rotationState"
shape="sync"
inverse
></cds-icon>
</button>
Run the validation checks once to see the result.
</li>
<li class="list-group-item" *ngIf="!taskUnset()">
<span *ngIf="task.success" class="label label-success">
<cds-icon shape="check" inverse></cds-icon>
</span>
<span *ngIf="!task.success" class="label label-danger">
<cds-icon shape="times" inverse></cds-icon>
</span>
<ng-container *ngIf="isOfReturnType(task, ['Match_Regex'])">
<span *ngIf="task.success">The Regex matches the output string.</span>
<span *ngIf="!task.success"
>The Regex does not match the output string.</span
>
</ng-container>
<ng-container *ngIf="isOfReturnType(task, ['Return_Code'])">
<span *ngIf="task.success"
>Returned Code matches the expected Code</span
>
<span *ngIf="!task.success">
Returned Code does not match the expected Code
</span>
</ng-container>
<ng-container *ngIf="isOfReturnType(task, ['Return_Text'])">
<span *ngIf="task.success"
>Returned Text matches the expected Text</span
>
<span *ngIf="!task.success">
Returned Text does not match the expected Text
</span>
</ng-container>
<ng-container *ngIf="isOfReturnType(task, ['Return_Code_And_Text'])">
<span *ngIf="task.success">
Returned Text and Code match the expected Text and Code
</span>
<span *ngIf="!task.success">
Either returned Text, Returned Code or both do not match the expected
Text and Code
</span>
</ng-container>
</li>
</ul>
</details>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.task-verification-box {
margin-top: 10px;
margin-bottom: 10px;
border: 0;
border-left: 3px solid;
border-radius: 5px;
}

.down {
transform: rotate(180deg);
}

.sideways {
transform: rotate(90deg);
}

.flex-container {
display: flex !important;
flex-direction: row;
justify-content: space-between;
}

.label-container {
display: flex !important;
flex-direction: row;
justify-content: space-between;
width: fit-content;
}

.label-status {
margin: auto;
margin-left: 4px;
margin-bottom: 7%;
}

.label:hover {
cursor: default;
}

#refreshButton:hover {
cursor: pointer !important;
}

.list-group {
width: 100%;
}

.greenBorder {
border-left-color: var(--clr-color-success-500, green) !important;
}

.redBorder {
border-left-color: #f0ad4e !important;
}

details {
border: 1px solid var(--clr-color-neutral-400, #cccccc);
border-left: 3px solid;
border-radius: 4px;
padding: 0.5em 0.5em 0;
&[open] {
padding: 0.5em;
summary {
margin-bottom: 0.5em;
}
}
}

summary {
font-weight: bold;
margin: -0.5em -0.5em 0;
padding: 0.5em;
display: list-item;
cursor: pointer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {
animate,
state,
style,
transition,
trigger,
} from '@angular/animations';
import { Component, Input, OnInit } from '@angular/core';
import { Task } from 'src/app/scenario/taskVerification.type';
import { VerificationService } from 'src/app/services/verification.service';

@Component({
selector: 'app-single-task-verification-markdown',
templateUrl: './single-task-verification-markdown.component.html',
animations: [
trigger('rotatedState', [
state('default', style({ transform: 'rotate(0)' })),
state('rotating', style({ transform: 'rotate(360deg)' })),
transition('default => rotating', animate('1500ms')),
]),
],
styleUrls: ['./single-task-verification-markdown.component.scss'],
})
export class SingleTaskVerificationMarkdownComponent implements OnInit {
@Input() target: string;
@Input() message: string;
@Input() taskName: string;

detailsOpen = false;

rotationState = 'default';

task?: Task;

constructor(private verificationService: VerificationService) {}

ngOnInit(): void {
this.verificationService.currentVerifications.subscribe(
(verificationMap) => {
const temp = verificationMap.get(this.target);
this.task = temp?.tasks?.filter(
(task) => task.name == this.taskName,
)[0];
},
);
}

isOfReturnType(task: Task, returnTypes: string[]): boolean {
return returnTypes.includes(task.return_type);
}

elementClicked() {
this.rotationState = 'rotating';
setTimeout(() => {
this.rotationState = 'default';
}, 1500);
this.verificationService
.verifyTask(this.target, this.taskName)
?.subscribe();
}

taskUnset(): boolean {
return this.task == undefined || this.task.success == undefined;
}
}
3 changes: 3 additions & 0 deletions src/app/scenario/Scenario.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { TaskVerification } from './taskVerification.type';

export class Scenario {
id: string;
name: string;
Expand All @@ -6,4 +8,5 @@ export class Scenario {
virtualmachines: Map<string, string>[];
pauseable: boolean;
printable: boolean;
vm_tasks: TaskVerification[];
}
Loading
Loading