Add frontend.
This commit is contained in:
14
cerberus/src/app/app-routing.module.ts
Normal file
14
cerberus/src/app/app-routing.module.ts
Normal 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 { }
|
||||
1
cerberus/src/app/app.component.html
Normal file
1
cerberus/src/app/app.component.html
Normal file
@@ -0,0 +1 @@
|
||||
<router-outlet></router-outlet>
|
||||
0
cerberus/src/app/app.component.scss
Normal file
0
cerberus/src/app/app.component.scss
Normal file
35
cerberus/src/app/app.component.spec.ts
Normal file
35
cerberus/src/app/app.component.spec.ts
Normal 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!');
|
||||
});
|
||||
});
|
||||
10
cerberus/src/app/app.component.ts
Normal file
10
cerberus/src/app/app.component.ts
Normal 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';
|
||||
}
|
||||
33
cerberus/src/app/app.module.ts
Normal file
33
cerberus/src/app/app.module.ts
Normal 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 { }
|
||||
@@ -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>
|
||||
@@ -0,0 +1,3 @@
|
||||
.card {
|
||||
margin: auto;
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
15
cerberus/src/app/core/components/select/select.component.ts
Normal file
15
cerberus/src/app/core/components/select/select.component.ts
Normal 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 {
|
||||
}
|
||||
|
||||
}
|
||||
6
cerberus/src/app/core/entities/Application.ts
Normal file
6
cerberus/src/app/core/entities/Application.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export interface Application {
|
||||
id: string;
|
||||
name: string;
|
||||
serviceName: string;
|
||||
serviceType: string;
|
||||
}
|
||||
4
cerberus/src/app/core/entities/ReferentialData.ts
Normal file
4
cerberus/src/app/core/entities/ReferentialData.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export interface ReferentialData {
|
||||
value: string,
|
||||
label: string
|
||||
}
|
||||
16
cerberus/src/app/core/services/application.service.spec.ts
Normal file
16
cerberus/src/app/core/services/application.service.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
17
cerberus/src/app/core/services/application.service.ts
Normal file
17
cerberus/src/app/core/services/application.service.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
16
cerberus/src/app/core/services/referential-data.service.ts
Normal file
16
cerberus/src/app/core/services/referential-data.service.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
46
cerberus/src/app/ui-kit/ui-kit.component.html
Normal file
46
cerberus/src/app/ui-kit/ui-kit.component.html
Normal 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>
|
||||
11
cerberus/src/app/ui-kit/ui-kit.component.scss
Normal file
11
cerberus/src/app/ui-kit/ui-kit.component.scss
Normal file
@@ -0,0 +1,11 @@
|
||||
.login-form {
|
||||
width: 15rem;
|
||||
|
||||
div, div input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.action {
|
||||
justify-content: right;
|
||||
}
|
||||
}
|
||||
25
cerberus/src/app/ui-kit/ui-kit.component.spec.ts
Normal file
25
cerberus/src/app/ui-kit/ui-kit.component.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
15
cerberus/src/app/ui-kit/ui-kit.component.ts
Normal file
15
cerberus/src/app/ui-kit/ui-kit.component.ts
Normal 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 {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user