Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
95b21b5
In package.json changed version of app from "0.1-SNAPSHOT" to "0.0.1"…
apspestana Feb 7, 2022
ea17190
Added info to the "get started" section of README.md to make it easie…
apspestana Feb 7, 2022
20a13e6
Added info to the "developer guide" section of README.md.
apspestana Feb 7, 2022
3f325aa
Did changes so that all files pass linting (command "ng lint").
apspestana Feb 8, 2022
2751d19
Updated version of dependencies @babel/core, @babel/preset-env, @babe…
apspestana Feb 8, 2022
80e5939
Changed environment.prod.ts to make it safer for the deployment scrip…
apspestana Feb 8, 2022
dd87d96
Added the components for service library, also added the routes and c…
scdsilva Mar 25, 2022
31783ef
Added missing imports
scdsilva Mar 28, 2022
b327b78
Added user systems by parameters, added applications request to use o…
scdsilva Mar 30, 2022
98e381d
Added service attributes, imported Bootstrap (v5) and added form elem…
scdsilva Mar 30, 2022
65e1f22
Added a few methods to switch fields showing, based on the selected t…
scdsilva Mar 30, 2022
8b00aae
Added call to invariants list for type and method, on service create/…
scdsilva Apr 4, 2022
a9595a2
Create service - first stable version. Added dynamic tables, dependen…
scdsilva Apr 5, 2022
d622e90
Added drag and drop file.
scdsilva Apr 6, 2022
452d127
Added request to get service, prearing for edit functionality. Remove…
scdsilva Apr 7, 2022
2f5f28b
Adjustments to model, to fit the names received. Permission check for…
scdsilva Apr 7, 2022
a6cec28
Permissions to edit, create, duplicate actions
scdsilva Apr 11, 2022
6685d10
Duplicate mode and some refactoring
scdsilva Apr 12, 2022
0ae8730
Added user preferences to get datatables configurations. Added load, …
scdsilva Apr 14, 2022
34a39f4
Modifications to user preferences
scdsilva Apr 18, 2022
ef128a7
Added a new preference for services datatable, on a new format
scdsilva Apr 18, 2022
00f4a16
Changes on Preferences for datatable
scdsilva Apr 20, 2022
abee137
Merge branch 'service-library-migration'
scdsilva Apr 20, 2022
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
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,38 @@ Brand new Cerberus front-end implementation

# get started

## dev environment

Current codebase is being developed with the following tools:

- node 14.16.1 (`node -v`)
- npm 6.14.12 (`npm -v`)
- Angular 8.2.0 (`ng version`)
- Typescript 3.5.3 (`tsc -v`)

