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/05/18 13:31:12 UTC

[incubator-dlab] branch develop updated: Dlab 1806 (#757)

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

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


The following commit(s) were added to refs/heads/develop by this push:
     new 8ff33ec  Dlab 1806 (#757)
8ff33ec is described below

commit 8ff33ec2070d4775d5bb10cebef966c9ad2386c0
Author: Dmytro Gnatyshyn <42...@users.noreply.github.com>
AuthorDate: Mon May 18 16:31:06 2020 +0300

    Dlab 1806 (#757)
    
    [DLAB-1806]: Added copy bucket name, fixed bug during creation folder
---
 .../webapp/src/app/core/util/copyPathUtils.ts      | 34 ++++++++++++++
 .../bucket-browser/bucket-browser.component.ts     | 13 +-----
 .../folder-tree/folder-tree.component.ts           |  2 +-
 .../detail-dialog/detail-dialog.component.html     | 54 ++++++++++++++++++----
 .../detail-dialog/detail-dialog.component.ts       | 16 ++++++-
 .../webapp/src/assets/styles/_dialogs.scss         |  6 +++
 6 files changed, 104 insertions(+), 21 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/core/util/copyPathUtils.ts b/services/self-service/src/main/resources/webapp/src/app/core/util/copyPathUtils.ts
new file mode 100644
index 0000000..86ff250
--- /dev/null
+++ b/services/self-service/src/main/resources/webapp/src/app/core/util/copyPathUtils.ts
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+export class CopyPathUtils {
+  public static copyPath(copyValue) {
+    const selBox = document.createElement('textarea');
+    selBox.style.position = 'fixed';
+    selBox.style.left = '0';
+    selBox.style.top = '0';
+    selBox.style.opacity = '0';
+    selBox.value = copyValue;
+    document.body.appendChild(selBox);
+    selBox.focus();
+    selBox.select();
+    document.execCommand('copy');
+    document.body.removeChild(selBox);
+  }
+}
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.ts
index d7a41f2..2fce5e4 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.ts
@@ -30,6 +30,7 @@ import {BucketDataService} from './bucket-data.service';
 import {BucketConfirmationDialogComponent} from './bucket-confirmation-dialog/bucket-confirmation-dialog.component';
 import {logger} from 'codelyzer/util/logger';
 import {HttpEventType, HttpResponse} from '@angular/common/http';
+import {CopyPathUtils} from '../../core/util/copyPathUtils';
 
 @Component({
   selector: 'dlab-bucket-browser',
@@ -316,18 +317,8 @@ export class BucketBrowserComponent implements OnInit {
   }
 
   public copyPath() {
-    const selBox = document.createElement('textarea');
     const selected = this.folderItems.filter(item => item.isSelected || item.isFolderSelected)[0];
-    selBox.style.position = 'fixed';
-    selBox.style.left = '0';
-    selBox.style.top = '0';
-    selBox.style.opacity = '0';
-    selBox.value = selected.object.bucket + '/' + selected.object.object;
-    document.body.appendChild(selBox);
-    selBox.focus();
-    selBox.select();
-    document.execCommand('copy');
-    document.body.removeChild(selBox);
+    CopyPathUtils.copyPath(selected.object.bucket + '/' + selected.object.object);
     this.clearSelection();
     this.isActionsOpen = false;
     this.toastr.success('Object path successfully copied!', 'Success!');
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/folder-tree/folder-tree.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/folder-tree/folder-tree.component.ts
index 2da66a0..5ef672b 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/folder-tree/folder-tree.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/folder-tree/folder-tree.component.ts
@@ -64,7 +64,7 @@ export class FolderTreeComponent implements OnInit, OnDestroy {
           }
           this.expandAllParents(this.selectedFolder || subjectData[0]);
           this.showItem(this.selectedFolder || subjectData[0]);
-          if (this.folderCreationParent) {
+          if (this.folderCreationParent && subject.getValue().filter(v => v.item === '').length === 0) {
             this.folderCreationRefresh(this.folderCreationParent, '', false);
           } else {
             this.disableAll.emit(false);
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html
index e8b0ad1..0b5a821 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html
@@ -62,7 +62,7 @@
             <p class="m-top-30">{{ DICTIONARY[PROVIDER].personal_storage }}: &nbsp;</p>
             <!--                 (click)="bucketBrowser(notebook.bucket_name, notebook.endpoint, this.bucketStatus.view)"-->
             <div class="links_block"
-                 (click)="bucketBrowser(notebook.bucket_name, notebook.endpoint, this.bucketStatus.view && this.isBucketAllowed)"
+                 (mouseleave)="isCopyIconVissible.project = false"
             >
               <span
                 [matTooltip]="!this.bucketStatus.view
@@ -72,22 +72,60 @@
                 matTooltipPosition="above"
                 [matTooltipClass]="'bucket-item-tooltip'"
               >
-              <p *ngIf="DICTIONARY[PROVIDER].cloud_provider === 'azure' && notebook.account_name">{{ DICTIONARY[PROVIDER].account }}
-                <span class="bucket-info bucket-link" [ngClass]="{'not-allow': !this.bucketStatus.view || !this.isBucketAllowed}">{{ notebook.account_name}}</span></p>
-              <p *ngIf="notebook.bucket_name">{{ DICTIONARY[PROVIDER].container }} <span
-                  class="bucket-info bucket-link" [ngClass]="{'not-allow': !this.bucketStatus.view || !this.isBucketAllowed}">{{ notebook.bucket_name }}</span></p></span>
+                <p *ngIf="DICTIONARY[PROVIDER].cloud_provider === 'azure' && notebook.account_name">{{ DICTIONARY[PROVIDER].account }}
+                  <span
+                    class="bucket-info bucket-link"
+                    [ngClass]="{'not-allow': !this.bucketStatus.view || !this.isBucketAllowed}"
+                    (mouseover)="showCopyIcon('project')"
+                    (click)="bucketBrowser('ofuks-1304-pr2-local-bucket', notebook.endpoint, this.bucketStatus.view && this.isBucketAllowed)"
+                  >
+                    {{ notebook.account_name}}
+                  </span>
+                  <span *ngIf="isCopyIconVissible.project" class="link-icon" (click)="copyBucketName(notebook.bucket_name)">
+                    <span class="material-icons" matTooltip="Copy bucket name" matTooltipPosition="above">content_copy</span>
+                  </span>
+                </p>
+                <p *ngIf="notebook.bucket_name">{{ DICTIONARY[PROVIDER].container }}
+                  <span
+                    class="bucket-info bucket-link" [ngClass]="{'not-allow': !this.bucketStatus.view || !this.isBucketAllowed}"
+                    (mouseover)="showCopyIcon('project')"
+                    (click)="bucketBrowser(notebook.bucket_name, notebook.endpoint, this.bucketStatus.view && this.isBucketAllowed)"
+                  >
+                    {{ notebook.bucket_name }}
+                </span>
+                  <span *ngIf="isCopyIconVissible.project" class="link-icon" (click)="copyBucketName(notebook.bucket_name)">
+                    <span _ngcontent-xpv-c19="" class="material-icons" matTooltip="Copy bucket name" matTooltipPosition="above">content_copy</span>
+                  </span>
+                </p>
+              </span>
             </div>
             <p>Shared endpoint bucket: &nbsp;</p>
-            <div class="links_block" (click)="bucketBrowser(notebook.shared_bucket_name, notebook.endpoint, this.bucketStatus.view)"
+            <div class="links_block"
                  [matTooltip]="'You have not permission to open bucket'"
                  matTooltipDisabled="{{this.bucketStatus.view}}"
                  matTooltipPosition="above"
                  [matTooltipClass]="'bucket-item-tooltip'"
+                 (mouseleave)="isCopyIconVissible.shared = false"
             >
               <p *ngIf="DICTIONARY[PROVIDER].cloud_provider === 'azure' && notebook.shared_account_name">{{ DICTIONARY[PROVIDER].account }}
-                <span class="bucket-info bucket-link" [ngClass]="{'not-allow': !this.bucketStatus.view}">{{ notebook.shared_account_name}}</span></p>
+                <span class="bucket-info bucket-link" [ngClass]="{'not-allow': !this.bucketStatus.view}" (mouseover)="showCopyIcon('shared')">{{ notebook.shared_account_name}}</span>
+                <span *ngIf="isCopyIconVissible.shared" class="link-icon" (click)="copyBucketName(notebook.shared_account_name)">
+                  <span _ngcontent-xpv-c19="" class="material-icons" matTooltip="Copy bucket name" matTooltipPosition="above">content_copy</span>
+                </span>
+              </p>
               <p *ngIf="notebook.shared_bucket_name">{{ DICTIONARY[PROVIDER].container }}
-                <span class="bucket-info bucket-link" [ngClass]="{'not-allow': !this.bucketStatus.view}">{{ notebook.shared_bucket_name }}</span></p>
+                <span
+                  class="bucket-info bucket-link"
+                  [ngClass]="{'not-allow': !this.bucketStatus.view}"
+                  (mouseover)="showCopyIcon('shared')"
+                  (click)="bucketBrowser(notebook.shared_bucket_name, notebook.endpoint, this.bucketStatus.view)"
+                >
+                  {{ notebook.shared_bucket_name }}
+                </span>
+                <span *ngIf="isCopyIconVissible.shared" class="link-icon" (click)="copyBucketName(notebook.notebook.shared_bucket_name)">
+                  <span _ngcontent-xpv-c19="" class="material-icons" matTooltip="Copy bucket name" matTooltipPosition="above">content_copy</span>
+                </span>
+              </p>
             </div>
             <br />
 
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts
index 829b22f..1ed64a1 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts
@@ -27,6 +27,7 @@ import { DICTIONARY } from '../../../../dictionary/global.dictionary';
 import { DataengineConfigurationService } from '../../../core/services';
 import { CLUSTER_CONFIGURATION } from '../../computational/computational-resource-create-dialog/cluster-configuration-templates';
 import {BucketBrowserComponent} from '../../bucket-browser/bucket-browser.component';
+import {CopyPathUtils} from '../../../core/util/copyPathUtils';
 
 @Component({
   selector: 'detail-dialog',
@@ -44,6 +45,10 @@ export class DetailDialogComponent implements OnInit {
   config: Array<{}> = [];
   bucketStatus: object = {};
   isBucketAllowed = true;
+  isCopyIconVissible = {
+    project: false,
+    shared: false
+  };
 
   public configurationForm: FormGroup;
 
@@ -72,7 +77,7 @@ export class DetailDialogComponent implements OnInit {
       this.getClusterConfiguration();
     if (this.notebook.edgeNodeStatus === 'terminated' ||
       this.notebook.edgeNodeStatus === 'terminating' ||
-      this.notebook.edgeNodeStatus === 'failed'){
+      this.notebook.edgeNodeStatus === 'failed') {
       this.isBucketAllowed = false;
     }
     }
@@ -136,4 +141,13 @@ export class DetailDialogComponent implements OnInit {
       panelClass: 'modal-fullscreen' })
     .afterClosed().subscribe();
   }
+
+  protected showCopyIcon(bucket) {
+    this.isCopyIconVissible[bucket] = true;
+  }
+
+  protected copyBucketName(copyValue) {
+    CopyPathUtils.copyPath(copyValue);
+    this.toastr.success('Bucket name successfully copied!', 'Success!');
+  }
 }
diff --git a/services/self-service/src/main/resources/webapp/src/assets/styles/_dialogs.scss b/services/self-service/src/main/resources/webapp/src/assets/styles/_dialogs.scss
index e7de7fd..c5b0655 100644
--- a/services/self-service/src/main/resources/webapp/src/assets/styles/_dialogs.scss
+++ b/services/self-service/src/main/resources/webapp/src/assets/styles/_dialogs.scss
@@ -263,6 +263,7 @@ mat-dialog-container {
   p {
     font-weight: 400;
     margin-bottom: 10px;
+    display: flex;
 
     small {
       font-size: 12px;
@@ -275,6 +276,11 @@ mat-dialog-container {
     overflow: hidden;
     text-overflow: ellipsis;
     display: block;
+    &.link-icon{
+      margin-left: 10px;
+      cursor: pointer;
+      padding-top: 3px;
+    }
   }
 
   .links_block {


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