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 15:33:26 UTC
[incubator-streampipes] 02/02: [STREAMPIPES-79] Meadurements in
data explorer can be truncated
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
commit 98e43434dd583265c47a32414e4135a2950310b0
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Tue Aug 31 17:32:55 2021 +0200
[STREAMPIPES-79] Meadurements in data explorer can be truncated
---
.../dataexplorer/v4/query/DataExplorerQueryV4.java | 2 +-
ui/src/app/configuration/configuration.module.ts | 62 +++++++++++-----------
.../datalake-configuration.component.html | 15 +++---
.../datalake-configuration.component.ts | 28 +++++++---
.../delete-datalake-index-dialog.component.html | 48 +++++++++++++++++
.../delete-datalake-index-dialog.component.scss | 19 +++++++
.../delete-datalake-index-dialog.component.ts | 61 +++++++++++++++++++++
.../datalake/DatalakeQueryParameterBuilder.ts | 9 ++--
.../apis/datalake-rest.service.ts | 13 +----
9 files changed, 198 insertions(+), 59 deletions(-)
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/DataExplorerQueryV4.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/DataExplorerQueryV4.java
index 799d89c..ee0847a 100644
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/DataExplorerQueryV4.java
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/DataExplorerQueryV4.java
@@ -108,7 +108,7 @@ public class DataExplorerQueryV4 {
if (this.params.containsKey(DataLakeManagementUtils.SELECT_FROM)) {
queryElements.add(new SelectFromStatement((SelectFromStatementParams) this.params.get(DataLakeManagementUtils.SELECT_FROM)));
} else {
- queryElements.add(new DeleteFromStatement((DeleteFromStatementParams) this.params.get(DataLakeManagementUtils.SELECT_FROM)));
+ queryElements.add(new DeleteFromStatement((DeleteFromStatementParams) this.params.get(DataLakeManagementUtils.DELETE_FROM)));
}
if (this.params.containsKey(DataLakeManagementUtils.WHERE)) {
diff --git a/ui/src/app/configuration/configuration.module.ts b/ui/src/app/configuration/configuration.module.ts
index 8248189..92828c5 100644
--- a/ui/src/app/configuration/configuration.module.ts
+++ b/ui/src/app/configuration/configuration.module.ts
@@ -41,38 +41,40 @@ import { MessagingConfigurationComponent } from './messaging-configuration/messa
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';
@NgModule({
- imports: [
- CommonModule,
- CustomMaterialModule,
- FlexLayoutModule,
- MatGridListModule,
- MatButtonModule,
- MatIconModule,
- MatInputModule,
- MatCheckboxModule,
- MatTooltipModule,
- FormsModule,
- DragDropModule
- ],
- declarations: [
- ConfigurationComponent,
- ConsulServiceComponent,
- ConsulConfigsComponent,
- ConsulConfigsTextComponent,
- ConsulConfigsPasswordComponent,
- ConsulConfigsBooleanComponent,
- ConsulConfigsNumberComponent,
- PipelineElementConfigurationComponent,
- MessagingConfigurationComponent,
- DatalakeConfigurationComponent
- ],
- providers: [
- ConfigurationService,
- DatalakeRestService
- ],
- entryComponents: [ConfigurationComponent],
+ imports: [
+ CommonModule,
+ CustomMaterialModule,
+ FlexLayoutModule,
+ MatGridListModule,
+ MatButtonModule,
+ MatIconModule,
+ MatInputModule,
+ MatCheckboxModule,
+ MatTooltipModule,
+ FormsModule,
+ DragDropModule
+ ],
+ declarations: [
+ ConfigurationComponent,
+ ConsulServiceComponent,
+ ConsulConfigsComponent,
+ ConsulConfigsTextComponent,
+ ConsulConfigsPasswordComponent,
+ ConsulConfigsBooleanComponent,
+ ConsulConfigsNumberComponent,
+ DeleteDatalakeIndexComponent,
+ PipelineElementConfigurationComponent,
+ MessagingConfigurationComponent,
+ DatalakeConfigurationComponent
+ ],
+ providers: [
+ ConfigurationService,
+ DatalakeRestService
+ ],
+ entryComponents: [ConfigurationComponent]
})
export class ConfigurationModule {
}
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 0068824..9383fcb 100644
--- a/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.html
+++ b/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.html
@@ -32,7 +32,6 @@
<th mat-header-cell mat-sort-header *matHeaderCellDef>Name</th>
<td mat-cell *matCellDef="let configurationEntry">
<h4 style="margin-bottom:0px;">{{configurationEntry.name}}</h4>
- <!-- <h5>{{adapter.description != '' ? adapter.description : '-'}}</h5>-->
</td>
</ng-container>
@@ -55,9 +54,13 @@
<td mat-cell *matCellDef="let measurement">
<div fxLayout="row">
<span fxFlex fxFlexOrder="3" fxLayout="row" fxLayoutAlign="center center">
- <button color="accent" mat-button mat-icon-button matTooltip="Delete adapter"
- data-cy="delete" matTooltipPosition="above"
- (click)="cleanDatalakeIndex(measurement)">
+ <button color="accent"
+ mat-button
+ mat-icon-button
+ matTooltip="Truncate all data from index"
+ matTooltipPosition="above"
+ data-cy="truncate-datalake-index"
+ (click)="cleanDatalakeIndex(measurement.name)">
<i class="material-icons">local_fire_department</i>
</button>
</span>
@@ -73,8 +76,8 @@
<button color="accent"
mat-button
mat-icon-button
- matTooltip="Delete data lake index"
- data-cy="delete"
+ matTooltip="Remove index from database"
+ data-cy="delete-datalake-index"
matTooltipPosition="above"
[disabled]="!configurationEntry.remove"
(click)="deleteDatalakeIndex(configurationEntry)">
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 07fae0a..3a5adb1 100644
--- a/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.ts
+++ b/ui/src/app/configuration/datalake-configuration/datalake-configuration.component.ts
@@ -17,7 +17,6 @@
*/
import { Component, OnInit, ViewChild } from '@angular/core';
-import { MatSnackBar } from '@angular/material/snack-bar';
import { DatalakeRestService } from '../../platform-services/apis/datalake-rest.service';
import { MatTableDataSource } from '@angular/material/table';
import { DataViewDataExplorerService } from '../../platform-services/apis/data-view-data-explorer.service';
@@ -26,6 +25,10 @@ import { DatalakeQueryParameters } from '../../core-services/datalake/DatalakeQu
import { DatalakeQueryParameterBuilder } from '../../core-services/datalake/DatalakeQueryParameterBuilder';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
+import { DialogRef } from '../../core-ui/dialog/base-dialog/dialog-ref';
+import { PanelType } from '../../core-ui/dialog/base-dialog/base-dialog.model';
+import { DialogService } from '../../core-ui/dialog/base-dialog/base-dialog.service';
+import { DeleteDatalakeIndexComponent } from '../dialog/delete-datalake-index/delete-datalake-index-dialog.component';
@Component({
selector: 'sp-datalake-configuration',
@@ -47,7 +50,7 @@ export class DatalakeConfigurationComponent implements OnInit {
// protected dataLakeRestService: DatalakeRestService,
private datalakeRestService: DatalakeRestService,
private dataViewDataExplorerService: DataViewDataExplorerService,
- private snackBar: MatSnackBar) {
+ private dialogService: DialogService) {
}
ngOnInit(): void {
@@ -55,12 +58,11 @@ export class DatalakeConfigurationComponent implements OnInit {
}
loadAvailableMeasurements() {
+ this.availableMeasurements = [];
// get all available measurements that are stored in the data lake
this.datalakeRestService.getAllMeasurementSeries().subscribe(allMeasurements => {
// get all measurements that are still used in pipelines
this.dataViewDataExplorerService.getAllPersistedDataStreams().subscribe(inUseMeasurements => {
- console.log('Pipelines');
- console.log(inUseMeasurements);
allMeasurements.forEach(measurement => {
const entry = new DataLakeConfigurationEntry();
entry.name = measurement.measureName;
@@ -93,12 +95,24 @@ export class DatalakeConfigurationComponent implements OnInit {
}
cleanDatalakeIndex(measurementIndex: string) {
- // TODO give user confirmation
- this.datalakeRestService.removeData(measurementIndex);
+ const dialogRef: DialogRef<DeleteDatalakeIndexComponent> = this.dialogService.open(DeleteDatalakeIndexComponent, {
+ panelType: PanelType.STANDARD_PANEL,
+ title: 'Truncate data',
+ width: '70vw',
+ data: {
+ 'measurementIndex': measurementIndex
+ }
+ });
+
+ dialogRef.afterClosed().subscribe(data => {
+ if (data) {
+ this.loadAvailableMeasurements();
+ }
+ });
}
deleteDatalakeIndex(measurmentIndex: string) {
- // TODO give user confirmation
+ // add user confirmation
this.datalakeRestService.dropSingleMeasurementSeries(measurmentIndex);
}
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
new file mode 100644
index 0000000..72d1f65
--- /dev/null
+++ b/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.html
@@ -0,0 +1,48 @@
+<!--
+ ~ 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.
+ ~
+ -->
+
+<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>
+ <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"
+ (click)="truncateData()"
+ data-cy="truncate-datalake-index">Truncate Data
+ </button>
+ </div>
+ </div>
+ <div fxFlex="100" fxLayoutAlign="center center" fxLayout="column" *ngIf="isInProgress"
+ data-cy="adapter-deletion-in-progress">
+ <div fxLayout="row" fxLayoutAlign="space-around">
+ <mat-spinner [mode]="'indeterminate'" color="accent"></mat-spinner>
+ </div>
+ <b><h4>{{currentStatus}}</h4></b>
+ </div>
+ </div>
+ <mat-divider></mat-divider>
+ <div class="sp-dialog-actions actions-align-right">
+ <button mat-button mat-raised-button class="mat-basic" (click)="close(false)">
+ Close
+ </button>
+ </div>
+</div>
diff --git a/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.scss b/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.scss
new file mode 100644
index 0000000..0a776e5
--- /dev/null
+++ b/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.scss
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ *
+ */
+
+@import '../../../../scss/sp/sp-dialog.scss';
\ No newline at end of file
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
new file mode 100644
index 0000000..f4aefd8
--- /dev/null
+++ b/ui/src/app/configuration/dialog/delete-datalake-index/delete-datalake-index-dialog.component.ts
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ *
+ */
+
+import { Component, Input } from '@angular/core';
+import { DialogRef } from '../../../core-ui/dialog/base-dialog/dialog-ref';
+import { DatalakeRestService } from '../../../platform-services/apis/datalake-rest.service';
+
+@Component({
+ selector: 'sp-delete-datalake-index-dialog',
+ templateUrl: './delete-datalake-index-dialog.component.html',
+ styleUrls: ['./delete-datalake-index-dialog.component.scss']
+})
+export class DeleteDatalakeIndexComponent {
+
+ @Input()
+ measurementIndex: string;
+
+ isInProgress = false;
+ currentStatus: any;
+
+ constructor(private dialogRef: DialogRef<DeleteDatalakeIndexComponent>,
+ private datalakeRestService: DatalakeRestService) {
+ }
+
+ close(refreshDataLakeIndex: boolean) {
+ this.dialogRef.close(refreshDataLakeIndex);
+ }
+
+ truncateData() {
+ this.isInProgress = true;
+ this.currentStatus = 'Truncating data...';
+ this.datalakeRestService.removeData(this.measurementIndex).subscribe(data => {
+ this.close(true);
+ });
+ }
+
+ deleteData() {
+ this.isInProgress = true;
+ this.currentStatus = 'Deleting data...';
+
+ this.datalakeRestService.dropSingleMeasurementSeries(this.measurementIndex).subscribe(data => {
+ this.close(true);
+ });
+ }
+
+}
diff --git a/ui/src/app/core-services/datalake/DatalakeQueryParameterBuilder.ts b/ui/src/app/core-services/datalake/DatalakeQueryParameterBuilder.ts
index 50c057f..9ab43c8 100644
--- a/ui/src/app/core-services/datalake/DatalakeQueryParameterBuilder.ts
+++ b/ui/src/app/core-services/datalake/DatalakeQueryParameterBuilder.ts
@@ -23,14 +23,15 @@ export class DatalakeQueryParameterBuilder {
private queryParams: DatalakeQueryParameters;
- static create(startTime: number,
- endTime: number): DatalakeQueryParameterBuilder {
+ static create(startTime?: number,
+ endTime?: number): DatalakeQueryParameterBuilder {
return new DatalakeQueryParameterBuilder(startTime, endTime);
}
- private constructor(startTime: number,
- endTime: number) {
+
+ private constructor(startTime?: number,
+ endTime?: number) {
this.queryParams = new DatalakeQueryParameters();
this.queryParams.startDate = startTime;
this.queryParams.endDate = endTime;
diff --git a/ui/src/app/platform-services/apis/datalake-rest.service.ts b/ui/src/app/platform-services/apis/datalake-rest.service.ts
index e89a9f8..42f66dd 100644
--- a/ui/src/app/platform-services/apis/datalake-rest.service.ts
+++ b/ui/src/app/platform-services/apis/datalake-rest.service.ts
@@ -138,19 +138,10 @@ export class DatalakeRestService {
return this.http.request(request);
}
- removeData(index: string, startDate?: number, endDate?: number) {
+ removeData(index: string) {
const url = this.dataLakeUrl + '/measurements/' + index;
- const queryParams: DatalakeQueryParameters = this.getQueryParameters(undefined, startDate, endDate, undefined,
- undefined, undefined, undefined, undefined, undefined, undefined);
-
- const request = new HttpRequest('DELETE', url, {
- reportProgress: true,
- responseType: 'text',
- params: queryParams
- });
-
- return this.http.request(request);
+ return this.http.delete(url);
}
dropSingleMeasurementSeries(index: string) {