Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix input of standalone dashboard component (#1547) #1569

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ui/cypress/support/utils/DashboardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ export class DashboardUtils {
cy.dataCy('show-dashboard-' + dashboardName).click();
}

public static showStandaloneDashboard(dashboardName: string) {
cy.dataCy('show-dashboard-' + dashboardName).click();
cy.location('href').then(url => {
const dashboardId = url.substring(url.lastIndexOf('/') + 1);
cy.visit(`#/standalone/${dashboardId}`);
cy.wait(2000);
});
}

public static addAndEditDashboard(dashboardName: string) {
cy.dataCy('new-dashboard-btn').click();
cy.dataCy('dashboard-name-input').type(dashboardName);
Expand Down
46 changes: 46 additions & 0 deletions ui/cypress/tests/dashboard/standaloneDashboardTest.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
import { DashboardUtils } from '../../support/utils/DashboardUtils';

describe('Test live dashboard in standalone mode', () => {
beforeEach('Setup Test', () => {
cy.initStreamPipesTest();
ConnectUtils.addMachineDataSimulator('simulator', true);
});

it('Perform Test', () => {
DashboardUtils.goToDashboard();

// Add new dashboard
const dashboardName = 'testDashboard';
DashboardUtils.addAndEditDashboard(dashboardName);

DashboardUtils.addWidget('Persist_simulator', 'raw');

cy.wait(1000);

DashboardUtils.goToDashboard();

DashboardUtils.showStandaloneDashboard(dashboardName);

// Validate that data is coming (at least 3 events)
DashboardUtils.validateRawWidgetEvents(3);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<sp-dashboard-grid
[editMode]="false"
[dashboard]="dashboard"
[allMeasurements]="allMeasurements"
class="h-100"
*ngIf="dashboardReady"
></sp-dashboard-grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
*/

import { Component, OnInit } from '@angular/core';
import { Dashboard, DashboardService } from '@streampipes/platform-services';
import {
Dashboard,
DashboardService,
DataLakeMeasure,
DatalakeRestService,
} from '@streampipes/platform-services';
import { ActivatedRoute } from '@angular/router';
import { zip } from 'rxjs';

@Component({
templateUrl: './standalone-dashboard.component.html',
Expand All @@ -27,21 +33,26 @@ export class StandaloneDashboardComponent implements OnInit {
dashboard: Dashboard;
dashboardReady = false;

allMeasurements: DataLakeMeasure[] = [];

constructor(
private activatedRoute: ActivatedRoute,
private dashboardService: DashboardService,
private datalakeRestService: DatalakeRestService,
) {}

ngOnInit(): void {
this.activatedRoute.params.subscribe(params => {
if (params['dashboardId']) {
const dashboardId = params['dashboardId'];
this.dashboardService
.getDashboard(dashboardId)
.subscribe(dashboard => {
this.dashboard = dashboard;
this.dashboardReady = true;
});
zip([
this.datalakeRestService.getAllMeasurementSeries(),
this.dashboardService.getDashboard(dashboardId),
]).subscribe(res => {
this.allMeasurements = res[0];
this.dashboard = res[1];
this.dashboardReady = true;
});
}
});
}
Expand Down