Skip to content

Commit

Permalink
frontend: make url for vdk ui lib configurable (#3421)
Browse files Browse the repository at this point in the history
VDK UI lib to consume pipelines control service url from app
configuration dependency injection.

---------

Signed-off-by: Goran Kokinovski <[email protected]>
  • Loading branch information
gorankokin committed Sep 18, 2024
1 parent 73d6576 commit faa6e3d
Show file tree
Hide file tree
Showing 24 changed files with 392 additions and 115 deletions.
9 changes: 6 additions & 3 deletions projects/frontend/cicd/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ frontend-data-pipelines-release:
- projects/frontend/data-pipelines/gui/package-lock.json
expire_in: 1 week

frontend_publish_ui_image:
# comment out, not relevant because there is no operational environment
.frontend_publish_ui_image:
extends: .images:dind:docker-push-to-vdk-repos
stage: pre_release_image
script:
Expand All @@ -120,7 +121,8 @@ frontend_publish_ui_image:
- if: '$CI_COMMIT_BRANCH == "main"'
changes: *frontend_data_pipelines_locations

frontend_tag_ui_image_stable:
# comment out, not relevant because there is no operational environment
.frontend_tag_ui_image_stable:
stage: release_image
before_script:
- cd projects/frontend
Expand Down Expand Up @@ -211,7 +213,8 @@ frontend_tag_ui_image_stable:
# - if: '$CI_COMMIT_BRANCH == "main"'
# changes: *frontend_data_pipelines_locations

frontend_publish_test_image:
# comment out, not relevant because there is no operational environment
.frontend_publish_test_image:
stage: release_image
script:
- docker login --username "${VDK_DOCKER_REGISTRY_USERNAME}" --password "${VDK_DOCKER_REGISTRY_PASSWORD}" "${VDK_DOCKER_REGISTRY_URL}"
Expand Down
2 changes: 1 addition & 1 deletion projects/frontend/data-pipelines/gui/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.12.0
16.15.0
12 changes: 6 additions & 6 deletions projects/frontend/data-pipelines/gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "data-pipelines-wrapper",
"version": "0.0.0",
"engines": {
"node": "^14.15.0 || >=18.12.0",
"npm": ">=9.7.2"
"node": "^14.15.0 || >=16.10.0",
"npm": ">=8.5.5"
},
"private": true,
"scripts": {
Expand Down Expand Up @@ -48,7 +48,7 @@
"@ngrx/store": "13.2.0",
"@swimlane/ngx-charts": "16.0.0",
"@swimlane/ngx-graph": "8.0.0",
"@versatiledatakit/shared": ">=0.0.0",
"@versatiledatakit/shared": "1.1.926473229",
"@webcomponents/custom-elements": "1.5.0",
"@yellowspot/ng-truncate": "2.0.1",
"angular-ng-autocomplete": "2.0.8",
Expand All @@ -66,14 +66,14 @@
"dompurify": "2.3.8",
"elasticlunr": "0.9.5",
"file-saver": "2.0.5",
"graphql": "16.8.1",
"graphql": "16.5.0",
"html-element": "2.3.1",
"html-frontmatter": "1.6.1",
"js-sha256": "0.9.0",
"lodash": "4.17.21",
"lottie-web": "5.9.4",
"lz-string": "1.4.4",
"moment": "2.29.4",
"moment": "2.29.3",
"ng2-date-picker": "12.0.4",
"ngx-clipboard": "15.1.0",
"ngx-cookie-service": "13.2.1",
Expand All @@ -84,7 +84,7 @@
"striptags": "3.2.0",
"superagent": "5.3.1",
"tslib": "2.3.1",
"ua-parser-js": "1.0.33",
"ua-parser-js": "1.0.2",
"zone.js": "0.11.5"
},
"optionalDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@versatiledatakit/data-pipelines",
"version": "0.0.0",
"engines": {
"node": "^14.15.0 || >=18.12.0",
"npm": ">=9.7.2"
"node": "^14.15.0 || >=16.10.0",
"npm": ">=8.5.5"
},
"license": "Apache-2.0",
"peerDependencies": {
Expand All @@ -28,7 +28,7 @@
"@ngrx/store": "~13.2.0",
"@swimlane/ngx-charts": "~16.0.0",
"@swimlane/ngx-graph": "~8.0.0",
"@versatiledatakit/shared": ">=0.0.0",
"@versatiledatakit/shared": "~1.1.926473229",
"@webcomponents/custom-elements": "~1.5.0",
"@yellowspot/ng-truncate": "~2.0.1",
"angular-ng-autocomplete": "~2.0.8",
Expand All @@ -53,7 +53,7 @@
"lodash": "~4.17.21",
"lottie-web": "~5.9.4",
"lz-string": "~1.4.4",
"moment": "~2.29.4",
"moment": "~2.29.3",
"ng2-date-picker": "~12.0.4",
"ngx-clipboard": "~15.1.0",
"ngx-cookie-service": "~13.2.1",
Expand All @@ -63,7 +63,7 @@
"rxjs": "~7.5.5",
"striptags": "~3.2.0",
"superagent": "~5.3.1",
"ua-parser-js": "~1.0.33",
"ua-parser-js": "~1.0.2",
"zone.js": "~0.11.5"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright 2023-2024 Broadcom
* SPDX-License-Identifier: Apache-2.0
*/

import { DatePipe } from '@angular/common';

import { TestBed } from '@angular/core/testing';

import { DATA_PIPELINES_DATE_TIME_FORMAT } from '../../../../../../../model';

import { GridDataJobExecution } from '../../../model';

import { ExecutionDateComparator } from './execution-date.comparator';

describe('ExecutionDateComparator', () => {
let datePipe: DatePipe;
let dataJobExecutions: GridDataJobExecution[];

beforeEach(() => {
TestBed.configureTestingModule({
providers: [DatePipe]
});

datePipe = TestBed.inject(DatePipe);

const aStartTime = new Date();
const bStartTime = new Date(aStartTime.getTime() + 100);
const aEndTime = new Date();
const bEndTime = new Date(aEndTime.getTime() + 110);

dataJobExecutions = [
{
id: 'aJob',
startTimeFormatted: datePipe.transform(aStartTime, DATA_PIPELINES_DATE_TIME_FORMAT),
startTime: aStartTime.toISOString(),
endTimeFormatted: datePipe.transform(aEndTime, DATA_PIPELINES_DATE_TIME_FORMAT),
endTime: aEndTime.toISOString(),
duration: '100',
jobVersion: ''
},
{
id: 'bJob',
startTimeFormatted: datePipe.transform(bStartTime, DATA_PIPELINES_DATE_TIME_FORMAT),
startTime: bStartTime.toISOString(),
endTimeFormatted: datePipe.transform(bEndTime, DATA_PIPELINES_DATE_TIME_FORMAT),
endTime: bEndTime.toISOString(),
duration: '110',
jobVersion: ''
}
];
});

describe('Properties::', () => {
describe('|property|', () => {
it('should verify value', () => {
// Given
const instance = new ExecutionDateComparator('endTime', 'ASC');

// Then
expect(instance.property).toEqual('endTime');
});
});

describe('|direction|', () => {
it('should verify value', () => {
// Given
const instance = new ExecutionDateComparator('startTime', 'ASC');

// Then
expect(instance.direction).toEqual('ASC');
});
});
});

describe('Methods::', () => {
describe('|compare|', () => {
it('should verify will return -100 because of ascending sort', () => {
// Given
const instance = new ExecutionDateComparator('startTime', 'ASC');

// When
const res = instance.compare(dataJobExecutions[0], dataJobExecutions[1]);

// Then
expect(res).toEqual(-100);
});

it('should verify will return 110 because of descending sort', () => {
// Given
const instance = new ExecutionDateComparator('endTime', 'DESC');

// When
const res = instance.compare(dataJobExecutions[0], dataJobExecutions[1]);

// Then
expect(res).toEqual(110);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2023-2024 Broadcom
* SPDX-License-Identifier: Apache-2.0
*/

import { get } from 'lodash';

import { Comparator } from '@versatiledatakit/shared';

import { GridDataJobExecution } from '../../../model/data-job-execution';

export class ExecutionDateComparator implements Comparator<GridDataJobExecution> {
/**
* ** Property path to value from GridDataJobExecution object.
*/
public readonly property: keyof GridDataJobExecution;

/**
* ** Sort direction.
*/
public readonly direction: 'ASC' | 'DESC';

/**
* ** Constructor.
*/
constructor(property: keyof GridDataJobExecution, direction: 'ASC' | 'DESC') {
this.property = property;
this.direction = direction;
}

/**
* @inheritDoc
*/
compare(exec1: GridDataJobExecution, exec2: GridDataJobExecution): number {
const value1 = get<GridDataJobExecution, keyof GridDataJobExecution>(exec1, this.property) as string;
const value2 = get<GridDataJobExecution, keyof GridDataJobExecution>(exec2, this.property) as string;

const date1 = value1 ? Date.parse(value1) : Date.now();
const date2 = value2 ? Date.parse(value2) : Date.now();

return this.direction === 'ASC' ? date1 - date2 : date2 - date1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright 2023-2024 Broadcom
* SPDX-License-Identifier: Apache-2.0
*/

export * from './execution-date.comparator';
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
*/

export * from './default';
export * from './date';
export * from './duration';
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
} from '../model';

import { ExecutionsStatusCriteria, ExecutionsStringCriteria, ExecutionsTypeCriteria } from './criteria';
import { ExecutionDefaultComparator, ExecutionDurationComparator } from './comparators';
import { ExecutionDateComparator, ExecutionDefaultComparator, ExecutionDurationComparator } from './comparators';

/**
* ** Supported filter criteria from Executions grid.
Expand Down Expand Up @@ -449,6 +449,10 @@ export class DataJobExecutionsGridComponent implements OnChanges, OnInit, OnDest
return new ExecutionDurationComparator(sortValue === ClrDatagridSortOrder.ASC ? 'ASC' : 'DESC');
}

if (sortCriteria === 'startTime' || sortCriteria === 'endTime') {
return new ExecutionDateComparator(sortCriteria, sortValue === ClrDatagridSortOrder.ASC ? 'ASC' : 'DESC');
}

return new ExecutionDefaultComparator(sortCriteria, sortValue === ClrDatagridSortOrder.ASC ? 'ASC' : 'DESC');
}

Expand Down
Loading

0 comments on commit faa6e3d

Please sign in to comment.