You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@submarine.apache.org by li...@apache.org on 2020/09/12 07:27:02 UTC
[submarine] branch master updated: SUBMARINE-609. [WEB] Delete
environment through UI
This is an automated email from the ASF dual-hosted git repository.
liuxun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git
The following commit(s) were added to refs/heads/master by this push:
new c11622a SUBMARINE-609. [WEB] Delete environment through UI
c11622a is described below
commit c11622acbeea33d3fb7a38da8626c94283c0d6a4
Author: Kevin Su <pi...@gmail.com>
AuthorDate: Mon Sep 7 17:38:49 2020 +0800
SUBMARINE-609. [WEB] Delete environment through UI
### What is this PR for?
Add button and checkbox to delete the environment
### What type of PR is it?
[Feature]
### Todos
* [ ] - Task
### What is the Jira issue?
https://issues.apache.org/jira/browse/SUBMARINE-609
### How should this be tested?
https://travis-ci.org/github/pingsutw/hadoop-submarine/builds/724862524
### Screenshots (if appropriate)
![Submarine - environment (1)](https://user-images.githubusercontent.com/37936015/92373990-bcb6a780-f131-11ea-9542-809423fc063d.gif)
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Author: Kevin Su <pi...@gmail.com>
Closes #396 from pingsutw/SUBMARINE-609 and squashes the following commits:
a9fef61 [Kevin Su] SUBMARINE-609. [WEB] Delete environment through UI
---
.../src/app/interfaces/environment-spec.ts | 1 +
.../environment/environment.component.html | 2 +-
.../workbench/environment/environment.component.ts | 35 +++++++++++++++++++---
.../workbench/experiment/experiment.component.ts | 2 +-
.../src/app/services/environment.service.ts | 16 ++++++++--
5 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/submarine-workbench/workbench-web-ng/src/app/interfaces/environment-spec.ts b/submarine-workbench/workbench-web-ng/src/app/interfaces/environment-spec.ts
index bfe702f..ffc32e8 100644
--- a/submarine-workbench/workbench-web-ng/src/app/interfaces/environment-spec.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/environment-spec.ts
@@ -23,6 +23,7 @@ export interface KernelSpec {
}
export interface EnvironmentSpec {
+ name: string;
description: string;
dockerImage: string;
image: string;
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/environment/environment.component.html b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/environment/environment.component.html
index 6ff5a45..10de4d5 100644
--- a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/environment/environment.component.html
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/environment/environment.component.html
@@ -71,7 +71,7 @@
nzTitle="Confirm to delete?"
nzCancelText="Cancel"
nzOkText="Ok"
- (nzOnConfirm)="deleteEnvironment()"
+ (nzOnConfirm)="deleteEnvironments()"
>
<i nz-icon nzType="delete" nzTheme="outline"></i>
Delete
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/environment/environment.component.ts b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/environment/environment.component.ts
index 256fe2d..dbef9ec 100644
--- a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/environment/environment.component.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/environment/environment.component.ts
@@ -18,8 +18,9 @@
*/
import { Component, OnInit } from '@angular/core';
-import { EnvironmentService } from '@submarine/services/environment.service';
import { Environment } from '@submarine/interfaces/environment-info';
+import { EnvironmentService } from '@submarine/services/environment.service';
+import { NzMessageService } from 'ng-zorro-antd';
@Component({
selector: 'submarine-environment',
@@ -27,7 +28,9 @@ import { Environment } from '@submarine/interfaces/environment-info';
styleUrls: ['./environment.component.scss']
})
export class EnvironmentComponent implements OnInit {
- constructor(private environmentService: EnvironmentService) {}
+ constructor(
+ private environmentService: EnvironmentService,
+ private nzMessageService: NzMessageService) {}
environmentList: Environment[] = [];
checkedList: boolean[] = [];
@@ -53,8 +56,32 @@ export class EnvironmentComponent implements OnInit {
// TODO(kobe860219): Update an environment
updateEnvironment(id: string, data) {}
- // TODO(kobe860219): Delete an environment
- deleteEnvironment(id: string) {}
+ onDeleteEnvironment(name: string, onMessage: boolean) {
+ this.environmentService.deleteEnvironment(name).subscribe(
+ () => {
+ if (onMessage === true) {
+ this.nzMessageService.success('Delete Experiment Successfully!');
+ }
+ this.fetchEnvironmentList();
+ },
+ (err) => {
+ if (onMessage === true) {
+ this.nzMessageService.error(err.message);
+ }
+ }
+ );
+ }
+
+ deleteEnvironments() {
+ for (let i = this.checkedList.length - 1; i >= 0; i--) {
+ console.log(this.environmentList[i].environmentSpec.name)
+ if (this.checkedList[i] === true) {
+ this.onDeleteEnvironment(this.environmentList[i].environmentSpec.name, false);
+ }
+ }
+
+ this.selectAllChecked = false;
+ }
selectAllEnv() {
for (let i = 0; i < this.checkedList.length; i++) {
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/experiment/experiment.component.ts b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/experiment/experiment.component.ts
index fde4738..4732450 100644
--- a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/experiment/experiment.component.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/experiment/experiment.component.ts
@@ -166,7 +166,7 @@ export class ExperimentComponent implements OnInit {
},
(err) => {
if (onMessage === true) {
- this.nzMessageService.success(err.message);
+ this.nzMessageService.error(err.message);
}
}
);
diff --git a/submarine-workbench/workbench-web-ng/src/app/services/environment.service.ts b/submarine-workbench/workbench-web-ng/src/app/services/environment.service.ts
index 7ace6b0..7f28365 100644
--- a/submarine-workbench/workbench-web-ng/src/app/services/environment.service.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/services/environment.service.ts
@@ -20,10 +20,10 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Rest } from '@submarine/interfaces';
+import { Environment } from '@submarine/interfaces/environment-info';
import { BaseApiService } from '@submarine/services/base-api.service';
import { of, throwError, Observable } from 'rxjs';
import { catchError, map, switchMap } from 'rxjs/operators';
-import { Environment } from '@submarine/interfaces/environment-info';
@Injectable({
providedIn: 'root'
@@ -54,6 +54,16 @@ export class EnvironmentService {
// TODO(kobe860219): Update an environment
updateEnvironment(updateData) {}
- // TODO(kobe860219): Delete an environment
- deleteEnvironment(id: string) {}
+ deleteEnvironment(name: string): Observable<Environment> {
+ const apiUrl = this.baseApi.getRestApi(`/v1/environment/${name}`);
+ return this.httpClient.delete<Rest<Environment>>(apiUrl).pipe(
+ switchMap((res) => {
+ if (res.success) {
+ return of(res.result);
+ } else {
+ throw this.baseApi.createRequestError(res.message, res.code, apiUrl, 'delete', name);
+ }
+ })
+ );
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@submarine.apache.org
For additional commands, e-mail: dev-help@submarine.apache.org