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

fix: workspace issues #131

Merged
merged 2 commits into from
Jun 22, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
(deleteWorkspaceTemplateClicked)="deleteWorkspaceTemplate($event)"
class="mr-3 pointer-hover"
[ngClass]="{selected: selectedTemplate?.name === template.name}"
[template]="template">
[template]="template"
[deleting]="deletingTemplates.has(template.uid)">
</app-workspace-template-summary-view>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ export class WorkspaceTemplateListComponent implements OnInit, CanComponentDeact

state: WorkspaceTemplateState = 'create';

/**
* terminatingTemplates keeps track of all of the workspace templates that are currently being
* deleted.
*/
deletingTemplates = new Map<string, WorkspaceTemplate>();

constructor(
private appRouter: AppRouter,
private workspaceTemplateService: WorkspaceTemplateServiceService,
Expand Down Expand Up @@ -251,16 +257,21 @@ export class WorkspaceTemplateListComponent implements OnInit, CanComponentDeact
return;
}

this.deletingTemplates.set(template.uid, template);

this.workspaceTemplateService.archiveWorkspaceTemplate(this.namespace, template.uid)
.subscribe(res => {
this.deletingTemplates.delete(template.uid);
const templateIndex = this.workspaceTemplates.indexOf(template);
if(templateIndex > -1) {
this.workspaceTemplates.splice(templateIndex, 1);
}

this.getWorkspaceTemplates();
this.selectedTemplate = null;
this.state = 'create';
}, (err: HttpErrorResponse) => {
this.deletingTemplates.delete(template.uid);
if(err.status === 400 && err.error.code === 9) {
this.alertService.storeAlert(new Alert({
message: 'Error deleting template ' + template.uid + ', it has running workspaces',
Expand All @@ -273,7 +284,6 @@ export class WorkspaceTemplateListComponent implements OnInit, CanComponentDeact
message: 'Error deleting template ' + template.uid,
type: 'danger',
}));

})
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<div class="workspace-template-summary-view op-border op-rounded-regular d-inline-flex flex-column align-items-center">
<button [class.hidden]="!showMenu" mat-icon-button [matMenuTriggerFor]="appMenu" style="align-self: flex-end">
<mat-icon>more_vert</mat-icon>
</button>
<div class="d-inline-flex justify-content-between w-100 align-items-center">
<div class="ml-3 font-roboto" [class.visible]="deleting" [class.hidden]="!deleting">
<img class="terminating-icon" src="/assets/images/status-icons/failed.svg"/>
<span class="ml-2">Deleting</span>
</div>
<button [class.hidden]="!showMenu" mat-icon-button [matMenuTriggerFor]="appMenu">
<mat-icon>more_vert</mat-icon>
</button>
</div>
<div class="content text-center">
<i [class]="iconClass"></i>
<div class="title font-proxima-bold font-size-regular mt-3">{{template.name}}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
.title {
font-weight: 900;
}

.terminating-icon {
position: relative;
top: 2px;
}
}

.workspace-template-menu-icon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class WorkspaceTemplateSummaryViewComponent implements OnInit {
@Input() iconClass = 'fas fa-desktop';
@Input() template: WorkspaceTemplate;
@Input() showMenu = true;
@Input() deleting = false;

@Output() createWorkspaceClicked = new EventEmitter<WorkspaceTemplate>();
@Output() cloneWorkspaceTemplateClicked = new EventEmitter<WorkspaceTemplate>();
Expand Down
7 changes: 3 additions & 4 deletions src/app/workspace/workspace-view/workspace-view.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router";
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from "@angular/router";
import { Parameter, UpdateWorkspaceBody, Workspace, WorkspaceServiceService } from "../../../api";
import { DomSanitizer, SafeResourceUrl } from "@angular/platform-browser";
import { MatDialog } from "@angular/material/dialog";
Expand All @@ -8,7 +8,6 @@ import {
ConfirmationDialogData
} from "../../confirmation-dialog/confirmation-dialog.component";
import { AppRouter } from "../../router/app-router.service";
import { WorkflowExecuteDialogComponent } from "../../workflow/workflow-execute-dialog/workflow-execute-dialog.component";

export type WorkspaceState = 'Launching' | 'Updating' | 'Pausing' | 'Paused' | 'Resuming' | 'Running' | 'Deleting';

Expand Down Expand Up @@ -76,7 +75,7 @@ export class WorkspaceViewComponent implements OnInit, OnDestroy {
getWorkspace() {
this.workspaceService.getWorkspace(this.namespace, this.workspaceUid).subscribe(res => {
this.workspace = res;
// t query parameter is so we avoid caching the response.
// We add a 't' query parameter is so we avoid caching the response.
this.workspaceUrl = this.domSanitizer.bypassSecurityTrustResourceUrl(res.url + "?t=" + Date.now());

this.parameters = res.parameters;
Expand Down