Add frontend.

This commit is contained in:
Florian THIERRY
2021-07-31 12:26:51 +02:00
parent ef04d3dbea
commit c281df00c7
56 changed files with 32276 additions and 1 deletions

17
cerberus/.browserslistrc Normal file
View File

@@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support
# You can see what browsers were selected by your queries by running:
# npx browserslist
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

16
cerberus/.editorconfig Normal file
View File

@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false

46
cerberus/.gitignore vendored Normal file
View File

@@ -0,0 +1,46 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db

27
cerberus/README.md Normal file
View File

@@ -0,0 +1,27 @@
# Cerberus
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 11.2.6.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.

133
cerberus/angular.json Normal file
View File

@@ -0,0 +1,133 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"cerberus": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
},
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/cerberus",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "cerberus:build"
},
"configurations": {
"production": {
"browserTarget": "cerberus:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "cerberus:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "cerberus:serve"
},
"configurations": {
"production": {
"devServerTarget": "cerberus:serve:production"
}
}
}
}
}
},
"defaultProject": "cerberus"
}

44
cerberus/karma.conf.js Normal file
View File

@@ -0,0 +1,44 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage/cerberus'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};

30905
cerberus/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

47
cerberus/package.json Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "cerberus",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~11.2.7",
"@angular/cdk": "^11.2.13",
"@angular/common": "~11.2.7",
"@angular/compiler": "~11.2.7",
"@angular/core": "~11.2.7",
"@angular/forms": "~11.2.7",
"@angular/material": "^11.2.13",
"@angular/platform-browser": "~11.2.7",
"@angular/platform-browser-dynamic": "~11.2.7",
"@angular/router": "~11.2.7",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1102.6",
"@angular/cli": "~11.2.6",
"@angular/compiler-cli": "~11.2.7",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.1.5"
}
}

6
cerberus/proxy.conf.json Normal file
View File

@@ -0,0 +1,6 @@
{
"/api": {
"target": "http://localhost:8080",
"secure": false
}
}

View File

@@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { CreateApplicationComponent } from './applications/create-application/create-application.component';
import { UiKitComponent } from './ui-kit/ui-kit.component';
const routes: Routes = [
{path: '', component: CreateApplicationComponent}
];
@NgModule({
imports: [RouterModule.forRoot(routes, { onSameUrlNavigation: 'reload' })],
exports: [RouterModule]
})
export class AppRoutingModule { }

View File

@@ -0,0 +1 @@
<router-outlet></router-outlet>

View File

View File

@@ -0,0 +1,35 @@
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'cerberus'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('cerberus');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain('cerberus app is running!');
});
});

View File

@@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'cerberus';
}

View File

