You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by dg...@apache.org on 2020/02/12 14:03:49 UTC

[incubator-dlab] 01/01: [DLAB-1544]: Changed behavior of Show Active button for notebooks

This is an automated email from the ASF dual-hosted git repository.

dgnatyshyn pushed a commit to branch DLAB-1544
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit 291c47107db3b9a742f7d8b1188587678e5a0173
Author: Dmytro Gnatyshyn <di...@ukr.net>
AuthorDate: Wed Feb 12 16:03:17 2020 +0200

    [DLAB-1544]: Changed behavior of Show Active button for notebooks
---
 .../create-environment.component.html              |  3 +-
 .../app/resources/exploratory/notebook.model.ts    | 42 ++++++++++++++++++++++
 .../resources-grid/resources-grid.component.ts     | 20 ++++++++---
 3 files changed, 58 insertions(+), 7 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.html b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.html
index c195189..43b3c71 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.html
@@ -106,8 +106,7 @@
                     && createExploratoryForm?.controls['name'].dirty
                     && createExploratoryForm?.controls['name'].hasError('duplication')" type="text"
               class="form-control" placeholder="Enter Name" formControlName="name">
-            <span class="error" *ngIf="createExploratoryForm?.controls['name'].hasError('duplication')">This name
-              already exists.</span>
+            <span class="error" *ngIf="createExploratoryForm?.controls['name'].hasError('duplication')">This name already exists in current project.</span>
             <span class="error" *ngIf="!createExploratoryForm?.controls.name.valid
                                         && createExploratoryForm?.controls['name'].dirty
                                         && !createExploratoryForm?.controls['name'].hasError('duplication')">Name
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/notebook.model.ts b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/notebook.model.ts
new file mode 100644
index 0000000..3e96932
--- /dev/null
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/notebook.model.ts
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* tslint:disable:no-empty */
+
+
+import {Injectable} from '@angular/core';
+
+@Injectable()
+
+export class NotebookModel {
+  constructor(
+    public project: string,
+    public exploratory: string,
+    public status: string,
+  ) { }
+
+  public static notebook(data) {
+    if (data) {
+      return data.map(value => value.exploratory.map(el =>  new NotebookModel(
+        value.project,
+        el.name,
+        el.status,
+      )));
+    }
+  }
+}
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts
index 8ce8836..ef8afa4 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts
@@ -41,6 +41,7 @@ import { SchedulerComponent } from '../scheduler';
 import { DICTIONARY } from '../../../dictionary/global.dictionary';
 import {ProgressBarService} from '../../core/services/progress-bar.service';
 import {ComputationModel} from '../computational/computational-resource.model';
+import {NotebookModel} from '../exploratory/notebook.model';
 
 
 
@@ -275,15 +276,24 @@ export class ResourcesGridComponent implements OnInit {
       this.updateUserPreferences(config);
     }
 
-
+    let failedNotebooks = NotebookModel.notebook(this.getEnvironmentsListCopy());
+    failedNotebooks = SortUtils.flatDeep(failedNotebooks, 1).filter(notebook => notebook.status === 'failed');
+    if (this.filteredEnvironments.length && this.activeFiltering) {
+      let creatingNotebook = NotebookModel.notebook(this.filteredEnvironments);
+      creatingNotebook = SortUtils.flatDeep(creatingNotebook, 1).filter(resourse => resourse.status === 'creating');
+      const fail = failedNotebooks
+        .filter(v => creatingNotebook
+          .some(create => create.project === v.project && create.exploratory === v.exploratory && create.resource === v.resource));
+      if (fail.length) {
+        this.toastr.error('Creating notebook failed!', 'Oops!');
+      }
+    }
 
     let failedResource = ComputationModel.computationRes(this.getEnvironmentsListCopy());
-    failedResource = SortUtils.flatDeep(failedResource, 3).filter(resourse => resourse.status === 'failed');
-
+    failedResource = SortUtils.flatDeep(failedResource, 2).filter(resourse => resourse.status === 'failed');
     if (this.filteredEnvironments.length && this.activeFiltering) {
       let creatingResource = ComputationModel.computationRes(this.filteredEnvironments);
-      creatingResource = SortUtils.flatDeep(creatingResource, 3).filter(resourse => resourse.status === 'creating');
-
+      creatingResource = SortUtils.flatDeep(creatingResource, 2).filter(resourse => resourse.status === 'creating');
       const fail = failedResource
         .filter(v => creatingResource
           .some(create => create.project === v.project && create.exploratory === v.exploratory && create.resource === v.resource));


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org