Skip to content

Commit

Permalink
feat(#3091): Add option to configure time ordering (#3092)
Browse files Browse the repository at this point in the history
* feat(#3091): Add option to configure time ordering

* Remove deprecated model

* Fix checkstyle

* test: Add time order test + minor changes (#3113)

* added time order test + minor changes

* minor changes for e2e test

---------

Co-authored-by: Marcelfrueh <[email protected]>
  • Loading branch information
dominikriemer and Marcelfrueh authored Aug 8, 2024
1 parent 542e822 commit 6048c0d
Show file tree
Hide file tree
Showing 28 changed files with 218 additions and 141 deletions.
8 changes: 8 additions & 0 deletions ui/cypress/support/utils/datalake/DataLakeBtns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ export class DataLakeBtns {
public static refreshDataLakeMeasures() {
return cy.dataCy('refresh-data-lake-measures');
}

public static saveDataViewButton() {
return cy.dataCy('save-data-view-btn').click();
}

public static editDataViewButton(widgetName: string) {
return cy.dataCy('edit-data-view-' + widgetName).click();
}
}
14 changes: 11 additions & 3 deletions ui/cypress/support/utils/datalake/DataLakeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ export class DataLakeUtils {
.click();
}

public static clickOrderBy(order: String) {
if (order == 'ascending') {
cy.dataCy('ascending-radio-button').click();
} else {
cy.dataCy('descending-radio-button').click();
}
}

/**
* Select visualization type
*/
Expand Down Expand Up @@ -351,14 +359,14 @@ export class DataLakeUtils {

public static selectTimeRange(from: Date, to: Date) {
DataLakeUtils.openTimeSelectorMenu();
const monthsBack = Math.abs(differenceInMonths(from, new Date()));
const monthsBack = Math.abs(differenceInMonths(from, new Date())) + 1;
DataLakeUtils.navigateCalendar('previous', monthsBack);
DataLakeUtils.selectDay(from.getDay());
DataLakeUtils.selectDay(from.getDate());

const monthsForward = Math.abs(differenceInMonths(from, to));
DataLakeUtils.navigateCalendar('next', monthsForward);

DataLakeUtils.selectDay(to.getDay());
DataLakeUtils.selectDay(to.getDate());

DataLakeUtils.setTimeInput('time-selector-start-time', from);
DataLakeUtils.setTimeInput('time-selector-end-time', to);
Expand Down
74 changes: 74 additions & 0 deletions ui/cypress/tests/datalake/timeOrderDataView.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* 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 { DataLakeUtils } from '../../support/utils/datalake/DataLakeUtils';
import { DataLakeBtns } from '../../support/utils/datalake/DataLakeBtns';

describe('Test Time Order in Data Explorer', () => {
beforeEach('Setup Test', () => {
cy.initStreamPipesTest();
DataLakeUtils.loadDataIntoDataLake('datalake/sample.csv', false);
DataLakeUtils.goToDatalake();
DataLakeUtils.createAndEditDataView('TestView');
});

it('Perform Test with ascending and descending order', () => {
const startDate = new Date(1653871499055);
const endDate = new Date(1653871608093);

DataLakeUtils.clickOrderBy('descending');

DataLakeUtils.openVisualizationConfig();
DataLakeUtils.selectVisualizationType('Table');
DataLakeUtils.selectTimeRange(startDate, endDate);
cy.wait(1000);

cy.dataCy('data-explorer-table').then($cells => {
const strings = $cells.map((index, cell) => cell.innerText).get();

// Check for date strings if order is descending
const dateStrings = strings.filter((_, index) => index % 4 === 0);
const dates = dateStrings.map(dateStr => new Date(dateStr));
const timestamps = dates.map(date => date.getTime());
for (let i = 0; i < timestamps.length - 1; i++) {
expect(timestamps[i]).to.be.at.least(timestamps[i + 1]);
}
});

// Save and leave view, edit view again and check ascending order
DataLakeBtns.saveDataViewButton();
DataLakeBtns.editDataViewButton('NewWidget');
DataLakeUtils.clickOrderBy('ascending');
DataLakeUtils.openVisualizationConfig();
DataLakeUtils.selectVisualizationType('Table');
DataLakeUtils.selectTimeRange(startDate, endDate);
cy.wait(1000);

cy.dataCy('data-explorer-table').then($cells => {
const strings = $cells.map((index, cell) => cell.innerText).get();

// Check for date strings if order is ascending
const dateStrings = strings.filter((_, index) => index % 4 === 0);
const dates = dateStrings.map(dateStr => new Date(dateStr));
const timestamps = dates.map(date => date.getTime());
for (let i = 0; i < timestamps.length - 1; i++) {
expect(timestamps[i]).to.be.at.most(timestamps[i + 1]);
}
});
});
});
4 changes: 2 additions & 2 deletions ui/cypress/tests/datalake/timeRangeSelectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Test Time Range Selectors in Data Explorer', () => {
isTimeWithinTolerance(
actualTime as string,
expectedDate,
3,
5,
),
).to.be.true;
});
Expand All @@ -92,7 +92,7 @@ describe('Test Time Range Selectors in Data Explorer', () => {
isTimeWithinTolerance(
actualTime as string,
expectedDate,
3,
5,
),
).to.be.true;
});
Expand Down
4 changes: 2 additions & 2 deletions ui/cypress/tests/datalake/widgets/timeSeriesSave.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ describe('Test if widget configuration is updated correctly', () => {

// Create first test data view with one time series widget
DataLakeUtils.addDataViewAndTimeSeriesWidget(testView1, dataSet);
DataLakeUtils.saveDataExplorerWidgetConfiguration();
DataLakeUtils.saveDataViewConfiguration();

// Create second test data view with one time series widget
DataLakeUtils.addDataViewAndTimeSeriesWidget(testView2, dataSet);
DataLakeUtils.saveDataExplorerWidgetConfiguration();
DataLakeUtils.saveDataViewConfiguration();
});

// This test case has two different options. The first one selects the edit button of the data explorer on the top right
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import {
DataLakeMeasure,
PageResult,
SpQueryResult,
} from '../model/gen/streampipes-model';
import { DataLakeMeasure, SpQueryResult } from '../model/gen/streampipes-model';
import { map } from 'rxjs/operators';
import { DatalakeQueryParameters } from '../model/datalake/DatalakeQueryParameters';

Expand Down Expand Up @@ -103,32 +99,6 @@ export class DatalakeRestService {
}
}

