You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2022/07/16 21:12:11 UTC

[incubator-streampipes] branch STREAMPIPES-558 updated: [STREAMPIPES-559] Allow deletion of pipeline element templates

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

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


The following commit(s) were added to refs/heads/STREAMPIPES-558 by this push:
     new 6a583385a [STREAMPIPES-559] Allow deletion of pipeline element templates
6a583385a is described below

commit 6a583385aca9a666fd22cc449d82eef3b420aff0
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Sat Jul 16 23:11:53 2022 +0200

    [STREAMPIPES-559] Allow deletion of pipeline element templates
---
 .../lib/apis/pipeline-element-template.service.ts  |  4 +++
 .../adapter-template-dialog.component.html         |  2 +-
 ...pipeline-element-template-config.component.html | 30 +++++++++++++++-------
 .../pipeline-element-template-config.component.ts  | 21 ++++++++++++++-
 4 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/ui/projects/streampipes/platform-services/src/lib/apis/pipeline-element-template.service.ts b/ui/projects/streampipes/platform-services/src/lib/apis/pipeline-element-template.service.ts
index d54250409..6cca1d56b 100644
--- a/ui/projects/streampipes/platform-services/src/lib/apis/pipeline-element-template.service.ts
+++ b/ui/projects/streampipes/platform-services/src/lib/apis/pipeline-element-template.service.ts
@@ -48,6 +48,10 @@ export class PipelineElementTemplateService {
         }));
   }
 
+  deletePipelineElementTemplate(templateId: string): Observable<any> {
+    return this.http.delete(`${this.platformServicesCommons.apiBasePath}/pipeline-element-templates/${templateId}`);
+  }
+
   getConfiguredDataProcessorForTemplate(templateId: string, invocation: DataProcessorInvocation): Observable<DataProcessorInvocation> {
     return this.http.post(this.platformServicesCommons.apiBasePath
         + '/pipeline-element-templates/' + templateId + '/processor', invocation)
diff --git a/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html b/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html
index 3758aaefd..7d395344f 100644
--- a/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html
+++ b/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html
@@ -32,7 +32,7 @@
         <button mat-button mat-raised-button color="accent"
                 (click)="saveTemplate()"
                 style="margin-right: 10px;">
-            Save
+            Create template
         </button>
         <button mat-button mat-raised-button class="mat-basic" (click)="dialogRef.close()">Close</button>
     </div>
diff --git a/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html b/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html
index 2b7bd7f22..712119dea 100644
--- a/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html
+++ b/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html
@@ -28,7 +28,7 @@
             <input [(ngModel)]="template.templateDescription" matInput name="templateDescription" class="sp"
                    required/>
         </mat-form-field>
-<!--        <mat-checkbox class="sp" color="accent">Make available as pipeline element</mat-checkbox>-->
+        <!--        <mat-checkbox class="sp" color="accent">Make available as pipeline element</mat-checkbox>-->
         <mat-divider class="divider"></mat-divider>
         <h4>Configuration</h4>
         <mat-hint style="margin-bottom: 10px;">(dynamic options cannot be saved and are hidden)</mat-hint>
@@ -44,18 +44,30 @@
                                       (change)="handleSelection(config)" name="store" class="sp" color="accent">Store
                             as template
                         </mat-checkbox>
-<!--                        <mat-checkbox *ngIf="templateConfigs.has(config.internalName)"-->
-<!--                                      (click)="toggleViewPermission(config)" name="displayed"-->
-<!--                                      class="sp" color="primary">Users can view-->
-<!--                        </mat-checkbox>-->
-<!--                        <mat-checkbox *ngIf="templateConfigs.has(config.internalName)"-->
-<!--                                      (click)="toggleEditPermission(config)" name="editable"-->
-<!--                                      class="sp" color="primary">Users can modify-->
-<!--                        </mat-checkbox>-->
+                        <!--                        <mat-checkbox *ngIf="templateConfigs.has(config.internalName)"-->
+                        <!--                                      (click)="toggleViewPermission(config)" name="displayed"-->
+                        <!--                                      class="sp" color="primary">Users can view-->
+                        <!--                        </mat-checkbox>-->
+                        <!--                        <mat-checkbox *ngIf="templateConfigs.has(config.internalName)"-->
+                        <!--                                      (click)="toggleEditPermission(config)" name="editable"-->
+                        <!--                                      class="sp" color="primary">Users can modify-->
+                        <!--                        </mat-checkbox>-->
                     </div>
                 </div>
             </div>
 
         </div>
+        <mat-divider class="divider"></mat-divider>
+        <h4>Existing templates</h4>
+        <div fxLayout="column" *ngFor="let template of existingTemplates" class="static-property-panel static-property-panel-border">
+            <div fxFlex="100" fxLayout="row">
+                <div fxFlex fxLayoutAlign="start center">{{template.templateName}}</div>
+                <div fxLayoutAlign="end center">
+                    <button mat-icon-button color="accent" (click)="deleteTemplate(template._id)"><mat-icon>delete</mat-icon></button>
+                </div>
+            </div>
+        </div>
+        <mat-hint style="margin-bottom: 10px;" *ngIf="existingTemplates.length === 0">(no templates available)</mat-hint>
+
     </div>
 </div>
diff --git a/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.ts b/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.ts
index 8c27bf476..e8a7f7846 100644
--- a/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.ts
+++ b/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.ts
@@ -18,8 +18,9 @@
 
 import { Component, Input, OnInit } from '@angular/core';
 import {
+  PipelineElementTemplateService,
   PipelineElementTemplate,
-  StaticPropertyUnion
+  StaticPropertyUnion,
 } from '@streampipes/platform-services';
 import { PipelineElementTemplateGenerator } from './pipeline-element-template-generator';
 
@@ -42,14 +43,27 @@ export class PipelineElementTemplateConfigComponent implements OnInit {
   @Input()
   staticProperties: StaticPropertyUnion[];
 
+  existingTemplates: PipelineElementTemplate[];
+
+  constructor(private pipelineElementTemplateService: PipelineElementTemplateService) {
+
+  }
+
 
   ngOnInit(): void {
+    this.loadTemplates();
     this.template.basePipelineElementAppId = this.appId;
     this.staticProperties.forEach(sp => {
       this.templateConfigs.set(sp.internalName, this.makeTemplateValue(sp));
     });
   }
 
+  loadTemplates() {
+    this.pipelineElementTemplateService.getPipelineElementTemplates(this.appId).subscribe(templates => {
+      this.existingTemplates = templates;
+    });
+  }
+
   handleSelection(sp: StaticPropertyUnion) {
     if (this.templateConfigs.has(sp.internalName)) {
       this.templateConfigs.delete(sp.internalName);
@@ -78,4 +92,9 @@ export class PipelineElementTemplateConfigComponent implements OnInit {
     this.templateConfigs.set(sp.internalName, config);
   }
 
+  deleteTemplate(templateId: string) {
+    this.pipelineElementTemplateService
+      .deletePipelineElementTemplate(templateId).subscribe(result => this.loadTemplates());
+  }
+
 }