You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2021/08/31 20:05:20 UTC

[incubator-streampipes] branch dev updated: [STREAMPIPES-79] Add functionlity to remove index from data lake

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

zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 7c9b6ce  [STREAMPIPES-79] Add functionlity to remove index from data lake
7c9b6ce is described below

commit 7c9b6ce3d337e8123660e75bb2711dafa6195b6c
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Tue Aug 31 22:04:37 2021 +0200

    [STREAMPIPES-79] Add functionlity to remove index from data lake
---
 ui/src/app/configuration/configuration.module.ts   |  2 ++
 .../datalake-configuration.component.html          |  6 +++---
 .../datalake-configuration.component.ts            | 24 +++++++++++++++++-----
 .../delete-datalake-index-dialog.component.html    | 21 ++++++++++++++++---
 .../delete-datalake-index-dialog.component.ts      |  4 ++++
 5 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/ui/src/app/configuration/configuration.module.ts b/ui/src/app/configuration/configuration.module.ts
index 92828c5..9235675 100644
--- a/ui/src/app/configuration/configuration.module.ts
+++ b/ui/src/app/configuration/configuration.module.ts
@@ -42,6 +42,7 @@ import { DragDropModule } from '@angular/cdk/drag-drop';
 import { DatalakeConfigurationComponent } from './datalake-configuration/datalake-configuration.component';
 import { DatalakeRestService } from '../core-services/datalake/datalake-rest.service';
 import { DeleteDatalakeIndexComponent } from './dialog/delete-datalake-index/delete-datalake-index-dialog.component';
+import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
 
 @NgModule({
   imports: [
@@ -50,6 +51,7 @@ import { DeleteDatalakeIndexComponent } from './dialog/delete-datalake-index/del
     FlexLayoutModule,
     MatGridListModule,
     MatButtonModule,
+    MatProgressSpinnerModule,
     MatIconModule,
     MatInputModule,
     MatCheckboxModule,
diff --git a/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.html b/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.html
index 9383fcb..a9445e6 100644
--- a/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.html
+++ b/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.html
@@ -51,7 +51,7 @@
 
                 <ng-container matColumnDef="truncate">
                     <th mat-header-cell *matHeaderCellDef>Truncate</th>
-                    <td mat-cell *matCellDef="let measurement">
+                    <td mat-cell *matCellDef="let configurationEntry">
                         <div fxLayout="row">
                             <span fxFlex fxFlexOrder="3" fxLayout="row" fxLayoutAlign="center center">
                                     <button color="accent"
@@ -60,7 +60,7 @@
                                             matTooltip="Truncate all data from index"
                                             matTooltipPosition="above"
                                             data-cy="truncate-datalake-index"
-                                            (click)="cleanDatalakeIndex(measurement.name)">
+                                            (click)="cleanDatalakeIndex(configurationEntry.name)">
                                         <i class="material-icons">local_fire_department</i>
                                     </button>
                                 </span>
@@ -80,7 +80,7 @@
                                             data-cy="delete-datalake-index"
                                             matTooltipPosition="above"
                                             [disabled]="!configurationEntry.remove"
-                                            (click)="deleteDatalakeIndex(configurationEntry)">
+                                            (click)="deleteDatalakeIndex(configurationEntry.name)">
                                         <i class="material-icons">delete</i>
                                     </button>
                                 </span>
diff --git a/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.ts b/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.ts
index 3a5adb1..d1ad609 100644
--- a/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.ts
+++ b/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.ts
@@ -78,7 +78,7 @@ export class DatalakeConfigurationComponent implements OnInit {
           this.datalakeRestService.getData(
             measurement.measureName,
             this.buildQ(measurement.eventSchema.eventProperties[0].label.toLocaleLowerCase())).subscribe(res => {
-            entry.events = res.rows[0][1];
+            res.rows !== null ? entry.events = res.rows[0][1] : entry.events = 0;
           });
 
           this.availableMeasurements.push(entry);
@@ -100,7 +100,8 @@ export class DatalakeConfigurationComponent implements OnInit {
       title: 'Truncate data',
       width: '70vw',
       data: {
-        'measurementIndex': measurementIndex
+        'measurementIndex': measurementIndex,
+        'deleteDialog': false
       }
     });
 
@@ -111,9 +112,22 @@ export class DatalakeConfigurationComponent implements OnInit {
     });
   }
 
-  deleteDatalakeIndex(measurmentIndex: string) {
-    // add user confirmation
-    this.datalakeRestService.dropSingleMeasurementSeries(measurmentIndex);
+  deleteDatalakeIndex(measurementIndex: string) {
+    const dialogRef: DialogRef<DeleteDatalakeIndexComponent> = this.dialogService.open(DeleteDatalakeIndexComponent, {
+      panelType: PanelType.STANDARD_PANEL,
+      title: 'Delete data',
+      width: '70vw',
+      data: {
+        'measurementIndex': measurementIndex,
+        'deleteDialog': true
+      }
+    });
+
+    dialogRef.afterClosed().subscribe(data => {
+      if (data) {
+        this.loadAvailableMeasurements();
+      }
+    });
   }
 
   private buildQ(column: string): DatalakeQueryParameters {
diff --git a/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.html b/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.html
index 72d1f65..2b9e5d2 100644
--- a/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.html
+++ b/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.html
@@ -19,16 +19,31 @@
 <div class="sp-dialog-container">
     <div class="sp-dialog-content p-15">
         <div *ngIf="!isInProgress" fxLayout="column">
-            <div fxFlex="100" fxLayoutAlign="center center" fxLayout="column">
-                <b><h4>Do you really want to truncate the data in {{measurementIndex}}?</h4></b>
+            <div
+                    fxFlex="100"
+                    fxLayoutAlign="center center"
+                    fxLayout="column">
+                <b *ngIf="deleteDialog"><h4>Do you really want to delete the data index {{measurementIndex}}?</h4></b>
+                <b *ngIf="!deleteDialog"><h4>Do you really want to truncate the data in {{measurementIndex}}?</h4></b>
                 <b><h5>This operation cannot be undone.</h5></b>
             </div>
 
             <div fxFlex="100" fxLayoutAlign="center center" fxLayout="column">
-                <button mat-button mat-raised-button color="accent"
+                <button mat-button
+                        mat-raised-button
+                        color="accent"
+                        *ngIf="!deleteDialog"
                         (click)="truncateData()"
                         data-cy="truncate-datalake-index">Truncate Data
                 </button>
+                <button
+                        mat-button
+                        mat-raised-button
+                        color="accent"
+                        *ngIf="deleteDialog"
+                        (click)="deleteData()"
+                        data-cy="truncate-datalake-index">Delete Data
+                </button>
             </div>
         </div>
         <div fxFlex="100" fxLayoutAlign="center center" fxLayout="column" *ngIf="isInProgress"
diff --git a/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.ts b/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.ts
index f4aefd8..123bacc 100644
--- a/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.ts
+++ b/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.ts
@@ -30,6 +30,9 @@ export class DeleteDatalakeIndexComponent {
   @Input()
   measurementIndex: string;
 
+  @Input()
+  deleteDialog: boolean;
+
   isInProgress = false;
   currentStatus: any;
 
@@ -53,6 +56,7 @@ export class DeleteDatalakeIndexComponent {
     this.isInProgress = true;
     this.currentStatus = 'Deleting data...';
 
+    // this.datalakeRestService.dropSingleMeasurementSeries(measurmentIndex);
     this.datalakeRestService.dropSingleMeasurementSeries(this.measurementIndex).subscribe(data => {
       this.close(true);
     });