Skip to content

Commit

Permalink
Merge pull request #5994 from deNBI/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dweinholz authored Jan 17, 2024
2 parents 5e49004 + d897ace commit 41d2151
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 19 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@denbi/cloud-portal-webapp",
"version": "4.807.0",
"version": "4.808.0",
"description": "de.NBI Cloud Portal",
"scripts": {
"ng": "ng serve",
Expand Down Expand Up @@ -52,7 +52,7 @@
"d3": "7.8.5",
"export-to-csv": "1.2.1",
"file-saver": "2.0.5",
"follow-redirects": "1.15.3",
"follow-redirects": "1.15.4",
"html2canvas": "1.4.1",
"is-promise": "4.0.0",
"jsnlog": "2.30.0",
Expand Down
2 changes: 1 addition & 1 deletion src/app/api-connector/virtualmachine.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export class VirtualmachineService {
}

setVmNeeded(openstack_id: string): Observable<any> {
return this.http.post<any>(`${this.baseVmUrl}${openstack_id}/need/`, null, {
return this.http.post<any>(`${this.baseVmUrl}${openstack_id}/need/`, {
withCredentials: true,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class VirtualMachine {
created_at_date: string;
deleted_at_date: string;
still_used_confirmation_requested_date: Date;
still_used_confirmed_user_id: string;
stopped_at: string;
elixir_id: string;
fixed_ip: string;
Expand All @@ -45,6 +46,8 @@ export class VirtualMachine {
days_running: number;
backend: Backend;
conda_packages: CondaPackage[] = [];
still_used_confirmed_date: Date;
// still used confirmed date missing in webapp!

migrate_project_to_simple_vm: boolean = false;
project_is_migrated_to_simple_vm: boolean = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ng-container *ngSwitchCase="VirtualMachineStates.staticDELETED">
<div class="callout callout-danger">
<small class="text-muted">Deleted at (d-m-y)</small><br />
<strong class="text-muted">{{ virtualMachine.deleted_at_date | date : 'dd-MM-yyyy' }}</strong>
<strong class="text-muted">{{ virtualMachine.deleted_at_date | date: 'dd-MM-yyyy' }}</strong>
</div>
</ng-container>
<ng-container *ngSwitchDefault>
Expand All @@ -53,6 +53,40 @@
</div>
</div>
</div>
<div class="row" *ngIf="virtualMachine.still_used_confirmation_requested_date">
<div class="col-3">
<div class="callout callout-info">
<small class="text-muted">Usage confirmation requested at (d-m-y)</small><br />
<strong class="text-muted">{{
virtualMachine.still_used_confirmation_requested_date | date: 'dd-MM-yyyy'
}}</strong>
</div>
</div>
<ng-container *ngIf="virtualMachine.still_used_confirmed_date">
<div class="col-3">
<div class="callout callout-success">
<small class="text-muted">Usage confirmed at (d-m-y)</small><br />
<strong class="text-muted">{{ virtualMachine.still_used_confirmed_date | date: 'dd-MM-yyyy' }}</strong>
</div>
</div>
<div class="col-6" *ngIf="userSurname && userName">
<div class="callout callout-success">
<small class="text-muted">Usage confirmed by {{ virtualMachine.still_used_confirmed_user_id }}</small
><br />
<strong class="text-muted">{{ this.userSurname }}, {{ this.userName }}</strong>
</div>
</div>
</ng-container>
<ng-container *ngIf="!virtualMachine.still_used_confirmed_date">
<div class="col-6">
<div class="callout callout-danger">
<small class="text-muted">Usage confirmed at (d-m-y)</small><br />
<strong class="text-muted">Usage not confirmed yet!</strong>
</div>
</div>
</ng-container>
</div>
<!-- adjust in model, still_used_confirmed_date and set on successful response-->
<div class="row">
<div class="col-3">
<div class="callout">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import {
Component, Input, OnChanges, SimpleChanges, OnInit, ChangeDetectorRef,
} from '@angular/core';
import { UserService } from 'app/api-connector/user.service';
import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates';
import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine';

Expand All @@ -8,11 +11,53 @@ import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine';
@Component({
selector: 'app-virtualmachineinfo',
templateUrl: './virtualmachineinfo.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
styleUrls: ['./virtualmachineinfo.component.scss'],

providers: [UserService],
})
export class VirtualmachineinfoComponent {
export class VirtualmachineinfoComponent implements OnChanges, OnInit {
VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates();
@Input() virtualMachine: VirtualMachine;
@Input() cluster_machine: boolean = false;
@Input() virtualMachine: VirtualMachine;
@Input() cluster_machine: boolean = false;

userName: string = '';
userSurname: string = '';

constructor(
private userService: UserService,
private changeDetectorRef: ChangeDetectorRef,
) {
this.userService = userService;
this.changeDetectorRef = changeDetectorRef;
}

ngOnInit(): void {
if (this.virtualMachine) {
if (this.virtualMachine.still_used_confirmed_user_id) {
this.userService
.getMemberDetailsByElixirId(this.virtualMachine.still_used_confirmed_user_id)
.subscribe((result: any) => {
this.userName = result['firstName'];
this.userSurname = result['lastName'];
this.changeDetectorRef.detectChanges();
});
}
}
}

ngOnChanges(changes: SimpleChanges): void {
const { changedVM } = changes;
console.log(changedVM);
if (changedVM) {
if (changedVM['virtualMachine']['currentValue']['still_used_confirmed_user_id']) {
this.userService
.getMemberDetailsByElixirId(this.virtualMachine.still_used_confirmed_user_id)
.subscribe((result: any) => {
this.userName = result['firstName'];
this.userSurname = result['lastName'];
this.changeDetectorRef.detectChanges();
});
}
}
}
}
5 changes: 4 additions & 1 deletion src/app/virtualmachines/vmdetail/vmdetail.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Subject, Subscription } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
Expand Down Expand Up @@ -177,6 +177,7 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit {
private biocondaService: BiocondaService,
private clipboardService: ClipboardService,
private groupService: GroupService,
private cdr: ChangeDetectorRef,
) {
super();
}
Expand Down Expand Up @@ -242,6 +243,8 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit {
this.virtualmachineService.setVmNeeded(this.virtualMachine.openstackid).subscribe((res: any): void => {
if (res['still_needed']) {
this.virtualMachine.still_used_confirmation_requested = false;
this.virtualMachine.still_used_confirmed_date = new Date();
this.cdr.detectChanges();
}
});
}
Expand Down

0 comments on commit 41d2151

Please sign in to comment.