For Linux and macOS, you can use [nvm](https://github.com/nvm-sh/nvm) to install and use different versions of node through the command line (npm is included in node). For Windows, you can use [nvm-windows](https://github.com/coreybutler/nvm-windows).

To install Angular 8.2.0, run:

- `npm install -g @angular/cli@8.2.0`
- `npm install -g @angular-devkit/build-angular@0.803.24`
- `npm install -g @angular/compiler-cli@8.2.0`
- `npm install -g @angular/language-service@8.2.0`
- `npm install -g @angular/compiler@8.2.0`

To install Typescript 3.5.3, run:

-`npm install -g typescript@3.5.3`

## run

After your dev environment is all set up (see previous section), just do:

- `npm install`
- `ng serve`

If after running `ng serve` you get the error "You seem to not be depending on "@angular/core" and/or "rxjs". This is an error.", run `npm link` and try again.

# installation guide

This application is secured by keycloak (https://www.keycloak.org).
Expand Down Expand Up @@ -48,7 +77,14 @@ The application is configured by default to work with `cerberus-angular` keycloa
- Web Origins : add "+"

# developer guide
As soon as you have access to the repository, please make sure before any push :

## application architecture

Configurations by environment are here: [src/environments](src/environments)

## contributing

Contributions to the source code are welcome. Before submitting your contribution, please make sure that:
- `ng lint` returns no error
- `ng build --prod` runs flawlessly

Expand Down
21,521 changes: 8,932 additions & 12,589 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cerberus-front",
"version": "0.1-SNAPSHOT",
"version": "0.0.1",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0",
Expand Down Expand Up @@ -91,10 +91,10 @@
"@angular/cli": "^8.2.0",
"@angular/compiler-cli": "^8.2.0",
"@angular/language-service": "^8.2.0",
"@babel/core": "^7.4.0",
"@babel/preset-env": "^7.4.1",
"@babel/register": "^7.4.0",
"@babel/compat-data": "~7.8.0",
"@babel/core": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/register": "^7.17.0",
"@babel/compat-data": "~7.17.0",
"@types/jasmine": "^2.8.16",
"@types/jasminewd2": "~2.0.3",
"@types/jquery": "^3.3.29",
Expand Down
6 changes: 6 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { CoreModule } from './core/core.module';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { SessionInterceptorService } from './core/services/auth/session.interceptor.service';
import { DesignModule } from './feat-design/design.module';
import { ConfigureModule } from './feat-configure/configure.module';
import { AnalyseModule } from './feat-analyse/analyse.module';
import { RunModule } from './feat-run/run.module';
import { CKEditorModule } from '@ckeditor/ckeditor5-angular';
import { MonacoEditorModule } from 'ngx-monaco-editor';

Expand All @@ -26,6 +29,9 @@ import { MonacoEditorModule } from 'ngx-monaco-editor';
SharedModule,
BrowserAnimationsModule,
DesignModule,
ConfigureModule,
AnalyseModule,
RunModule,
CKEditorModule,
MonacoEditorModule.forRoot()
],
Expand Down
42 changes: 24 additions & 18 deletions src/app/core/services/api/filter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ export class FilterService {
* @params pageInformation : information on the current page
* @params globalSearch : quick search keyword
*/
// TODO : pass the systems as an input
generateQueryStringParameters(
columnList: Array<Column>,
pageInformation: { size: number, sort: any, number: number, totalCount: number },
globalSearch: string
globalSearch: string,
userSystems?: string[]
): string {

let queryParameter = '';
const formData = {};
const columnListWithActiveFilter = columnList.filter(e => e.sSearch)
Expand Down Expand Up @@ -95,21 +96,8 @@ export class FilterService {
if (columnListWithActiveFilter[column].type === 'label') {
formData['sSearch_' + column] = (columnListWithActiveFilter[column].sSearch) ? columnListWithActiveFilter[column].sSearch.map(a => a.label).join(',') : ''; // value(s) to filter (only label)
} else if (columnListWithActiveFilter[column].contentName === 'system') {
const systemByService = this.getSystemInRawFormat(userSystems);
const systemByFilter = ((columnListWithActiveFilter[column].sSearch.length !== 0) ? columnListWithActiveFilter[column].sSearch.join(',') : '');
let systemByService;
if (this.userService.user.defaultSystem) {
const systemByFilterRaw = new Array<String>();
if (this.userService.user.defaultSystem.length !== 0) {
this.userService.user.defaultSystem.forEach(system => {
systemByFilterRaw.push(system);
});
systemByService = ',' + systemByFilterRaw.join(',');
} else {
systemByService = ''; // prevent sending 'undefined' if no system are selected
}
} else {
systemByService = '';
}
formData['sSearch_' + column] = systemByFilter + ((systemByFilter !== '' && systemByService !== '') ? ',' : '') + systemByService; // value(s) to filter
} else {
if (columnListWithActiveFilter[column].filterMode === 'SEARCH_FIELD') {
Expand All @@ -128,6 +116,10 @@ export class FilterService {
formData['sLike'] = columnListWithActiveFilter.filter(c => c.filterMode === 'SEARCH_FIELD').map(column => column.apiName).join(','); // databaseName of like filters
}

if(userSystems){
formData['system'] = this.getSystemInRawFormat(userSystems);
}

// encode the whole formData content
for (const item in formData) { if (item) { queryParameter += encodeURIComponent(item) + '=' + encodeURIComponent(formData[item]) + '&'; } }

Expand All @@ -146,9 +138,9 @@ export class FilterService {
if (response) {
if (servlet === '/ReadTest') {
// formatting test folders, waiting for: https://github.com/cerberustesting/cerberus-source/issues/2104
callback(this.globalService.formatTestFolderList(response.contentTable), response.iTotalRecords);
callback(this.globalService.formatTestFolderList(response.contentTable), response.iTotalRecords, response.hasPermissions);
} else {
callback(response.contentTable, response.iTotalRecords);
callback(response.contentTable, response.iTotalRecords, response.hasPermissions);
}
}
});
Expand All @@ -170,4 +162,18 @@ export class FilterService {
this.refreshContentEvent.emit(null);
}

// get user default systems
private getSystemInRawFormat(userSystems: string[]) {

if (userSystems && userSystems.length !== 0) {
let systemByFilterRaw = new Array<String>();
userSystems.forEach(system => {
systemByFilterRaw.push(system);
});
return systemByFilterRaw.join(',');
}
return '';
}

}

30 changes: 30 additions & 0 deletions src/app/core/services/api/invariants.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class InvariantsService {
systemsList: Array<any>;
environmentsList: Array<Invariant>;
appService: Array<any>;
serviceTypeList: Array<Invariant>;
serviceMethodList: Array<Invariant>;
serviceContentActList: Array<Invariant>;

// observables
observableCountriesList = new BehaviorSubject<Invariant[]>(this.countriesList);
Expand All @@ -54,6 +57,9 @@ export class InvariantsService {
observablePropertyNatureList = new BehaviorSubject<Invariant[]>(this.propertyNatureList);
observablePropertyDatabaseList = new BehaviorSubject<Invariant[]>(this.propertyDatabaseList);
observableAppService = new BehaviorSubject<any[]>(this.propertyDatabaseList);
observableServiceTypeList = new BehaviorSubject<Invariant[]>(this.serviceTypeList);
observableServiceMethodList = new BehaviorSubject<any[]>(this.serviceMethodList);
observableServiceContentActList = new BehaviorSubject<any[]>(this.serviceContentActList);

constructor(private http: HttpClient, private Notification: NotificationService) {
this.USERGROUP_list = undefined;
Expand Down Expand Up @@ -191,6 +197,30 @@ export class InvariantsService {
this.appService = response.contentTable;
this.observableAppService.next(this.appService);
}, (err) => this.Notification.createANotification(err, NotificationStyle.Error));
}

getServiceTypeList(): void {
this.http.get<Invariant[]>(environment.cerberus_api_url + '/FindInvariantByID?idName=SRVTYPE')
.subscribe(response => {
this.serviceTypeList = response;
this.observableServiceTypeList.next(this.serviceTypeList);
}, (err) => this.Notification.createANotification(err, NotificationStyle.Error));
}

getServiceMethodList(): void {
this.http.get<Invariant[]>(environment.cerberus_api_url + '/FindInvariantByID?idName=SRVMETHOD')
.subscribe(response => {
this.serviceMethodList = response;
this.observableServiceMethodList.next(this.serviceMethodList);
}, (err) => this.Notification.createANotification(err, NotificationStyle.Error));
}

getServiceContentActList(): void {
this.http.get<Invariant[]>(environment.cerberus_api_url + '/FindInvariantByID?idName=APPSERVICECONTENTACT')
.subscribe(response => {
this.serviceContentActList = response;
this.observableServiceContentActList.next(this.serviceContentActList);
}, (err) => this.Notification.createANotification(err, NotificationStyle.Error));
}

// new method to implement
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TestBed, inject } from '@angular/core/testing';

import { ServiceLibraryService } from './servicelibrary.service';

describe('ServiceLibraryService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [ServiceLibraryService]
});
});

it('should be created', inject([ServiceLibraryService], (service: ServiceLibraryService) => {
expect(service).toBeTruthy();
}));
});
131 changes: 131 additions & 0 deletions src/app/core/services/api/servicelibrary/servicelibrary.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { BehaviorSubject } from 'rxjs';
import { Service } from 'src/app/shared/model/back/servicelibrary/servicelibrary.model';
import { environment } from 'src/environments/environment';
import { GlobalService } from '../../utils/global.service';

