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 2021/11/08 20:07:36 UTC

[incubator-streampipes] branch STREAMPIPES-426 updated (80d2dd6 -> 2e9f6c3)

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

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


    from 80d2dd6  Merge branch 'STREAMPIPES-426' of github.com:apache/incubator-streampipes into STREAMPIPES-426
     new f47d02c  [STREAMPIPES-426] Regenerate typescript models
     new 943ac66  [STREAMPIPES-426] Hide UI features that are inaccessible by user role
     new 2e9f6c3  [STREAMPIPES-426] Hide data explorer features that are inaccessible by user role

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/streampipes/model/client/user/Role.java |  6 +-
 ui/src/app/_enums/user-privilege.enum.ts           | 56 ++++++++++++++++++
 .../app/core-model/gen/streampipes-model-client.ts | 29 +--------
 ui/src/app/core-model/gen/streampipes-model.ts     | 35 +++++++++--
 .../static-file-input.component.ts                 |  3 +-
 .../overview/dashboard-overview.component.html     | 69 +++++++---------------
 .../overview/dashboard-overview.component.ts       |  9 ++-
 ui/src/app/dashboard/dashboard.component.html      |  2 +-
 ui/src/app/dashboard/dashboard.component.ts        |  7 ++-
 ...data-explorer-dashboard-overview.component.html | 45 +++++---------
 .../data-explorer-dashboard-overview.component.ts  | 10 +++-
 .../data-explorer-dashboard-widget.component.html  |  4 +-
 .../data-explorer-dashboard-widget.component.ts    | 12 +++-
 .../app/data-explorer/data-explorer.component.html |  4 +-
 .../app/data-explorer/data-explorer.component.ts   | 19 +++++-
 .../file-overview/file-overview.component.ts       |  2 +-
 ui/src/app/platform-services/apis/files.service.ts |  3 +-
 ui/src/app/services/auth.service.ts                |  2 +-
 18 files changed, 186 insertions(+), 131 deletions(-)
 create mode 100644 ui/src/app/_enums/user-privilege.enum.ts

[incubator-streampipes] 02/03: [STREAMPIPES-426] Hide UI features that are inaccessible by user role

Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 943ac66dd6bef34abdcacf8e03df7350d8aabdc9
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Mon Nov 8 19:48:58 2021 +0100

    [STREAMPIPES-426] Hide UI features that are inaccessible by user role
---
 ui/src/app/_enums/user-privilege.enum.ts           | 56 ++++++++++++++++++
 .../static-file-input.component.ts                 |  3 +-
 .../overview/dashboard-overview.component.html     | 69 +++++++---------------
 .../overview/dashboard-overview.component.ts       |  9 ++-
 ui/src/app/dashboard/dashboard.component.html      |  2 +-
 ui/src/app/dashboard/dashboard.component.ts        |  7 ++-
 ui/src/app/services/auth.service.ts                |  2 +-
 7 files changed, 92 insertions(+), 56 deletions(-)

