Skip to content

Commit

Permalink
Merge pull request #1569 from apache/1547-standalone-dashborad-empty
Browse files Browse the repository at this point in the history
Fix input of standalone dashboard component (#1547)
  • Loading branch information
obermeier committed May 15, 2023
2 parents ca36427 + 116ed2e commit fd5d837
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 7 deletions.
9 changes: 9 additions & 0 deletions ui/cypress/support/utils/DashboardUtils.ts
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
@@ -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);
});
});
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
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

0 comments on commit fd5d837

Please sign in to comment.