@Injectable({
providedIn: 'root'
})
export class ServiceLibraryService {

/** list of service libraries */
public serviceList: Array<Service> = null;

/** observable for the service list */
public observableServiceList = new BehaviorSubject<Service[]>(this.serviceList);

constructor(
private http: HttpClient,
private globalService: GlobalService
) { }

/**
* refresh the service list
* @param system (optional) name of a system to filter on
*/
refreshServiceLibrary(system?: string): void {
let url = environment.cerberus_api_url + '/ReadAppService';
// if a system is passed, use it 4 filtering
if (system) { url += '?system=' + system; }
this.http.get<Service[]>(url)
.subscribe(response => {
if (response) {
// @ts-ignore
this.serviceList = response.contentTable;
this.observableServiceList.next(this.serviceList);
}
});
}

/**
* get the list of services from the API
* @param callback function to use to process the result
*/
getServices(callback: (services: Service[]) => void, system?: string): void {
let url = environment.cerberus_api_url + '/ReadAppService';
if (system) { url += '?system=' + system; }
this.http.get<Array<Service>>(url)
.toPromise()
.then((result: any) => {
callback(result.contentTable);
});
}
/**
* get the service from the API
* @param callback function to use to process the result
*/
getService(serviceName: string, callback: (service: Service) => void): void {
let url = environment.cerberus_api_url + '/ReadAppService';
this.http.post<any>(url, "service="+encodeURIComponent(serviceName), environment.httpOptions)
.subscribe(response => {
callback(response.contentTable);
});
}

/**
* create a service
* @param service the service object to create
*/
createService(service: Service, callback: (response: any) => void): void {

// set the url to post
const url = environment.cerberus_api_url + '/CreateAppService';

// build the data to post
let formData = this.globalService.toFormData(service);
formData.set("contentList", JSON.stringify(service.contentList));
formData.set("headerList", JSON.stringify(service.headerList));
// formData.append("srvRequest", encodeURIComponent(editor.getSession().getDocument().getValue()));

if (service.file && service.file.size > 0) {
formData.append("file", service.file);
}

this.http.post<any>(url, formData).subscribe(response => {
callback(response);
});
}

/**
* update the content of a service
* @param service the service object to update
*/
updateService(service: Service, callback: (response: any) => void): void {

// set the url to post
const url = environment.cerberus_api_url + '/UpdateAppService';

// build the data to post
let formData = this.globalService.toFormData(service);
formData.set("contentList", JSON.stringify(service.contentList));
formData.set("headerList", JSON.stringify(service.headerList));

if (service.file && service.file.size > 0) {
formData.append("file", service.file);
}

this.http.post<any>(url, formData).subscribe(response => {
callback(response);
});
}

/**
* remove a service
* @param servicethe name of the service to remove
*/
deleteService(service: Service, callback: (response: any) => void): void {

// set the url to post
const url = environment.cerberus_api_url + '/DeleteAppService';

// build the data to post
const formData = this.globalService.toQueryString(service, ['service']);

this.http.post<any>(url, formData, environment.httpOptions).subscribe(response => {
callback(response);
});
}

}
4 changes: 2 additions & 2 deletions src/app/core/services/api/test/test.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class TestService {
const url = environment.cerberus_api_url + '/CreateTest';

// build the data to post
let formData = this.globalService.toQueryString(testfolder, ['test', 'isActive', 'description']);
const formData = this.globalService.toQueryString(testfolder, ['test', 'isActive', 'description']);

this.http.post<any>(url, formData, environment.httpOptions).subscribe(response => {
callback(response);
Expand Down Expand Up @@ -103,7 +103,7 @@ export class TestService {
const url = environment.cerberus_api_url + '/DeleteTest';

// build the data to post
let formData = this.globalService.toQueryString(testfolder, ['test']);
const formData = this.globalService.toQueryString(testfolder, ['test']);

this.http.post<any>(url, formData, environment.httpOptions).subscribe(response => {
callback(response);
Expand Down
Loading