diff --git a/ui/src/app/_enums/user-privilege.enum.ts b/ui/src/app/_enums/user-privilege.enum.ts
new file mode 100644
index 0000000..1d0e550
--- /dev/null
+++ b/ui/src/app/_enums/user-privilege.enum.ts
@@ -0,0 +1,56 @@
+/*
+ * 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 enum UserPrivilege {
+  PRIVILEGE_READ_PIPELINE = 'PRIVILEGE_READ_PIPELINE',
+  PRIVILEGE_WRITE_PIPELINE = 'PRIVILEGE_WRITE_PIPELINE',
+  PRIVILEGE_DELETE_PIPELINE = 'PRIVILEGE_DELETE_PIPELINE',
+
+  PRIVILEGE_READ_DATA_EXPLORER = 'PRIVILEGE_READ_DATA_EXPLORER',
+  PRIVILEGE_WRITE_DATA_EXPLORER = 'PRIVILEGE_WRITE_DATA_EXPLORER',
+  PRIVILEGE_DELETE_DATA_EXPLORER = 'PRIVILEGE_DELETE_DATA_EXPLORER',
+
+  PRIVILEGE_READ_DASHBOARD = 'PRIVILEGE_READ_DASHBOARD',
+  PRIVILEGE_WRITE_DASHBOARD = 'PRIVILEGE_WRITE_DASHBOARD',
+  PRIVILEGE_DELETE_DASHBOARD = 'PRIVILEGE_DELETE_DASHBOARD',
+
+  PRIVILEGE_READ_ADAPTER = 'PRIVILEGE_READ_ADAPTER',
+  PRIVILEGE_WRITE_ADAPTER = 'PRIVILEGE_WRITE_ADAPTER',
+  PRIVILEGE_DELETE_ADAPTER = 'PRIVILEGE_DELETE_ADAPTER',
+
+  PRIVILEGE_READ_PIPELINE_ELEMENT = 'PRIVILEGE_READ_PIPELINE_ELEMENT',
+  PRIVILEGE_WRITE_PIPELINE_ELEMENT = 'PRIVILEGE_WRITE_PIPELINE_ELEMENT',
+  PRIVILEGE_DELETE_PIPELINE_ELEMENT = 'PRIVILEGE_DELETE_PIPELINE_ELEMENT',
+
+  PRIVILEGE_READ_DATA_EXPLORER_WIDGET = 'PRIVILEGE_READ_DATA_EXPLORER_WIDGET',
+  PRIVILEGE_WRITE_DATA_EXPLORER_WIDGET = 'PRIVILEGE_WRITE_DATA_EXPLORER_WIDGET',
+  PRIVILEGE_DELETE_DATA_EXPLORER_WIDGET = 'PRIVILEGE_DELETE_DATA_EXPLORER_WIDGET',
+
+  PRIVILEGE_READ_DASHBOARD_WIDGET = 'PRIVILEGE_READ_DASHBOARD_WIDGET',
+  PRIVILEGE_WRITE_DASHBOARD_WIDGET = 'PRIVILEGE_WRITE_DASHBOARD_WIDGET',
+  PRIVILEGE_DELETE_DASHBOARD_WIDGET = 'PRIVILEGE_DELETE_DASHBOARD_WIDGET',
+
+  PRIVILEGE_READ_APPS = 'PRIVILEGE_READ_APPS',
+  PRIVILEGE_WRITE_APPS = 'PRIVILEGE_WRITE_APPS',
+
+  PRIVILEGE_READ_NOTIFICATIONS = 'PRIVILEGE_READ_NOTIFICATIONS',
+
+  PRIVILEGE_READ_FILES = 'PRIVILEGE_READ_FILES',
+  PRIVILEGE_WRITE_FILES = 'PRIVILEGE_WRITE_FILES',
+  PRIVILEGE_DELETE_FILES = 'PRIVILEGE_DELETE_FILES'
+}
diff --git a/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts b/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts
index d9150d1..feebd2f 100644
--- a/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts
+++ b/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts
@@ -18,9 +18,8 @@
 
 import { Component, EventEmitter, OnInit, Output } from '@angular/core';
 import { HttpEventType, HttpResponse } from '@angular/common/http';
-import { FileStaticProperty } from '../../../core-model/gen/streampipes-model';
+import { FileStaticProperty, FileMetadata } from '../../../core-model/gen/streampipes-model';
 import { FilesService } from '../../../platform-services/apis/files.service';
-import { FileMetadata } from '../../../core-model/gen/streampipes-model';
 import { ConfigurationInfo } from '../../../connect/model/ConfigurationInfo';
 import { AbstractValidatedStaticPropertyRenderer } from '../base/abstract-validated-static-property';
 import { FormControl, ValidatorFn, Validators } from '@angular/forms';
diff --git a/ui/src/app/dashboard/components/overview/dashboard-overview.component.html b/ui/src/app/dashboard/components/overview/dashboard-overview.component.html
index a32fce3..828ff62 100644
--- a/ui/src/app/dashboard/components/overview/dashboard-overview.component.html
+++ b/ui/src/app/dashboard/components/overview/dashboard-overview.component.html
@@ -20,7 +20,7 @@
     <div fxFlex="100" fxLayout="column">
         <div fxLayout="row" class="fixed-height options-bar sp-tab-bg">
             <div class="options-bar-item pl-10" fxLayoutAlign="start center" fxLayout="row">
-                <button mat-button mat-raised-button color="accent" (click)="openNewDashboardDialog()">
+                <button mat-button mat-raised-button color="accent" (click)="openNewDashboardDialog()" *ngIf="hasDashboardWritePrivileges">
                     <i class="material-icons">add</i>
                     <span> New dashboard</span>
                 </button>
@@ -46,73 +46,46 @@
                     </td>
                 </ng-container>
 
-                <ng-container matColumnDef="open">
-                    <th fxFlex="8" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Show</th>
-                    <td fxFlex="8" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
-                        <div fxLayout="row">
+                <ng-container matColumnDef="actions">
+                    <th fxFlex="40" fxLayoutAlign="center center" mat-header-cell *matHeaderCellDef> Actions</th>
+                    <td fxFlex="40" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
+                        <div fxLayout="row" fxFlex="100">
+                            <span fxFlex fxFlexOrder="1" fxLayout="row" fxLayoutAlign="center center">
                             <button mat-button mat-icon-button color="accent"
                                     (click)="showDashboard(element, false)">
                                 <i class="material-icons">visibility</i>
                             </button>
-                        </div>
-                    </td>
-                </ng-container>
-
-                <ng-container matColumnDef="openWindow">
-                    <th fxFlex="8" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Window</th>
-                    <td fxFlex="8" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
-                        <div fxLayout="row">
+                            </span>
+                            <span fxFlex fxFlexOrder="2" fxLayout="row" fxLayoutAlign="center center">
                             <button mat-button mat-icon-button color="accent"
                                     (click)="openExternalDashboard(element)">
                                 <i class="material-icons">open_in_new</i>
                             </button>
-                        </div>
-                    </td>
-                </ng-container>
-
-                <ng-container matColumnDef="settings">
-                    <th fxFlex="8" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Settings</th>
-                    <td fxFlex="8" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
-                        <div fxLayout="row">
+                            </span>
+                            <span fxFlex fxFlexOrder="3" fxLayout="row" fxLayoutAlign="center center" *ngIf="hasDashboardWritePrivileges">
                             <button mat-button mat-icon-button color="accent"
                                     (click)="openEditDashboardDialog(element)">
                                 <i class="material-icons">settings</i>
                             </button>
-                        </div>
-                    </td>
-                </ng-container>
-
-                <ng-container matColumnDef="edit">
-                    <th fxFlex="8" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Edit</th>
-                    <td fxFlex="8" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
-                        <div fxLayout="row">
+                            </span>
+                            <span fxFlex fxFlexOrder="4" fxLayout="row" fxLayoutAlign="center center" *ngIf="hasDashboardWritePrivileges">
                             <button mat-button mat-icon-button color="accent"
                                     (click)="showDashboard(element, true)">
                                 <i class="material-icons">edit</i>
                             </button>
-                        </div>
-                    </td>
-                </ng-container>
-                <ng-container matColumnDef="permissions" *ngIf="isAdmin">
-                        <th fxFlex="8" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Permissions</th>
-                        <td fxFlex="8" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
-                            <div fxLayout="row">
-                                <button mat-button mat-icon-button color="accent"
-                                        (click)="showPermissionsDialog(element)">
-                                    <i class="material-icons">share</i>
-                                </button>
-                            </div>
-                    </td>
-                </ng-container>
-
-                <ng-container matColumnDef="delete">
-                    <th fxFlex="10" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Delete</th>
-                    <td fxFlex="10" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
-                        <div fxLayout="row">
+                            </span>
+                            <span fxFlex fxFlexOrder="5" fxLayout="row" fxLayoutAlign="center center" *ngIf="isAdmin">
+                            <button mat-button mat-icon-button color="accent"
+                                    (click)="showPermissionsDialog(element)">
+                                <i class="material-icons">share</i>
+                            </button>
+                            </span>
+                            <span fxFlex fxFlexOrder="6" fxLayout="row" fxLayoutAlign="center center" *ngIf="hasDashboardDeletePrivileges">
                             <button mat-button mat-icon-button color="accent"
                                     (click)="openDeleteDashboardDialog(element)">
                                 <i class="material-icons">delete</i>
                             </button>
+                            </span>
                         </div>
                     </td>
                 </ng-container>
diff --git a/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts b/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts
index 016bc2b..e021254 100644
--- a/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts
+++ b/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts
@@ -29,6 +29,7 @@ import { PanelType } from '../../../core-ui/dialog/base-dialog/base-dialog.model
 import { DialogService } from '../../../core-ui/dialog/base-dialog/base-dialog.service';
 import { UserRole } from '../../../_enums/user-role.enum';
 import { AuthService } from '../../../services/auth.service';
+import { UserPrivilege } from '../../../_enums/user-privilege.enum';
 
 @Component({
   selector: 'dashboard-overview',
@@ -45,6 +46,8 @@ export class DashboardOverviewComponent implements OnInit {
   displayedColumns: string[] = [];
 
   isAdmin = false;
+  hasDashboardWritePrivileges = false;
+  hasDashboardDeletePrivileges = false;
 
   constructor(private dashboardService: DashboardService,
               public dialog: MatDialog,
@@ -57,9 +60,9 @@ export class DashboardOverviewComponent implements OnInit {
   ngOnInit(): void {
     this.authService.user$.subscribe(user => {
       this.isAdmin = user.roles.indexOf(UserRole.ROLE_ADMIN) > -1;
-      this.displayedColumns = this.isAdmin ?
-          ['name', 'open', 'openWindow', 'settings', 'edit', 'permissions', 'delete'] :
-          this.displayedColumns = ['name', 'open', 'openWindow', 'settings', 'edit', 'delete'];
+      this.hasDashboardWritePrivileges = this.authService.hasRole(UserPrivilege.PRIVILEGE_WRITE_DASHBOARD);
+      this.hasDashboardDeletePrivileges = this.authService.hasRole(UserPrivilege.PRIVILEGE_DELETE_DASHBOARD);
+      this.displayedColumns = ['name', 'actions'];
 
     });
     this.dataSource.data = this.dashboards;
diff --git a/ui/src/app/dashboard/dashboard.component.html b/ui/src/app/dashboard/dashboard.component.html
index 315ea30..7cb4e9c 100644
--- a/ui/src/app/dashboard/dashboard.component.html
+++ b/ui/src/app/dashboard/dashboard.component.html
@@ -28,7 +28,7 @@
                 </div>
                 <div fxFlex fxLayoutAlign="end center" class="mr-20">
                 <button mat-button mat-icon-button color="accent"
-                        *ngIf="selectedIndex > 0" (click)="toggleEditMode()" [disabled]="editMode">
+                        *ngIf="selectedIndex > 0 && hasDashboardWritePrivileges" (click)="toggleEditMode()" [disabled]="editMode">
                     <i class="material-icons">edit</i>
                 </button>
                 </div>
diff --git a/ui/src/app/dashboard/dashboard.component.ts b/ui/src/app/dashboard/dashboard.component.ts
index fb5e9e1..5ec5bd8 100644
--- a/ui/src/app/dashboard/dashboard.component.ts
+++ b/ui/src/app/dashboard/dashboard.component.ts
@@ -23,6 +23,8 @@ import { RefreshDashboardService } from './services/refresh-dashboard.service';
 import { Tuple2 } from '../core-model/base/Tuple2';
 import { EditModeService } from './services/edit-mode.service';
 import { ActivatedRoute } from '@angular/router';
+import { AuthService } from '../services/auth.service';
+import { UserPrivilege } from '../_enums/user-privilege.enum';
 
 @Component({
     selector: 'dashboard',
@@ -39,15 +41,18 @@ export class DashboardComponent implements OnInit {
     editMode = false;
 
     dashboards: Dashboard[];
+    hasDashboardWritePrivileges = false;
 
     routeParams: any;
 
     constructor(private dashboardService: DashboardService,
                 private refreshDashboardService: RefreshDashboardService,
                 private editModeService: EditModeService,
-                private route: ActivatedRoute) {}
+                private route: ActivatedRoute,
+                private authService: AuthService) {}
 
     ngOnInit() {
+        this.hasDashboardWritePrivileges = this.authService.hasRole(UserPrivilege.PRIVILEGE_WRITE_DASHBOARD);
         this.route.queryParams.subscribe(params => {
             this.getDashboards(params['dashboardId']);
         });
diff --git a/ui/src/app/services/auth.service.ts b/ui/src/app/services/auth.service.ts
index 6999819..407a4e9 100644
--- a/ui/src/app/services/auth.service.ts
+++ b/ui/src/app/services/auth.service.ts
@@ -124,7 +124,7 @@ export class AuthService {
     }
 
     public hasRole(role: RoleModel): boolean {
-        return this.getUserRoles().includes(role);
+        return this.getUserRoles().includes('ROLE_ADMIN') || this.getUserRoles().includes(role);
     }
 
     public hasAnyRole(roles: RoleModel[]): boolean {

[incubator-streampipes] 01/03: [STREAMPIPES-426] Regenerate typescript models

Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f47d02c09cd828edebea9dfd14fb0144b534f1b2
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Mon Nov 8 19:10:39 2021 +0100

    [STREAMPIPES-426] Regenerate typescript models
---
 .../apache/streampipes/model/client/user/Role.java |  6 ++--
 .../app/core-model/gen/streampipes-model-client.ts | 29 +-----------------
 ui/src/app/core-model/gen/streampipes-model.ts     | 35 +++++++++++++++++++---
 .../static-file-input.component.ts                 |  2 +-
 .../file-overview/file-overview.component.ts       |  2 +-
 ui/src/app/platform-services/apis/files.service.ts |  3 +-
 6 files changed, 40 insertions(+), 37 deletions(-)

diff --git a/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/Role.java b/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/Role.java
index 68d2957..8b963ed 100644
--- a/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/Role.java
+++ b/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/Role.java
@@ -62,13 +62,15 @@ public enum Role {
   ROLE_DASHBOARD_USER(
           Constants.ROLE_DASHBOARD_USER_VALUE,
           Privilege.PRIVILEGE_READ_DASHBOARD,
-          Privilege.PRIVILEGE_READ_DASHBOARD_WIDGET
+          Privilege.PRIVILEGE_READ_DASHBOARD_WIDGET,
+          Privilege.PRIVILEGE_READ_PIPELINE
   ),
 
   ROLE_DATA_EXPLORER_USER(
           Constants.ROLE_DATA_EXPLORER_USER_VALUE,
           Privilege.PRIVILEGE_READ_DATA_EXPLORER_VIEW,
-          Privilege.PRIVILEGE_READ_DATA_EXPLORER_WIDGET
+          Privilege.PRIVILEGE_READ_DATA_EXPLORER_WIDGET,
+          Privilege.PRIVILEGE_READ_PIPELINE
   ),
 
   ROLE_PIPELINE_USER(
diff --git a/ui/src/app/core-model/gen/streampipes-model-client.ts b/ui/src/app/core-model/gen/streampipes-model-client.ts
index 5def80c..957e0f2 100644
--- a/ui/src/app/core-model/gen/streampipes-model-client.ts
+++ b/ui/src/app/core-model/gen/streampipes-model-client.ts
@@ -18,7 +18,7 @@
 /* tslint:disable */
 /* eslint-disable */
 // @ts-nocheck
