Skip to content

Commit

Permalink
Rename services
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikriemer committed Jan 28, 2025
1 parent c69e23a commit b52bcc2
Show file tree
Hide file tree
Showing 20 changed files with 167 additions and 131 deletions.
7 changes: 5 additions & 2 deletions ui/deployment/home.service.mst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import { AuthService } from '../services/auth.service';
import { ServiceLink } from './models/home.model';
import {
AdapterService,
DataViewDataExplorerService, PipelineElementService,
DashboardService,
ChartService,
PipelineElementService,
PipelineService
} from '@streampipes/platform-services';
import { UserPrivilege } from '../_enums/user-privilege.enum';
Expand All @@ -32,7 +34,8 @@ export class HomeService {

constructor(private authService: AuthService,
private adapterService: AdapterService,
private dataViewService: DataViewDataExplorerService,
private chartService: ChartService,
private dashboardService: DashboardService,
private pipelineService: PipelineService,
private pipelineElementService: PipelineElementService) {
}
Expand Down
4 changes: 2 additions & 2 deletions ui/deployment/modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ spDashboard:
createLinks: "['dashboard']"
title: 'Dashboards'
createTitle: 'New dashboard'
dataFns: '[this.dataViewService.getDataViews()]'
dataFns: '[this.dashboardService.getDashboards()]'
viewRoles: '[UserPrivilege.PRIVILEGE_READ_DASHBOARD, UserPrivilege.PRIVILEGE_WRITE_DASHBOARD]'
createRoles: '[UserPrivilege.PRIVILEGE_WRITE_DASHBOARD]'
spDataExplorer:
Expand All @@ -140,6 +140,6 @@ spDataExplorer:
createLinks: "['dataexplorer']"
title: 'Charts'
createTitle: 'New chart'
dataFns: '[this.dataViewService.getAllWidgets()]'
dataFns: '[this.chartService.getAllCharts()]'
viewRoles: '[UserPrivilege.PRIVILEGE_READ_DATA_EXPLORER_VIEW, UserPrivilege.PRIVILEGE_WRITE_DATA_EXPLORER_VIEW]'
createRoles: '[UserPrivilege.PRIVILEGE_WRITE_DATA_EXPLORER_VIEW]'
Original file line number Diff line number Diff line change
Expand Up @@ -16,80 +16,28 @@
*
*/

import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { catchError, Observable, throwError } from 'rxjs';
import { map } from 'rxjs/operators';
import { Dashboard } from '../model/dashboard/dashboard.model';
import { Injectable } from '@angular/core';
import {
DataExplorerWidgetModel,
DataLakeMeasure,
} from '../model/gen/streampipes-model';
import { SharedDatalakeRestService } from './shared-dashboard.service';

@Injectable({
providedIn: 'root',
})
export class DataViewDataExplorerService {
constructor(
private http: HttpClient,
private sharedDatalakeRestService: SharedDatalakeRestService,
) {}
export class ChartService {
constructor(private http: HttpClient) {}

getDataViews(): Observable<Dashboard[]> {
return this.sharedDatalakeRestService.getDashboards(this.dashboardUrl);
}

getDashboard(dashboardId: string): Observable<Dashboard> {
return this.http
.get(`${this.dashboardUrl}/${dashboardId}`)
.pipe(map(data => data as Dashboard));
}

updateDashboard(dashboard: Dashboard): Observable<Dashboard> {
return this.sharedDatalakeRestService.updateDashboard(
this.dashboardUrl,
dashboard,
);
}

deleteDashboard(dashboard: Dashboard): Observable<any> {
return this.sharedDatalakeRestService.deleteDashboard(
this.dashboardUrl,
dashboard,
);
}

saveDataView(dataViewDashboard: Dashboard): Observable<any> {
return this.sharedDatalakeRestService.saveDashboard(
this.dashboardUrl,
dataViewDashboard,
);
}

private get baseUrl() {
return '/streampipes-backend';
}

private get persistedDataStreamsUrl() {
return `${this.baseUrl}/api/v3/datalake/pipelines`;
}

private get dashboardUrl() {
return `${this.baseUrl}/api/v3/datalake/dashboard`;
}

private get dashboardWidgetUrl() {
return `${this.baseUrl}/api/v3/datalake/dashboard/widgets`;
}

getAllWidgets(): Observable<DataExplorerWidgetModel[]> {
getAllCharts(): Observable<DataExplorerWidgetModel[]> {
return this.http
.get(this.dashboardWidgetUrl)
.pipe(map(res => res as DataExplorerWidgetModel[]));
}

getWidget(widgetId: string): Observable<DataExplorerWidgetModel> {
getChart(widgetId: string): Observable<DataExplorerWidgetModel> {
return this.http.get(this.dashboardWidgetUrl + '/' + widgetId).pipe(
catchError(() => {
return throwError(() => new Error('Failed to get widget data'));
Expand All @@ -102,7 +50,7 @@ export class DataViewDataExplorerService {
);
}

saveWidget(
saveChart(
widget: DataExplorerWidgetModel,
): Observable<DataExplorerWidgetModel> {
return this.http.post(this.dashboardWidgetUrl, widget).pipe(
Expand All @@ -114,17 +62,29 @@ export class DataViewDataExplorerService {
);
}

deleteWidget(widgetId: string): Observable<any> {
deleteChart(widgetId: string): Observable<any> {
return this.http.delete(`${this.dashboardWidgetUrl}/${widgetId}`);
}

updateWidget(widget: DataExplorerWidgetModel): Observable<any> {
updateChart(widget: DataExplorerWidgetModel): Observable<any> {
return this.http.put(
this.dashboardWidgetUrl + '/' + widget.elementId,
widget,
);
}

private get baseUrl() {
return '/streampipes-backend';
}

private get persistedDataStreamsUrl() {
return `${this.baseUrl}/api/v3/datalake/pipelines`;
}

private get dashboardWidgetUrl() {
return `${this.baseUrl}/api/v3/datalake/dashboard/widgets`;
}

getPersistedDataStream(
pipelineId: string,
measureName: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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 { HttpClient } from '@angular/common/http';
import {
Dashboard,
SharedDatalakeRestService,
} from '@streampipes/platform-services';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

@Injectable({
providedIn: 'root',
})
export class DashboardService {
constructor(
private http: HttpClient,
private sharedDatalakeRestService: SharedDatalakeRestService,
) {}

getDashboards(): Observable<Dashboard[]> {
return this.sharedDatalakeRestService.getDashboards(this.dashboardUrl);
}

getDashboard(dashboardId: string): Observable<Dashboard> {
return this.http
.get(`${this.dashboardUrl}/${dashboardId}`)
.pipe(map(data => data as Dashboard));
}

updateDashboard(dashboard: Dashboard): Observable<Dashboard> {
return this.sharedDatalakeRestService.updateDashboard(
this.dashboardUrl,
dashboard,
);
}

deleteDashboard(dashboard: Dashboard): Observable<any> {
return this.sharedDatalakeRestService.deleteDashboard(
this.dashboardUrl,
dashboard,
);
}

saveDashboard(dashboard: Dashboard): Observable<any> {
return this.sharedDatalakeRestService.saveDashboard(
this.dashboardUrl,
dashboard,
);
}

private get baseUrl() {
return '/streampipes-backend';
}

private get dashboardUrl() {
return `${this.baseUrl}/api/v3/datalake/dashboard`;
}
}
3 changes: 2 additions & 1 deletion ui/projects/streampipes/platform-services/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export * from './lib/apis/adapter.service';
export * from './lib/apis/adapter-monitoring.service';
export * from './lib/apis/asset-management.service';
export * from './lib/apis/compact-pipeline.service';
export * from './lib/apis/data-view-data-explorer.service';
export * from './lib/apis/chart.service';
export * from './lib/apis/dashboard.service';
export * from './lib/apis/datalake-rest.service';
export * from './lib/apis/files.service';
export * from './lib/apis/functions.service';
Expand Down
10 changes: 6 additions & 4 deletions ui/src/app/assets/dialog/base-asset-links.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import { Directive } from '@angular/core';
import {
AdapterDescription,
AdapterService,
ChartService,
Dashboard,
DashboardService,
DataExplorerWidgetModel,
DataLakeMeasure,
DatalakeRestService,
DataViewDataExplorerService,
FileMetadata,
FilesService,
GenericStorageService,
Expand All @@ -51,7 +52,8 @@ export abstract class BaseAssetLinksDirective {
constructor(
protected genericStorageService: GenericStorageService,
protected pipelineService: PipelineService,
protected dataViewService: DataViewDataExplorerService,
protected chartService: ChartService,
protected dashboardService: DashboardService,
protected dataLakeService: DatalakeRestService,
protected pipelineElementService: PipelineElementService,
protected adapterService: AdapterService,
Expand All @@ -65,8 +67,8 @@ export abstract class BaseAssetLinksDirective {
getAllResources() {
zip(
this.pipelineService.getPipelines(),
this.dataViewService.getAllWidgets(),
this.dataViewService.getDataViews(),
this.chartService.getAllCharts(),
this.dashboardService.getDashboards(),
this.pipelineElementService.getDataStreams(),
this.dataLakeService.getAllMeasurementSeries(),
this.filesService.getFileMetadata(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import { Component, Input } from '@angular/core';
import {
AssetManagementService,
DataViewDataExplorerService,
SpAssetModel,
} from '@streampipes/platform-services';
import { DialogRef } from '@streampipes/shared-ui';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import {
AdapterService,
AssetLink,
AssetLinkType,
ChartService,
DashboardService,
DatalakeRestService,
DataViewDataExplorerService,
FilesService,
GenericStorageService,
PipelineService,
PipelineElementService,
FilesService,
PipelineService,
} from '@streampipes/platform-services';
import { UntypedFormGroup } from '@angular/forms';
import { MatSelectChange } from '@angular/material/select';
Expand Down Expand Up @@ -63,7 +64,8 @@ export class EditAssetLinkDialogComponent
private dialogRef: DialogRef<EditAssetLinkDialogComponent>,
protected genericStorageService: GenericStorageService,
protected pipelineService: PipelineService,
protected dataViewService: DataViewDataExplorerService,
protected chartService: ChartService,
protected dashboardService: DashboardService,
protected dataLakeService: DatalakeRestService,
protected pipelineElementService: PipelineElementService,
protected adapterService: AdapterService,
Expand All @@ -72,7 +74,8 @@ export class EditAssetLinkDialogComponent
super(
genericStorageService,
pipelineService,
dataViewService,
chartService,
dashboardService,
dataLakeService,
pipelineElementService,
adapterService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import {
AdapterService,
AssetLink,
AssetLinkType,
ChartService,
DashboardService,
DatalakeRestService,
DataViewDataExplorerService,
FilesService,
GenericStorageService,
PipelineService,
PipelineElementService,
FilesService,
PipelineService,
} from '@streampipes/platform-services';
import { BaseAssetLinksDirective } from '../base-asset-links.directive';

Expand Down Expand Up @@ -58,7 +59,8 @@ export class SpManageAssetLinksDialogComponent
private dialogRef: DialogRef<SpManageAssetLinksDialogComponent>,
protected genericStorageService: GenericStorageService,
protected pipelineService: PipelineService,
protected dataViewService: DataViewDataExplorerService,
protected chartService: ChartService,
protected dashboardService: DashboardService,
protected dataLakeService: DatalakeRestService,
protected pipelineElementService: PipelineElementService,
protected adapterService: AdapterService,
Expand All @@ -67,7 +69,8 @@ export class SpManageAssetLinksDialogComponent
super(
genericStorageService,
pipelineService,
dataViewService,
chartService,
dashboardService,
dataLakeService,
pipelineElementService,
adapterService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { Component, OnInit, ViewChild } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table';
import { DataLakeConfigurationEntry } from './datalake-configuration-entry';
import {
ChartService,
DatalakeRestService,
DataViewDataExplorerService,
} from '@streampipes/platform-services';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
Expand Down Expand Up @@ -64,7 +64,7 @@ export class DatalakeConfigurationComponent implements OnInit {

constructor(
private datalakeRestService: DatalakeRestService,
private dataViewDataExplorerService: DataViewDataExplorerService,
private dataViewDataExplorerService: ChartService,
private dialogService: DialogService,
private breadcrumbService: SpBreadcrumbService,
private tabService: SpConfigurationTabsService,
Expand Down
Loading

0 comments on commit b52bcc2

Please sign in to comment.