@@ -0,0 +1,33 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { UiKitComponent } from './ui-kit/ui-kit.component';
import { CreateApplicationComponent } from './applications/create-application/create-application.component';
import { SelectComponent } from './core/components/select/select.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MatIconModule} from '@angular/material/icon';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
@NgModule({
declarations: [
AppComponent,
UiKitComponent,
CreateApplicationComponent,
SelectComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MatIconModule,
FormsModule,
ReactiveFormsModule,
HttpClientModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

View File

@@ -0,0 +1,23 @@
<div class="card">
<h1>Add a new application</h1>
<form [formGroup]="form" (ngSubmit)="onSubmit()" ngNativeValidate>
<div class="row">
<input formControlName="name" placeholder="Application name" required/>
</div>
<div class="row">
<input formControlName="serviceName" placeholder="Service name" required/>
</div>
<div class="row">
<label for="service-type">Type:</label>
<select formControlName="serviceType">
<option *ngFor="let type of serviceTypes" [value]="type.value">
{{type.label}}
</option>
</select>
</div>
<div class="row action">
<button type="button" class="secondary">Cancel</button>
<button type="submit">Save</button>
</div>
</form>
</div>

View File

@@ -0,0 +1,3 @@
.card {
margin: auto;
}

View File

@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CreateApplicationComponent } from './create-application.component';
describe('CreateApplicationComponent', () => {
let component: CreateApplicationComponent;
let fixture: ComponentFixture<CreateApplicationComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ CreateApplicationComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(CreateApplicationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,43 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Application } from 'src/app/core/entities/Application';
import { ReferentialData } from 'src/app/core/entities/ReferentialData';
import { ApplicationService } from 'src/app/core/services/application.service';
import { ReferentialDataService } from 'src/app/core/services/referential-data.service';
@Component({
selector: 'app-create-application',
templateUrl: './create-application.component.html',
styleUrls: ['./create-application.component.scss']
})
export class CreateApplicationComponent implements OnInit {
form: FormGroup = this._formBuilder.group({
name: [undefined, Validators.required],
serviceName: [undefined, Validators.required],
serviceType: [undefined, Validators.required]
});
serviceTypes: ReferentialData[] = [];
constructor(
private _formBuilder: FormBuilder,
private _referentialDataService: ReferentialDataService,
private _applicationService: ApplicationService
) { }
ngOnInit(): void {
this._referentialDataService.getServiceTypes()
.then(serviceTypes => this.serviceTypes = serviceTypes)
.catch(error => console.error('An error occured while loading service types.'));
}
onSubmit(): void {
if (this.form.valid) {
const appToAdd: Application = this.form.value as Application;
this._applicationService.add(appToAdd)
.then(applicationAdded => console.log('Application added.'))
.catch(error => console.error('An error occured while adding the new application.'));
} else {
console.error('Form is invalid');
}
}
}

View File

@@ -0,0 +1,9 @@
<div class="container">
<select #select>
<option>Option 1</option>
<option>Option 2</option>
</select>
<div class="icon">
<mat-icon (click)="select.focus()">unfold_more</mat-icon>
</div>
</div>

View File

@@ -0,0 +1,39 @@
$btn-primary-background-top: #4ca4f6;
$btn-primary-background-bottom: #0073f7;
$select-icon-radius: 4px;
.container {
position: relative;
display: flex;
justify-content: center;
align-items: center;
select {
}
.icon {
position: absolute;
top: 0;
right: 0;
width: 1.5rem;
background-image: linear-gradient($btn-primary-background-top, $btn-primary-background-bottom);
color: white;
height: 23px;
top: 3px;
right: 0;
border-radius: 0 $select-icon-radius $select-icon-radius 0;
mat-icon {
font-size: 19px;
display: flex;
justify-content: center;
align-items: center;
&:hover {
cursor: default;
}
}
}
}

View File

@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SelectComponent } from './select.component';
describe('SelectComponent', () => {
let component: SelectComponent;
let fixture: ComponentFixture<SelectComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SelectComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SelectComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-select',
templateUrl: './select.component.html',
styleUrls: ['./select.component.scss']
})
export class SelectComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@@ -0,0 +1,6 @@
export interface Application {
id: string;
name: string;
serviceName: string;
serviceType: string;
}

View File

@@ -0,0 +1,4 @@
export interface ReferentialData {
value: string,
label: string
}

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ApplicationService } from './application.service';
describe('ApplicationService', () => {
let service: ApplicationService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ApplicationService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,17 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Application } from '../entities/Application';
@Injectable({
providedIn: 'root'
})
export class ApplicationService {
constructor(
private _httpClient: HttpClient
) {}
add(application: Application): Promise<Application> {
return this._httpClient.post<Application>('/api/applications', application).toPromise();
}
}

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ReferentialDataService } from './referential-data.service';
describe('ReferentialDataService', () => {
let service: ReferentialDataService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ReferentialDataService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,16 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ReferentialData } from '../entities/ReferentialData';
@Injectable({
providedIn: 'root'
})
export class ReferentialDataService {
constructor(
private _httpClient: HttpClient
) {}
getServiceTypes(): Promise<ReferentialData[]> {
return this._httpClient.get<ReferentialData[]>('/api/referentialData/serviceTypes').toPromise();
}
}

View File

@@ -0,0 +1,46 @@
<button>Test1</button>
<input type="checkbox" />
<div class="login-form card">
<div class="row">
<input type="text" placeholder="Login"/>
</div>
<div class="row">
<input type="password" placeholder="Password"/>
</div>
<div class="row action">
<button>Login</button>
</div>
</div>
<div class="card">
<div class="row">
<input type="checkbox"/>
Log out after
<input type="number" value="5"/>
minutes
</div>
<div class="row">
<input type="checkbox"/>
Require an administrator password
</div>
<div class="row">
<div class="select">
<select>
<option>Option 1</option>
<option>Option 2</option>
</select>
</div>
</div>
<div class="row">
<input type="text" class="max-width" placeholder="Rechercher"/>
</div>
<div class="row action">
<button class="help">?</button>
<div class="row">
<button class="secondary">Annuler</button>
<button>Ok</button>
</div>
</div>
</div>

View File

@@ -0,0 +1,11 @@
.login-form {
width: 15rem;
div, div input {
width: 100%;
}
div.action {
justify-content: right;
}
}

View File

@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UiKitComponent } from './ui-kit.component';
describe('UiKitComponent', () => {
let component: UiKitComponent;
let fixture: ComponentFixture<UiKitComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ UiKitComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(UiKitComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-ui-kit',
templateUrl: './ui-kit.component.html',
styleUrls: ['./ui-kit.component.scss']
})
export class UiKitComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,3 @@
export const environment = {
production: true
};

View File

@@ -0,0 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
};
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.

BIN
cerberus/src/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 948 B

16
cerberus/src/index.html Normal file
View File

@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Cerberus</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
</html>

12
cerberus/src/main.ts Normal file
View File

@@ -0,0 +1,12 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));