-// Generated using typescript-generator version 2.27.744 on 2021-11-04 13:01:00.
+// Generated using typescript-generator version 2.27.744 on 2021-11-08 19:00:56.
 
 export class ExtensionsServiceEndpointItem {
     appId: string;
@@ -55,33 +55,6 @@ export class ExtensionsServiceEndpointItem {
     }
 }
 
-export class FileMetadata {
-    createdAt: number;
-    createdByUser: string;
-    fileId: string;
-    filetype: string;
-    internalFilename: string;
-    lastModified: number;
-    originalFilename: string;
-    rev: string;
-
-    static fromData(data: FileMetadata, target?: FileMetadata): FileMetadata {
-        if (!data) {
-            return data;
-        }
-        const instance = target || new FileMetadata();
-        instance.fileId = data.fileId;
-        instance.rev = data.rev;
-        instance.internalFilename = data.internalFilename;
-        instance.originalFilename = data.originalFilename;
-        instance.filetype = data.filetype;
-        instance.createdAt = data.createdAt;
-        instance.lastModified = data.lastModified;
-        instance.createdByUser = data.createdByUser;
-        return instance;
-    }
-}
-
 export class Group {
     groupId: string;
     groupName: string;
diff --git a/ui/src/app/core-model/gen/streampipes-model.ts b/ui/src/app/core-model/gen/streampipes-model.ts
index 53025c1..1f2b259 100644
--- a/ui/src/app/core-model/gen/streampipes-model.ts
+++ b/ui/src/app/core-model/gen/streampipes-model.ts
@@ -18,7 +18,7 @@
 /* tslint:disable */
 /* eslint-disable */
 // @ts-nocheck
-// Generated using typescript-generator version 2.27.744 on 2021-11-01 21:23:48.
+// Generated using typescript-generator version 2.27.744 on 2021-11-08 19:04:54.
 
 export class AbstractStreamPipesEntity {
   "@class": "org.apache.streampipes.model.base.AbstractStreamPipesEntity" | "org.apache.streampipes.model.base.NamedStreamPipesEntity" | "org.apache.streampipes.model.connect.adapter.AdapterDescription" | "org.apache.streampipes.model.connect.adapter.AdapterSetDescription" | "org.apache.streampipes.model.connect.adapter.GenericAdapterSetDescription" | "org.apache.streampipes.model.connect.adapter.SpecificAdapterSetDescription" | "org.apache.streampipes.model.connect.adapter.AdapterStream [...]
@@ -151,8 +151,8 @@ export class NamedStreamPipesEntity extends AbstractStreamPipesEntity {
     instance.applicationLinks = __getCopyArrayFn(ApplicationLink.fromData)(data.applicationLinks);
     instance.internallyManaged = data.internallyManaged;
     instance.connectedTo = __getCopyArrayFn(__identity<string>())(data.connectedTo);
-    instance.dom = data.dom;
     instance.uri = data.uri;
+    instance.dom = data.dom;
     instance._rev = data._rev;
     return instance;
   }
@@ -192,8 +192,8 @@ export class AdapterDescription extends NamedStreamPipesEntity {
     instance.selectedEndpointUrl = data.selectedEndpointUrl;
     instance.correspondingServiceGroup = data.correspondingServiceGroup;
     instance.correspondingDataStreamElementId = data.correspondingDataStreamElementId;
-    instance.schemaRules = __getCopyArrayFn(__identity<any>())(data.schemaRules);
     instance.streamRules = __getCopyArrayFn(__identity<any>())(data.streamRules);
+    instance.schemaRules = __getCopyArrayFn(__identity<any>())(data.schemaRules);
     instance.valueRules = __getCopyArrayFn(__identity<any>())(data.valueRules);
     return instance;
   }
@@ -1506,6 +1506,33 @@ export class EventStreamQualityRequirement extends UnnamedStreamPipesEntity {
   }
 }
 
+export class FileMetadata {
+  createdAt: number;
+  createdByUser: string;
+  fileId: string;
+  filetype: string;
+  internalFilename: string;
+  lastModified: number;
+  originalFilename: string;
+  rev: string;
+
+  static fromData(data: FileMetadata, target?: FileMetadata): FileMetadata {
+    if (!data) {
+      return data;
+    }
+    const instance = target || new FileMetadata();
+    instance.fileId = data.fileId;
+    instance.rev = data.rev;
+    instance.internalFilename = data.internalFilename;
+    instance.originalFilename = data.originalFilename;
+    instance.filetype = data.filetype;
+    instance.createdAt = data.createdAt;
+    instance.lastModified = data.lastModified;
+    instance.createdByUser = data.createdByUser;
+    return instance;
+  }
+}
+
 export class FileStaticProperty extends StaticProperty {
   "@class": "org.apache.streampipes.model.staticproperty.FileStaticProperty";
   endpointUrl: string;
@@ -2410,9 +2437,9 @@ export class PipelineTemplateDescription extends NamedStreamPipesEntity {
     const instance = target || new PipelineTemplateDescription();
     super.fromData(data, instance);
     instance.boundTo = __getCopyArrayFn(BoundPipelineElement.fromData)(data.boundTo);
+    instance.pipelineTemplateDescription = data.pipelineTemplateDescription;
     instance.pipelineTemplateId = data.pipelineTemplateId;
     instance.pipelineTemplateName = data.pipelineTemplateName;
-    instance.pipelineTemplateDescription = data.pipelineTemplateDescription;
     return instance;
   }
 }
diff --git a/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts b/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts
index 6b1be2d..d9150d1 100644
--- a/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts
+++ b/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts
@@ -20,7 +20,7 @@ import { Component, EventEmitter, OnInit, Output } from '@angular/core';
 import { HttpEventType, HttpResponse } from '@angular/common/http';
 import { FileStaticProperty } from '../../../core-model/gen/streampipes-model';
 import { FilesService } from '../../../platform-services/apis/files.service';
-import { FileMetadata } from '../../../core-model/gen/streampipes-model-client';
+import { FileMetadata } from '../../../core-model/gen/streampipes-model';
 import { ConfigurationInfo } from '../../../connect/model/ConfigurationInfo';
 import { AbstractValidatedStaticPropertyRenderer } from '../base/abstract-validated-static-property';
 import { FormControl, ValidatorFn, Validators } from '@angular/forms';
diff --git a/ui/src/app/files/components/file-overview/file-overview.component.ts b/ui/src/app/files/components/file-overview/file-overview.component.ts
index 06a6c56..196d48a 100644
--- a/ui/src/app/files/components/file-overview/file-overview.component.ts
+++ b/ui/src/app/files/components/file-overview/file-overview.component.ts
@@ -18,7 +18,7 @@
 
 import { Component, OnInit, ViewChild } from '@angular/core';
 import { FilesService } from '../../../platform-services/apis/files.service';
-import { FileMetadata } from '../../../core-model/gen/streampipes-model-client';
+import { FileMetadata } from '../../../core-model/gen/streampipes-model';
 import { MatTableDataSource } from '@angular/material/table';
 import { MatPaginator } from '@angular/material/paginator';
 import { ConfirmDialogComponent } from '../../../core-ui/dialog/confirm-dialog/confirm-dialog.component';
diff --git a/ui/src/app/platform-services/apis/files.service.ts b/ui/src/app/platform-services/apis/files.service.ts
index 1267a6a..66b040f 100644
--- a/ui/src/app/platform-services/apis/files.service.ts
+++ b/ui/src/app/platform-services/apis/files.service.ts
@@ -21,7 +21,8 @@ import { HttpClient, HttpEvent, HttpParams, HttpRequest } from '@angular/common/
 import { PlatformServicesCommons } from './commons.service';
 import { Observable } from 'rxjs';
 import { map } from 'rxjs/operators';
-import { FileMetadata } from '../../core-model/gen/streampipes-model-client';
+import { FileMetadata } from '../../core-model/gen/streampipes-model';
+
 
 @Injectable()
 export class FilesService {

[incubator-streampipes] 03/03: [STREAMPIPES-426] Hide data explorer features that are inaccessible by user role

Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 2e9f6c35e6ca4daefa146deb19512e5943670912
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Mon Nov 8 21:07:23 2021 +0100

    [STREAMPIPES-426] Hide data explorer features that are inaccessible by user role
---
 ui/src/app/_enums/user-privilege.enum.ts           |  6 +--
 ...data-explorer-dashboard-overview.component.html | 45 ++++++++--------------
 .../data-explorer-dashboard-overview.component.ts  | 10 +++--
 .../data-explorer-dashboard-widget.component.html  |  4 +-
 .../data-explorer-dashboard-widget.component.ts    | 12 +++++-
 .../app/data-explorer/data-explorer.component.html |  4 +-
 .../app/data-explorer/data-explorer.component.ts   | 19 ++++++++-
 7 files changed, 58 insertions(+), 42 deletions(-)

diff --git a/ui/src/app/_enums/user-privilege.enum.ts b/ui/src/app/_enums/user-privilege.enum.ts
index 1d0e550..6f58fdf 100644
--- a/ui/src/app/_enums/user-privilege.enum.ts
+++ b/ui/src/app/_enums/user-privilege.enum.ts
@@ -21,9 +21,9 @@ export enum UserPrivilege {
   PRIVILEGE_WRITE_PIPELINE = 'PRIVILEGE_WRITE_PIPELINE',
   PRIVILEGE_DELETE_PIPELINE = 'PRIVILEGE_DELETE_PIPELINE',
 
-  PRIVILEGE_READ_DATA_EXPLORER = 'PRIVILEGE_READ_DATA_EXPLORER',
-  PRIVILEGE_WRITE_DATA_EXPLORER = 'PRIVILEGE_WRITE_DATA_EXPLORER',
-  PRIVILEGE_DELETE_DATA_EXPLORER = 'PRIVILEGE_DELETE_DATA_EXPLORER',
+  PRIVILEGE_READ_DATA_EXPLORER_VIEW = 'PRIVILEGE_READ_DATA_EXPLORER_VIEW',
+  PRIVILEGE_WRITE_DATA_EXPLORER_VIEW = 'PRIVILEGE_WRITE_DATA_EXPLORER_VIEW',
+  PRIVILEGE_DELETE_DATA_EXPLORER_VIEW = 'PRIVILEGE_DELETE_DATA_EXPLORER_VIEW',
 
   PRIVILEGE_READ_DASHBOARD = 'PRIVILEGE_READ_DASHBOARD',
   PRIVILEGE_WRITE_DASHBOARD = 'PRIVILEGE_WRITE_DASHBOARD',
diff --git a/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview.component.html b/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview.component.html
index 57666e3..314fc84 100644
--- a/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview.component.html
+++ b/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview.component.html
@@ -23,7 +23,7 @@
             <div fxLayoutAlign="start center" fxLayout="row" class="pl-10">
                 <button mat-button mat-raised-button color="accent"
                         data-cy="open-new-data-view-dialog"
-                        (click)="openNewDataViewDialog()" class="mr-10">
+                        (click)="openNewDataViewDialog()" class="mr-10" *ngIf="hasDataExplorerWritePrivileges">
                     <i class="material-icons">add</i>
                     <span>New Data View</span>
                 </button>
@@ -45,57 +45,42 @@
                 <table mat-table [dataSource]="dataSource" multiTemplateDataRows>
 
                     <ng-container matColumnDef="name">
-                        <th fxFlex="80" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Data View</th>
-                        <td fxFlex="80" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
+                        <th fxFlex="60" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Data View</th>
+                        <td fxFlex="60" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
                             {{element.name}}<br/>
                             {{element.description}}
                         </td>
                     </ng-container>
 
-                    <ng-container matColumnDef="open">
-                        <th fxFlex="10" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Show</th>
-                        <td fxFlex="10" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
-                            <div fxLayout="row">
+                    <ng-container matColumnDef="actions">
+                        <th fxFlex="40" fxLayoutAlign="center center" mat-header-cell *matHeaderCellDef> Actions</th>
+                        <td fxFlex="40" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
+                            <div fxLayout="row" fxFlex="100">
+                                <span fxFlex fxFlexOrder="1" fxLayout="row" fxLayoutAlign="center center">
                                 <button mat-button mat-icon-button color="accent"
                                         (click)="showDashboard(element, false)">
                                     <i class="material-icons">visibility</i>
                                 </button>
-                            </div>
-                        </td>
-                    </ng-container>
-
-                    <ng-container matColumnDef="edit">
-                        <th fxFlex="10" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Edit</th>
-                        <td fxFlex="10" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
-                            <div fxLayout="row">
+                                </span>
+                                <span fxFlex fxFlexOrder="2" fxLayout="row" fxLayoutAlign="center center" *ngIf="hasDataExplorerWritePrivileges">
                                 <button mat-button mat-icon-button color="accent"
                                         data-cy="edit-data-view"
                                         (click)="showDashboard(element, true)">
                                     <i class="material-icons">edit</i>
                                 </button>
-                            </div>
-                        </td>
-                    </ng-container>
-                    <ng-container matColumnDef="permissions" *ngIf="isAdmin">
-                        <th fxFlex="8" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Permissions</th>
-                        <td fxFlex="8" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
-                            <div fxLayout="row">
+                                </span>
+                                <span fxFlex fxFlexOrder="3" fxLayout="row" fxLayoutAlign="center center" *ngIf="isAdmin">
                                 <button mat-button mat-icon-button color="accent"
                                         (click)="showPermissionsDialog(element)">
                                     <i class="material-icons">share</i>
                                 </button>
-                            </div>
-                        </td>
-                    </ng-container>
-
-                    <ng-container matColumnDef="delete">
-                        <th fxFlex="10" fxLayoutAlign="start center" mat-header-cell *matHeaderCellDef> Delete</th>
-                        <td fxFlex="10" fxLayoutAlign="start center" mat-cell *matCellDef="let element">
-                            <div fxLayout="row">
+                                </span>
+                                <span fxFlex fxFlexOrder="4" fxLayout="row" fxLayoutAlign="center center" *ngIf="hasDataExplorerDeletePrivileges">
                                 <button mat-button mat-icon-button color="accent"
                                         (click)="openDeleteDashboardDialog(element)">
                                     <i class="material-icons">delete</i>
                                 </button>
+                                </span>
                             </div>
                         </td>
                     </ng-container>
diff --git a/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview.component.ts b/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview.component.ts
index ce0ef13..d47725f 100644
--- a/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview.component.ts
+++ b/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview.component.ts
@@ -27,6 +27,7 @@ import { DialogService } from '../../../core-ui/dialog/base-dialog/base-dialog.s
 import { ObjectPermissionDialogComponent } from '../../../core-ui/object-permission-dialog/object-permission-dialog.component';
 import { UserRole } from '../../../_enums/user-role.enum';
 import { AuthService } from '../../../services/auth.service';
+import { UserPrivilege } from '../../../_enums/user-privilege.enum';
 
 @Component({
   selector: 'sp-data-explorer-dashboard-overview',
@@ -45,6 +46,9 @@ export class DataExplorerDashboardOverviewComponent implements OnInit {
   editLabels: boolean;
   isAdmin = false;
 
+  hasDataExplorerWritePrivileges = false;
+  hasDataExplorerDeletePrivileges = false;
+
   constructor(private dashboardService: DataViewDataExplorerService,
               public dialogService: DialogService,
               private authService: AuthService) {
@@ -53,10 +57,10 @@ export class DataExplorerDashboardOverviewComponent implements OnInit {
 
   ngOnInit(): void {
     this.authService.user$.subscribe(user => {
+      this.hasDataExplorerWritePrivileges = this.authService.hasRole(UserPrivilege.PRIVILEGE_WRITE_DATA_EXPLORER_VIEW);
+      this.hasDataExplorerDeletePrivileges = this.authService.hasRole(UserPrivilege.PRIVILEGE_DELETE_DATA_EXPLORER_VIEW);
       this.isAdmin = user.roles.indexOf(UserRole.ROLE_ADMIN) > -1;
-      this.displayedColumns = this.isAdmin ?
-          ['name', 'open', 'edit', 'permissions', 'delete'] :
-          this.displayedColumns = ['name', 'open', 'edit', 'delete'];
+      this.displayedColumns = ['name', 'actions'];
 
     });
     this.dataSource.data = this.dataViewDashboards;
diff --git a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.html b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.html
index 957741d..019429a 100644
--- a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.html
+++ b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.html
@@ -40,11 +40,11 @@
                         <mat-icon>get_app</mat-icon>
                         <span>Download data</span>
                     </button>
-                    <button mat-menu-item (click)="startEditMode()" *ngIf="!editMode">
+                    <button mat-menu-item (click)="startEditMode()" *ngIf="!editMode && hasDataExplorerWritePrivileges">
                         <mat-icon>edit</mat-icon>
                         <span>Edit Widget</span>
                     </button>
-                    <button mat-menu-item (click)="removeWidget()" *ngIf="editMode">
+                    <button mat-menu-item (click)="removeWidget()" *ngIf="editMode && hasDataExplorerDeletePrivileges">
                         <mat-icon>clear</mat-icon>
                         <span>Delete widget</span>
                     </button>
diff --git a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts
index ce6aad6..61a4c08 100644
--- a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts
+++ b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts
@@ -41,6 +41,8 @@ import { DataExplorerWidgetRegistry } from '../../registry/data-explorer-widget-
 import { WidgetDirective } from './widget.directive';
 import { BaseWidgetData } from '../widgets/base/data-explorer-widget-data';
 import { WidgetTypeService } from '../../services/widget-type.service';
+import { AuthService } from '../../../services/auth.service';
+import { UserPrivilege } from '../../../_enums/user-privilege.enum';
 
 @Component({
   selector: 'sp-data-explorer-dashboard-widget',
@@ -86,15 +88,23 @@ export class DataExplorerDashboardWidgetComponent implements OnInit {
   timerActive = false;
   loadingTime = 0;
 
+  hasDataExplorerWritePrivileges = false;
+  hasDataExplorerDeletePrivileges = false;
+
   @ViewChild(WidgetDirective, {static: true}) widgetHost!: WidgetDirective;
 
   constructor(private dataViewDataExplorerService: DataViewDataExplorerService,
               private dialog: MatDialog,
               private componentFactoryResolver: ComponentFactoryResolver,
-              private widgetTypeService: WidgetTypeService) {
+              private widgetTypeService: WidgetTypeService,
+              private authService: AuthService) {
   }
 
   ngOnInit(): void {
+    this.authService.user$.subscribe(user => {
+      this.hasDataExplorerWritePrivileges = this.authService.hasRole(UserPrivilege.PRIVILEGE_WRITE_DATA_EXPLORER_VIEW);
+      this.hasDataExplorerDeletePrivileges = this.authService.hasRole(UserPrivilege.PRIVILEGE_DELETE_DATA_EXPLORER_VIEW);
+    });
     this.widgetLoaded = true;
     this.title = this.dataLakeMeasure.measureName;
     this.widgetTypeService.widgetTypeChangeSubject.subscribe(typeChange => {
diff --git a/ui/src/app/data-explorer/data-explorer.component.html b/ui/src/app/data-explorer/data-explorer.component.html
index 7fb3b3b..651757b 100644
--- a/ui/src/app/data-explorer/data-explorer.component.html
+++ b/ui/src/app/data-explorer/data-explorer.component.html
@@ -31,7 +31,7 @@
                         <mat-icon>more_vert</mat-icon>
                     </button>
                     <mat-menu #menu="matMenu">
-                        <button mat-menu-item (click)="triggerEditMode()" *ngIf="!editMode">
+                        <button mat-menu-item (click)="triggerEditMode()" *ngIf="!editMode && hasDataExplorerWritePrivileges">
                             <mat-icon>edit</mat-icon>
                             <span>Edit dashboard</span>
                         </button>
@@ -47,7 +47,7 @@
                             <mat-icon>alarm_off</mat-icon>
                             <span>Hide time range selector</span>
                         </button>
-                        <button mat-menu-item>
+                        <button mat-menu-item *ngIf="hasDataExplorerDeletePrivileges" (click)="deleteDashboard(selectedDataViewDashboard)">
                             <mat-icon>clear</mat-icon>
                             <span>Delete dashboard</span>
                         </button>
diff --git a/ui/src/app/data-explorer/data-explorer.component.ts b/ui/src/app/data-explorer/data-explorer.component.ts
index c7d0b4c..87d0f60 100644
--- a/ui/src/app/data-explorer/data-explorer.component.ts
+++ b/ui/src/app/data-explorer/data-explorer.component.ts
@@ -24,6 +24,8 @@ import { Dashboard, TimeSettings } from '../dashboard/models/dashboard.model';
 import { Tuple2 } from '../core-model/base/Tuple2';
 import { ActivatedRoute } from '@angular/router';
 import { TimeSelectionService } from './services/time-selection.service';
+import { AuthService } from '../services/auth.service';
+import { UserPrivilege } from '../_enums/user-privilege.enum';
 
 @Component({
   selector: 'sp-data-explorer',
@@ -43,16 +45,25 @@ export class DataExplorerComponent implements OnInit {
 
   routeParams: any;
 
+  hasDataExplorerWritePrivileges = false;
+  hasDataExplorerDeletePrivileges = false;
+
   @ViewChild('dashboardPanel') dashboardPanel: DataExplorerDashboardPanelComponent;
 
   constructor(private dataViewService: DataViewDataExplorerService,
               private refreshDashboardService: RefreshDashboardService,
               private route: ActivatedRoute,
-              private timeSelectionService: TimeSelectionService) {
+              private timeSelectionService: TimeSelectionService,
+              private authService: AuthService,
+              private dashboardService: DataViewDataExplorerService) {
   }
 
 
   public ngOnInit() {
+    this.authService.user$.subscribe(user => {
+      this.hasDataExplorerWritePrivileges = this.authService.hasRole(UserPrivilege.PRIVILEGE_WRITE_DATA_EXPLORER_VIEW);
+      this.hasDataExplorerDeletePrivileges = this.authService.hasRole(UserPrivilege.PRIVILEGE_DELETE_DATA_EXPLORER_VIEW);
+    });
     this.route.queryParams.subscribe(params => {
       this.routeParams = { startTime: params['startTime'], endTime: params['endTime'], dashboardId: params['dashboardId'] };
       this.getDashboards();
@@ -129,4 +140,10 @@ export class DataExplorerComponent implements OnInit {
   triggerEditMode() {
     this.editMode = true;
   }
+
+  deleteDashboard(dashboard: Dashboard) {
+    this.dashboardService.deleteDashboard(dashboard).subscribe(result => {
+      this.getDashboards();
+    });
+  }
 }