getPagedData(
index: string,
itemsPerPage: number,
page: number,
columns?: string,
order?: string,
): Observable<PageResult> {
const url = this.dataLakeUrl + '/measurements/' + index;

const queryParams: DatalakeQueryParameters = this.getQueryParameters(
columns,
undefined,
undefined,
page,
itemsPerPage,
undefined,
undefined,
order,
undefined,
undefined,
);

// @ts-ignore
return this.http.get<PageResult>(url, { params: queryParams });
}

getTagValues(
index: string,
fieldNames: string[],
Expand Down Expand Up @@ -237,6 +207,7 @@ export class DatalakeRestService {
if (endDate) {
queryParams.endDate = endDate;
}

if (page) {
queryParams.page = page;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@
*ngComponentOutlet="
extendedAppearanceConfigComponent;
inputs: {
appearanceConfig:
currentlyConfiguredWidget.baseAppearanceConfig,
widgetId: widgetId
appearanceConfig: currentlyConfiguredWidget.baseAppearanceConfig
}
"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export class DataExplorerWidgetAppearanceSettingsComponent
implements OnInit, OnDestroy
{
@Input() currentlyConfiguredWidget: DataExplorerWidgetModel;
@Input() widgetId: string;

presetColors: string[] = [
'#39B54A',
Expand Down Expand Up @@ -81,7 +80,6 @@ export class DataExplorerWidgetAppearanceSettingsComponent

triggerViewUpdate() {
this.widgetConfigurationService.notify({
widgetId: this.widgetId,
refreshView: true,
refreshData: false,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
<sp-data-explorer-widget-appearance-settings
fxFlex="100"
fxLayout="column"
[widgetId]="currentlyConfiguredWidget.elementId"
[currentlyConfiguredWidget]="
currentlyConfiguredWidget
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,19 @@
<sp-field-selection-panel
#fieldSelectionPanel
[sourceConfig]="sourceConfig"
[widgetId]="widgetId"
></sp-field-selection-panel>

<sp-filter-selection-panel
[sourceConfig]="sourceConfig"
[widgetId]="widgetId"
></sp-filter-selection-panel>

<sp-group-selection-panel
#groupSelectionPanel
[sourceConfig]="sourceConfig"
[widgetId]="widgetId"
></sp-group-selection-panel>

<sp-order-selection-panel [sourceConfig]="sourceConfig">
</sp-order-selection-panel>
</div>
</div>
</mat-expansion-panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ export class DataExplorerWidgetDataSettingsComponent implements OnInit {

triggerDataRefresh() {
this.widgetConfigService.notify({
widgetId: this.widgetId,
refreshData: true,
refreshView: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export class FieldSelectionPanelComponent implements OnInit {
MAX_INITIAL_FIELDS = 3;

@Input() sourceConfig: SourceConfig;
@Input() widgetId: string;

expandFields = false;

Expand Down Expand Up @@ -97,7 +96,6 @@ export class FieldSelectionPanelComponent implements OnInit {
field => (field.selected = selected),
);
this.widgetConfigService.notify({
widgetId: this.widgetId,
refreshData: true,
refreshView: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { WidgetConfigurationService } from '../../../../../services/widget-confi
export class FieldSelectionComponent implements OnInit {
@Input() field: FieldConfig;
@Input() sourceConfig: SourceConfig;
@Input() widgetId: string;

@Output() addFieldEmitter: EventEmitter<EventPropertyUnion> =
new EventEmitter<EventPropertyUnion>();
Expand All @@ -47,7 +46,6 @@ export class FieldSelectionComponent implements OnInit {

triggerConfigurationUpdate() {
this.widgetConfigService.notify({
widgetId: this.widgetId,
refreshData: true,
refreshView: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ import { DataExplorerFieldProviderService } from '../../../../../services/data-e
@Component({
selector: 'sp-filter-selection-panel',
templateUrl: './filter-selection-panel.component.html',
styleUrls: ['./filter-selection-panel.component.scss'],
})
export class FilterSelectionPanelComponent implements OnInit {
@Input() sourceConfig: SourceConfig;
@Input() widgetId: string;

tagValues: Map<string, string[]> = new Map<string, string[]>();

Expand Down Expand Up @@ -84,7 +82,6 @@ export class FilterSelectionPanelComponent implements OnInit {
};
this.sourceConfig.queryConfig.selectedFilters.push(newFilter);
this.widgetConfigService.notify({
widgetId: this.widgetId,
refreshData: true,
refreshView: true,
});
Expand All @@ -95,7 +92,6 @@ export class FilterSelectionPanelComponent implements OnInit {
sourceConfig.queryConfig.selectedFilters.splice(index, 1);

this.widgetConfigService.notify({
widgetId: this.widgetId,
refreshData: true,
refreshView: true,
});
Expand All @@ -112,7 +108,6 @@ export class FilterSelectionPanelComponent implements OnInit {

if (update) {
this.widgetConfigService.notify({
widgetId: this.widgetId,
refreshData: true,
refreshView: true,
});
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ import {
@Component({
selector: 'sp-group-selection-panel',
templateUrl: './group-selection-panel.component.html',
styleUrls: ['./group-selection-panel.component.scss'],
})
export class GroupSelectionPanelComponent implements OnInit {
@Input() sourceConfig: SourceConfig;
@Input() widgetId: string;

constructor(
private fieldProvider: DataExplorerFieldProviderService,
Expand Down Expand Up @@ -75,7 +73,6 @@ export class GroupSelectionPanelComponent implements OnInit {
field => (field.selected = selected),
);
this.widgetConfigService.notify({
widgetId: this.widgetId,
refreshData: true,
refreshView: true,
});
Expand All @@ -92,7 +89,6 @@ export class GroupSelectionPanelComponent implements OnInit {

triggerConfigurationUpdate() {
this.widgetConfigService.notify({
widgetId: this.widgetId,
refreshData: true,
refreshView: true,
});
Expand Down
Loading

0 comments on commit 6048c0d

Please sign in to comment.