65
cerberus/src/polyfills.ts Normal file
View File

@@ -0,0 +1,65 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/**
* IE11 requires the following for NgClass support on SVG elements
*/
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/

156
cerberus/src/styles.scss Normal file
View File

@@ -0,0 +1,156 @@
/* You can add global styles to this file, and also import other style files */
@font-face {
font-family: helvetica;
src: url(assets/fonts/Helvetica.ttf);
}
$blue: #017aff;
$btn-primary-border: #2f8df9;
$btn-primary-background-top: #4ca4f6;
$btn-primary-background-bottom: #0073f7;
$btn-primary-active-border: #007cf8;
$btn-primary-active-background-top: #0093f8;
$btn-primary-active-background-bottom: #0064dd;
$btn-secondary-border: #c3c5c6;
$btn-secondary-background: #ffffff;
$btn-secondary-active-border: #c8c8c8;
$btn-secondary-active-background: #f0f0f0;
$font-size: 14px;
body {
font-size: $font-size;
font-family: helvetica;
}
button {
// background-color: $blue;
background-image: linear-gradient($btn-primary-background-top, $btn-primary-background-bottom);
color: white;
border: solid 1px $btn-primary-background-bottom;
display: flex;
justify-content: center;
align-items: center;
min-width: 5rem;
border-radius: .3rem;
padding: .15rem 1rem;
font-weight: 600;
margin: .2rem .5rem;
&:active {
border-color: $btn-primary-active-border;
background-image: linear-gradient($btn-primary-active-background-top, $btn-primary-active-background-bottom);
}
&.secondary {
background-image: none;
background-color: $btn-secondary-background;
border-color: $btn-secondary-border;
color: #222;
font-weight: 500;
&:active {
background-color: $btn-secondary-active-background;
border-color: $btn-secondary-active-border;
}
}
&.help {
border-radius: 10em;
padding: 0;
background-image: none;
background-color: #eeeeee;
color: #333;
border-color: #bbb;
min-width: min-content;
width: 1.5rem;
height: 1.5rem;
&:hover {
background-color: #dddddd;
}
}
}
div.card {
width: max-content;
padding: .5rem 1rem;
box-shadow: 0px 13px 28px 4px rgba(0,0,0,0.2);
border-radius: .4rem;
margin: 2rem;
}
label {
display: flex;
flex: 0 !important;
margin-right: .5rem;
}
input {
margin: 0 .5rem;
border: none;
box-shadow: 0px 1px 2px 1px rgba(0,0,0,0.1);
padding: .2rem .5rem;
border-radius: .2rem;
width: 3rem;
}
select {
// A reset of styles, including removing the default dropdown arrow
appearance: none;
// Additional resets for further consistency
border: none;
box-shadow: 0px 1px 2px 1px rgba(0,0,0,0.1);
color: #333;
border-radius: .3rem;
padding: .15rem .5rem;
font-weight: 600;
margin: .2rem .5rem;
font-size: $font-size;
width: 10em;
&::-ms-expand {
display: none;
}
}
.select {
display: grid;
grid-template-areas: "select";
align-items: center;
}
// Utilitary classes
.max-width {
width: 100%;
}
div.row {
display: flex;
flex-direction: row;
align-items: center;
margin: .5rem 0;
max-width: 100%;
&.action {
margin-top: 1.5rem;
justify-content: space-between;
}
& > * {
display: flex;
flex: 1 0;
}
& > input, select {
margin-left: 0;
margin-right: 0;
}
}
html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }

25
cerberus/src/test.ts Normal file
View File

@@ -0,0 +1,25 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: {
context(path: string, deep?: boolean, filter?: RegExp): {
keys(): string[];
<T>(id: string): T;
};
};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);

View File

@@ -0,0 +1,15 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}

30
cerberus/tsconfig.json Normal file
View File

@@ -0,0 +1,30 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}

View File

@@ -0,0 +1,18 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"files": [
"src/test.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}

152
cerberus/tslint.json Normal file
View File

@@ -0,0 +1,152 @@
{
"extends": "tslint:recommended",
"rulesDirectory": [
"codelyzer"
],
"rules": {
"align": {
"options": [
"parameters",
"statements"
]
},
"array-type": false,
"arrow-return-shorthand": true,
"curly": true,
"deprecation": {
"severity": "warning"
},
"eofline": true,
"import-blacklist": [
true,
"rxjs/Rx"
],
"import-spacing": true,
"indent": {
"options": [
"spaces"
]
},
"max-classes-per-file": false,
"max-line-length": [
true,
140
],
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-empty": false,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-switch-case-fall-through": true,
"no-var-requires": false,
"object-literal-key-quotes": [
true,
"as-needed"
],
"quotemark": [
true,
"single"
],
"semicolon": {
"options": [
"always"
]
},
"space-before-function-paren": {
"options": {
"anonymous": "never",
"asyncArrow": "always",
"constructor": "never",
"method": "never",
"named": "never"
}
},
"typedef": [
true,
"call-signature"
],
"typedef-whitespace": {
"options": [
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}
]
},
"variable-name": {
"options": [
"ban-keywords",
"check-format",
"allow-pascal-case"
]
},
"whitespace": {
"options": [
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type",
"check-typecast"
]
},
"component-class-suffix": true,
"contextual-lifecycle": true,
"directive-class-suffix": true,
"no-conflicting-lifecycle": true,
"no-host-metadata-property": true,
"no-input-rename": true,
"no-inputs-metadata-property": true,
"no-output-native": true,
"no-output-on-prefix": true,
"no-output-rename": true,
"no-outputs-metadata-property": true,
"template-banana-in-box": true,
"template-no-negated-async": true,
"use-lifecycle-interface": true,
"use-pipe-transform-interface": true,
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
]
}
}

View File

@@ -0,0 +1,28 @@
package org.takiguchi.cerberus.cerberusapp.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.takiguchi.cerberus.cerberusapp.model.ReferentialDataDTO;
import org.takiguchi.cerberus.cerberusapp.model.ServiceType;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.takiguchi.cerberus.cerberusapp.model.ReferentialDataDTO.aReferentialData;
@RestController
@RequestMapping("/api/referentialData")
public class ReferentialDataController {
@GetMapping("/serviceTypes")
public List<ReferentialDataDTO> getServiceTypes() {
return Stream.of(ServiceType.values())
.map(type -> aReferentialData()
.withValue(type.name())
.withLabel(type.name().toLowerCase())
.build()
)
.collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,45 @@
package org.takiguchi.cerberus.cerberusapp.model;
public class ReferentialDataDTO {
private final String value;
private final String label;
private ReferentialDataDTO(String value, String label) {
this.value = value;
this.label = label;
}
public static Builder aReferentialData() {
return new Builder();
}
public String getValue() {
return value;
}
public String getLabel() {
return label;
}
public static class Builder {
private String value;
private String label;
private Builder() {
}
public Builder withValue(String value) {
this.value = value;
return this;
}
public Builder withLabel(String label) {
this.label = label;
return this;
}
public ReferentialDataDTO build() {
return new ReferentialDataDTO(value, label);
}
}
}

View File

@@ -12,4 +12,10 @@ spring:
driverClassName: org.postgresql.Driver driverClassName: org.postgresql.Driver
url: jdbc:postgresql://localhost:50001/cerberus url: jdbc:postgresql://localhost:50001/cerberus
username: h23 username: h23
password: P@ssword1 password: P@ssword1
# Disable feature detection by this undocumented parameter.
# Check the org.hibernate.engine.jdbc.internal.JdbcServiceImpl.configure method for more details.
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
properties.hibernate.temp.use_jdbc_metadata_defaults: false
open-in-view: false