From cb658f969de968dce813dfb0478eb298f92c92b8 Mon Sep 17 00:00:00 2001 From: Allan Asp Christensen Date: Tue, 25 Aug 2020 13:44:15 +0200 Subject: [PATCH 1/9] refactor --- .vscode/launch.json | 28 +++++++++++-------- package-lock.json | 15 ---------- src/app/app-routing.module.ts | 4 +-- .../applications-table-row.component.html | 0 .../applications-table-row.component.scss | 0 .../applications-table-row.component.spec.ts | 0 .../applications-table-row.component.ts | 0 .../mine-applikationer.component.html | 0 .../mine-applikationer.component.scss | 0 .../mine-applikationer.component.spec.ts | 4 +-- .../mine-applikationer.component.ts | 0 .../mine-applikationer.module.ts | 6 ++-- 12 files changed, 24 insertions(+), 33 deletions(-) rename src/app/views/mine-applikationer/{ => applications-table}/applications-table-row/applications-table-row.component.html (100%) rename src/app/views/mine-applikationer/{ => applications-table}/applications-table-row/applications-table-row.component.scss (100%) rename src/app/views/mine-applikationer/{ => applications-table}/applications-table-row/applications-table-row.component.spec.ts (100%) rename src/app/views/mine-applikationer/{ => applications-table}/applications-table-row/applications-table-row.component.ts (100%) rename src/app/views/mine-applikationer/{mine-applikationer => }/mine-applikationer.component.html (100%) rename src/app/views/mine-applikationer/{mine-applikationer => }/mine-applikationer.component.scss (100%) rename src/app/views/mine-applikationer/{mine-applikationer => }/mine-applikationer.component.spec.ts (89%) rename src/app/views/mine-applikationer/{mine-applikationer => }/mine-applikationer.component.ts (100%) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0c95de90..5eb02650 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,13 +1,19 @@ { - "version": "0.2.0", - "configurations": [ - { - "type": "firefox", - "request": "launch", - "reAttach": true, - "name": "Launch localhost", - "url": "http://localhost:4200", - "webRoot": "${workspaceFolder}" - } - ] + "version": "0.2.0", + "configurations": [{ + "type": "firefox", + "request": "launch", + "reAttach": true, + "name": "Launch localhost with Firefox", + "url": "http://localhost:4200", + "webRoot": "${workspaceFolder}" + }, + { + "name": "Launch localhost with Chrome", + "type": "chrome", + "request": "launch", + "url": "http://localhost:4200", + "webRoot": "${workspaceFolder}" + }, + ] } diff --git a/package-lock.json b/package-lock.json index cdf515d8..968b2a0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2036,21 +2036,6 @@ } } }, - "@ng-select/ng-select": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@ng-select/ng-select/-/ng-select-5.0.1.tgz", - "integrity": "sha512-HXGZbJHUK/Bch88LUgvNard+Kg9tTB9HTG4SalBP64/hwvYOdQIcsFmf2Zxl0VvhUfKo7qLLIY3HKsy9i0wqJg==", - "requires": { - "tslib": "^2.0.0" - }, - "dependencies": { - "tslib": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", - "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==" - } - } - }, "@ngtools/webpack": { "version": "9.1.9", "resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-9.1.9.tgz", diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 1fbe640b..72027f39 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { DashboardComponent } from './views/dashboard/dashboard/dashboard.component'; -import { MineApplikationerComponent } from './views/mine-applikationer/mine-applikationer/mine-applikationer.component'; +import { MineApplikationerComponent } from './views/mine-applikationer/mine-applikationer.component'; import { EditApplicationComponent } from './views/mine-applikationer/edit-application/edit-application.component'; import { ListApplicationsComponent } from './views/mine-applikationer/list-applications/list-applications.component'; import { ApplicationComponent } from './views/mine-applikationer/application/application.component'; @@ -51,4 +51,4 @@ const routes: Routes = [ imports: [RouterModule.forRoot(routes)], exports: [RouterModule], }) -export class AppRoutingModule {} +export class AppRoutingModule { } diff --git a/src/app/views/mine-applikationer/applications-table-row/applications-table-row.component.html b/src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.html similarity index 100% rename from src/app/views/mine-applikationer/applications-table-row/applications-table-row.component.html rename to src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.html diff --git a/src/app/views/mine-applikationer/applications-table-row/applications-table-row.component.scss b/src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.scss similarity index 100% rename from src/app/views/mine-applikationer/applications-table-row/applications-table-row.component.scss rename to src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.scss diff --git a/src/app/views/mine-applikationer/applications-table-row/applications-table-row.component.spec.ts b/src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.spec.ts similarity index 100% rename from src/app/views/mine-applikationer/applications-table-row/applications-table-row.component.spec.ts rename to src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.spec.ts diff --git a/src/app/views/mine-applikationer/applications-table-row/applications-table-row.component.ts b/src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.ts similarity index 100% rename from src/app/views/mine-applikationer/applications-table-row/applications-table-row.component.ts rename to src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.ts diff --git a/src/app/views/mine-applikationer/mine-applikationer/mine-applikationer.component.html b/src/app/views/mine-applikationer/mine-applikationer.component.html similarity index 100% rename from src/app/views/mine-applikationer/mine-applikationer/mine-applikationer.component.html rename to src/app/views/mine-applikationer/mine-applikationer.component.html diff --git a/src/app/views/mine-applikationer/mine-applikationer/mine-applikationer.component.scss b/src/app/views/mine-applikationer/mine-applikationer.component.scss similarity index 100% rename from src/app/views/mine-applikationer/mine-applikationer/mine-applikationer.component.scss rename to src/app/views/mine-applikationer/mine-applikationer.component.scss diff --git a/src/app/views/mine-applikationer/mine-applikationer/mine-applikationer.component.spec.ts b/src/app/views/mine-applikationer/mine-applikationer.component.spec.ts similarity index 89% rename from src/app/views/mine-applikationer/mine-applikationer/mine-applikationer.component.spec.ts rename to src/app/views/mine-applikationer/mine-applikationer.component.spec.ts index 06b76a9d..9e9c2458 100644 --- a/src/app/views/mine-applikationer/mine-applikationer/mine-applikationer.component.spec.ts +++ b/src/app/views/mine-applikationer/mine-applikationer.component.spec.ts @@ -8,9 +8,9 @@ describe('MineApplikationerComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ MineApplikationerComponent ] + declarations: [MineApplikationerComponent] }) - .compileComponents(); + .compileComponents(); })); beforeEach(() => { diff --git a/src/app/views/mine-applikationer/mine-applikationer/mine-applikationer.component.ts b/src/app/views/mine-applikationer/mine-applikationer.component.ts similarity index 100% rename from src/app/views/mine-applikationer/mine-applikationer/mine-applikationer.component.ts rename to src/app/views/mine-applikationer/mine-applikationer.component.ts diff --git a/src/app/views/mine-applikationer/mine-applikationer.module.ts b/src/app/views/mine-applikationer/mine-applikationer.module.ts index 20609581..91845ada 100644 --- a/src/app/views/mine-applikationer/mine-applikationer.module.ts +++ b/src/app/views/mine-applikationer/mine-applikationer.module.ts @@ -7,10 +7,10 @@ import { TranslateModule } from '@ngx-translate/core'; import { TopBarModule } from 'src/app/shared/top-bar/top-bar.module'; import { FormModule } from 'src/app/shared/form/form.module'; -import { MineApplikationerComponent } from './mine-applikationer/mine-applikationer.component'; +import { MineApplikationerComponent } from './mine-applikationer.component'; import { ApplicationComponent } from './application/application.component'; import { ApplicationsTableComponent } from './applications-table/applications-table.component'; -import { ApplicationsTableRowComponent } from './applications-table-row/applications-table-row.component'; +import { ApplicationsTableRowComponent } from './applications-table/applications-table-row/applications-table-row.component'; import { EditApplicationComponent } from './edit-application/edit-application.component'; import { ListApplicationsComponent } from './list-applications/list-applications.component'; import { AlleIotEnhederModule } from '../alle-iot-enheder/alle-iot-enheder.module'; @@ -39,4 +39,4 @@ import { AlleIotEnhederModule } from '../alle-iot-enheder/alle-iot-enheder.modul AlleIotEnhederModule ] }) -export class MineApplikationerModule {} +export class MineApplikationerModule { } From 17f598d8ce0f9678314cd8997f383a65d8a8ee13 Mon Sep 17 00:00:00 2001 From: Allan Asp Christensen Date: Tue, 25 Aug 2020 14:12:39 +0200 Subject: [PATCH 2/9] refactor my-applications --- src/app/app-routing.module.ts | 12 ++++----- src/app/app.module.ts | 4 +-- .../form-body-application.component.ts | 10 ++++---- .../form-body-iot-devices.component.ts | 8 +++--- src/app/shared/navbar/navbar.component.html | 8 +++--- .../alle-iot-enheder.component.spec.ts | 25 ------------------- .../iot-device/iot-device.component.ts | 12 ++++----- .../mine-applikationer.component.ts | 15 ----------- .../application/application.component.html | 0 .../application/application.component.scss | 0 .../application/application.component.spec.ts | 0 .../application/application.component.ts | 10 ++++---- .../applications-table-row.component.html | 0 .../applications-table-row.component.scss | 0 .../applications-table-row.component.spec.ts | 0 .../applications-table-row.component.ts | 0 .../applications-table.component.html | 0 .../applications-table.component.scss | 0 .../applications-table.component.spec.ts | 0 .../applications-table.component.ts | 0 .../edit-application.component.html | 0 .../edit-application.component.scss | 0 .../edit-application.component.spec.ts | 0 .../edit-application.component.ts | 16 ++++++------ .../list-applications.component.html | 0 .../list-applications.component.scss | 0 .../list-applications.component.spec.ts | 0 .../list-applications.component.ts | 0 .../my-applications.component.html} | 0 .../my-applications.component.scss} | 0 .../my-applications.component.spec.ts} | 12 ++++----- .../my-applications.component.ts | 15 +++++++++++ .../my-applications.module.ts} | 6 ++--- 33 files changed, 65 insertions(+), 88 deletions(-) delete mode 100644 src/app/views/alle-iot-enheder/alle-iot-enheder.component.spec.ts delete mode 100644 src/app/views/mine-applikationer/mine-applikationer.component.ts rename src/app/views/{mine-applikationer => my-applications}/application/application.component.html (100%) rename src/app/views/{mine-applikationer => my-applications}/application/application.component.scss (100%) rename src/app/views/{mine-applikationer => my-applications}/application/application.component.spec.ts (100%) rename src/app/views/{mine-applikationer => my-applications}/application/application.component.ts (94%) rename src/app/views/{mine-applikationer => my-applications}/applications-table/applications-table-row/applications-table-row.component.html (100%) rename src/app/views/{mine-applikationer => my-applications}/applications-table/applications-table-row/applications-table-row.component.scss (100%) rename src/app/views/{mine-applikationer => my-applications}/applications-table/applications-table-row/applications-table-row.component.spec.ts (100%) rename src/app/views/{mine-applikationer => my-applications}/applications-table/applications-table-row/applications-table-row.component.ts (100%) rename src/app/views/{mine-applikationer => my-applications}/applications-table/applications-table.component.html (100%) rename src/app/views/{mine-applikationer => my-applications}/applications-table/applications-table.component.scss (100%) rename src/app/views/{mine-applikationer => my-applications}/applications-table/applications-table.component.spec.ts (100%) rename src/app/views/{mine-applikationer => my-applications}/applications-table/applications-table.component.ts (100%) rename src/app/views/{mine-applikationer => my-applications}/edit-application/edit-application.component.html (100%) rename src/app/views/{mine-applikationer => my-applications}/edit-application/edit-application.component.scss (100%) rename src/app/views/{mine-applikationer => my-applications}/edit-application/edit-application.component.spec.ts (100%) rename src/app/views/{mine-applikationer => my-applications}/edit-application/edit-application.component.ts (68%) rename src/app/views/{mine-applikationer => my-applications}/list-applications/list-applications.component.html (100%) rename src/app/views/{mine-applikationer => my-applications}/list-applications/list-applications.component.scss (100%) rename src/app/views/{mine-applikationer => my-applications}/list-applications/list-applications.component.spec.ts (100%) rename src/app/views/{mine-applikationer => my-applications}/list-applications/list-applications.component.ts (100%) rename src/app/views/{mine-applikationer/mine-applikationer.component.html => my-applications/my-applications.component.html} (100%) rename src/app/views/{mine-applikationer/mine-applikationer.component.scss => my-applications/my-applications.component.scss} (100%) rename src/app/views/{mine-applikationer/mine-applikationer.component.spec.ts => my-applications/my-applications.component.spec.ts} (50%) create mode 100644 src/app/views/my-applications/my-applications.component.ts rename src/app/views/{mine-applikationer/mine-applikationer.module.ts => my-applications/my-applications.module.ts} (90%) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 72027f39..feef9f95 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,18 +1,18 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { DashboardComponent } from './views/dashboard/dashboard/dashboard.component'; -import { MineApplikationerComponent } from './views/mine-applikationer/mine-applikationer.component'; -import { EditApplicationComponent } from './views/mine-applikationer/edit-application/edit-application.component'; -import { ListApplicationsComponent } from './views/mine-applikationer/list-applications/list-applications.component'; -import { ApplicationComponent } from './views/mine-applikationer/application/application.component'; +import { MyApplicationsComponent } from './views/my-applications/my-applications.component'; +import { EditApplicationComponent } from './views/my-applications/edit-application/edit-application.component'; +import { ListApplicationsComponent } from './views/my-applications/list-applications/list-applications.component'; +import { ApplicationComponent } from './views/my-applications/application/application.component'; import { IoTDeviceComponent } from './views/alle-iot-enheder/iot-device/iot-device.component'; import { EditIotDeviceComponent } from './views/alle-iot-enheder/edit-iot-device/edit-iot-device.component'; const routes: Routes = [ { path: 'home', component: DashboardComponent }, { - path: 'mine-applikationer', - component: MineApplikationerComponent, + path: 'my-applications', + component: MyApplicationsComponent, children: [ { path: '', component: ListApplicationsComponent }, { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 6cb9110c..1d566649 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -9,7 +9,7 @@ import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { DashboardModule } from './views/dashboard/dashboard.module'; -import { MineApplikationerModule } from './views/mine-applikationer/mine-applikationer.module'; +import { MineApplikationerModule } from './views/my-applications/my-applications.module'; import { AlleIotEnhederModule } from './views/alle-iot-enheder/alle-iot-enheder.module'; import { NavbarModule } from './shared/navbar/navbar.module'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; @@ -46,4 +46,4 @@ export function HttpLoaderFactory(http: HttpClient) { bootstrap: [AppComponent], exports: [TranslateModule], }) -export class AppModule {} +export class AppModule { } diff --git a/src/app/shared/form/form-body-application/form-body-application.component.ts b/src/app/shared/form/form-body-application/form-body-application.component.ts index 4eeb9da5..ee084370 100644 --- a/src/app/shared/form/form-body-application/form-body-application.component.ts +++ b/src/app/shared/form/form-body-application/form-body-application.component.ts @@ -15,7 +15,7 @@ export class User { public email: string; public password: string; public hobbies: string; - } +} @Component({ selector: 'app-form-body-application', @@ -41,7 +41,7 @@ export class FormBodyApplicationComponent implements OnInit, OnDestroy { private route: ActivatedRoute, public translate: TranslateService, private router: Router - ) {} + ) { } ngOnInit(): void { this.translate.use('da'); @@ -73,7 +73,7 @@ export class FormBodyApplicationComponent implements OnInit, OnDestroy { .subscribe( (response) => { console.log(response); - this.router.navigateByUrl('/mine-applikationer'); + this.router.navigateByUrl('/my-applications'); }, (error: HttpErrorResponse) => { this.errorFields = []; @@ -95,7 +95,7 @@ export class FormBodyApplicationComponent implements OnInit, OnDestroy { .subscribe( (response) => { console.log(response); - this.router.navigateByUrl('/mine-applikationer'); + this.router.navigateByUrl('/my-applications'); }, (error: HttpErrorResponse) => { this.errorFields = []; @@ -112,7 +112,7 @@ export class FormBodyApplicationComponent implements OnInit, OnDestroy { } routeBack(): void { - this.router.navigateByUrl('/mine-applikationer'); + this.router.navigateByUrl('/my-applications'); } ngOnDestroy() { diff --git a/src/app/shared/form/form-body-iot-devices/form-body-iot-devices.component.ts b/src/app/shared/form/form-body-iot-devices/form-body-iot-devices.component.ts index 9c82f5d7..9642d5f8 100644 --- a/src/app/shared/form/form-body-iot-devices/form-body-iot-devices.component.ts +++ b/src/app/shared/form/form-body-iot-devices/form-body-iot-devices.component.ts @@ -38,7 +38,7 @@ export class FormBodyIotDevicesComponent implements OnInit, OnDestroy { private router: Router, private applicationService: ApplicationService, private iotDeviceService: IoTDeviceService - ) {} + ) { } ngOnInit(): void { this.translate.use('da'); @@ -80,7 +80,7 @@ export class FormBodyIotDevicesComponent implements OnInit, OnDestroy { this.iotDeviceService.createIoTDevice(this.iotDevice).subscribe( () => { this.router.navigate([ - 'mine-applikationer/application', + 'my-applications/application', this.iotDevice.applicationId, ]); }, @@ -102,7 +102,7 @@ export class FormBodyIotDevicesComponent implements OnInit, OnDestroy { this.iotDeviceService.updateIoTDevice(this.iotDevice, id).subscribe( () => { this.router.navigate([ - 'mine-applikationer/application', + 'my-applications/application', this.application.id, ]); }, @@ -121,7 +121,7 @@ export class FormBodyIotDevicesComponent implements OnInit, OnDestroy { } routeBack(): void { - this.router.navigateByUrl('/mine-applikationer'); + this.router.navigateByUrl('/my-applications'); } onCoordinateKey(event: any) { diff --git a/src/app/shared/navbar/navbar.component.html b/src/app/shared/navbar/navbar.component.html index bc580d57..c41cb9be 100644 --- a/src/app/shared/navbar/navbar.component.html +++ b/src/app/shared/navbar/navbar.component.html @@ -16,16 +16,18 @@ - + \ No newline at end of file diff --git a/src/app/views/alle-iot-enheder/alle-iot-enheder.component.spec.ts b/src/app/views/alle-iot-enheder/alle-iot-enheder.component.spec.ts deleted file mode 100644 index 2b87dac2..00000000 --- a/src/app/views/alle-iot-enheder/alle-iot-enheder.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AlleIotEnhederComponent } from './alle-iot-enheder.component'; - -describe('AlleIotEnhederComponent', () => { - let component: AlleIotEnhederComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ AlleIotEnhederComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(AlleIotEnhederComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/views/alle-iot-enheder/iot-device/iot-device.component.ts b/src/app/views/alle-iot-enheder/iot-device/iot-device.component.ts index 2b12fd9c..b08c02b2 100644 --- a/src/app/views/alle-iot-enheder/iot-device/iot-device.component.ts +++ b/src/app/views/alle-iot-enheder/iot-device/iot-device.component.ts @@ -15,12 +15,12 @@ import { BackButton } from 'src/app/models/back-button'; }) export class IoTDeviceComponent implements OnInit, OnDestroy { public deviceId: number; - public backButton: BackButton = {label: '', routerLink: '/mine-applikationer'}; + public backButton: BackButton = { label: '', routerLink: '/my-applications' }; public application: Application; public latitude: number; public longitude: number; public iotDeviceSubscription: Subscription; - + // TODO: Få aktivt miljø? public baseUrl = environment.baseUrl; public genericHttpDeviceUrl: string; @@ -31,7 +31,7 @@ export class IoTDeviceComponent implements OnInit, OnDestroy { private route: ActivatedRoute, private iotDeviceService: IoTDeviceService, private translate: TranslateService - ) {} + ) { } ngOnInit(): void { this.deviceId = +this.route.snapshot.paramMap.get('deviceId'); @@ -41,9 +41,9 @@ export class IoTDeviceComponent implements OnInit, OnDestroy { } this.translate.get(['NAV.MY-APPLICATIONS']) - .subscribe(translations => { - this.backButton.label = translations['NAV.MY-APPLICATIONS']; - }); + .subscribe(translations => { + this.backButton.label = translations['NAV.MY-APPLICATIONS']; + }); } bindIoTDeviceAndApplication(deviceId: number) { diff --git a/src/app/views/mine-applikationer/mine-applikationer.component.ts b/src/app/views/mine-applikationer/mine-applikationer.component.ts deleted file mode 100644 index 97b775ef..00000000 --- a/src/app/views/mine-applikationer/mine-applikationer.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-mine-applikationer', - templateUrl: './mine-applikationer.component.html', - styleUrls: ['./mine-applikationer.component.scss'] -}) -export class MineApplikationerComponent implements OnInit { - - constructor() { } - - ngOnInit(): void { - } - -} diff --git a/src/app/views/mine-applikationer/application/application.component.html b/src/app/views/my-applications/application/application.component.html similarity index 100% rename from src/app/views/mine-applikationer/application/application.component.html rename to src/app/views/my-applications/application/application.component.html diff --git a/src/app/views/mine-applikationer/application/application.component.scss b/src/app/views/my-applications/application/application.component.scss similarity index 100% rename from src/app/views/mine-applikationer/application/application.component.scss rename to src/app/views/my-applications/application/application.component.scss diff --git a/src/app/views/mine-applikationer/application/application.component.spec.ts b/src/app/views/my-applications/application/application.component.spec.ts similarity index 100% rename from src/app/views/mine-applikationer/application/application.component.spec.ts rename to src/app/views/my-applications/application/application.component.spec.ts diff --git a/src/app/views/mine-applikationer/application/application.component.ts b/src/app/views/my-applications/application/application.component.ts similarity index 94% rename from src/app/views/mine-applikationer/application/application.component.ts rename to src/app/views/my-applications/application/application.component.ts index 69b344e9..1ef08f04 100644 --- a/src/app/views/mine-applikationer/application/application.component.ts +++ b/src/app/views/my-applications/application/application.component.ts @@ -19,7 +19,7 @@ import { BackButton } from 'src/app/models/back-button'; export class ApplicationComponent implements OnInit { public applicationsSubscription: Subscription; public application: Application; - public backButton: BackButton = {label: '', routerLink: '/mine-applikationer'}; + public backButton: BackButton = { label: '', routerLink: '/my-applications' }; private id: number; public pageLimit: number = 10; public selectedSortId: number = 6; @@ -111,7 +111,7 @@ export class ApplicationComponent implements OnInit { private applicationService: ApplicationService, private route: ActivatedRoute, public translate: TranslateService - ) {} + ) { } ngOnInit(): void { this.id = +this.route.snapshot.paramMap.get('id'); @@ -119,9 +119,9 @@ export class ApplicationComponent implements OnInit { this.bindApplication(this.id); } this.translate.get(['NAV.MY-APPLICATIONS']) - .subscribe(translations => { - this.backButton.label = translations['NAV.MY-APPLICATIONS']; - }); + .subscribe(translations => { + this.backButton.label = translations['NAV.MY-APPLICATIONS']; + }); } bindApplication(id: number): void { diff --git a/src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.html b/src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.html similarity index 100% rename from src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.html rename to src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.html diff --git a/src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.scss b/src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.scss similarity index 100% rename from src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.scss rename to src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.scss diff --git a/src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.spec.ts b/src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.spec.ts similarity index 100% rename from src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.spec.ts rename to src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.spec.ts diff --git a/src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.ts b/src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.ts similarity index 100% rename from src/app/views/mine-applikationer/applications-table/applications-table-row/applications-table-row.component.ts rename to src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.ts diff --git a/src/app/views/mine-applikationer/applications-table/applications-table.component.html b/src/app/views/my-applications/applications-table/applications-table.component.html similarity index 100% rename from src/app/views/mine-applikationer/applications-table/applications-table.component.html rename to src/app/views/my-applications/applications-table/applications-table.component.html diff --git a/src/app/views/mine-applikationer/applications-table/applications-table.component.scss b/src/app/views/my-applications/applications-table/applications-table.component.scss similarity index 100% rename from src/app/views/mine-applikationer/applications-table/applications-table.component.scss rename to src/app/views/my-applications/applications-table/applications-table.component.scss diff --git a/src/app/views/mine-applikationer/applications-table/applications-table.component.spec.ts b/src/app/views/my-applications/applications-table/applications-table.component.spec.ts similarity index 100% rename from src/app/views/mine-applikationer/applications-table/applications-table.component.spec.ts rename to src/app/views/my-applications/applications-table/applications-table.component.spec.ts diff --git a/src/app/views/mine-applikationer/applications-table/applications-table.component.ts b/src/app/views/my-applications/applications-table/applications-table.component.ts similarity index 100% rename from src/app/views/mine-applikationer/applications-table/applications-table.component.ts rename to src/app/views/my-applications/applications-table/applications-table.component.ts diff --git a/src/app/views/mine-applikationer/edit-application/edit-application.component.html b/src/app/views/my-applications/edit-application/edit-application.component.html similarity index 100% rename from src/app/views/mine-applikationer/edit-application/edit-application.component.html rename to src/app/views/my-applications/edit-application/edit-application.component.html diff --git a/src/app/views/mine-applikationer/edit-application/edit-application.component.scss b/src/app/views/my-applications/edit-application/edit-application.component.scss similarity index 100% rename from src/app/views/mine-applikationer/edit-application/edit-application.component.scss rename to src/app/views/my-applications/edit-application/edit-application.component.scss diff --git a/src/app/views/mine-applikationer/edit-application/edit-application.component.spec.ts b/src/app/views/my-applications/edit-application/edit-application.component.spec.ts similarity index 100% rename from src/app/views/mine-applikationer/edit-application/edit-application.component.spec.ts rename to src/app/views/my-applications/edit-application/edit-application.component.spec.ts diff --git a/src/app/views/mine-applikationer/edit-application/edit-application.component.ts b/src/app/views/my-applications/edit-application/edit-application.component.ts similarity index 68% rename from src/app/views/mine-applikationer/edit-application/edit-application.component.ts rename to src/app/views/my-applications/edit-application/edit-application.component.ts index 08442d3b..9906fcc4 100644 --- a/src/app/views/mine-applikationer/edit-application/edit-application.component.ts +++ b/src/app/views/my-applications/edit-application/edit-application.component.ts @@ -8,7 +8,7 @@ import { BackButton } from 'src/app/models/back-button'; styleUrls: ['./edit-application.component.scss'] }) export class EditApplicationComponent implements OnInit { - public backButton: BackButton = {label: '', routerLink: '/mine-applikationer'}; + public backButton: BackButton = { label: '', routerLink: '/my-applications' }; public multiPage: boolean = false; public title: string = ''; public sectionTitle: string = ''; @@ -16,16 +16,16 @@ export class EditApplicationComponent implements OnInit { constructor( public translate: TranslateService - ) { + ) { translate.use('da'); } - + ngOnInit(): void { this.translate.get(['NAV.MY-APPLICATIONS', 'FORM.EDIT-NEW-APPLICATION', 'APPLICATION.SAVE']) - .subscribe(translations => { - this.backButton.label = translations['NAV.MY-APPLICATIONS']; - this.title = translations['FORM.EDIT-NEW-APPLICATION']; - this.submitButton = translations['APPLICATION.SAVE']; - }); + .subscribe(translations => { + this.backButton.label = translations['NAV.MY-APPLICATIONS']; + this.title = translations['FORM.EDIT-NEW-APPLICATION']; + this.submitButton = translations['APPLICATION.SAVE']; + }); } } diff --git a/src/app/views/mine-applikationer/list-applications/list-applications.component.html b/src/app/views/my-applications/list-applications/list-applications.component.html similarity index 100% rename from src/app/views/mine-applikationer/list-applications/list-applications.component.html rename to src/app/views/my-applications/list-applications/list-applications.component.html diff --git a/src/app/views/mine-applikationer/list-applications/list-applications.component.scss b/src/app/views/my-applications/list-applications/list-applications.component.scss similarity index 100% rename from src/app/views/mine-applikationer/list-applications/list-applications.component.scss rename to src/app/views/my-applications/list-applications/list-applications.component.scss diff --git a/src/app/views/mine-applikationer/list-applications/list-applications.component.spec.ts b/src/app/views/my-applications/list-applications/list-applications.component.spec.ts similarity index 100% rename from src/app/views/mine-applikationer/list-applications/list-applications.component.spec.ts rename to src/app/views/my-applications/list-applications/list-applications.component.spec.ts diff --git a/src/app/views/mine-applikationer/list-applications/list-applications.component.ts b/src/app/views/my-applications/list-applications/list-applications.component.ts similarity index 100% rename from src/app/views/mine-applikationer/list-applications/list-applications.component.ts rename to src/app/views/my-applications/list-applications/list-applications.component.ts diff --git a/src/app/views/mine-applikationer/mine-applikationer.component.html b/src/app/views/my-applications/my-applications.component.html similarity index 100% rename from src/app/views/mine-applikationer/mine-applikationer.component.html rename to src/app/views/my-applications/my-applications.component.html diff --git a/src/app/views/mine-applikationer/mine-applikationer.component.scss b/src/app/views/my-applications/my-applications.component.scss similarity index 100% rename from src/app/views/mine-applikationer/mine-applikationer.component.scss rename to src/app/views/my-applications/my-applications.component.scss diff --git a/src/app/views/mine-applikationer/mine-applikationer.component.spec.ts b/src/app/views/my-applications/my-applications.component.spec.ts similarity index 50% rename from src/app/views/mine-applikationer/mine-applikationer.component.spec.ts rename to src/app/views/my-applications/my-applications.component.spec.ts index 9e9c2458..6e72d739 100644 --- a/src/app/views/mine-applikationer/mine-applikationer.component.spec.ts +++ b/src/app/views/my-applications/my-applications.component.spec.ts @@ -1,20 +1,20 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { MineApplikationerComponent } from './mine-applikationer.component'; +import { MyApplicationsComponent } from './my-applications.component'; -describe('MineApplikationerComponent', () => { - let component: MineApplikationerComponent; - let fixture: ComponentFixture; +describe('MyApplicationsComponent', () => { + let component: MyApplicationsComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [MineApplikationerComponent] + declarations: [MyApplicationsComponent] }) .compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(MineApplikationerComponent); + fixture = TestBed.createComponent(MyApplicationsComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/src/app/views/my-applications/my-applications.component.ts b/src/app/views/my-applications/my-applications.component.ts new file mode 100644 index 00000000..bad8c479 --- /dev/null +++ b/src/app/views/my-applications/my-applications.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-my-applications', + templateUrl: './my-applications.component.html', + styleUrls: ['./my-applications.component.scss'] +}) +export class MyApplicationsComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/views/mine-applikationer/mine-applikationer.module.ts b/src/app/views/my-applications/my-applications.module.ts similarity index 90% rename from src/app/views/mine-applikationer/mine-applikationer.module.ts rename to src/app/views/my-applications/my-applications.module.ts index 91845ada..28125bb9 100644 --- a/src/app/views/mine-applikationer/mine-applikationer.module.ts +++ b/src/app/views/my-applications/my-applications.module.ts @@ -7,7 +7,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { TopBarModule } from 'src/app/shared/top-bar/top-bar.module'; import { FormModule } from 'src/app/shared/form/form.module'; -import { MineApplikationerComponent } from './mine-applikationer.component'; +import { MyApplicationsComponent } from './my-applications.component'; import { ApplicationComponent } from './application/application.component'; import { ApplicationsTableComponent } from './applications-table/applications-table.component'; import { ApplicationsTableRowComponent } from './applications-table/applications-table-row/applications-table-row.component'; @@ -17,7 +17,7 @@ import { AlleIotEnhederModule } from '../alle-iot-enheder/alle-iot-enheder.modul @NgModule({ declarations: [ - MineApplikationerComponent, + MyApplicationsComponent, ApplicationComponent, ApplicationsTableComponent, ApplicationsTableRowComponent, @@ -25,7 +25,7 @@ import { AlleIotEnhederModule } from '../alle-iot-enheder/alle-iot-enheder.modul ListApplicationsComponent, ], exports: [ - MineApplikationerComponent, + MyApplicationsComponent, ApplicationComponent, ApplicationsTableComponent, ApplicationsTableRowComponent, From e3d9bc09facd5241b36e7800c32f89af09f2fd40 Mon Sep 17 00:00:00 2001 From: Allan Asp Christensen Date: Mon, 31 Aug 2020 12:25:06 +0200 Subject: [PATCH 3/9] adding profiles, refactor services & Navbar --- src/app/app-routing.module.ts | 2 ++ src/app/app.module.ts | 2 +- .../{shared => }/navbar/navbar.component.html | 6 +++++ .../{shared => }/navbar/navbar.component.scss | 0 .../navbar/navbar.component.spec.ts | 0 .../{shared => }/navbar/navbar.component.ts | 0 src/app/{shared => }/navbar/navbar.module.ts | 4 +-- src/app/profiles/profiles.component.html | 1 + src/app/profiles/profiles.component.scss | 0 src/app/profiles/profiles.component.spec.ts | 25 +++++++++++++++++++ src/app/profiles/profiles.component.ts | 15 +++++++++++ src/app/shared/alert/alert.component.ts | 4 +-- .../form-body-application.component.ts | 4 +-- .../form-body-iot-devices.component.ts | 4 +-- .../alert.service.spec.ts | 0 .../{_services => services}/alert.service.ts | 0 .../application.service.spec.ts | 0 .../application.service.ts | 0 .../iot-device.service.spec.ts | 0 .../iot-device.service.ts | 0 .../rest.service.spec.ts | 0 .../{_services => services}/rest.service.ts | 4 +-- .../edit-iot-device.component.ts | 2 +- .../iot-device/iot-device.component.ts | 2 +- .../iot-devices-table-row.component.ts | 20 +++++++-------- .../iot-devices-table.component.ts | 6 ++--- .../application/application.component.ts | 2 +- .../applications-table.component.ts | 2 +- 28 files changed, 77 insertions(+), 28 deletions(-) rename src/app/{shared => }/navbar/navbar.component.html (97%) rename src/app/{shared => }/navbar/navbar.component.scss (100%) rename src/app/{shared => }/navbar/navbar.component.spec.ts (100%) rename src/app/{shared => }/navbar/navbar.component.ts (100%) rename src/app/{shared => }/navbar/navbar.module.ts (81%) create mode 100644 src/app/profiles/profiles.component.html create mode 100644 src/app/profiles/profiles.component.scss create mode 100644 src/app/profiles/profiles.component.spec.ts create mode 100644 src/app/profiles/profiles.component.ts rename src/app/shared/{_services => services}/alert.service.spec.ts (100%) rename src/app/shared/{_services => services}/alert.service.ts (100%) rename src/app/shared/{_services => services}/application.service.spec.ts (100%) rename src/app/shared/{_services => services}/application.service.ts (100%) rename src/app/shared/{_services => services}/iot-device.service.spec.ts (100%) rename src/app/shared/{_services => services}/iot-device.service.ts (100%) rename src/app/shared/{_services => services}/rest.service.spec.ts (100%) rename src/app/shared/{_services => services}/rest.service.ts (99%) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index feef9f95..a6d2aff5 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -7,6 +7,7 @@ import { ListApplicationsComponent } from './views/my-applications/list-applicat import { ApplicationComponent } from './views/my-applications/application/application.component'; import { IoTDeviceComponent } from './views/alle-iot-enheder/iot-device/iot-device.component'; import { EditIotDeviceComponent } from './views/alle-iot-enheder/edit-iot-device/edit-iot-device.component'; +import { ProfilesComponent } from './profiles/profiles.component'; const routes: Routes = [ { path: 'home', component: DashboardComponent }, @@ -43,6 +44,7 @@ const routes: Routes = [ }, ], }, + { path: 'profiles', component: ProfilesComponent }, { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: '**', redirectTo: '/home', pathMatch: 'full' }, ]; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1d566649..5b12bd84 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -11,7 +11,7 @@ import { AppComponent } from './app.component'; import { DashboardModule } from './views/dashboard/dashboard.module'; import { MineApplikationerModule } from './views/my-applications/my-applications.module'; import { AlleIotEnhederModule } from './views/alle-iot-enheder/alle-iot-enheder.module'; -import { NavbarModule } from './shared/navbar/navbar.module'; +import { NavbarModule } from './navbar/navbar.module'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { ReactiveFormsModule } from '@angular/forms'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; diff --git a/src/app/shared/navbar/navbar.component.html b/src/app/navbar/navbar.component.html similarity index 97% rename from src/app/shared/navbar/navbar.component.html rename to src/app/navbar/navbar.component.html index c41cb9be..7d7013a1 100644 --- a/src/app/shared/navbar/navbar.component.html +++ b/src/app/navbar/navbar.component.html @@ -28,6 +28,12 @@ {{ 'NAV.ALL-IOT-DEVICES' | translate }} + \ No newline at end of file diff --git a/src/app/shared/navbar/navbar.component.scss b/src/app/navbar/navbar.component.scss similarity index 100% rename from src/app/shared/navbar/navbar.component.scss rename to src/app/navbar/navbar.component.scss diff --git a/src/app/shared/navbar/navbar.component.spec.ts b/src/app/navbar/navbar.component.spec.ts similarity index 100% rename from src/app/shared/navbar/navbar.component.spec.ts rename to src/app/navbar/navbar.component.spec.ts diff --git a/src/app/shared/navbar/navbar.component.ts b/src/app/navbar/navbar.component.ts similarity index 100% rename from src/app/shared/navbar/navbar.component.ts rename to src/app/navbar/navbar.component.ts diff --git a/src/app/shared/navbar/navbar.module.ts b/src/app/navbar/navbar.module.ts similarity index 81% rename from src/app/shared/navbar/navbar.module.ts rename to src/app/navbar/navbar.module.ts index 2a0c0d30..3f075901 100644 --- a/src/app/shared/navbar/navbar.module.ts +++ b/src/app/navbar/navbar.module.ts @@ -5,10 +5,10 @@ import { CommonModule } from '@angular/common'; import { NavbarComponent } from './navbar.component'; // Modules -import { SharedModule } from '../shared.module'; +import { SharedModule } from '../shared/shared.module'; // Services -import { RestService } from '../_services/rest.service'; +import { RestService } from '../shared/services/rest.service'; import { RouterModule } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; diff --git a/src/app/profiles/profiles.component.html b/src/app/profiles/profiles.component.html new file mode 100644 index 00000000..f5bb37f9 --- /dev/null +++ b/src/app/profiles/profiles.component.html @@ -0,0 +1 @@ +

profiles works!

diff --git a/src/app/profiles/profiles.component.scss b/src/app/profiles/profiles.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/app/profiles/profiles.component.spec.ts b/src/app/profiles/profiles.component.spec.ts new file mode 100644 index 00000000..491f1251 --- /dev/null +++ b/src/app/profiles/profiles.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProfilesComponent } from './profiles.component'; + +describe('ProfilesComponent', () => { + let component: ProfilesComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ProfilesComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ProfilesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/profiles/profiles.component.ts b/src/app/profiles/profiles.component.ts new file mode 100644 index 00000000..97cd49c5 --- /dev/null +++ b/src/app/profiles/profiles.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-profiles', + templateUrl: './profiles.component.html', + styleUrls: ['./profiles.component.scss'] +}) +export class ProfilesComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/shared/alert/alert.component.ts b/src/app/shared/alert/alert.component.ts index 1a4a2072..d6b0dca1 100644 --- a/src/app/shared/alert/alert.component.ts +++ b/src/app/shared/alert/alert.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { AlertService } from '../_services/alert.service'; +import { AlertService } from '../services/alert.service'; @Component({ selector: 'app-alert', @@ -8,7 +8,7 @@ import { AlertService } from '../_services/alert.service'; }) export class AlertComponent implements OnInit { - constructor(public alertService: AlertService) {} + constructor(public alertService: AlertService) { } ngOnInit() { } diff --git a/src/app/shared/form/form-body-application/form-body-application.component.ts b/src/app/shared/form/form-body-application/form-body-application.component.ts index ee084370..0f5e2f8e 100644 --- a/src/app/shared/form/form-body-application/form-body-application.component.ts +++ b/src/app/shared/form/form-body-application/form-body-application.component.ts @@ -4,10 +4,10 @@ import { Subscription } from 'rxjs'; import { TranslateService } from '@ngx-translate/core'; -import { RestService } from '../../_services/rest.service'; +import { RestService } from '../../services/rest.service'; import { Application } from 'src/app/models/application'; -import { ApplicationService } from '../../_services/application.service'; +import { ApplicationService } from '../../services/application.service'; import { HttpErrorResponse } from '@angular/common/http'; export class User { diff --git a/src/app/shared/form/form-body-iot-devices/form-body-iot-devices.component.ts b/src/app/shared/form/form-body-iot-devices/form-body-iot-devices.component.ts index a8d0b272..8bf20723 100644 --- a/src/app/shared/form/form-body-iot-devices/form-body-iot-devices.component.ts +++ b/src/app/shared/form/form-body-iot-devices/form-body-iot-devices.component.ts @@ -7,9 +7,9 @@ import { TranslateService } from '@ngx-translate/core'; import { Application } from 'src/app/models/application'; import { IotDevice } from 'src/app/models/iot-device'; import { Subscription } from 'rxjs'; -import { IoTDeviceService } from '../../_services/iot-device.service'; +import { IoTDeviceService } from '../../services/iot-device.service'; import { HttpErrorResponse } from '@angular/common/http'; -import { ApplicationService } from '../../_services/application.service'; +import { ApplicationService } from '../../services/application.service'; @Component({ selector: 'app-form-body-iot-devices', diff --git a/src/app/shared/_services/alert.service.spec.ts b/src/app/shared/services/alert.service.spec.ts similarity index 100% rename from src/app/shared/_services/alert.service.spec.ts rename to src/app/shared/services/alert.service.spec.ts diff --git a/src/app/shared/_services/alert.service.ts b/src/app/shared/services/alert.service.ts similarity index 100% rename from src/app/shared/_services/alert.service.ts rename to src/app/shared/services/alert.service.ts diff --git a/src/app/shared/_services/application.service.spec.ts b/src/app/shared/services/application.service.spec.ts similarity index 100% rename from src/app/shared/_services/application.service.spec.ts rename to src/app/shared/services/application.service.spec.ts diff --git a/src/app/shared/_services/application.service.ts b/src/app/shared/services/application.service.ts similarity index 100% rename from src/app/shared/_services/application.service.ts rename to src/app/shared/services/application.service.ts diff --git a/src/app/shared/_services/iot-device.service.spec.ts b/src/app/shared/services/iot-device.service.spec.ts similarity index 100% rename from src/app/shared/_services/iot-device.service.spec.ts rename to src/app/shared/services/iot-device.service.spec.ts diff --git a/src/app/shared/_services/iot-device.service.ts b/src/app/shared/services/iot-device.service.ts similarity index 100% rename from src/app/shared/_services/iot-device.service.ts rename to src/app/shared/services/iot-device.service.ts diff --git a/src/app/shared/_services/rest.service.spec.ts b/src/app/shared/services/rest.service.spec.ts similarity index 100% rename from src/app/shared/_services/rest.service.spec.ts rename to src/app/shared/services/rest.service.spec.ts diff --git a/src/app/shared/_services/rest.service.ts b/src/app/shared/services/rest.service.ts similarity index 99% rename from src/app/shared/_services/rest.service.ts rename to src/app/shared/services/rest.service.ts index 4b44af66..48498be6 100644 --- a/src/app/shared/_services/rest.service.ts +++ b/src/app/shared/services/rest.service.ts @@ -18,7 +18,7 @@ interface IHttpOptions { withCredentials?: boolean; } -@Injectable() +@Injectable({ providedIn: 'root' }) export class RestService { constructor( private http: HttpClient, @@ -133,7 +133,7 @@ export class RestService { catchError(this.handleError('delete', [])) ); } - + public replace( url: string, object: any, diff --git a/src/app/views/alle-iot-enheder/edit-iot-device/edit-iot-device.component.ts b/src/app/views/alle-iot-enheder/edit-iot-device/edit-iot-device.component.ts index 70550cbd..ffebe445 100644 --- a/src/app/views/alle-iot-enheder/edit-iot-device/edit-iot-device.component.ts +++ b/src/app/views/alle-iot-enheder/edit-iot-device/edit-iot-device.component.ts @@ -3,7 +3,7 @@ import { Application } from 'src/app/models/application'; import { BackButton } from 'src/app/models/back-button'; import { TranslateService } from '@ngx-translate/core'; import { ActivatedRoute } from '@angular/router'; -import { ApplicationService } from 'src/app/shared/_services/application.service'; +import { ApplicationService } from 'src/app/shared/services/application.service'; @Component({ selector: 'app-edit-iot-device', diff --git a/src/app/views/alle-iot-enheder/iot-device/iot-device.component.ts b/src/app/views/alle-iot-enheder/iot-device/iot-device.component.ts index b08c02b2..d595ec33 100644 --- a/src/app/views/alle-iot-enheder/iot-device/iot-device.component.ts +++ b/src/app/views/alle-iot-enheder/iot-device/iot-device.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Subscription } from 'rxjs'; -import { IoTDeviceService } from 'src/app/shared/_services/iot-device.service'; +import { IoTDeviceService } from 'src/app/shared/services/iot-device.service'; import { TranslateService } from '@ngx-translate/core'; import { Application } from 'src/app/models/application'; import { IotDevice } from '../../../models/iot-device'; diff --git a/src/app/views/alle-iot-enheder/iot-devices-table-row/iot-devices-table-row.component.ts b/src/app/views/alle-iot-enheder/iot-devices-table-row/iot-devices-table-row.component.ts index 4418852c..60eb7c48 100644 --- a/src/app/views/alle-iot-enheder/iot-devices-table-row/iot-devices-table-row.component.ts +++ b/src/app/views/alle-iot-enheder/iot-devices-table-row/iot-devices-table-row.component.ts @@ -2,9 +2,9 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { IotDevice } from 'src/app/models/iot-device'; import { TranslateService } from '@ngx-translate/core'; import { Router } from '@angular/router'; -import * as moment from 'moment'; +import * as moment from 'moment'; import 'moment/locale/da'; -import { IoTDeviceService } from '../../../shared/_services/iot-device.service'; +import { IoTDeviceService } from '../../../shared/services/iot-device.service'; @Component({ selector: 'tr[app-iot-devices-table-row]', @@ -20,24 +20,24 @@ export class IotDevicesTableRowComponent implements OnInit { public iotDeviceService: IoTDeviceService, public translate: TranslateService, private router: Router - ) { - translate.use('da'); - moment.locale('da') + ) { + translate.use('da'); + moment.locale('da') } - ngOnInit(): void {} + ngOnInit(): void { } clickDelete() { const id = this.device.id; this.iotDeviceService.deleteIoTDevice(id).subscribe((response) => { - if (response.ok && response.body.affected > 0) { - this.deleteDevice.emit(id); - } + if (response.ok && response.body.affected > 0) { + this.deleteDevice.emit(id); + } }); } navigateToEditPage() { - this.router.navigate(['edit-iot-device', this.device.id]); + this.router.navigate(['edit-iot-device', this.device.id]); } lastActive() { diff --git a/src/app/views/alle-iot-enheder/iot-devices-table/iot-devices-table.component.ts b/src/app/views/alle-iot-enheder/iot-devices-table/iot-devices-table.component.ts index 12d57aea..9e531570 100644 --- a/src/app/views/alle-iot-enheder/iot-devices-table/iot-devices-table.component.ts +++ b/src/app/views/alle-iot-enheder/iot-devices-table/iot-devices-table.component.ts @@ -3,7 +3,7 @@ import { Subscription, Observable } from 'rxjs'; import { TranslateService } from '@ngx-translate/core'; -import { RestService } from 'src/app/shared/_services/rest.service'; +import { RestService } from 'src/app/shared/services/rest.service'; import { IotDevice } from 'src/app/models/iot-device'; import { Sort } from 'src/app/models/sort'; @@ -30,7 +30,7 @@ export class IotDevicesTableComponent implements OnInit, OnChanges, OnDestroy { translate.use('da'); } - ngOnInit(): void {} + ngOnInit(): void { } ngOnChanges() { this.getDevices(); @@ -43,7 +43,7 @@ export class IotDevicesTableComponent implements OnInit, OnChanges, OnDestroy { this.iotDevices = application.iotDevices; }); } - + deleteDevice(id: number): void { this.getDevices(); } diff --git a/src/app/views/my-applications/application/application.component.ts b/src/app/views/my-applications/application/application.component.ts index 1ef08f04..1c156740 100644 --- a/src/app/views/my-applications/application/application.component.ts +++ b/src/app/views/my-applications/application/application.component.ts @@ -8,7 +8,7 @@ import { Application } from 'src/app/models/application'; import { Sort } from 'src/app/models/sort'; import { QuickActionButton } from 'src/app/models/quick-action-button'; import { IotDevice } from 'src/app/models/iot-device'; -import { ApplicationService } from '../../../shared/_services/application.service'; +import { ApplicationService } from '../../../shared/services/application.service'; import { BackButton } from 'src/app/models/back-button'; @Component({ diff --git a/src/app/views/my-applications/applications-table/applications-table.component.ts b/src/app/views/my-applications/applications-table/applications-table.component.ts index c60eae69..95228f69 100644 --- a/src/app/views/my-applications/applications-table/applications-table.component.ts +++ b/src/app/views/my-applications/applications-table/applications-table.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy, Input, OnChanges } from '@angular/core'; import { Subscription, Observable } from 'rxjs'; import { TranslateService } from '@ngx-translate/core'; -import { ApplicationService } from 'src/app/shared/_services/application.service'; +import { ApplicationService } from 'src/app/shared/services/application.service'; import { Application } from 'src/app/models/application'; import { Sort } from 'src/app/models/sort'; From 2c3c2049a2a33b024ed65ab9255e1d8a00936fda Mon Sep 17 00:00:00 2001 From: Allan Asp Christensen Date: Mon, 31 Aug 2020 13:13:08 +0200 Subject: [PATCH 4/9] refactor my-applications --- src/app/app-routing.module.ts | 8 ++++---- src/app/app.module.ts | 2 +- .../application/application.component.html | 0 .../application/application.component.scss | 0 .../application/application.component.spec.ts | 0 .../my-applications/application/application.component.ts | 2 +- .../applications-table-row.component.html | 0 .../applications-table-row.component.scss | 0 .../applications-table-row.component.spec.ts | 0 .../applications-table-row.component.ts | 0 .../applications-table/applications-table.component.html | 0 .../applications-table/applications-table.component.scss | 0 .../applications-table.component.spec.ts | 0 .../applications-table/applications-table.component.ts | 0 .../edit-application/edit-application.component.html | 0 .../edit-application/edit-application.component.scss | 0 .../edit-application/edit-application.component.spec.ts | 0 .../edit-application/edit-application.component.ts | 0 .../list-applications/list-applications.component.html | 0 .../list-applications/list-applications.component.scss | 0 .../list-applications/list-applications.component.spec.ts | 0 .../list-applications/list-applications.component.ts | 0 .../my-applications/my-applications.component.html | 0 .../my-applications/my-applications.component.scss | 0 .../my-applications/my-applications.component.spec.ts | 0 .../my-applications/my-applications.component.ts | 0 .../{views => }/my-applications/my-applications.module.ts | 6 +++--- 27 files changed, 9 insertions(+), 9 deletions(-) rename src/app/{views => }/my-applications/application/application.component.html (100%) rename src/app/{views => }/my-applications/application/application.component.scss (100%) rename src/app/{views => }/my-applications/application/application.component.spec.ts (100%) rename src/app/{views => }/my-applications/application/application.component.ts (98%) rename src/app/{views => }/my-applications/applications-table/applications-table-row/applications-table-row.component.html (100%) rename src/app/{views => }/my-applications/applications-table/applications-table-row/applications-table-row.component.scss (100%) rename src/app/{views => }/my-applications/applications-table/applications-table-row/applications-table-row.component.spec.ts (100%) rename src/app/{views => }/my-applications/applications-table/applications-table-row/applications-table-row.component.ts (100%) rename src/app/{views => }/my-applications/applications-table/applications-table.component.html (100%) rename src/app/{views => }/my-applications/applications-table/applications-table.component.scss (100%) rename src/app/{views => }/my-applications/applications-table/applications-table.component.spec.ts (100%) rename src/app/{views => }/my-applications/applications-table/applications-table.component.ts (100%) rename src/app/{views => }/my-applications/edit-application/edit-application.component.html (100%) rename src/app/{views => }/my-applications/edit-application/edit-application.component.scss (100%) rename src/app/{views => }/my-applications/edit-application/edit-application.component.spec.ts (100%) rename src/app/{views => }/my-applications/edit-application/edit-application.component.ts (100%) rename src/app/{views => }/my-applications/list-applications/list-applications.component.html (100%) rename src/app/{views => }/my-applications/list-applications/list-applications.component.scss (100%) rename src/app/{views => }/my-applications/list-applications/list-applications.component.spec.ts (100%) rename src/app/{views => }/my-applications/list-applications/list-applications.component.ts (100%) rename src/app/{views => }/my-applications/my-applications.component.html (100%) rename src/app/{views => }/my-applications/my-applications.component.scss (100%) rename src/app/{views => }/my-applications/my-applications.component.spec.ts (100%) rename src/app/{views => }/my-applications/my-applications.component.ts (100%) rename src/app/{views => }/my-applications/my-applications.module.ts (86%) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index a6d2aff5..88198d39 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,10 +1,10 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { DashboardComponent } from './views/dashboard/dashboard/dashboard.component'; -import { MyApplicationsComponent } from './views/my-applications/my-applications.component'; -import { EditApplicationComponent } from './views/my-applications/edit-application/edit-application.component'; -import { ListApplicationsComponent } from './views/my-applications/list-applications/list-applications.component'; -import { ApplicationComponent } from './views/my-applications/application/application.component'; +import { MyApplicationsComponent } from './my-applications/my-applications.component'; +import { EditApplicationComponent } from './my-applications/edit-application/edit-application.component'; +import { ListApplicationsComponent } from './my-applications/list-applications/list-applications.component'; +import { ApplicationComponent } from './my-applications/application/application.component'; import { IoTDeviceComponent } from './views/alle-iot-enheder/iot-device/iot-device.component'; import { EditIotDeviceComponent } from './views/alle-iot-enheder/edit-iot-device/edit-iot-device.component'; import { ProfilesComponent } from './profiles/profiles.component'; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5b12bd84..42295fd1 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -9,7 +9,7 @@ import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { DashboardModule } from './views/dashboard/dashboard.module'; -import { MineApplikationerModule } from './views/my-applications/my-applications.module'; +import { MineApplikationerModule } from './my-applications/my-applications.module'; import { AlleIotEnhederModule } from './views/alle-iot-enheder/alle-iot-enheder.module'; import { NavbarModule } from './navbar/navbar.module'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; diff --git a/src/app/views/my-applications/application/application.component.html b/src/app/my-applications/application/application.component.html similarity index 100% rename from src/app/views/my-applications/application/application.component.html rename to src/app/my-applications/application/application.component.html diff --git a/src/app/views/my-applications/application/application.component.scss b/src/app/my-applications/application/application.component.scss similarity index 100% rename from src/app/views/my-applications/application/application.component.scss rename to src/app/my-applications/application/application.component.scss diff --git a/src/app/views/my-applications/application/application.component.spec.ts b/src/app/my-applications/application/application.component.spec.ts similarity index 100% rename from src/app/views/my-applications/application/application.component.spec.ts rename to src/app/my-applications/application/application.component.spec.ts diff --git a/src/app/views/my-applications/application/application.component.ts b/src/app/my-applications/application/application.component.ts similarity index 98% rename from src/app/views/my-applications/application/application.component.ts rename to src/app/my-applications/application/application.component.ts index 1c156740..d68530b4 100644 --- a/src/app/views/my-applications/application/application.component.ts +++ b/src/app/my-applications/application/application.component.ts @@ -8,7 +8,7 @@ import { Application } from 'src/app/models/application'; import { Sort } from 'src/app/models/sort'; import { QuickActionButton } from 'src/app/models/quick-action-button'; import { IotDevice } from 'src/app/models/iot-device'; -import { ApplicationService } from '../../../shared/services/application.service'; +import { ApplicationService } from '../../shared/services/application.service'; import { BackButton } from 'src/app/models/back-button'; @Component({ diff --git a/src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.html b/src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.html similarity index 100% rename from src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.html rename to src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.html diff --git a/src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.scss b/src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.scss similarity index 100% rename from src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.scss rename to src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.scss diff --git a/src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.spec.ts b/src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.spec.ts similarity index 100% rename from src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.spec.ts rename to src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.spec.ts diff --git a/src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.ts b/src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.ts similarity index 100% rename from src/app/views/my-applications/applications-table/applications-table-row/applications-table-row.component.ts rename to src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.ts diff --git a/src/app/views/my-applications/applications-table/applications-table.component.html b/src/app/my-applications/applications-table/applications-table.component.html similarity index 100% rename from src/app/views/my-applications/applications-table/applications-table.component.html rename to src/app/my-applications/applications-table/applications-table.component.html diff --git a/src/app/views/my-applications/applications-table/applications-table.component.scss b/src/app/my-applications/applications-table/applications-table.component.scss similarity index 100% rename from src/app/views/my-applications/applications-table/applications-table.component.scss rename to src/app/my-applications/applications-table/applications-table.component.scss diff --git a/src/app/views/my-applications/applications-table/applications-table.component.spec.ts b/src/app/my-applications/applications-table/applications-table.component.spec.ts similarity index 100% rename from src/app/views/my-applications/applications-table/applications-table.component.spec.ts rename to src/app/my-applications/applications-table/applications-table.component.spec.ts diff --git a/src/app/views/my-applications/applications-table/applications-table.component.ts b/src/app/my-applications/applications-table/applications-table.component.ts similarity index 100% rename from src/app/views/my-applications/applications-table/applications-table.component.ts rename to src/app/my-applications/applications-table/applications-table.component.ts diff --git a/src/app/views/my-applications/edit-application/edit-application.component.html b/src/app/my-applications/edit-application/edit-application.component.html similarity index 100% rename from src/app/views/my-applications/edit-application/edit-application.component.html rename to src/app/my-applications/edit-application/edit-application.component.html diff --git a/src/app/views/my-applications/edit-application/edit-application.component.scss b/src/app/my-applications/edit-application/edit-application.component.scss similarity index 100% rename from src/app/views/my-applications/edit-application/edit-application.component.scss rename to src/app/my-applications/edit-application/edit-application.component.scss diff --git a/src/app/views/my-applications/edit-application/edit-application.component.spec.ts b/src/app/my-applications/edit-application/edit-application.component.spec.ts similarity index 100% rename from src/app/views/my-applications/edit-application/edit-application.component.spec.ts rename to src/app/my-applications/edit-application/edit-application.component.spec.ts diff --git a/src/app/views/my-applications/edit-application/edit-application.component.ts b/src/app/my-applications/edit-application/edit-application.component.ts similarity index 100% rename from src/app/views/my-applications/edit-application/edit-application.component.ts rename to src/app/my-applications/edit-application/edit-application.component.ts diff --git a/src/app/views/my-applications/list-applications/list-applications.component.html b/src/app/my-applications/list-applications/list-applications.component.html similarity index 100% rename from src/app/views/my-applications/list-applications/list-applications.component.html rename to src/app/my-applications/list-applications/list-applications.component.html diff --git a/src/app/views/my-applications/list-applications/list-applications.component.scss b/src/app/my-applications/list-applications/list-applications.component.scss similarity index 100% rename from src/app/views/my-applications/list-applications/list-applications.component.scss rename to src/app/my-applications/list-applications/list-applications.component.scss diff --git a/src/app/views/my-applications/list-applications/list-applications.component.spec.ts b/src/app/my-applications/list-applications/list-applications.component.spec.ts similarity index 100% rename from src/app/views/my-applications/list-applications/list-applications.component.spec.ts rename to src/app/my-applications/list-applications/list-applications.component.spec.ts diff --git a/src/app/views/my-applications/list-applications/list-applications.component.ts b/src/app/my-applications/list-applications/list-applications.component.ts similarity index 100% rename from src/app/views/my-applications/list-applications/list-applications.component.ts rename to src/app/my-applications/list-applications/list-applications.component.ts diff --git a/src/app/views/my-applications/my-applications.component.html b/src/app/my-applications/my-applications.component.html similarity index 100% rename from src/app/views/my-applications/my-applications.component.html rename to src/app/my-applications/my-applications.component.html diff --git a/src/app/views/my-applications/my-applications.component.scss b/src/app/my-applications/my-applications.component.scss similarity index 100% rename from src/app/views/my-applications/my-applications.component.scss rename to src/app/my-applications/my-applications.component.scss diff --git a/src/app/views/my-applications/my-applications.component.spec.ts b/src/app/my-applications/my-applications.component.spec.ts similarity index 100% rename from src/app/views/my-applications/my-applications.component.spec.ts rename to src/app/my-applications/my-applications.component.spec.ts diff --git a/src/app/views/my-applications/my-applications.component.ts b/src/app/my-applications/my-applications.component.ts similarity index 100% rename from src/app/views/my-applications/my-applications.component.ts rename to src/app/my-applications/my-applications.component.ts diff --git a/src/app/views/my-applications/my-applications.module.ts b/src/app/my-applications/my-applications.module.ts similarity index 86% rename from src/app/views/my-applications/my-applications.module.ts rename to src/app/my-applications/my-applications.module.ts index 28125bb9..5b3ca245 100644 --- a/src/app/views/my-applications/my-applications.module.ts +++ b/src/app/my-applications/my-applications.module.ts @@ -4,8 +4,8 @@ import { RouterModule } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; -import { TopBarModule } from 'src/app/shared/top-bar/top-bar.module'; -import { FormModule } from 'src/app/shared/form/form.module'; +import { TopBarModule } from '../shared/top-bar/top-bar.module'; +import { FormModule } from '../shared/form/form.module'; import { MyApplicationsComponent } from './my-applications.component'; import { ApplicationComponent } from './application/application.component'; @@ -13,7 +13,7 @@ import { ApplicationsTableComponent } from './applications-table/applications-ta import { ApplicationsTableRowComponent } from './applications-table/applications-table-row/applications-table-row.component'; import { EditApplicationComponent } from './edit-application/edit-application.component'; import { ListApplicationsComponent } from './list-applications/list-applications.component'; -import { AlleIotEnhederModule } from '../alle-iot-enheder/alle-iot-enheder.module'; +import { AlleIotEnhederModule } from '../views/alle-iot-enheder/alle-iot-enheder.module'; @NgModule({ declarations: [ From 78c7be96237bff52cdc2525624f283b4b6858ab4 Mon Sep 17 00:00:00 2001 From: Allan Asp Christensen Date: Wed, 2 Sep 2020 15:54:54 +0200 Subject: [PATCH 5/9] Service profiles with ngrx --- package-lock.json | 118 ++++++++- package.json | 5 + src/app/app-routing.module.ts | 4 +- src/app/app.module.ts | 17 +- src/app/logging.service.ts | 12 + .../application/application.component.html | 2 +- .../applications-table.component.html | 10 +- src/app/navbar/navbar.component.html | 6 +- src/app/profiles/profiles-routing.module.ts | 31 +++ src/app/profiles/profiles.component.html | 12 +- src/app/profiles/profiles.component.ts | 9 +- src/app/profiles/profiles.module.ts | 23 ++ .../service-profiles/service-profile.model.ts | 31 +++ .../service-profile.service.ts | 42 +++ .../service-profile-item.component.html | 5 + .../service-profile-item.component.scss} | 0 .../service-profile-item.component.spec.ts} | 12 +- .../service-profile-item.component.ts | 18 ++ .../service-profiles-list.component.html | 13 + .../service-profiles-list.component.scss | 0 .../service-profiles-list.component.ts | 50 ++++ .../service-profiles-resolver.service.ts | 42 +++ .../service-profiles.component.html | 0 .../service-profiles.component.ts | 14 + .../store/service-profile.actions.ts | 50 ++++ .../store/service-profile.effects.ts | 61 +++++ .../store/service-profile.reducer.ts | 50 ++++ src/app/shared/services/iot-device.service.ts | 4 +- src/app/shared/shared.module.ts | 4 +- src/app/store/app.reducer.ts | 11 + src/environments/environment.ts | 2 +- tsconfig.json | 3 +- tslint.json | 250 ++++++++++-------- 33 files changed, 771 insertions(+), 140 deletions(-) create mode 100644 src/app/logging.service.ts create mode 100644 src/app/profiles/profiles-routing.module.ts create mode 100644 src/app/profiles/profiles.module.ts create mode 100644 src/app/profiles/service-profiles/service-profile.model.ts create mode 100644 src/app/profiles/service-profiles/service-profile.service.ts create mode 100644 src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html rename src/app/profiles/{profiles.component.scss => service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.scss} (100%) rename src/app/profiles/{profiles.component.spec.ts => service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.spec.ts} (50%) create mode 100644 src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.ts create mode 100644 src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html create mode 100644 src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.scss create mode 100644 src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts create mode 100644 src/app/profiles/service-profiles/service-profiles-resolver.service.ts create mode 100644 src/app/profiles/service-profiles/service-profiles.component.html create mode 100644 src/app/profiles/service-profiles/service-profiles.component.ts create mode 100644 src/app/profiles/service-profiles/store/service-profile.actions.ts create mode 100644 src/app/profiles/service-profiles/store/service-profile.effects.ts create mode 100644 src/app/profiles/service-profiles/store/service-profile.reducer.ts create mode 100644 src/app/store/app.reducer.ts diff --git a/package-lock.json b/package-lock.json index 968b2a0b..dd9b93b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2036,6 +2036,68 @@ } } }, + "@ngrx/effects": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@ngrx/effects/-/effects-10.0.0.tgz", + "integrity": "sha512-HHcQQ6mj1Cd0rQgnX5Wp3f7G8PKhh+Rk+jofsOsE6aHQPuuNhmnDwSA1U4PT4sXNv6JmFi5GjUqBz+tuw83oFQ==", + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==" + } + } + }, + "@ngrx/router-store": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@ngrx/router-store/-/router-store-10.0.0.tgz", + "integrity": "sha512-naK+IlgTQNEWWlKndQIBS/EQZ2h3pRF4owF+4kVpn+OI5Il7+Nugf0spj+0IFGd21Z7YvBe9C54SQPOPP4HARg==", + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==" + } + } + }, + "@ngrx/store": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@ngrx/store/-/store-10.0.0.tgz", + "integrity": "sha512-+mhTGJXjc+55KI1pWV5SSuP+JBAr35U1AbnBYJqqXuwJVXnJ8+n6gAr06qpPN+YMf+zRQDFwAIrqyFOfMqeJHg==", + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==" + } + } + }, + "@ngrx/store-devtools": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@ngrx/store-devtools/-/store-devtools-10.0.0.tgz", + "integrity": "sha512-+7SSPW9H+IdGX04QYmfgqYOeFM++PLD6CxGRUkIIc+6jFovanMS6CVKw6V+WeerPwoZaRn43cMIDj9FChMQ4oA==", + "dev": true, + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==", + "dev": true + } + } + }, "@ngtools/webpack": { "version": "9.1.9", "resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-9.1.9.tgz", @@ -2632,7 +2694,6 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, "requires": { "sprintf-js": "~1.0.2" } @@ -3290,6 +3351,11 @@ "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "dev": true }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, "builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", @@ -3689,8 +3755,7 @@ "commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" }, "commondir": { "version": "1.0.1", @@ -4636,8 +4701,7 @@ "diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" }, "diffie-hellman": { "version": "5.0.3", @@ -5296,8 +5360,7 @@ "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, "esquery": { "version": "1.3.1", @@ -6023,7 +6086,6 @@ "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -7348,7 +7410,6 @@ "version": "3.14.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", - "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -8346,7 +8407,6 @@ "version": "0.5.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, "requires": { "minimist": "^1.2.5" } @@ -12016,8 +12076,7 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" }, "sshpk": { "version": "1.16.1", @@ -12716,12 +12775,47 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" }, + "tslint": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", + "integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.3", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.13.0", + "tsutils": "^2.29.0" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + } + } + }, "tslint-config-prettier": { "version": "1.18.0", "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz", "integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==", "dev": true }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, "tty-browserify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", diff --git a/package.json b/package.json index 63fff09b..70b58437 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,9 @@ "@fortawesome/fontawesome-free": "^5.13.1", "@ng-bootstrap/ng-bootstrap": "^6.1.0", "@ng-bootstrap/schematics": "^2.0.0-alpha.1", + "@ngrx/effects": "^10.0.0", + "@ngrx/router-store": "^10.0.0", + "@ngrx/store": "^10.0.0", "@ngx-translate/core": "^13.0.0", "@ngx-translate/http-loader": "^6.0.0", "all": "0.0.0", @@ -33,12 +36,14 @@ "popper.js": "^1.16.0", "rxjs": "~6.5.4", "tslib": "^1.10.0", + "tslint": "^6.1.3", "zone.js": "~0.10.2" }, "devDependencies": { "@angular-devkit/build-angular": "^0.901.9", "@angular/cli": "~9.1.9", "@angular/compiler-cli": "~9.1.11", + "@ngrx/store-devtools": "^10.0.0", "@types/jasmine": "~3.5.0", "@types/jasminewd2": "~2.0.3", "@types/node": "^12.11.1", diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 88198d39..74eb31ce 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -8,6 +8,7 @@ import { ApplicationComponent } from './my-applications/application/application. import { IoTDeviceComponent } from './views/alle-iot-enheder/iot-device/iot-device.component'; import { EditIotDeviceComponent } from './views/alle-iot-enheder/edit-iot-device/edit-iot-device.component'; import { ProfilesComponent } from './profiles/profiles.component'; +import { AlleIotEnhederComponent } from './views/alle-iot-enheder/alle-iot-enheder/alle-iot-enheder.component'; const routes: Routes = [ { path: 'home', component: DashboardComponent }, @@ -44,7 +45,8 @@ const routes: Routes = [ }, ], }, - { path: 'profiles', component: ProfilesComponent }, + { path: 'iot-devices', component: AlleIotEnhederComponent }, + { path: 'profiles', loadChildren: () => import('./profiles/profiles.module').then(m => m.ProfilesModule) }, { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: '**', redirectTo: '/home', pathMatch: 'full' }, ]; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 42295fd1..f60e6821 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -3,10 +3,17 @@ import { NgModule } from '@angular/core'; import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { HttpClient, HttpClientModule } from '@angular/common/http'; +import { StoreModule } from '@ngrx/store'; +import { EffectsModule } from '@ngrx/effects'; +import { StoreDevtoolsModule } from '@ngrx/store-devtools'; +import { StoreRouterConnectingModule } from '@ngrx/router-store'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; +import { appReducer } from './store/app.reducer'; +import { ServiceProfileEffects } from './profiles/service-profiles/store/service-profile.effects'; +import { environment } from '../environments/environment'; import { DashboardModule } from './views/dashboard/dashboard.module'; import { MineApplikationerModule } from './my-applications/my-applications.module'; @@ -15,6 +22,8 @@ import { NavbarModule } from './navbar/navbar.module'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { ReactiveFormsModule } from '@angular/forms'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { LoggingService } from './logging.service'; +import { ProfilesModule } from './profiles/profiles.module'; export function HttpLoaderFactory(http: HttpClient) { return new TranslateHttpLoader(http, './assets/i18n/', '.json'); @@ -30,6 +39,11 @@ export function HttpLoaderFactory(http: HttpClient) { MineApplikationerModule, AlleIotEnhederModule, NavbarModule, + ProfilesModule, + StoreModule.forRoot(appReducer, { runtimeChecks: {} }), + EffectsModule.forRoot([ServiceProfileEffects]), + StoreDevtoolsModule.instrument({ logOnly: environment.production }), + StoreRouterConnectingModule.forRoot(), TranslateModule.forRoot({ defaultLanguage: 'da', loader: { @@ -41,8 +55,9 @@ export function HttpLoaderFactory(http: HttpClient) { NgbModule, ReactiveFormsModule, BrowserAnimationsModule, + StoreModule.forRoot({}, {}), ], - providers: [], + providers: [LoggingService], bootstrap: [AppComponent], exports: [TranslateModule], }) diff --git a/src/app/logging.service.ts b/src/app/logging.service.ts new file mode 100644 index 00000000..0aec60c6 --- /dev/null +++ b/src/app/logging.service.ts @@ -0,0 +1,12 @@ +import { Injectable } from '@angular/core'; + +// @Injectable({ providedIn: 'root' }) +export class LoggingService { + lastlog: string; + + printLog(message: string) { + console.log(message); + console.log(this.lastlog); + this.lastlog = message; + } +} diff --git a/src/app/my-applications/application/application.component.html b/src/app/my-applications/application/application.component.html index 9fec3f70..26eae0bd 100644 --- a/src/app/my-applications/application/application.component.html +++ b/src/app/my-applications/application/application.component.html @@ -20,4 +20,4 @@

{{ 'APPLICATION.DESCRIPTION' | translate }}

- + \ No newline at end of file diff --git a/src/app/my-applications/applications-table/applications-table.component.html b/src/app/my-applications/applications-table/applications-table.component.html index 4e570ab7..3f6173a1 100644 --- a/src/app/my-applications/applications-table/applications-table.component.html +++ b/src/app/my-applications/applications-table/applications-table.component.html @@ -7,8 +7,8 @@ - + @@ -16,7 +16,9 @@ + \ No newline at end of file diff --git a/src/app/navbar/navbar.component.html b/src/app/navbar/navbar.component.html index 7d7013a1..2048ed8b 100644 --- a/src/app/navbar/navbar.component.html +++ b/src/app/navbar/navbar.component.html @@ -23,15 +23,15 @@ diff --git a/src/app/profiles/profiles-routing.module.ts b/src/app/profiles/profiles-routing.module.ts new file mode 100644 index 00000000..16b1accd --- /dev/null +++ b/src/app/profiles/profiles-routing.module.ts @@ -0,0 +1,31 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { ProfilesComponent } from './profiles.component'; + + +const routes: Routes = [ + { + path: '', + component: ProfilesComponent, + // children: [ + // { path: '', component: RecipeStartComponent }, + // { path: 'new', component: RecipeEditComponent }, + // { + // path: ':id', + // component: RecipeDetailComponent, + // resolve: [RecipesResolverService] + // }, + // { + // path: ':id/edit', + // component: RecipeEditComponent, + // resolve: [RecipesResolverService] + // } + // ] + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class ProfilesRoutingModule { } \ No newline at end of file diff --git a/src/app/profiles/profiles.component.html b/src/app/profiles/profiles.component.html index f5bb37f9..9e089706 100644 --- a/src/app/profiles/profiles.component.html +++ b/src/app/profiles/profiles.component.html @@ -1 +1,11 @@ -

profiles works!

+
+
+ +
+
+
+
+
+ +
+
\ No newline at end of file diff --git a/src/app/profiles/profiles.component.ts b/src/app/profiles/profiles.component.ts index 97cd49c5..60cbd6b3 100644 --- a/src/app/profiles/profiles.component.ts +++ b/src/app/profiles/profiles.component.ts @@ -1,15 +1,18 @@ import { Component, OnInit } from '@angular/core'; +import { LoggingService } from '../logging.service'; @Component({ selector: 'app-profiles', - templateUrl: './profiles.component.html', - styleUrls: ['./profiles.component.scss'] + templateUrl: './profiles.component.html' }) export class ProfilesComponent implements OnInit { - constructor() { } + constructor( + private loggingService: LoggingService, + ) { } ngOnInit(): void { + this.loggingService.printLog('Profiles tapped'); } } diff --git a/src/app/profiles/profiles.module.ts b/src/app/profiles/profiles.module.ts new file mode 100644 index 00000000..3e5d85c4 --- /dev/null +++ b/src/app/profiles/profiles.module.ts @@ -0,0 +1,23 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { ServiceProfilesListComponent } from './service-profiles/service-profiles-list/service-profiles-list.component'; +import { ProfilesComponent } from './profiles.component'; +import { ProfilesRoutingModule } from './profiles-routing.module'; +import { LoggingService } from '../logging.service'; +import { ServiceProfilesComponent } from './service-profiles/service-profiles.component'; +import { ServiceProfileService } from './service-profiles/service-profile.service'; +import { ServiceProfileItemComponent } from './service-profiles/service-profiles-list/service-profile-item/service-profile-item.component'; + + + +@NgModule({ + declarations: [ProfilesComponent, ServiceProfilesListComponent, ServiceProfileItemComponent, ServiceProfilesComponent], + exports: [], + imports: [ + CommonModule, + ProfilesRoutingModule, + ], + providers: [LoggingService, ServiceProfileService] +}) +export class ProfilesModule { } diff --git a/src/app/profiles/service-profiles/service-profile.model.ts b/src/app/profiles/service-profiles/service-profile.model.ts new file mode 100644 index 00000000..77370656 --- /dev/null +++ b/src/app/profiles/service-profiles/service-profile.model.ts @@ -0,0 +1,31 @@ +export class ServiceProfile { + id: string; + name: string; + networkServerID: string; + addGWMetaData: boolean; + channelMask: string; + devStatusReqFreq: number; + dlBucketSize: number; + dlRate: number; + dlRatePolicy: string; + drMax: number; + drMin: number; + hrAllowed: boolean; + minGWDiversity: number; + nwkGeoLoc: boolean; + organizationID: string; + prAllowed: boolean; + raAllowed: boolean; + reportDevStatusBattery: boolean; + reportDevStatusMargin: boolean; + targetPER: number; + ulBucketSize: number; + ulRate: number; + ulRatePolicy: string; +} + +export interface ServiceProfileData { + data: ServiceProfile[]; + ok?: boolean; + count?: number; +} \ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profile.service.ts b/src/app/profiles/service-profiles/service-profile.service.ts new file mode 100644 index 00000000..76b44e2a --- /dev/null +++ b/src/app/profiles/service-profiles/service-profile.service.ts @@ -0,0 +1,42 @@ +import { Injectable } from '@angular/core'; +import { Subject, Observable } from 'rxjs'; + +import { ServiceProfileData, ServiceProfile } from './service-profile.model'; +import { RestService } from 'src/app/shared/services/rest.service'; + + +@Injectable() +export class ServiceProfileService { + + serviceProfileChanged = new Subject(); + + + constructor(private restService: RestService) { } + + createServiceProfile(body: any): Observable { + return this.restService.post('chirpstack/service-profiles', body, { observe: 'response' }); + } + + updateServiceProfile(body: any, id: number): Observable { + return this.restService.replace('chirpstack/service-profiles', body, id, { observe: 'response' }); + } + + getServiceProfile(id: number): Observable { + return this.restService.get('chirpstack/service-profiles', {}, id); + } + + getServiceProfiles( + limit: number, + offset: number, + ): Observable { + const body = { + limit: limit, + offset: offset, + }; + return this.restService.get('chirpstack/service-profiles', body); + } + + deleteServiceProfile(id: number) { + return this.restService.delete('chirpstack/service-profiles', id); + } +} \ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html new file mode 100644 index 00000000..52198f8e --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html @@ -0,0 +1,5 @@ + +
+

{{ serviceProfile.name }}

+
+
\ No newline at end of file diff --git a/src/app/profiles/profiles.component.scss b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.scss similarity index 100% rename from src/app/profiles/profiles.component.scss rename to src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.scss diff --git a/src/app/profiles/profiles.component.spec.ts b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.spec.ts similarity index 50% rename from src/app/profiles/profiles.component.spec.ts rename to src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.spec.ts index 491f1251..429848f3 100644 --- a/src/app/profiles/profiles.component.spec.ts +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.spec.ts @@ -1,20 +1,20 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { ProfilesComponent } from './profiles.component'; +import { ServiceProfileItemComponent } from './service-profile-item.component'; -describe('ProfilesComponent', () => { - let component: ProfilesComponent; - let fixture: ComponentFixture; +describe('ServiceProfileItemComponent', () => { + let component: ServiceProfileItemComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ProfilesComponent ] + declarations: [ ServiceProfileItemComponent ] }) .compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(ProfilesComponent); + fixture = TestBed.createComponent(ServiceProfileItemComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.ts b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.ts new file mode 100644 index 00000000..36fade2c --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.ts @@ -0,0 +1,18 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { ServiceProfile } from '../../service-profile.model'; + +@Component({ + selector: 'app-service-profile-item', + templateUrl: './service-profile-item.component.html', + styleUrls: ['./service-profile-item.component.scss'] +}) +export class ServiceProfileItemComponent implements OnInit { + @Input() serviceProfile: ServiceProfile; + @Input() index: number; + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html new file mode 100644 index 00000000..737c4cf5 --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html @@ -0,0 +1,13 @@ +
+
+ + +
+
+
+
+
+ +
+
\ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.scss b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts new file mode 100644 index 00000000..897d1840 --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts @@ -0,0 +1,50 @@ +import { Component, OnInit, OnChanges, OnDestroy, Input } from '@angular/core'; +import { Subscription } from 'rxjs'; + +import { ServiceProfile } from '../service-profile.model'; +import { map } from 'rxjs/operators'; +import { Store } from '@ngrx/store'; +import * as fromApp from '../../../store/app.reducer'; + + + + +@Component({ + selector: 'app-service-profiles-list', + templateUrl: './service-profiles-list.component.html', + styleUrls: ['./service-profiles-list.component.scss'] +}) +export class ServiceProfilesListComponent implements OnInit, OnDestroy { + serviceProfiles: ServiceProfile[]; + subscription: Subscription; + public pageLimit: number = 10; + public pageOffset: number = 0; + + constructor( + private store: Store + ) { } + + ngOnInit() { + this.subscription = this.store + .select('serviceProfiles') + .pipe(map(serviceProfileState => serviceProfileState.serviceProfiles)) + .subscribe((serviceProfiles: ServiceProfile[]) => { + this.serviceProfiles = serviceProfiles; + }); + } + private fetchServiceProfiles() { + // this.shouldLoadNewHold = false; + // this.isFetching = true; + this.pageCount = this.pageCount + 1; + this.store.dispatch('serviceProfiles' ({limit: this.pageLimit})); + } + + // onNewServiceProfile() { + // this.router.navigate(['new'], { relativeTo: this.route }); + // } + + ngOnDestroy() { + this.subscription.unsubscribe(); + } + +} diff --git a/src/app/profiles/service-profiles/service-profiles-resolver.service.ts b/src/app/profiles/service-profiles/service-profiles-resolver.service.ts new file mode 100644 index 00000000..cb5c713f --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-resolver.service.ts @@ -0,0 +1,42 @@ +import { Injectable } from '@angular/core'; +import { + Resolve, + ActivatedRouteSnapshot, + RouterStateSnapshot +} from '@angular/router'; +import { Store } from '@ngrx/store'; +import { Actions, ofType } from '@ngrx/effects'; +import { take, map, switchMap } from 'rxjs/operators'; +import { of } from 'rxjs'; + +import { ServiceProfile } from './service-profile.model'; +import * as fromApp from '../../store/app.reducer'; +import * as ServiceProfileActions from './store/service-profile.actions'; + +@Injectable({ providedIn: 'root' }) +export class RecipesResolverService implements Resolve { + constructor( + private store: Store, + private actions$: Actions + ) { } + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + return this.store.select('serviceProfiles').pipe( + take(1), + map(serviceProfileState => { + return serviceProfileState.serviceProfiles; + }), + switchMap(serviceProfiles => { + if (serviceProfiles.length === 0) { + this.store.dispatch(new ServiceProfileActions.FetchServiceProfiles()); + return this.actions$.pipe( + ofType(ServiceProfileActions.SET_SERVICEPROFILES), + take(1) + ); + } else { + return of(serviceProfiles); + } + }) + ); + } +} diff --git a/src/app/profiles/service-profiles/service-profiles.component.html b/src/app/profiles/service-profiles/service-profiles.component.html new file mode 100644 index 00000000..e69de29b diff --git a/src/app/profiles/service-profiles/service-profiles.component.ts b/src/app/profiles/service-profiles/service-profiles.component.ts new file mode 100644 index 00000000..9f7e7b01 --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles.component.ts @@ -0,0 +1,14 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-service-profiles', + templateUrl: './service-profiles.component.html', +}) +export class ServiceProfilesComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/profiles/service-profiles/store/service-profile.actions.ts b/src/app/profiles/service-profiles/store/service-profile.actions.ts new file mode 100644 index 00000000..c118f6ed --- /dev/null +++ b/src/app/profiles/service-profiles/store/service-profile.actions.ts @@ -0,0 +1,50 @@ +import { Action } from '@ngrx/store'; +import { ServiceProfile } from '../service-profile.model'; + + +export const SET_SERVICEPROFILES = '[Service Profile] Set Service Profiles'; +export const FETCH_SERVICEPROFILES = '[Service Profile] Fetch Service Profiles'; +export const ADD_SERVICEPROFILE = '[Service Profile] Add Service Profile'; +export const UPDATE_SERVICEPROFILE = '[Service Profile] Update Service Profile'; +export const DELETE_SERVICEPROFILE = '[Service Profile] Delete Service Profile'; +export const STORE_SERVICEPROFILES = '[Service Profile] Store Service Profiles'; + +export class SetServiceProfiles implements Action { + readonly type = SET_SERVICEPROFILES; + + constructor(public payload: ServiceProfile[]) { } +} + +export class FetchServiceProfiles implements Action { + readonly type = FETCH_SERVICEPROFILES; +} + +export class AddServiceProfile implements Action { + readonly type = ADD_SERVICEPROFILE; + + constructor(public payload: ServiceProfile) { } +} + +export class UpdateServiceProfile implements Action { + readonly type = UPDATE_SERVICEPROFILE; + + constructor(public payload: { index: number; updateServiceProfile: ServiceProfile }) { } +} + +export class DeleteServiceProfile implements Action { + readonly type = DELETE_SERVICEPROFILE; + + constructor(public payload: number) { } +} + +export class StoreServiceProfiles implements Action { + readonly type = STORE_SERVICEPROFILES; +} + +export type ServiceProfileActions = + | SetServiceProfiles + | FetchServiceProfiles + | AddServiceProfile + | UpdateServiceProfile + | DeleteServiceProfile + | StoreServiceProfiles; diff --git a/src/app/profiles/service-profiles/store/service-profile.effects.ts b/src/app/profiles/service-profiles/store/service-profile.effects.ts new file mode 100644 index 00000000..cf0796da --- /dev/null +++ b/src/app/profiles/service-profiles/store/service-profile.effects.ts @@ -0,0 +1,61 @@ +import { Injectable } from '@angular/core'; +import { Actions, Effect, ofType } from '@ngrx/effects'; +import { Store } from '@ngrx/store'; +import { HttpClient } from '@angular/common/http'; +import { switchMap, map, withLatestFrom } from 'rxjs/operators'; + +import * as ServiceProfileActions from './service-profile.actions'; +import { ServiceProfile, ServiceProfileData } from '../service-profile.model'; +import * as fromApp from '../../../store/app.reducer'; + +import { environment } from 'src/environments/environment'; +import { RestService } from 'src/app/shared/services/rest.service'; +import { Observable } from 'rxjs'; + + + +@Injectable() +export class ServiceProfileEffects { + restService: RestService; + @Effect() + fetchServiceProfiles = this.actions$.pipe( + ofType(ServiceProfileActions.FETCH_SERVICEPROFILES), + switchMap((limit: number, offset: number): Observable => { + const body = { + limit: limit, + offset: offset, + }; + return this.restService.get('chirpstack/service-profiles', body); + + }), + map(serviceProfiles => { + return serviceProfiles.map(serviceProfile => { + return { + ...serviceProfile, + }; + }); + }), + map(serviceProfiles => { + return new ServiceProfileActions.SetServiceProfiles(serviceProfiles); + }) + ); + + @Effect({ dispatch: false }) + storeServiceProfiles = this.actions$.pipe( + ofType(ServiceProfileActions.STORE_SERVICEPROFILES), + withLatestFrom(this.store.select('serviceProfiles')), + switchMap((body: any): Observable => { + return this.restService.post( + 'chirpstack/service-profiles', + body, + { observe: 'response' } + ); + }) + ); + + constructor( + private actions$: Actions, + private http: HttpClient, + private store: Store + ) { } +} diff --git a/src/app/profiles/service-profiles/store/service-profile.reducer.ts b/src/app/profiles/service-profiles/store/service-profile.reducer.ts new file mode 100644 index 00000000..d589ef2e --- /dev/null +++ b/src/app/profiles/service-profiles/store/service-profile.reducer.ts @@ -0,0 +1,50 @@ +import { ServiceProfile } from '../service-profile.model'; +import * as ServiceProfileActions from './service-profile.actions'; + +export interface State { + serviceProfiles: ServiceProfile[]; +} + +const initialState: State = { + serviceProfiles: [], +}; + +export function serviceProfileReducer( + state = initialState, + action: ServiceProfileActions.ServiceProfileActions +) { + switch (action.type) { + case ServiceProfileActions.SET_SERVICEPROFILES: + return { + ...state, + serviceProfiles: [...action.payload], + }; + case ServiceProfileActions.ADD_SERVICEPROFILE: + return { + ...state, + serviceProfiles: [...state.serviceProfiles, action.payload] + }; + case ServiceProfileActions.UPDATE_SERVICEPROFILE: + const updatedRecipe = { + ...state.serviceProfiles[action.payload.index], + ...action.payload.updateServiceProfile + }; + + const updatedServiceProfiles = [...state.serviceProfiles]; + updatedServiceProfiles[action.payload.index] = updatedRecipe; + + return { + ...state, + serviceProfiles: updatedServiceProfiles + }; + case ServiceProfileActions.DELETE_SERVICEPROFILE: + return { + ...state, + serviceProfiles: state.serviceProfiles.filter((serviceProfile, index) => { + return index !== action.payload; + }) + }; + default: + return state; + } +} diff --git a/src/app/shared/services/iot-device.service.ts b/src/app/shared/services/iot-device.service.ts index 04b1472e..62ae62d1 100644 --- a/src/app/shared/services/iot-device.service.ts +++ b/src/app/shared/services/iot-device.service.ts @@ -7,14 +7,14 @@ import { IotDevice, IotDeviceData } from '../../models/iot-device'; providedIn: 'root', }) export class IoTDeviceService { - constructor(private restService: RestService) {} + constructor(private restService: RestService) { } createIoTDevice(body: IotDevice): Observable { return this.restService.post('iot-device', body); } updateIoTDevice(body: IotDevice, id: number): Observable { - return this.restService.replace('iot-device', body, id, {observe: 'response'}); + return this.restService.replace('iot-device', body, id, { observe: 'response' }); } getIoTDevice(id: number): Observable { diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 807a2a58..19694127 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -7,6 +7,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AlertComponent } from './alert/alert.component'; import { SearchBarComponent } from './search-bar/search-bar.component'; import { TranslateModule } from '@ngx-translate/core'; +import { LoggingService } from '../logging.service'; @NgModule({ declarations: [ @@ -23,6 +24,7 @@ import { TranslateModule } from '@ngx-translate/core'; BrowserAnimationsModule, HttpClientModule, TranslateModule - ] + ], + providers: [LoggingService] }) export class SharedModule { } diff --git a/src/app/store/app.reducer.ts b/src/app/store/app.reducer.ts new file mode 100644 index 00000000..2253ead1 --- /dev/null +++ b/src/app/store/app.reducer.ts @@ -0,0 +1,11 @@ +import { ActionReducerMap } from '@ngrx/store'; + +import * as fromServiceProfiles from '../profiles/service-profiles/store/service-profile.reducer'; + +export interface AppState { + serviceProfiles: fromServiceProfiles.State; +} + +export const appReducer: ActionReducerMap = { + serviceProfiles: fromServiceProfiles.serviceProfileReducer, +}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 37be9ad9..3049be24 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,7 +4,7 @@ export const environment = { production: false, - baseUrl: 'http://localhost:3000/api/v1/' + baseUrl: 'http://[::1]:3000/api/v1/' }; /* diff --git a/tsconfig.json b/tsconfig.json index 253b3354..ebe72c45 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,8 @@ "moduleResolution": "node", "importHelpers": true, "target": "es2015", - "lib": ["es2018", "dom"] + "lib": ["es2018", "dom"], + "typeRoots": ["node_modules/@types"] }, "angularCompilerOptions": { "fullTemplateTypeCheck": true, diff --git a/tslint.json b/tslint.json index 0a5244e8..0577aa05 100644 --- a/tslint.json +++ b/tslint.json @@ -1,107 +1,151 @@ { - "extends": [ - "tslint:recommended", - "tslint-angular", - "tslint-config-prettier" + "extends": [ + "tslint:recommended", + "tslint-angular", + "tslint-config-prettier" + ], + "rules": { + "align": { + "options": ["parameters", "statements"] + }, + "array-type": false, + "arrow-return-shorthand": true, + "callable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "component-class-suffix": true, + "component-selector": [true, "element", "app", "kebab-case"], + "curly": true, + "deprecation": { + "severity": "warning" + }, + "contextual-lifecycle": true, + "directive-class-suffix": true, + "directive-selector": [true, "attribute", "app", "camelCase"], + "eofline": true, + "forin": true, + "interface-over-type-literal": true, + "import-blacklist": [true, "rxjs/Rx"], + "import-spacing": true, + "indent": { + "options": ["spaces"] + }, + "label-position": true, + "max-classes-per-file": false, + "max-line-length": [true, 200], + "member-access": false, + "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"] + }, + "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, + "no-arg": true, + "no-bitwise": true, + "no-construct": true, + "no-debugger": true, + "no-duplicate-super": true, + "no-empty-interface": true, + "no-eval": true, + "no-misused-new": true, + "no-shadowed-variable": [ + false, + { + "class": true, + "enum": true, + "function": true, + "interface": false, + "namespace": true, + "typeAlias": false, + "typeParameter": false + } + ], + "no-string-literal": false, + "no-string-throw": true, + "no-trailing-whitespace": true, + "no-unnecessary-initializer": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" ], - "rules": { - "align": { - "options": ["parameters", "statements"] - }, - "array-type": false, - "arrow-return-shorthand": true, - "curly": true, - "deprecation": { - "severity": "warning" - }, - "component-class-suffix": true, - "contextual-lifecycle": true, - "directive-class-suffix": true, - "directive-selector": [true, "attribute", "app", "camelCase"], - "component-selector": [true, "element", "app", "kebab-case"], - "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-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" - ] - }, - "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 + "prefer-const": true, + "radix": true, + "space-before-function-paren": { + "options": { + "anonymous": "never", + "asyncArrow": "always", + "constructor": "never", + "method": "never", + "named": "never" + } + }, + "template-banana-in-box": true, + "template-no-negated-async": true, + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": { + "options": [{ + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }] + }, + "unified-signatures": true, + "use-lifecycle-interface": true, + "use-pipe-transform-interface": true, + "variable-name": { + "options": ["ban-keywords", "check-format", "allow-pascal-case"] }, - "rulesDirectory": ["codelyzer"] + "whitespace": { + "options": [ + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type", + "check-typecast", + "check-module" + ] + } + }, + "rulesDirectory": ["codelyzer"] } From df12b99ba19f8c283263018fc8d6b6d7030669ab Mon Sep 17 00:00:00 2001 From: Allan Asp Christensen Date: Wed, 2 Sep 2020 23:55:38 +0200 Subject: [PATCH 6/9] adding edit and details page --- package-lock.json | 15 +++ package.json | 1 + src/app/app.module.ts | 9 +- src/app/profiles/profiles-routing.module.ts | 31 ------ src/app/profiles/profiles.module.ts | 21 +++- .../service-profile-resolver.service.ts | 43 +++++++ .../service-profiles/service-profile.model.ts | 105 +++++++++++++----- .../service-profiles-detail.component.html | 35 ++++++ .../service-profiles-detail.component.ts | 58 ++++++++++ .../service-profiles-edit.component.html | 36 ++++++ .../service-profiles-edit.component.ts | 84 ++++++++++++++ .../service-profiles-list.component.html | 2 +- .../service-profiles-list.component.ts | 15 +-- .../service-profiles-resolver.service.ts | 8 +- .../service-profiles-routing.module.ts | 36 ++++++ .../service-profiles-start.component.html | 1 + .../service-profiles-start.component.ts | 14 +++ src/app/store/app.reducer.ts | 10 +- 18 files changed, 444 insertions(+), 80 deletions(-) delete mode 100644 src/app/profiles/profiles-routing.module.ts create mode 100644 src/app/profiles/service-profiles/service-profile-resolver.service.ts create mode 100644 src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html create mode 100644 src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts create mode 100644 src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html create mode 100644 src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts create mode 100644 src/app/profiles/service-profiles/service-profiles-routing.module.ts create mode 100644 src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.html create mode 100644 src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.ts diff --git a/package-lock.json b/package-lock.json index dd9b93b9..be332f76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4492,6 +4492,12 @@ "regexp.prototype.flags": "^1.2.0" } }, + "deep-freeze-strict": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/deep-freeze-strict/-/deep-freeze-strict-1.1.1.tgz", + "integrity": "sha1-d9BYPKJKab5LvZrC+uQV1VUj5bA=", + "dev": true + }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -8504,6 +8510,15 @@ "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", "dev": true }, + "ngrx-store-freeze": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/ngrx-store-freeze/-/ngrx-store-freeze-0.2.4.tgz", + "integrity": "sha512-90awpbbMa/x2H81eWWYniyli3LJ1PZU/FaztL10d9Rp/4kw2+97pqyLjdxSPxcOv9St//m9kfuWZ7gyoVDjgcg==", + "dev": true, + "requires": { + "deep-freeze-strict": "^1.1.1" + } + }, "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", diff --git a/package.json b/package.json index 70b58437..f54e8f47 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "karma-coverage-istanbul-reporter": "~2.1.0", "karma-jasmine": "~3.0.1", "karma-jasmine-html-reporter": "^1.4.2", + "ngrx-store-freeze": "^0.2.4", "prettier": "^2.0.5", "protractor": "~7.0.0", "ts-node": "~8.3.0", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index f60e6821..83caf061 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -11,7 +11,7 @@ import { StoreRouterConnectingModule } from '@ngrx/router-store'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; -import { appReducer } from './store/app.reducer'; +import { appReducer, metaReducers } from './store/app.reducer'; import { ServiceProfileEffects } from './profiles/service-profiles/store/service-profile.effects'; import { environment } from '../environments/environment'; @@ -40,10 +40,10 @@ export function HttpLoaderFactory(http: HttpClient) { AlleIotEnhederModule, NavbarModule, ProfilesModule, - StoreModule.forRoot(appReducer, { runtimeChecks: {} }), + StoreModule.forRoot(appReducer, { metaReducers }), + !environment.production ? StoreDevtoolsModule.instrument() : [], EffectsModule.forRoot([ServiceProfileEffects]), - StoreDevtoolsModule.instrument({ logOnly: environment.production }), - StoreRouterConnectingModule.forRoot(), + StoreRouterConnectingModule.forRoot({ stateKey: 'router' }), TranslateModule.forRoot({ defaultLanguage: 'da', loader: { @@ -55,7 +55,6 @@ export function HttpLoaderFactory(http: HttpClient) { NgbModule, ReactiveFormsModule, BrowserAnimationsModule, - StoreModule.forRoot({}, {}), ], providers: [LoggingService], bootstrap: [AppComponent], diff --git a/src/app/profiles/profiles-routing.module.ts b/src/app/profiles/profiles-routing.module.ts deleted file mode 100644 index 16b1accd..00000000 --- a/src/app/profiles/profiles-routing.module.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; -import { ProfilesComponent } from './profiles.component'; - - -const routes: Routes = [ - { - path: '', - component: ProfilesComponent, - // children: [ - // { path: '', component: RecipeStartComponent }, - // { path: 'new', component: RecipeEditComponent }, - // { - // path: ':id', - // component: RecipeDetailComponent, - // resolve: [RecipesResolverService] - // }, - // { - // path: ':id/edit', - // component: RecipeEditComponent, - // resolve: [RecipesResolverService] - // } - // ] - } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class ProfilesRoutingModule { } \ No newline at end of file diff --git a/src/app/profiles/profiles.module.ts b/src/app/profiles/profiles.module.ts index 3e5d85c4..a6c7f28a 100644 --- a/src/app/profiles/profiles.module.ts +++ b/src/app/profiles/profiles.module.ts @@ -3,20 +3,37 @@ import { CommonModule } from '@angular/common'; import { ServiceProfilesListComponent } from './service-profiles/service-profiles-list/service-profiles-list.component'; import { ProfilesComponent } from './profiles.component'; -import { ProfilesRoutingModule } from './profiles-routing.module'; +import { ProfilesRoutingModule } from './service-profiles/service-profiles-routing.module'; import { LoggingService } from '../logging.service'; import { ServiceProfilesComponent } from './service-profiles/service-profiles.component'; import { ServiceProfileService } from './service-profiles/service-profile.service'; import { ServiceProfileItemComponent } from './service-profiles/service-profiles-list/service-profile-item/service-profile-item.component'; +import { ServiceProfilesDetailComponent } from './service-profiles/service-profiles-detail/service-profiles-detail.component'; +import { ServiceProfilesEditComponent } from './service-profiles/service-profiles-edit/service-profiles-edit.component'; +import { ServiceProfilesStartComponent } from './service-profiles/service-profiles-start/service-profiles-start.component'; +import { ReactiveFormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; +import { StoreModule } from '@ngrx/store'; +import * as fromServiceProfiles from './service-profiles/store/service-profile.reducer'; @NgModule({ - declarations: [ProfilesComponent, ServiceProfilesListComponent, ServiceProfileItemComponent, ServiceProfilesComponent], + declarations: [ + ProfilesComponent, + ServiceProfilesListComponent, + ServiceProfileItemComponent, + ServiceProfilesComponent, + ServiceProfilesDetailComponent, + ServiceProfilesEditComponent, + ServiceProfilesStartComponent], exports: [], imports: [ + RouterModule, + ReactiveFormsModule, CommonModule, ProfilesRoutingModule, + StoreModule.forFeature('serviceProfiles', fromServiceProfiles.serviceProfileReducer), ], providers: [LoggingService, ServiceProfileService] }) diff --git a/src/app/profiles/service-profiles/service-profile-resolver.service.ts b/src/app/profiles/service-profiles/service-profile-resolver.service.ts new file mode 100644 index 00000000..84c4bb04 --- /dev/null +++ b/src/app/profiles/service-profiles/service-profile-resolver.service.ts @@ -0,0 +1,43 @@ +import { Injectable } from '@angular/core'; +import { + Resolve, + ActivatedRouteSnapshot, + RouterStateSnapshot +} from '@angular/router'; +import { Store } from '@ngrx/store'; +import { Actions, ofType } from '@ngrx/effects'; +import { take, map, switchMap } from 'rxjs/operators'; +import { of } from 'rxjs'; + +import { ServiceProfile } from './service-profile.model'; +import * as fromApp from '../../store/app.reducer'; +import * as ServiceProfilesActions from '../service-profiles/store/service-profile.actions'; + +@Injectable({ providedIn: 'root' }) +export class ServiceProfilesResolverService implements Resolve<{ serviceProfiles: ServiceProfile[] }> { + constructor( + private store: Store, + private actions$: Actions + ) { } + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + + return this.store.select('serviceProfiles').pipe( + take(1), + map(serviceProfilesState => { + return serviceProfilesState.serviceProfiles; + }), + switchMap(serviceProfiles => { + if (serviceProfiles.length === 0) { + this.store.dispatch(ServiceProfilesActions.fetchServiceProfiles()); + return this.actions$.pipe( + ofType(ServiceProfilesActions.setServiceProfiles), + take(1) + ); + } else { + return of({ serviceProfiles }); + } + }) + ); + } +} \ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profile.model.ts b/src/app/profiles/service-profiles/service-profile.model.ts index 77370656..3cea8e47 100644 --- a/src/app/profiles/service-profiles/service-profile.model.ts +++ b/src/app/profiles/service-profiles/service-profile.model.ts @@ -1,31 +1,80 @@ export class ServiceProfile { - id: string; - name: string; - networkServerID: string; - addGWMetaData: boolean; - channelMask: string; - devStatusReqFreq: number; - dlBucketSize: number; - dlRate: number; - dlRatePolicy: string; - drMax: number; - drMin: number; - hrAllowed: boolean; - minGWDiversity: number; - nwkGeoLoc: boolean; - organizationID: string; - prAllowed: boolean; - raAllowed: boolean; - reportDevStatusBattery: boolean; - reportDevStatusMargin: boolean; - targetPER: number; - ulBucketSize: number; - ulRate: number; - ulRatePolicy: string; + public id: string; + public name: string; + public networkServerID: string; + public addGWMetaData: boolean; + public channelMask: string; + public devStatusReqFreq: number; + public dlBucketSize: number; + public dlRate: number; + public dlRatePolicy: string; + public drMax: number; + public drMin: number; + public hrAllowed: boolean; + public minGWDiversity: number; + public nwkGeoLoc: boolean; + public organizationID: string; + public prAllowed: boolean; + public raAllowed: boolean; + public reportDevStatusBattery: boolean; + public reportDevStatusMargin: boolean; + public targetPER: number; + public ulBucketSize: number; + public ulRate: number; + public ulRatePolicy: string; + + constructor( + id: string, + name: string, + networkServerID: string, + addGWMetaData: boolean, + channelMask: string, + devStatusReqFreq: number, + dlBucketSize: number, + dlRate: number, + dlRatePolicy: string, + drMax: number, + drMin: number, + hrAllowed: boolean, + minGWDiversity: number, + nwkGeoLoc: boolean, + organizationID: string, + prAllowed: boolean, + raAllowed: boolean, + reportDevStatusBattery: boolean, + reportDevStatusMargin: boolean, + targetPER: number, + ulBucketSize: number, + ulRate: number, + ulRatePolicy: string) { + this.id = id; + this.name = name; + this.networkServerID = networkServerID; + this.addGWMetaData = addGWMetaData; + this.channelMask = channelMask; + this.devStatusReqFreq = devStatusReqFreq; + this.dlBucketSize = dlBucketSize; + this.dlRate = dlRate; + this.dlRatePolicy = dlRatePolicy; + this.drMax = drMax; + this.drMin = drMin; + this.hrAllowed = hrAllowed; + this.minGWDiversity = minGWDiversity; + this.nwkGeoLoc = nwkGeoLoc; + this.organizationID = organizationID; + this.prAllowed = prAllowed; + this.raAllowed = raAllowed; + this.reportDevStatusBattery = reportDevStatusBattery; + this.reportDevStatusMargin = reportDevStatusMargin; + this.targetPER = targetPER; + this.ulBucketSize = ulBucketSize; + this.ulRate = ulRate; + this.ulRatePolicy = ulRatePolicy; + } } -export interface ServiceProfileData { - data: ServiceProfile[]; - ok?: boolean; - count?: number; -} \ No newline at end of file +// export interface ServiceProfileData { +// data: ServiceProfile[]; +// ok?: boolean; +// count?: number; +// } \ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html new file mode 100644 index 00000000..10550d39 --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html @@ -0,0 +1,35 @@ +
+
+ +
+
+
+
+

{{ serviceProfile.name }}

+
+
+
+
+
+ + +
+
+
+
+
+ {{ serviceProfile.id }} +
+
+
+
+
    + +
+
+
\ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts new file mode 100644 index 00000000..830ad505 --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts @@ -0,0 +1,58 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Store } from '@ngrx/store'; +import { map, switchMap } from 'rxjs/operators'; + +import { ServiceProfile } from '../service-profile.model'; +import * as fromApp from '../../../store/app.reducer'; +import * as ServiceProfilesActions from '../store/service-profile.actions'; + + +@Component({ + selector: 'app-service-profiles-detail', + templateUrl: './service-profiles-detail.component.html', + +}) +export class ServiceProfilesDetailComponent implements OnInit { + serviceProfile: ServiceProfile; + id: number; + + constructor( + private route: ActivatedRoute, + private router: Router, + private store: Store + ) { } + + ngOnInit() { + this.route.params + .pipe( + map(params => { + return +params['id']; + }), + switchMap(id => { + this.id = id; + return this.store.select('serviceProfiles'); + }), + map(serviceProfilesState => { + return serviceProfilesState.serviceProfiles.find((serviceProfile, index) => { + return index === this.id; + }); + }) + ) + .subscribe(serviceProfile => { + this.serviceProfile = serviceProfile; + }); + } + + + onEditServiceProfile() { + this.router.navigate(['edit'], { relativeTo: this.route }); + // this.router.navigate(['../', this.id, 'edit'], {relativeTo: this.route}); + } + + onDeleteServiceProfile() { + this.store.dispatch(ServiceProfilesActions.deleteServiceProfile({ index: this.id })); + this.router.navigate(['/serviceProfiles']); + } + +} diff --git a/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html new file mode 100644 index 00000000..49cd68aa --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html @@ -0,0 +1,36 @@ +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
\ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts new file mode 100644 index 00000000..572aec0c --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts @@ -0,0 +1,84 @@ +import { Component, OnInit } from '@angular/core'; +import { FormGroup, FormControl, Validators } from '@angular/forms'; +import { Subscription } from 'rxjs'; +import { ActivatedRoute, Router, Params } from '@angular/router'; +import { Store } from '@ngrx/store'; +import { map } from 'rxjs/operators'; + +import * as fromApp from '../../../store/app.reducer'; +import * as ServiceProfilesActions from '../store/service-profile.actions'; + +@Component({ + selector: 'app-service-profiles-edit', + templateUrl: './service-profiles-edit.component.html', + +}) +export class ServiceProfilesEditComponent implements OnInit { + id: number; + editMode = false; + serviceProfileForm: FormGroup; + + private storeSub: Subscription; + + constructor( + private route: ActivatedRoute, + private router: Router, + private store: Store + ) { } + + ngOnInit() { + this.route.params.subscribe((params: Params) => { + this.id = +params['id']; + this.editMode = params['id'] != null; + this.initForm(); + }); + } + + onSubmit() { + if (this.editMode) { + this.store.dispatch(ServiceProfilesActions.updateServiceProfile({ index: this.id, serviceProfile: this.serviceProfileForm.value })); + } else { + this.store.dispatch(ServiceProfilesActions.addServiceProfile({ serviceProfile: this.serviceProfileForm.value })); + } + this.onCancel(); + } + + + onCancel() { + this.router.navigate(['../'], { relativeTo: this.route }); + } + + ngOnDestroy() { + if (this.storeSub) { + this.storeSub.unsubscribe(); + } + } + + private initForm() { + let serviceProfileName = ''; + let serviceProfileId = ''; + + if (this.editMode) { + this.storeSub = this.store + .select('serviceProfiles') + .pipe( + map(serviceProfileState => { + return serviceProfileState.serviceProfiles.find((serviceProfile, index) => { + return index === this.id; + }); + }) + ) + .subscribe(serviceProfile => { + serviceProfileName = serviceProfile.name; + serviceProfileId = serviceProfile.id; + }); + } + + this.serviceProfileForm = new FormGroup({ + name: new FormControl(serviceProfileName, Validators.required), + id: new FormControl(serviceProfileId, Validators.required), + + }); + } + +} diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html index 737c4cf5..8dc3d789 100644 --- a/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html @@ -1,6 +1,6 @@
- +
diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts index 897d1840..9bbcc72e 100644 --- a/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts @@ -5,6 +5,7 @@ import { ServiceProfile } from '../service-profile.model'; import { map } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import * as fromApp from '../../../store/app.reducer'; +import { Router, ActivatedRoute } from '@angular/router'; @@ -21,6 +22,8 @@ export class ServiceProfilesListComponent implements OnInit, OnDestroy { public pageOffset: number = 0; constructor( + private router: Router, + private route: ActivatedRoute, private store: Store ) { } @@ -32,16 +35,10 @@ export class ServiceProfilesListComponent implements OnInit, OnDestroy { this.serviceProfiles = serviceProfiles; }); } - private fetchServiceProfiles() { - // this.shouldLoadNewHold = false; - // this.isFetching = true; - this.pageCount = this.pageCount + 1; - this.store.dispatch('serviceProfiles' ({limit: this.pageLimit})); - } - // onNewServiceProfile() { - // this.router.navigate(['new'], { relativeTo: this.route }); - // } + onNewServiceProfile() { + this.router.navigate(['new'], { relativeTo: this.route }); + } ngOnDestroy() { this.subscription.unsubscribe(); diff --git a/src/app/profiles/service-profiles/service-profiles-resolver.service.ts b/src/app/profiles/service-profiles/service-profiles-resolver.service.ts index cb5c713f..3fb0845b 100644 --- a/src/app/profiles/service-profiles/service-profiles-resolver.service.ts +++ b/src/app/profiles/service-profiles/service-profiles-resolver.service.ts @@ -12,12 +12,14 @@ import { of } from 'rxjs'; import { ServiceProfile } from './service-profile.model'; import * as fromApp from '../../store/app.reducer'; import * as ServiceProfileActions from './store/service-profile.actions'; +import { LoggingService } from 'src/app/logging.service'; @Injectable({ providedIn: 'root' }) export class RecipesResolverService implements Resolve { constructor( private store: Store, - private actions$: Actions + private actions$: Actions, + private loggingService: LoggingService, ) { } resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { @@ -28,9 +30,9 @@ export class RecipesResolverService implements Resolve { }), switchMap(serviceProfiles => { if (serviceProfiles.length === 0) { - this.store.dispatch(new ServiceProfileActions.FetchServiceProfiles()); + this.store.dispatch(ServiceProfileActions.fetchServiceProfiles()); return this.actions$.pipe( - ofType(ServiceProfileActions.SET_SERVICEPROFILES), + ofType(ServiceProfileActions.setServiceProfiles), take(1) ); } else { diff --git a/src/app/profiles/service-profiles/service-profiles-routing.module.ts b/src/app/profiles/service-profiles/service-profiles-routing.module.ts new file mode 100644 index 00000000..df27ed8e --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-routing.module.ts @@ -0,0 +1,36 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { ProfilesComponent } from '../profiles.component'; +import { ServiceProfilesStartComponent } from './service-profiles-start/service-profiles-start.component'; +import { ServiceProfilesEditComponent } from './service-profiles-edit/service-profiles-edit.component'; +import { ServiceProfilesDetailComponent } from './service-profiles-detail/service-profiles-detail.component'; +import { ServiceProfilesResolverService } from './service-profile-resolver.service'; +import { ServiceProfilesComponent } from './service-profiles.component'; + + +const routes: Routes = [ + { + path: '', + component: ServiceProfilesComponent, + children: [ + { path: '', component: ServiceProfilesStartComponent }, + { path: 'new', component: ServiceProfilesEditComponent }, + { + path: ':id', + component: ServiceProfilesDetailComponent, + resolve: [ServiceProfilesResolverService] + }, + { + path: ':id/edit', + component: ServiceProfilesEditComponent, + resolve: [ServiceProfilesResolverService] + } + ] + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class ProfilesRoutingModule { } \ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.html b/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.html new file mode 100644 index 00000000..fc57c6b7 --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.html @@ -0,0 +1 @@ +

Please select a Profile!

\ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.ts b/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.ts new file mode 100644 index 00000000..b63c94b4 --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.ts @@ -0,0 +1,14 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-service-profiles-start', + templateUrl: './service-profiles-start.component.html', +}) +export class ServiceProfilesStartComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/store/app.reducer.ts b/src/app/store/app.reducer.ts index 2253ead1..93b0bfb2 100644 --- a/src/app/store/app.reducer.ts +++ b/src/app/store/app.reducer.ts @@ -1,11 +1,19 @@ -import { ActionReducerMap } from '@ngrx/store'; +import { storeFreeze } from 'ngrx-store-freeze'; +import { ActionReducerMap, MetaReducer } from '@ngrx/store'; +import { routerReducer, RouterReducerState } from '@ngrx/router-store'; import * as fromServiceProfiles from '../profiles/service-profiles/store/service-profile.reducer'; +import { environment } from 'src/environments/environment'; export interface AppState { serviceProfiles: fromServiceProfiles.State; + router: RouterReducerState; } export const appReducer: ActionReducerMap = { serviceProfiles: fromServiceProfiles.serviceProfileReducer, + router: routerReducer, }; + +export const metaReducers: MetaReducer[] = + !environment.production ? [storeFreeze] : []; \ No newline at end of file From b1cc7f817b6629115085865a3526bb23e51fee7e Mon Sep 17 00:00:00 2001 From: Allan Asp Christensen Date: Thu, 3 Sep 2020 14:26:39 +0200 Subject: [PATCH 7/9] Styling --- src/app/app-routing.module.ts | 4 +- src/app/app.module.ts | 2 + .../applications-table-row.component.html | 8 +- .../profiles-list.component.html | 6 + .../profiles-list.component.scss | 0 .../profiles-list/profiles-list.component.ts | 22 +++ ...g.module.ts => profiles-routing.module.ts} | 21 ++- src/app/profiles/profiles.component.html | 12 +- src/app/profiles/profiles.module.ts | 41 +++-- .../service-profile-resolver.service.ts | 33 ++-- .../service-profile.service.ts | 42 ----- .../service-profiles-detail.component.html | 66 ++++---- .../service-profiles-detail.component.ts | 13 +- .../service-profiles-edit.component.html | 65 ++++++-- .../service-profiles-edit.component.ts | 31 +++- .../service-profile-item.component.html | 15 +- .../service-profile-item.component.ts | 22 ++- .../service-profiles-list.component.html | 10 +- .../service-profiles-resolver.service.ts | 44 ------ .../service-profiles-start.component.html | 1 - .../service-profiles-start.component.ts | 14 -- .../service-profiles.component.html | 2 + .../service-profiles.module.ts | 41 +++++ .../store/service-profile.effects.ts | 27 ++-- .../store/service-profile.reducer.ts | 26 +++- .../shared/directives/directives.module.ts | 20 +++ .../shared/directives/dropdown.directive.ts | 12 ++ .../directives/placeholder.directive.ts | 8 + src/app/shared/shared.module.ts | 8 +- src/app/shared/top-bar/top-bar.component.html | 8 +- src/app/shared/top-bar/top-bar.component.ts | 3 +- src/assets/scss/_tables.scss | 145 +++++++++--------- 32 files changed, 451 insertions(+), 321 deletions(-) create mode 100644 src/app/profiles/profiles-list/profiles-list.component.html create mode 100644 src/app/profiles/profiles-list/profiles-list.component.scss create mode 100644 src/app/profiles/profiles-list/profiles-list.component.ts rename src/app/profiles/{service-profiles/service-profiles-routing.module.ts => profiles-routing.module.ts} (50%) delete mode 100644 src/app/profiles/service-profiles/service-profile.service.ts delete mode 100644 src/app/profiles/service-profiles/service-profiles-resolver.service.ts delete mode 100644 src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.html delete mode 100644 src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.ts create mode 100644 src/app/profiles/service-profiles/service-profiles.module.ts create mode 100644 src/app/shared/directives/directives.module.ts create mode 100644 src/app/shared/directives/dropdown.directive.ts create mode 100644 src/app/shared/directives/placeholder.directive.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 74eb31ce..a7f9d048 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,5 +1,5 @@ import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; +import { Routes, RouterModule, PreloadAllModules } from '@angular/router'; import { DashboardComponent } from './views/dashboard/dashboard/dashboard.component'; import { MyApplicationsComponent } from './my-applications/my-applications.component'; import { EditApplicationComponent } from './my-applications/edit-application/edit-application.component'; @@ -52,7 +52,7 @@ const routes: Routes = [ ]; @NgModule({ - imports: [RouterModule.forRoot(routes)], + imports: [RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })], exports: [RouterModule], }) export class AppRoutingModule { } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 83caf061..c623ac1e 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -33,6 +33,7 @@ export function HttpLoaderFactory(http: HttpClient) { declarations: [AppComponent], imports: [ BrowserModule, + BrowserAnimationsModule, HttpClientModule, AppRoutingModule, DashboardModule, @@ -40,6 +41,7 @@ export function HttpLoaderFactory(http: HttpClient) { AlleIotEnhederModule, NavbarModule, ProfilesModule, + TranslateModule, StoreModule.forRoot(appReducer, { metaReducers }), !environment.production ? StoreDevtoolsModule.instrument() : [], EffectsModule.forRoot([ServiceProfileEffects]), diff --git a/src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.html b/src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.html index 71121abc..7c4ff1ab 100644 --- a/src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.html +++ b/src/app/my-applications/applications-table/applications-table-row/applications-table-row.component.html @@ -1,5 +1,7 @@ -{{application.name}} + + {{application.name}} + {{application.iotDevices.length}} @@ -19,4 +21,4 @@ routerLinkActive="active">{{ 'APPLICATION-TABLE-ROW.EDIT' | translate }} - + \ No newline at end of file diff --git a/src/app/profiles/profiles-list/profiles-list.component.html b/src/app/profiles/profiles-list/profiles-list.component.html new file mode 100644 index 00000000..d77f261e --- /dev/null +++ b/src/app/profiles/profiles-list/profiles-list.component.html @@ -0,0 +1,6 @@ +
+ +
+
+ +
\ No newline at end of file diff --git a/src/app/profiles/profiles-list/profiles-list.component.scss b/src/app/profiles/profiles-list/profiles-list.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/app/profiles/profiles-list/profiles-list.component.ts b/src/app/profiles/profiles-list/profiles-list.component.ts new file mode 100644 index 00000000..3a25b661 --- /dev/null +++ b/src/app/profiles/profiles-list/profiles-list.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; + +@Component({ + selector: 'app-profiles-list', + templateUrl: './profiles-list.component.html', + styleUrls: ['./profiles-list.component.scss'] +}) +export class ProfilesListComponent implements OnInit { + + constructor( + private router: Router, + private route: ActivatedRoute, + ) { } + + ngOnInit(): void { + } + + onNewServiceProfile() { + this.router.navigate(['new-profile'], { relativeTo: this.route }); + } +} diff --git a/src/app/profiles/service-profiles/service-profiles-routing.module.ts b/src/app/profiles/profiles-routing.module.ts similarity index 50% rename from src/app/profiles/service-profiles/service-profiles-routing.module.ts rename to src/app/profiles/profiles-routing.module.ts index df27ed8e..f19c4c9d 100644 --- a/src/app/profiles/service-profiles/service-profiles-routing.module.ts +++ b/src/app/profiles/profiles-routing.module.ts @@ -1,29 +1,28 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; -import { ProfilesComponent } from '../profiles.component'; -import { ServiceProfilesStartComponent } from './service-profiles-start/service-profiles-start.component'; -import { ServiceProfilesEditComponent } from './service-profiles-edit/service-profiles-edit.component'; -import { ServiceProfilesDetailComponent } from './service-profiles-detail/service-profiles-detail.component'; -import { ServiceProfilesResolverService } from './service-profile-resolver.service'; -import { ServiceProfilesComponent } from './service-profiles.component'; +import { ServiceProfilesEditComponent } from './service-profiles/service-profiles-edit/service-profiles-edit.component'; +import { ServiceProfilesDetailComponent } from './service-profiles/service-profiles-detail/service-profiles-detail.component'; +import { ServiceProfileResolverService } from './service-profiles/service-profile-resolver.service'; +import { ProfilesComponent } from './profiles.component'; +import { ProfilesListComponent } from './profiles-list/profiles-list.component'; const routes: Routes = [ { path: '', - component: ServiceProfilesComponent, + component: ProfilesComponent, children: [ - { path: '', component: ServiceProfilesStartComponent }, + { path: '', component: ProfilesListComponent }, { path: 'new', component: ServiceProfilesEditComponent }, { path: ':id', component: ServiceProfilesDetailComponent, - resolve: [ServiceProfilesResolverService] + resolve: [ServiceProfileResolverService] }, { - path: ':id/edit', + path: ':id/edit-profile', component: ServiceProfilesEditComponent, - resolve: [ServiceProfilesResolverService] + resolve: [ServiceProfileResolverService] } ] } diff --git a/src/app/profiles/profiles.component.html b/src/app/profiles/profiles.component.html index 9e089706..9742badc 100644 --- a/src/app/profiles/profiles.component.html +++ b/src/app/profiles/profiles.component.html @@ -1,11 +1,3 @@ -
-
- -
-
-
-
-
- -
+
+
\ No newline at end of file diff --git a/src/app/profiles/profiles.module.ts b/src/app/profiles/profiles.module.ts index a6c7f28a..389b6a1f 100644 --- a/src/app/profiles/profiles.module.ts +++ b/src/app/profiles/profiles.module.ts @@ -1,40 +1,37 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { ServiceProfilesListComponent } from './service-profiles/service-profiles-list/service-profiles-list.component'; import { ProfilesComponent } from './profiles.component'; -import { ProfilesRoutingModule } from './service-profiles/service-profiles-routing.module'; +import { ProfilesRoutingModule } from './profiles-routing.module'; import { LoggingService } from '../logging.service'; -import { ServiceProfilesComponent } from './service-profiles/service-profiles.component'; -import { ServiceProfileService } from './service-profiles/service-profile.service'; -import { ServiceProfileItemComponent } from './service-profiles/service-profiles-list/service-profile-item/service-profile-item.component'; -import { ServiceProfilesDetailComponent } from './service-profiles/service-profiles-detail/service-profiles-detail.component'; -import { ServiceProfilesEditComponent } from './service-profiles/service-profiles-edit/service-profiles-edit.component'; -import { ServiceProfilesStartComponent } from './service-profiles/service-profiles-start/service-profiles-start.component'; -import { ReactiveFormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; -import { StoreModule } from '@ngrx/store'; -import * as fromServiceProfiles from './service-profiles/store/service-profile.reducer'; +import { ServiceProfilesModule } from './service-profiles/service-profiles.module'; +import { ProfilesListComponent } from './profiles-list/profiles-list.component'; +import { SharedModule } from '../shared/shared.module'; +import { TopBarModule } from '../shared/top-bar/top-bar.module'; +import { FormModule } from '../shared/form/form.module'; +import { TranslateModule } from '@ngx-translate/core'; @NgModule({ declarations: [ ProfilesComponent, - ServiceProfilesListComponent, - ServiceProfileItemComponent, - ServiceProfilesComponent, - ServiceProfilesDetailComponent, - ServiceProfilesEditComponent, - ServiceProfilesStartComponent], + ProfilesListComponent, + ], exports: [], imports: [ - RouterModule, - ReactiveFormsModule, - CommonModule, + ServiceProfilesModule, ProfilesRoutingModule, - StoreModule.forFeature('serviceProfiles', fromServiceProfiles.serviceProfileReducer), + RouterModule, + TopBarModule, + SharedModule, + FormModule, + TranslateModule + ], - providers: [LoggingService, ServiceProfileService] + providers: [ + LoggingService, + ] }) export class ProfilesModule { } diff --git a/src/app/profiles/service-profiles/service-profile-resolver.service.ts b/src/app/profiles/service-profiles/service-profile-resolver.service.ts index 84c4bb04..d69f0f90 100644 --- a/src/app/profiles/service-profiles/service-profile-resolver.service.ts +++ b/src/app/profiles/service-profiles/service-profile-resolver.service.ts @@ -1,43 +1,40 @@ + + +import { ServiceProfile } from './service-profile.model'; +import * as fromApp from '../../store/app.reducer'; +import * as ServiceProfileActions from './store/service-profile.actions'; +import { LoggingService } from 'src/app/logging.service'; import { Injectable } from '@angular/core'; -import { - Resolve, - ActivatedRouteSnapshot, - RouterStateSnapshot -} from '@angular/router'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { Store } from '@ngrx/store'; import { Actions, ofType } from '@ngrx/effects'; import { take, map, switchMap } from 'rxjs/operators'; import { of } from 'rxjs'; -import { ServiceProfile } from './service-profile.model'; -import * as fromApp from '../../store/app.reducer'; -import * as ServiceProfilesActions from '../service-profiles/store/service-profile.actions'; - @Injectable({ providedIn: 'root' }) -export class ServiceProfilesResolverService implements Resolve<{ serviceProfiles: ServiceProfile[] }> { +export class ServiceProfileResolverService implements Resolve { constructor( private store: Store, - private actions$: Actions + private actions$: Actions, ) { } resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { - return this.store.select('serviceProfiles').pipe( take(1), - map(serviceProfilesState => { - return serviceProfilesState.serviceProfiles; + map(serviceProfileState => { + return serviceProfileState.serviceProfiles; }), switchMap(serviceProfiles => { if (serviceProfiles.length === 0) { - this.store.dispatch(ServiceProfilesActions.fetchServiceProfiles()); + this.store.dispatch(new ServiceProfileActions.FetchServiceProfiles()); return this.actions$.pipe( - ofType(ServiceProfilesActions.setServiceProfiles), + ofType(ServiceProfileActions.SET_SERVICEPROFILES), take(1) ); } else { - return of({ serviceProfiles }); + return of(serviceProfiles); } }) ); } -} \ No newline at end of file +} diff --git a/src/app/profiles/service-profiles/service-profile.service.ts b/src/app/profiles/service-profiles/service-profile.service.ts deleted file mode 100644 index 76b44e2a..00000000 --- a/src/app/profiles/service-profiles/service-profile.service.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Subject, Observable } from 'rxjs'; - -import { ServiceProfileData, ServiceProfile } from './service-profile.model'; -import { RestService } from 'src/app/shared/services/rest.service'; - - -@Injectable() -export class ServiceProfileService { - - serviceProfileChanged = new Subject(); - - - constructor(private restService: RestService) { } - - createServiceProfile(body: any): Observable { - return this.restService.post('chirpstack/service-profiles', body, { observe: 'response' }); - } - - updateServiceProfile(body: any, id: number): Observable { - return this.restService.replace('chirpstack/service-profiles', body, id, { observe: 'response' }); - } - - getServiceProfile(id: number): Observable { - return this.restService.get('chirpstack/service-profiles', {}, id); - } - - getServiceProfiles( - limit: number, - offset: number, - ): Observable { - const body = { - limit: limit, - offset: offset, - }; - return this.restService.get('chirpstack/service-profiles', body); - } - - deleteServiceProfile(id: number) { - return this.restService.delete('chirpstack/service-profiles', id); - } -} \ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html index 10550d39..cd49feb5 100644 --- a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html +++ b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html @@ -1,35 +1,49 @@
-
- +
+
+ +
-
-
-
-

{{ serviceProfile.name }}

+
+
+
+ + +
+
-
-
-
-
- - +
+
+

{{ 'IOTDEVICE.NAME' }}

+
+
+

{{serviceProfile.name}}

-
-
-
- {{ serviceProfile.id }} +
+
+

{{ 'IOTDEVICE.TYPE' }}

+
+
+

{{ 'IOT-DEVICE-TYPES.' + serviceProfile.drMin }}

+
-
-
-
-
    + {{ serviceProfile.addGWMetaData }} + {{ serviceProfile.drMin }} + {{ serviceProfile.drMax }} + {{ serviceProfile.targetPER }} + -
+
+
+
    + +
+
\ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts index 830ad505..92a6754e 100644 --- a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts +++ b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts @@ -6,6 +6,8 @@ import { map, switchMap } from 'rxjs/operators'; import { ServiceProfile } from '../service-profile.model'; import * as fromApp from '../../../store/app.reducer'; import * as ServiceProfilesActions from '../store/service-profile.actions'; +import { BackButton } from 'src/app/models/back-button'; +import { TranslateService } from '@ngx-translate/core'; @Component({ @@ -14,14 +16,17 @@ import * as ServiceProfilesActions from '../store/service-profile.actions'; }) export class ServiceProfilesDetailComponent implements OnInit { + public backButton: BackButton = { label: 'Go back', routerLink: '/profiles' }; + public title: string = ''; serviceProfile: ServiceProfile; id: number; constructor( private route: ActivatedRoute, private router: Router, - private store: Store - ) { } + private store: Store, + private translate: TranslateService + ) { translate.use('da'); } ngOnInit() { this.route.params @@ -42,16 +47,16 @@ export class ServiceProfilesDetailComponent implements OnInit { .subscribe(serviceProfile => { this.serviceProfile = serviceProfile; }); + } onEditServiceProfile() { this.router.navigate(['edit'], { relativeTo: this.route }); - // this.router.navigate(['../', this.id, 'edit'], {relativeTo: this.route}); } onDeleteServiceProfile() { - this.store.dispatch(ServiceProfilesActions.deleteServiceProfile({ index: this.id })); + this.store.dispatch(new ServiceProfilesActions.DeleteServiceProfile(this.id)); this.router.navigate(['/serviceProfiles']); } diff --git a/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html index 49cd68aa..6e93c0f0 100644 --- a/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html +++ b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html @@ -1,34 +1,75 @@
+
+
- - +
+ + +
+ + +
- - + +
+
-
+
+
+ + +
+
+
+
+ + +
-
+
- - + + +
+
+ +
+ + + +
+
+ +
diff --git a/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts index 572aec0c..43ca5bb3 100644 --- a/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts +++ b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts @@ -4,9 +4,9 @@ import { Subscription } from 'rxjs'; import { ActivatedRoute, Router, Params } from '@angular/router'; import { Store } from '@ngrx/store'; import { map } from 'rxjs/operators'; - import * as fromApp from '../../../store/app.reducer'; import * as ServiceProfilesActions from '../store/service-profile.actions'; +import { BackButton } from 'src/app/models/back-button'; @Component({ selector: 'app-service-profiles-edit', @@ -14,6 +14,8 @@ import * as ServiceProfilesActions from '../store/service-profile.actions'; }) export class ServiceProfilesEditComponent implements OnInit { + public backButton: BackButton = { label: '', routerLink: '/profiles' }; + public title: string = 'Service Profile Edit'; id: number; editMode = false; serviceProfileForm: FormGroup; @@ -36,9 +38,14 @@ export class ServiceProfilesEditComponent implements OnInit { onSubmit() { if (this.editMode) { - this.store.dispatch(ServiceProfilesActions.updateServiceProfile({ index: this.id, serviceProfile: this.serviceProfileForm.value })); + this.store.dispatch( + new ServiceProfilesActions.UpdateServiceProfile({ + index: this.id, + updateServiceProfile: this.serviceProfileForm.value + }) + ); } else { - this.store.dispatch(ServiceProfilesActions.addServiceProfile({ serviceProfile: this.serviceProfileForm.value })); + this.store.dispatch(new ServiceProfilesActions.AddServiceProfile(this.serviceProfileForm.value)); } this.onCancel(); } @@ -56,7 +63,11 @@ export class ServiceProfilesEditComponent implements OnInit { private initForm() { let serviceProfileName = ''; - let serviceProfileId = ''; + let serviceProfileGWData = '{"Json":{"data":1}}'; + let serviceProfileBatteryStatus = true; + let serviceProfileMinDateRate = 2000; + let serviceProfileMaxDateRate = 2000; + let serviceProfileReportEndDevice = 2000; if (this.editMode) { this.storeSub = this.store @@ -70,13 +81,21 @@ export class ServiceProfilesEditComponent implements OnInit { ) .subscribe(serviceProfile => { serviceProfileName = serviceProfile.name; - serviceProfileId = serviceProfile.id; + serviceProfileBatteryStatus = serviceProfile.reportDevStatusBattery; + serviceProfileMinDateRate = serviceProfile.drMin; + serviceProfileMaxDateRate = serviceProfile.drMax; + serviceProfileReportEndDevice = serviceProfile.targetPER; + }); } this.serviceProfileForm = new FormGroup({ name: new FormControl(serviceProfileName, Validators.required), - id: new FormControl(serviceProfileId, Validators.required), + reportDevStatusBattery: new FormControl(serviceProfileBatteryStatus, Validators.required), + drMin: new FormControl(serviceProfileMinDateRate, Validators.required), + drMax: new FormControl(serviceProfileMaxDateRate, Validators.required), + targetPER: new FormControl(serviceProfileReportEndDevice, Validators.required) + }); } diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html index 52198f8e..6ee9e8b9 100644 --- a/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html @@ -1,5 +1,12 @@ - -
-

{{ serviceProfile.name }}

+
\ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.ts b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.ts index 36fade2c..2f228460 100644 --- a/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.ts +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.ts @@ -1,5 +1,10 @@ import { Component, OnInit, Input } from '@angular/core'; import { ServiceProfile } from '../../service-profile.model'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Store } from '@ngrx/store'; +import * as ServiceProfilesActions from '../../store/service-profile.actions'; +import * as fromApp from '../../../../store/app.reducer'; + @Component({ selector: 'app-service-profile-item', @@ -9,10 +14,25 @@ import { ServiceProfile } from '../../service-profile.model'; export class ServiceProfileItemComponent implements OnInit { @Input() serviceProfile: ServiceProfile; @Input() index: number; + id: number; - constructor() { } + constructor( + private route: ActivatedRoute, + private router: Router, + private store: Store + ) { } ngOnInit(): void { } + onEditServiceProfile() { + //this.router.navigate(['edit-profile'], { relativeTo: this.route }); + this.router.navigate([this.index, 'edit-profile'], { relativeTo: this.route }); + } + + onDeleteServiceProfile() { + this.store.dispatch(new ServiceProfilesActions.DeleteServiceProfile(this.index)); + this.router.navigate(['/profiles']); + } + } diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html index 8dc3d789..757c5f06 100644 --- a/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.html @@ -1,7 +1,9 @@ -
-
- - +
+
+

Service Profiles

+
+
+

diff --git a/src/app/profiles/service-profiles/service-profiles-resolver.service.ts b/src/app/profiles/service-profiles/service-profiles-resolver.service.ts deleted file mode 100644 index 3fb0845b..00000000 --- a/src/app/profiles/service-profiles/service-profiles-resolver.service.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Injectable } from '@angular/core'; -import { - Resolve, - ActivatedRouteSnapshot, - RouterStateSnapshot -} from '@angular/router'; -import { Store } from '@ngrx/store'; -import { Actions, ofType } from '@ngrx/effects'; -import { take, map, switchMap } from 'rxjs/operators'; -import { of } from 'rxjs'; - -import { ServiceProfile } from './service-profile.model'; -import * as fromApp from '../../store/app.reducer'; -import * as ServiceProfileActions from './store/service-profile.actions'; -import { LoggingService } from 'src/app/logging.service'; - -@Injectable({ providedIn: 'root' }) -export class RecipesResolverService implements Resolve { - constructor( - private store: Store, - private actions$: Actions, - private loggingService: LoggingService, - ) { } - - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { - return this.store.select('serviceProfiles').pipe( - take(1), - map(serviceProfileState => { - return serviceProfileState.serviceProfiles; - }), - switchMap(serviceProfiles => { - if (serviceProfiles.length === 0) { - this.store.dispatch(ServiceProfileActions.fetchServiceProfiles()); - return this.actions$.pipe( - ofType(ServiceProfileActions.setServiceProfiles), - take(1) - ); - } else { - return of(serviceProfiles); - } - }) - ); - } -} diff --git a/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.html b/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.html deleted file mode 100644 index fc57c6b7..00000000 --- a/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.html +++ /dev/null @@ -1 +0,0 @@ -

Please select a Profile!

\ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.ts b/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.ts deleted file mode 100644 index b63c94b4..00000000 --- a/src/app/profiles/service-profiles/service-profiles-start/service-profiles-start.component.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-service-profiles-start', - templateUrl: './service-profiles-start.component.html', -}) -export class ServiceProfilesStartComponent implements OnInit { - - constructor() { } - - ngOnInit(): void { - } - -} diff --git a/src/app/profiles/service-profiles/service-profiles.component.html b/src/app/profiles/service-profiles/service-profiles.component.html index e69de29b..19c10e03 100644 --- a/src/app/profiles/service-profiles/service-profiles.component.html +++ b/src/app/profiles/service-profiles/service-profiles.component.html @@ -0,0 +1,2 @@ +

Service profiles virker +

\ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles.module.ts b/src/app/profiles/service-profiles/service-profiles.module.ts new file mode 100644 index 00000000..807c077c --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles.module.ts @@ -0,0 +1,41 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { ServiceProfilesEditComponent } from './service-profiles-edit/service-profiles-edit.component'; +import { ServiceProfilesComponent } from './service-profiles.component'; +import { ServiceProfilesListComponent } from './service-profiles-list/service-profiles-list.component'; +import { ServiceProfileItemComponent } from './service-profiles-list/service-profile-item/service-profile-item.component'; +import { ServiceProfilesDetailComponent } from './service-profiles-detail/service-profiles-detail.component'; +import { ReactiveFormsModule } from '@angular/forms'; +import { StoreModule } from '@ngrx/store'; +import * as fromServiceProfiles from './../service-profiles/store/service-profile.reducer'; +import { RouterModule } from '@angular/router'; +import { FormModule } from 'src/app/shared/form/form.module'; +import { SharedModule } from 'src/app/shared/shared.module'; +import { DirectivesModule } from 'src/app/shared/directives/directives.module'; +import { TranslateModule } from '@ngx-translate/core'; + + + + +@NgModule({ + declarations: [ + ServiceProfilesListComponent, + ServiceProfileItemComponent, + ServiceProfilesComponent, + ServiceProfilesDetailComponent, + ServiceProfilesEditComponent, + ], + exports: [ + ServiceProfilesListComponent + ], + imports: [ + DirectivesModule, + CommonModule, + RouterModule, + ReactiveFormsModule, + FormModule, + TranslateModule, + StoreModule.forFeature('serviceProfiles', fromServiceProfiles.serviceProfileReducer), + ] +}) +export class ServiceProfilesModule { } diff --git a/src/app/profiles/service-profiles/store/service-profile.effects.ts b/src/app/profiles/service-profiles/store/service-profile.effects.ts index cf0796da..b1dc4557 100644 --- a/src/app/profiles/service-profiles/store/service-profile.effects.ts +++ b/src/app/profiles/service-profiles/store/service-profile.effects.ts @@ -5,12 +5,14 @@ import { HttpClient } from '@angular/common/http'; import { switchMap, map, withLatestFrom } from 'rxjs/operators'; import * as ServiceProfileActions from './service-profile.actions'; -import { ServiceProfile, ServiceProfileData } from '../service-profile.model'; +import { ServiceProfile } from '../service-profile.model'; import * as fromApp from '../../../store/app.reducer'; import { environment } from 'src/environments/environment'; import { RestService } from 'src/app/shared/services/rest.service'; import { Observable } from 'rxjs'; +import { of } from 'rxjs'; +import { catchError } from 'rxjs/operators'; @@ -20,13 +22,10 @@ export class ServiceProfileEffects { @Effect() fetchServiceProfiles = this.actions$.pipe( ofType(ServiceProfileActions.FETCH_SERVICEPROFILES), - switchMap((limit: number, offset: number): Observable => { - const body = { - limit: limit, - offset: offset, - }; - return this.restService.get('chirpstack/service-profiles', body); - + switchMap(() => { + return this.http.get( + 'http://[::1]:3000/api/v1/chirpstack/service-profiles?limit=100&offset=0' + ); }), map(serviceProfiles => { return serviceProfiles.map(serviceProfile => { @@ -37,18 +36,18 @@ export class ServiceProfileEffects { }), map(serviceProfiles => { return new ServiceProfileActions.SetServiceProfiles(serviceProfiles); - }) + }), + catchError(() => of({ type: ' Loaded Error' })) ); @Effect({ dispatch: false }) storeServiceProfiles = this.actions$.pipe( ofType(ServiceProfileActions.STORE_SERVICEPROFILES), withLatestFrom(this.store.select('serviceProfiles')), - switchMap((body: any): Observable => { - return this.restService.post( - 'chirpstack/service-profiles', - body, - { observe: 'response' } + switchMap(([actionData, serviceProfileState]) => { + return this.http.post( + 'http://[::1]:3000/api/v1/chirpstack/service-profiles', + serviceProfileState.serviceProfiles ); }) ); diff --git a/src/app/profiles/service-profiles/store/service-profile.reducer.ts b/src/app/profiles/service-profiles/store/service-profile.reducer.ts index d589ef2e..27f4384b 100644 --- a/src/app/profiles/service-profiles/store/service-profile.reducer.ts +++ b/src/app/profiles/service-profiles/store/service-profile.reducer.ts @@ -6,7 +6,31 @@ export interface State { } const initialState: State = { - serviceProfiles: [], + serviceProfiles: [{ + id: 'ID', + name: 'Vandmåler', + networkServerID: 'networkserverID', + addGWMetaData: true, + channelMask: 'channelmask', + devStatusReqFreq: 789, + dlBucketSize: 123, + dlRate: 456, + dlRatePolicy: 'dlRatePolicy', + drMax: 789, + drMin: 132, + hrAllowed: true, + minGWDiversity: 123, + nwkGeoLoc: true, + organizationID: 'organizationID', + prAllowed: true, + raAllowed: true, + reportDevStatusBattery: true, + reportDevStatusMargin: true, + targetPER: 123, + ulBucketSize: 456, + ulRate: 789, + ulRatePolicy: 'ulRatePolicy' + }], }; export function serviceProfileReducer( diff --git a/src/app/shared/directives/directives.module.ts b/src/app/shared/directives/directives.module.ts new file mode 100644 index 00000000..e612d487 --- /dev/null +++ b/src/app/shared/directives/directives.module.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { DropdownDirective } from './dropdown.directive'; +import { PlaceholderDirective } from './placeholder.directive'; + + + +@NgModule({ + declarations: [ + DropdownDirective, + PlaceholderDirective], + imports: [ + CommonModule + ], + exports: [ + DropdownDirective, + PlaceholderDirective + ] +}) +export class DirectivesModule { } diff --git a/src/app/shared/directives/dropdown.directive.ts b/src/app/shared/directives/dropdown.directive.ts new file mode 100644 index 00000000..90529ef1 --- /dev/null +++ b/src/app/shared/directives/dropdown.directive.ts @@ -0,0 +1,12 @@ +import { Directive, HostListener, HostBinding } from '@angular/core'; + +@Directive({ + selector: '[appDropdown]' +}) +export class DropdownDirective { + @HostBinding('class.open') isOpen = false; + + @HostListener('click') toggleOpen() { + this.isOpen = !this.isOpen; + } +} diff --git a/src/app/shared/directives/placeholder.directive.ts b/src/app/shared/directives/placeholder.directive.ts new file mode 100644 index 00000000..1cde7668 --- /dev/null +++ b/src/app/shared/directives/placeholder.directive.ts @@ -0,0 +1,8 @@ +import { Directive, ViewContainerRef } from '@angular/core'; + +@Directive({ + selector: '[appPlaceholder]' +}) +export class PlaceholderDirective { + constructor(public viewContainerRef: ViewContainerRef) { } +} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 19694127..b52d25b6 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -8,6 +8,7 @@ import { AlertComponent } from './alert/alert.component'; import { SearchBarComponent } from './search-bar/search-bar.component'; import { TranslateModule } from '@ngx-translate/core'; import { LoggingService } from '../logging.service'; +import { DirectivesModule } from './directives/directives.module'; @NgModule({ declarations: [ @@ -15,15 +16,12 @@ import { LoggingService } from '../logging.service'; SearchBarComponent, ], imports: [ + DirectivesModule, CommonModule, - HttpClientModule, - BrowserAnimationsModule, ], exports: [ AlertComponent, - BrowserAnimationsModule, - HttpClientModule, - TranslateModule + TranslateModule, ], providers: [LoggingService] }) diff --git a/src/app/shared/top-bar/top-bar.component.html b/src/app/shared/top-bar/top-bar.component.html index 811ba17f..36317889 100644 --- a/src/app/shared/top-bar/top-bar.component.html +++ b/src/app/shared/top-bar/top-bar.component.html @@ -2,7 +2,7 @@

{{title}}

-

{{title}}

+

{{title}}

@@ -16,8 +16,8 @@

{{title}}

{{ 'GEN.PER-PAGE' | translate }} --> -
@@ -26,4 +26,4 @@

{{title}}

type="button" [attr.aria-label]="ctaLabel">{{ctaLabel}}
-
+
\ No newline at end of file diff --git a/src/app/shared/top-bar/top-bar.component.ts b/src/app/shared/top-bar/top-bar.component.ts index 5afbff66..7c5ab8ca 100644 --- a/src/app/shared/top-bar/top-bar.component.ts +++ b/src/app/shared/top-bar/top-bar.component.ts @@ -16,6 +16,7 @@ export class TopBarComponent implements OnInit { @Input() pageLimit: number; @Input() selectedSortId: number; @Input() component: boolean = false; + @Input() showSelectedSort = true; @Output() selectedSortChange = new EventEmitter(); @Output() updatePageLimit = new EventEmitter(); @@ -24,7 +25,7 @@ export class TopBarComponent implements OnInit { translate.use('da'); } - ngOnInit(): void {} + ngOnInit(): void { } changeSort(id: number) { this.selectedSortChange.emit(id); diff --git a/src/assets/scss/_tables.scss b/src/assets/scss/_tables.scss index 65f5883c..f9e88f6f 100644 --- a/src/assets/scss/_tables.scss +++ b/src/assets/scss/_tables.scss @@ -1,97 +1,98 @@ .table { - background-color: $white; - // -webkit-border-radius: .25rem; - // -moz-border-radius: .25rem; - // border-radius: .25rem; - box-shadow: 0px 1px 10px rgba(0, 0, 0, 0.14), - 0px 1px 13px rgba(0, 0, 0, 0.03), 0px 0px 1px rgba(0, 0, 0, 0.22); - -webkit-box-shadow: 0px 1px 10px rgba(0, 0, 0, 0.14), - 0px 1px 13px rgba(0, 0, 0, 0.03), 0px 0px 1px rgba(0, 0, 0, 0.22); - -moz-box-shadow: 0px 1px 10px rgba(0, 0, 0, 0.14), - 0px 1px 13px rgba(0, 0, 0, 0.03), 0px 0px 1px rgba(0, 0, 0, 0.22); - // border: $grey-border solid 1px; + background-color: $white; + // -webkit-border-radius: .25rem; + // -moz-border-radius: .25rem; + // border-radius: .25rem; + box-shadow: 0px 1px 10px rgba(0, 0, 0, 0.14), + 0px 1px 13px rgba(0, 0, 0, 0.03), 0px 0px 1px rgba(0, 0, 0, 0.22); + -webkit-box-shadow: 0px 1px 10px rgba(0, 0, 0, 0.14), + 0px 1px 13px rgba(0, 0, 0, 0.03), 0px 0px 1px rgba(0, 0, 0, 0.22); + -moz-box-shadow: 0px 1px 10px rgba(0, 0, 0, 0.14), + 0px 1px 13px rgba(0, 0, 0, 0.03), 0px 0px 1px rgba(0, 0, 0, 0.22); + // border: $grey-border solid 1px; + * { * { - * { - border-bottom-width: 0 !important; - } + border-bottom-width: 0 !important; } + } - th, - td { - padding: 0.5rem 1rem; - } + th, + td { + padding: 0.5rem 1rem; + } - thead { - font-family: roboto-light; - font-weight: 300; - font-size: 15px; - line-height: 24px; - color: $grey-tablehead; - background-color: $grey-dark; - } + thead { + font-family: roboto-light; + font-weight: 300; + font-size: 15px; + line-height: 24px; + color: $grey-tablehead; + background-color: $grey-dark; + } - tbody { - color: $black; - font-family: roboto; + tbody { + color: $black; + font-family: roboto; - tr { - border-top: $grey-border solid 1px; - line-height: 40px; - color: $black; + tr { + border-top: $grey-border solid 1px; + line-height: 40px; + color: $black; - &:hover { - background-color: $grey-highlight; - } - } + &:hover { + background-color: $grey-highlight; + } } + } } .dropdown { - right: 3rem; - top: 10px; + right: 3rem; + top: 10px; - .applicationRow__edit { - width: 10px; - height: 20px; - background-image: radial-gradient(circle, $black 2px, transparent 1px); - background-size: 100% 33.33%; - padding: 2px 10px; + .applicationRow__edit { + width: 10px; + height: 20px; + background-image: radial-gradient(circle, $black 2px, transparent 1px); + background-size: 100% 33.33%; + padding: 2px 10px; - &:after { - display: none; - } + &:after { + display: none; } + } - .dropdown-menu { - min-width: 90px !important; - left: -35px !important; + .dropdown-menu { + min-width: 90px !important; + left: -35px !important; - li { - a { - font-family: roboto-bold; - color: $black; - font-size: 12px; - line-height: 14px; - } + li { + a { + font-family: roboto-bold; + color: $black; + font-size: 12px; + line-height: 14px; + } - &:hover, - &:active { - color: $black; - text-decoration: none; - background-color: #0d6efd; - } - } + &:hover, + &:active { + color: $black; + text-decoration: none; + background-color: #0d6efd; + } } + } } .pagination { - .page-item { - .page-link { - color: $black; - &:focus { - box-shadow: 0 0 0 0.2rem $grey-outline; - } - } + .page-item { + .page-link { + color: $black; + + &:focus { + box-shadow: 0 0 0 0.2rem $grey-outline; + } } + } } From ca6e46286e710f8cffa7f09de729f082607d89bd Mon Sep 17 00:00:00 2001 From: Allan Asp Christensen Date: Thu, 3 Sep 2020 16:01:31 +0200 Subject: [PATCH 8/9] fIX af htpp request --- src/app/profiles/profiles.component.ts | 11 +++++++ .../service-profiles/service-profile.model.ts | 9 +++--- .../service-profiles-detail.component.html | 2 +- .../store/service-profile.effects.ts | 31 ++++++++++++------- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/app/profiles/profiles.component.ts b/src/app/profiles/profiles.component.ts index 60cbd6b3..15d81056 100644 --- a/src/app/profiles/profiles.component.ts +++ b/src/app/profiles/profiles.component.ts @@ -1,5 +1,9 @@ import { Component, OnInit } from '@angular/core'; import { LoggingService } from '../logging.service'; +import { ServiceProfile } from './service-profiles/service-profile.model'; +import * as ServiceProfilesAction from './service-profiles/store/service-profile.actions' +import { Store } from '@ngrx/store'; +import * as fromApp from '../store/app.reducer' @Component({ selector: 'app-profiles', @@ -8,11 +12,18 @@ import { LoggingService } from '../logging.service'; export class ProfilesComponent implements OnInit { constructor( + private store: Store, private loggingService: LoggingService, ) { } ngOnInit(): void { this.loggingService.printLog('Profiles tapped'); + this.onFetchData(); + } + + onFetchData() { + // this.dataStorageService.fetchRecipes().subscribe(); + this.store.dispatch(new ServiceProfilesAction.FetchServiceProfiles()); } } diff --git a/src/app/profiles/service-profiles/service-profile.model.ts b/src/app/profiles/service-profiles/service-profile.model.ts index 3cea8e47..479c9143 100644 --- a/src/app/profiles/service-profiles/service-profile.model.ts +++ b/src/app/profiles/service-profiles/service-profile.model.ts @@ -73,8 +73,7 @@ export class ServiceProfile { } } -// export interface ServiceProfileData { -// data: ServiceProfile[]; -// ok?: boolean; -// count?: number; -// } \ No newline at end of file +export interface ServiceProfileData { + result: ServiceProfile[]; + totalCount?: string; +} \ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html index cd49feb5..f30056b7 100644 --- a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html +++ b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html @@ -19,7 +19,7 @@
-

{{ 'IOTDEVICE.NAME' }}

+

{{ 'IOTDEVICE.NAME' | translate }}

{{serviceProfile.name}}

diff --git a/src/app/profiles/service-profiles/store/service-profile.effects.ts b/src/app/profiles/service-profiles/store/service-profile.effects.ts index b1dc4557..ddc22ad4 100644 --- a/src/app/profiles/service-profiles/store/service-profile.effects.ts +++ b/src/app/profiles/service-profiles/store/service-profile.effects.ts @@ -5,7 +5,7 @@ import { HttpClient } from '@angular/common/http'; import { switchMap, map, withLatestFrom } from 'rxjs/operators'; import * as ServiceProfileActions from './service-profile.actions'; -import { ServiceProfile } from '../service-profile.model'; +import { ServiceProfile, ServiceProfileData } from '../service-profile.model'; import * as fromApp from '../../../store/app.reducer'; import { environment } from 'src/environments/environment'; @@ -18,17 +18,22 @@ import { catchError } from 'rxjs/operators'; @Injectable() export class ServiceProfileEffects { - restService: RestService; + @Effect() fetchServiceProfiles = this.actions$.pipe( ofType(ServiceProfileActions.FETCH_SERVICEPROFILES), - switchMap(() => { - return this.http.get( - 'http://[::1]:3000/api/v1/chirpstack/service-profiles?limit=100&offset=0' - ); + switchMap((): Observable => { + const body = { + limit: 10, + offset: 0, + }; + const result = this.restService.get( + 'chirpstack/service-profiles', body); + console.log(result) + return result }), map(serviceProfiles => { - return serviceProfiles.map(serviceProfile => { + return serviceProfiles.result.map(serviceProfile => { return { ...serviceProfile, }; @@ -44,15 +49,19 @@ export class ServiceProfileEffects { storeServiceProfiles = this.actions$.pipe( ofType(ServiceProfileActions.STORE_SERVICEPROFILES), withLatestFrom(this.store.select('serviceProfiles')), - switchMap(([actionData, serviceProfileState]) => { - return this.http.post( - 'http://[::1]:3000/api/v1/chirpstack/service-profiles', - serviceProfileState.serviceProfiles + switchMap(([actionData, serviceProfileState]): Observable => { + const result = this.restService.post( + 'chirpstack/service-profiles', + serviceProfileState.serviceProfiles, + { observe: 'response' } ); + console.log(result) + return result }) ); constructor( + private restService: RestService, private actions$: Actions, private http: HttpClient, private store: Store From caaf6ca83a3e67b51ebf6c15aed182eb056e31b2 Mon Sep 17 00:00:00 2001 From: Allan Asp Christensen Date: Fri, 4 Sep 2020 00:35:19 +0200 Subject: [PATCH 9/9] sidste fixes --- package-lock.json | 6 + package.json | 1 + src/app/profiles/profiles-routing.module.ts | 2 +- src/app/profiles/profiles.component.ts | 4 +- .../service-profiles/service-profile.model.ts | 2 +- .../service-profiles-detail.component.html | 56 +++- .../service-profiles-detail.component.ts | 2 +- .../service-profiles-edit.component.html | 54 ++-- .../service-profiles-edit.component.scss | 3 + .../service-profiles-edit.component.ts | 22 +- .../service-profile-item.component.html | 7 +- .../service-profiles-list.component.ts | 4 +- .../service-profiles.module.ts | 2 + .../store/service-profile.effects.ts | 4 +- src/app/shared/Modules/material.module.ts | 95 ++++++ src/app/shared/services/rest.service.ts | 2 +- src/app/shared/top-bar/top-bar.component.ts | 2 +- src/app/store/app.reducer.ts | 2 +- src/assets/i18n/da.json | 253 ++++++++------- src/styles.scss | 24 +- tsconfig.json | 56 ++-- tslint.json | 290 +++++++++--------- 22 files changed, 538 insertions(+), 355 deletions(-) create mode 100644 src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.scss create mode 100644 src/app/shared/Modules/material.module.ts diff --git a/package-lock.json b/package-lock.json index be332f76..a2de4c23 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12817,6 +12817,12 @@ } } }, + "tslint-angular": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/tslint-angular/-/tslint-angular-3.0.3.tgz", + "integrity": "sha512-5xD1gLE89lBExfSbMslDw/ZfOZM0t0CJsoJa4svsgF7tlwVS3IpXjzNcNRN0RZqDBj+cdTlbeel6GpZ3PqpPiw==", + "dev": true + }, "tslint-config-prettier": { "version": "1.18.0", "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz", diff --git a/package.json b/package.json index f54e8f47..4c28bcda 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "prettier": "^2.0.5", "protractor": "~7.0.0", "ts-node": "~8.3.0", + "tslint-angular": "^3.0.3", "tslint-config-prettier": "^1.18.0", "typescript": "~3.8.3" } diff --git a/src/app/profiles/profiles-routing.module.ts b/src/app/profiles/profiles-routing.module.ts index f19c4c9d..2fd0e98d 100644 --- a/src/app/profiles/profiles-routing.module.ts +++ b/src/app/profiles/profiles-routing.module.ts @@ -32,4 +32,4 @@ const routes: Routes = [ imports: [RouterModule.forChild(routes)], exports: [RouterModule] }) -export class ProfilesRoutingModule { } \ No newline at end of file +export class ProfilesRoutingModule { } diff --git a/src/app/profiles/profiles.component.ts b/src/app/profiles/profiles.component.ts index 15d81056..b24894a1 100644 --- a/src/app/profiles/profiles.component.ts +++ b/src/app/profiles/profiles.component.ts @@ -1,9 +1,9 @@ import { Component, OnInit } from '@angular/core'; import { LoggingService } from '../logging.service'; import { ServiceProfile } from './service-profiles/service-profile.model'; -import * as ServiceProfilesAction from './service-profiles/store/service-profile.actions' +import * as ServiceProfilesAction from './service-profiles/store/service-profile.actions'; import { Store } from '@ngrx/store'; -import * as fromApp from '../store/app.reducer' +import * as fromApp from '../store/app.reducer'; @Component({ selector: 'app-profiles', diff --git a/src/app/profiles/service-profiles/service-profile.model.ts b/src/app/profiles/service-profiles/service-profile.model.ts index 479c9143..8db1b008 100644 --- a/src/app/profiles/service-profiles/service-profile.model.ts +++ b/src/app/profiles/service-profiles/service-profile.model.ts @@ -76,4 +76,4 @@ export class ServiceProfile { export interface ServiceProfileData { result: ServiceProfile[]; totalCount?: string; -} \ No newline at end of file +} diff --git a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html index f30056b7..1a38a536 100644 --- a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html +++ b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.html @@ -8,18 +8,21 @@
-

{{ 'IOTDEVICE.NAME' | translate }}

+

{{'PROFILES.SERVICE_PROFILE.NAME' | translate}}

{{serviceProfile.name}}

@@ -27,23 +30,42 @@

{{ 'IOTDEVICE.NAME' | translate }}

-

{{ 'IOTDEVICE.TYPE' }}

+

{{'PROFILES.SERVICE_PROFILE.REPORTBATTERYSTATUS' | translate}}

-

{{ 'IOT-DEVICE-TYPES.' + serviceProfile.drMin }}

+

{{serviceProfile.reportDevStatusBattery}}

- {{ serviceProfile.addGWMetaData }} - {{ serviceProfile.drMin }} - {{ serviceProfile.drMax }} - {{ serviceProfile.targetPER }} - - -
-
-
    - -
+
+
+

{{'PROFILES.SERVICE_PROFILE.ADDGWMETADATA' | translate}}

+
+
+

{{ serviceProfile.addGWMetaData }}

+
+
+
+
+

{{'PROFILES.SERVICE_PROFILE.DRRATEMIN' | translate}}

+
+
+

{{ serviceProfile.drMin }}

+
+
+
+
+

{{'PROFILES.SERVICE_PROFILE.DRRATEMAX' | translate}}

+
+
+

{{ serviceProfile.drMax}}

+
+
+
+
+

{{'PROFILES.SERVICE_PROFILE.REPORT_END_DEVICE' | translate}}

+
+
+

{{ serviceProfile.targetPER }}

\ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts index 92a6754e..126b05b6 100644 --- a/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts +++ b/src/app/profiles/service-profiles/service-profiles-detail/service-profiles-detail.component.ts @@ -17,7 +17,7 @@ import { TranslateService } from '@ngx-translate/core'; }) export class ServiceProfilesDetailComponent implements OnInit { public backButton: BackButton = { label: 'Go back', routerLink: '/profiles' }; - public title: string = ''; + public title: ''; serviceProfile: ServiceProfile; id: number; diff --git a/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html index 6e93c0f0..3b4501cd 100644 --- a/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html +++ b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.html @@ -1,30 +1,38 @@
- + +
- +
- +
- +
@@ -32,15 +40,17 @@
-
+
- +
-
+
- +
@@ -48,27 +58,19 @@
- +
-
- - - -
+
- -
diff --git a/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.scss b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.scss new file mode 100644 index 00000000..414bc59c --- /dev/null +++ b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.scss @@ -0,0 +1,3 @@ +.form-group { + margin-top: 25px; +} diff --git a/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts index 43ca5bb3..5ae94722 100644 --- a/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts +++ b/src/app/profiles/service-profiles/service-profiles-edit/service-profiles-edit.component.ts @@ -7,25 +7,29 @@ import { map } from 'rxjs/operators'; import * as fromApp from '../../../store/app.reducer'; import * as ServiceProfilesActions from '../store/service-profile.actions'; import { BackButton } from 'src/app/models/back-button'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'app-service-profiles-edit', templateUrl: './service-profiles-edit.component.html', + styleUrls: ['./service-profiles-edit.component.scss'] }) export class ServiceProfilesEditComponent implements OnInit { public backButton: BackButton = { label: '', routerLink: '/profiles' }; - public title: string = 'Service Profile Edit'; + public title: 'Service Profile'; id: number; editMode = false; serviceProfileForm: FormGroup; + GWvalues: string[] = ['true', 'false']; private storeSub: Subscription; constructor( private route: ActivatedRoute, private router: Router, - private store: Store + private store: Store, + private translate: TranslateService ) { } ngOnInit() { @@ -34,6 +38,12 @@ export class ServiceProfilesEditComponent implements OnInit { this.editMode = params['id'] != null; this.initForm(); }); + this.translate.get(['PROFILES.SERVICE_PROFILE.GOBACK', 'PROFILES.SERVICE_PROFILE.ADDSERVICEPROFILE',]) + .subscribe(translations => { + this.backButton.label = translations['PROFILES.SERVICE_PROFILE.GOBACK']; + this.title = translations['PROFILES.SERVICE_PROFILE.ADDSERVICEPROFILE']; + + }); } onSubmit() { @@ -55,15 +65,15 @@ export class ServiceProfilesEditComponent implements OnInit { this.router.navigate(['../'], { relativeTo: this.route }); } - ngOnDestroy() { + ngDestroy() { if (this.storeSub) { this.storeSub.unsubscribe(); } } private initForm() { - let serviceProfileName = ''; - let serviceProfileGWData = '{"Json":{"data":1}}'; + let serviceProfileName = 'Navngiv din profil'; + let serviceProfileGWData = false; let serviceProfileBatteryStatus = true; let serviceProfileMinDateRate = 2000; let serviceProfileMaxDateRate = 2000; @@ -81,6 +91,7 @@ export class ServiceProfilesEditComponent implements OnInit { ) .subscribe(serviceProfile => { serviceProfileName = serviceProfile.name; + serviceProfileGWData = serviceProfile.addGWMetaData; serviceProfileBatteryStatus = serviceProfile.reportDevStatusBattery; serviceProfileMinDateRate = serviceProfile.drMin; serviceProfileMaxDateRate = serviceProfile.drMax; @@ -91,6 +102,7 @@ export class ServiceProfilesEditComponent implements OnInit { this.serviceProfileForm = new FormGroup({ name: new FormControl(serviceProfileName, Validators.required), + addGWMetaData: new FormControl(serviceProfileGWData, Validators.required), reportDevStatusBattery: new FormControl(serviceProfileBatteryStatus, Validators.required), drMin: new FormControl(serviceProfileMinDateRate, Validators.required), drMax: new FormControl(serviceProfileMaxDateRate, Validators.required), diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html index 6ee9e8b9..800e9cf6 100644 --- a/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profile-item/service-profile-item.component.html @@ -3,10 +3,11 @@ -
\ No newline at end of file diff --git a/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts index 9bbcc72e..cb79016a 100644 --- a/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts +++ b/src/app/profiles/service-profiles/service-profiles-list/service-profiles-list.component.ts @@ -18,8 +18,8 @@ import { Router, ActivatedRoute } from '@angular/router'; export class ServiceProfilesListComponent implements OnInit, OnDestroy { serviceProfiles: ServiceProfile[]; subscription: Subscription; - public pageLimit: number = 10; - public pageOffset: number = 0; + public pageLimit: 10; + public pageOffset: 0; constructor( private router: Router, diff --git a/src/app/profiles/service-profiles/service-profiles.module.ts b/src/app/profiles/service-profiles/service-profiles.module.ts index 807c077c..e0a4e9f3 100644 --- a/src/app/profiles/service-profiles/service-profiles.module.ts +++ b/src/app/profiles/service-profiles/service-profiles.module.ts @@ -13,6 +13,7 @@ import { FormModule } from 'src/app/shared/form/form.module'; import { SharedModule } from 'src/app/shared/shared.module'; import { DirectivesModule } from 'src/app/shared/directives/directives.module'; import { TranslateModule } from '@ngx-translate/core'; +import { MaterialModule } from 'src/app/shared/Modules/material.module'; @@ -35,6 +36,7 @@ import { TranslateModule } from '@ngx-translate/core'; ReactiveFormsModule, FormModule, TranslateModule, + MaterialModule, StoreModule.forFeature('serviceProfiles', fromServiceProfiles.serviceProfileReducer), ] }) diff --git a/src/app/profiles/service-profiles/store/service-profile.effects.ts b/src/app/profiles/service-profiles/store/service-profile.effects.ts index ddc22ad4..e9893987 100644 --- a/src/app/profiles/service-profiles/store/service-profile.effects.ts +++ b/src/app/profiles/service-profiles/store/service-profile.effects.ts @@ -29,8 +29,8 @@ export class ServiceProfileEffects { }; const result = this.restService.get( 'chirpstack/service-profiles', body); - console.log(result) - return result + console.log(result); + return result; }), map(serviceProfiles => { return serviceProfiles.result.map(serviceProfile => { diff --git a/src/app/shared/Modules/material.module.ts b/src/app/shared/Modules/material.module.ts new file mode 100644 index 00000000..00e1b2a9 --- /dev/null +++ b/src/app/shared/Modules/material.module.ts @@ -0,0 +1,95 @@ +import { A11yModule } from '@angular/cdk/a11y'; +import { DragDropModule } from '@angular/cdk/drag-drop'; +import { PortalModule } from '@angular/cdk/portal'; +import { ScrollingModule } from '@angular/cdk/scrolling'; +import { CdkStepperModule } from '@angular/cdk/stepper'; +import { CdkTableModule } from '@angular/cdk/table'; +import { CdkTreeModule } from '@angular/cdk/tree'; +import { NgModule } from '@angular/core'; +import { MatAutocompleteModule } from '@angular/material/autocomplete'; +import { MatBadgeModule } from '@angular/material/badge'; +import { MatBottomSheetModule } from '@angular/material/bottom-sheet'; +import { MatButtonModule } from '@angular/material/button'; +import { MatButtonToggleModule } from '@angular/material/button-toggle'; +import { MatCardModule } from '@angular/material/card'; +import { MatCheckboxModule } from '@angular/material/checkbox'; +import { MatChipsModule } from '@angular/material/chips'; +import { MatNativeDateModule, MatRippleModule } from '@angular/material/core'; +import { MatDatepickerModule } from '@angular/material/datepicker'; +import { MatDialogModule } from '@angular/material/dialog'; +import { MatDividerModule } from '@angular/material/divider'; +import { MatExpansionModule } from '@angular/material/expansion'; +import { MatGridListModule } from '@angular/material/grid-list'; +import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; +import { MatListModule } from '@angular/material/list'; +import { MatMenuModule } from '@angular/material/menu'; +import { MatPaginatorModule } from '@angular/material/paginator'; +import { MatProgressBarModule } from '@angular/material/progress-bar'; +import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; +import { MatRadioModule } from '@angular/material/radio'; +import { MatSelectModule } from '@angular/material/select'; +import { MatSidenavModule } from '@angular/material/sidenav'; +import { MatSlideToggleModule } from '@angular/material/slide-toggle'; +import { MatSliderModule } from '@angular/material/slider'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; +import { MatSortModule } from '@angular/material/sort'; +import { MatStepperModule } from '@angular/material/stepper'; +import { MatTableModule } from '@angular/material/table'; +import { MatTabsModule } from '@angular/material/tabs'; +import { MatToolbarModule } from '@angular/material/toolbar'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { MatTreeModule } from '@angular/material/tree'; + +@NgModule({ + exports: [ + A11yModule, + CdkStepperModule, + CdkTableModule, + CdkTreeModule, + DragDropModule, + MatAutocompleteModule, + MatBadgeModule, + MatBottomSheetModule, + MatButtonModule, + MatButtonToggleModule, + MatCardModule, + MatCheckboxModule, + MatChipsModule, + MatStepperModule, + MatDatepickerModule, + MatDialogModule, + MatDividerModule, + MatExpansionModule, + MatGridListModule, + MatIconModule, + MatInputModule, + MatListModule, + MatMenuModule, + MatNativeDateModule, + MatPaginatorModule, + MatProgressBarModule, + MatProgressSpinnerModule, + MatRadioModule, + MatRippleModule, + MatSelectModule, + MatSidenavModule, + MatSliderModule, + MatSlideToggleModule, + MatSnackBarModule, + MatSortModule, + MatTableModule, + MatTabsModule, + MatToolbarModule, + MatTooltipModule, + MatTreeModule, + PortalModule, + ScrollingModule, + ] +}) +export class MaterialModule { } + + +/** Copyright 2019 Google Inc. All Rights Reserved. + Use of this source code is governed by an MIT-style license that + can be found in the LICENSE file at http://angular.io/license */ diff --git a/src/app/shared/services/rest.service.ts b/src/app/shared/services/rest.service.ts index 48498be6..6c05449e 100644 --- a/src/app/shared/services/rest.service.ts +++ b/src/app/shared/services/rest.service.ts @@ -228,7 +228,7 @@ export class RestService { }; } - /** Use the AlertService to notify of the request*/ + // Use the AlertService to notify of the request private log(alert: Alert) { this.alertService.add(alert); } diff --git a/src/app/shared/top-bar/top-bar.component.ts b/src/app/shared/top-bar/top-bar.component.ts index 7c5ab8ca..35b6c4bf 100644 --- a/src/app/shared/top-bar/top-bar.component.ts +++ b/src/app/shared/top-bar/top-bar.component.ts @@ -15,7 +15,7 @@ export class TopBarComponent implements OnInit { @Input() sort: Sort[]; @Input() pageLimit: number; @Input() selectedSortId: number; - @Input() component: boolean = false; + @Input() component: false; @Input() showSelectedSort = true; @Output() selectedSortChange = new EventEmitter(); diff --git a/src/app/store/app.reducer.ts b/src/app/store/app.reducer.ts index 93b0bfb2..d803cdd7 100644 --- a/src/app/store/app.reducer.ts +++ b/src/app/store/app.reducer.ts @@ -16,4 +16,4 @@ export const appReducer: ActionReducerMap = { }; export const metaReducers: MetaReducer[] = - !environment.production ? [storeFreeze] : []; \ No newline at end of file + !environment.production ? [storeFreeze] : []; diff --git a/src/assets/i18n/da.json b/src/assets/i18n/da.json index b5fa155b..a5a2124c 100644 --- a/src/assets/i18n/da.json +++ b/src/assets/i18n/da.json @@ -1,122 +1,139 @@ { - "GEN": { - "CANCEL": "Annuller", - "SHOW": "Vis", - "PER-PAGE": "Per side", - "BACK": "Tilbage", - "EDIT": "Redigér", - "APPLICATION": "Applikation", - "HTTP": "Generisk HTTP" - }, - "NAV": { - "DASHBOARD": "Dashboard", - "MY-APPLICATIONS": "Mine applikationer", - "ALL-IOT-DEVICES": "Alle IoT enheder" - }, - "APPLICATION": { - "CREATE": "Opret applikation", - "SAVE": "Gem applikation", - "DELETE": "Slet applikation", - "NAME": "Applikationens navn", - "DESCRIPTION": "Applikationens beskrivelse", - "ATTACHED-IOT": "Tilknyttede IoT enheder" - }, - "IOT-DEVICE": { - "CREATE": "Opret IoT enhed", - "SAVE": "Gem IoT enhed", - "DELETE": "Slet IoT enhed", - "RESTART": "Genstart IoT enhed" - }, - "APPLICATION-TABLE": { - "NAME": "NAVN", - "IOT-DEVICES": "IOT ENHEDER", - "UPDATED": "SENEST OPDATERET" - }, - "IOT-TABLE": { - "APPLICATION": "APPLIKATION", - "NETWORK-TECHNOLOGY": "NETVÆRKSTEKNOLOGI", - "ALARM": "ALARM", - "BATTERY": "BATTERI", - "ACTIVE": "AKTIV", - "DATA": "DATA(24 TIMER)" - }, - "IOT-DEVICE-TYPES": { - "GENERIC_HTTP": "Generisk HTTP" - }, - "ACTIVITY": { - "NEVER": "Aldrig set" + "GEN": { + "CANCEL": "Annuller", + "SHOW": "Vis", + "PER-PAGE": "Per side", + "BACK": "Tilbage", + "EDIT": "Redigér", + "APPLICATION": "Applikation", + "HTTP": "Generisk HTTP" + }, + "NAV": { + "DASHBOARD": "Dashboard", + "MY-APPLICATIONS": "Mine applikationer", + "ALL-IOT-DEVICES": "Alle IoT enheder" + }, + "APPLICATION": { + "CREATE": "Opret applikation", + "SAVE": "Gem applikation", + "DELETE": "Slet applikation", + "NAME": "Applikationens navn", + "DESCRIPTION": "Applikationens beskrivelse", + "ATTACHED-IOT": "Tilknyttede IoT enheder" + }, + "IOT-DEVICE": { + "CREATE": "Opret IoT enhed", + "SAVE": "Gem IoT enhed", + "DELETE": "Slet IoT enhed", + "RESTART": "Genstart IoT enhed" + }, + "APPLICATION-TABLE": { + "NAME": "NAVN", + "IOT-DEVICES": "IOT ENHEDER", + "UPDATED": "SENEST OPDATERET" + }, + "IOT-TABLE": { + "APPLICATION": "APPLIKATION", + "NETWORK-TECHNOLOGY": "NETVÆRKSTEKNOLOGI", + "ALARM": "ALARM", + "BATTERY": "BATTERI", + "ACTIVE": "AKTIV", + "DATA": "DATA(24 TIMER)" + }, + "IOT-DEVICE-TYPES": { + "GENERIC_HTTP": "Generisk HTTP" + }, + "ACTIVITY": { + "NEVER": "Aldrig set" + }, + "TABLE": { + "PAGINATION": "Navigér tabel" + }, + "APPLICATION-TABLE-ROW": { + "DELETE": "Slet", + "EDIT": "Redigér", + "SHOW-OPTIONS": "Vis muligheder" + }, + "IOTDEVICE-TABLE-ROW": { + "DELETE": "Slet", + "EDIT": "Redigér", + "SHOW-OPTIONS": "Vis muligheder" + }, + "FORM": { + "CREATE-NEW-APPLICATION": "Opret ny applikation", + "EDIT-NEW-APPLICATION": "Redigér applikation", + "CREATE-NEW-IOT-DEVICE": "Tilføj en IoT enhed", + "TRANSMISSION_PROTOCOL_TEXT": "Vælg transmissionsprotokol", + "TRANSMISSION_PROTOCOL_DESCRIPTION": "Transmissions protokollen angiver måden IoT-enheden forbinder til OS2IoT", + "ALERT-NO-DELETE-DEVICES": "Du kan ikke slette denne applikation da den indeholder IOT enhed(er)" + }, + "QUESTION": { + "GIVE-APPLICATION-NAME": "Navngiv applikation", + "APPLICATION-NAME-PLACEHOLDER": "Applikationens navn", + "GIVE-APPLICATION-DESCRIPTION": "Applikationens beskrivelse", + "APPLICATION-DESCRIPTION-PLACEHOLDER": "Kort beskrivelse af applikationen", + "TRANSMISSION-PROTOCOL": "Vælg transmissionsprotokol", + "ESTABLISH-CONNECTION-TO-DEVICE": "Opret forbindelse til din enhed", + "ADD-MORE-INFO-ABOUT-DEVICE": "Tilføj yderlige informationer om din enhed", + "DATATARGET": "Datatarget - Hvor vil du sende data hen?", + "REVIEW-AND-SUBMIT": "Gennemgå og godkend indstillinger for din IoT enhed", + "DEVICE-NAME-PLACEHOLDER": "Enhedsnavn", + "GIVE-DEVICE-NAME": "Navngiv enhed", + "EXTRA-COMMENT-PLACEHOLDER": "Anden relevant information", + "LOCATION-DESCRIPTION": "Beskrivelse af placering", + "LOCATION-DESCRIPTION-PLACEHOLDER": "F.eks. køleskab på 3. sal", + "CHOOSE-APPLICATION": "Vælg applikation" + }, + "SORT": { + "SORT": "Sortér", + "UPDATED-ASCENDING": "Senest opdateret: stigende", + "UPDATED-DESCENDING": "Senest opdateret: faldende", + "CREATED-ASCENDING": "Oprettet: stigende", + "CREATED-DESCENDING": "Oprettet: faldende", + "NAME-ASCENDING": "Navn: stigende", + "NAME-DESCENDING": "Navn: faldende", + "APPLICATION-ASCENDING": "Applikation: stigende", + "APPLICATION-DESCENDING": "Applikation: faldende", + "BATTERY-ASCENDING": "Batteri: stigende", + "BATTERY-DESCENDING": "Batteri: faldende" + }, + "IOTDEVICE": { + "HEADING": { + "PROTOCOL": "Transmission Protokol", + "BASIC": "Basis info", + "OPTIONAL": "Yderligere info" }, - "TABLE": { - "PAGINATION": "Navigér tabel" - }, - "APPLICATION-TABLE-ROW": { - "DELETE": "Slet", - "EDIT": "Redigér", - "SHOW-OPTIONS": "Vis muligheder" - }, - "IOTDEVICE-TABLE-ROW": { - "DELETE": "Slet", - "EDIT": "Redigér", - "SHOW-OPTIONS": "Vis muligheder" - }, - "FORM": { - "CREATE-NEW-APPLICATION": "Opret ny applikation", - "EDIT-NEW-APPLICATION": "Redigér applikation", - "CREATE-NEW-IOT-DEVICE": "Tilføj en IoT enhed", - "TRANSMISSION_PROTOCOL_TEXT": "Vælg transmissionsprotokol", - "TRANSMISSION_PROTOCOL_DESCRIPTION": "Transmissions protokollen angiver måden IoT-enheden forbinder til OS2IoT", - "ALERT-NO-DELETE-DEVICES": "Du kan ikke slette denne applikation da den indeholder IOT enhed(er)" - }, - "QUESTION": { - "GIVE-APPLICATION-NAME": "Navngiv applikation", - "APPLICATION-NAME-PLACEHOLDER": "Applikationens navn", - "GIVE-APPLICATION-DESCRIPTION": "Applikationens beskrivelse", - "APPLICATION-DESCRIPTION-PLACEHOLDER": "Kort beskrivelse af applikationen", - "TRANSMISSION-PROTOCOL": "Vælg transmissionsprotokol", - "ESTABLISH-CONNECTION-TO-DEVICE": "Opret forbindelse til din enhed", - "ADD-MORE-INFO-ABOUT-DEVICE": "Tilføj yderlige informationer om din enhed", - "DATATARGET": "Datatarget - Hvor vil du sende data hen?", - "REVIEW-AND-SUBMIT": "Gennemgå og godkend indstillinger for din IoT enhed", - "DEVICE-NAME-PLACEHOLDER": "Enhedsnavn", - "GIVE-DEVICE-NAME": "Navngiv enhed", - "EXTRA-COMMENT-PLACEHOLDER": "Anden relevant information", - "LOCATION-DESCRIPTION": "Beskrivelse af placering", - "LOCATION-DESCRIPTION-PLACEHOLDER": "F.eks. køleskab på 3. sal", - "CHOOSE-APPLICATION": "Vælg applikation" - }, - "SORT": { - "SORT": "Sortér", - "UPDATED-ASCENDING": "Senest opdateret: stigende", - "UPDATED-DESCENDING": "Senest opdateret: faldende", - "CREATED-ASCENDING": "Oprettet: stigende", - "CREATED-DESCENDING": "Oprettet: faldende", - "NAME-ASCENDING": "Navn: stigende", - "NAME-DESCENDING": "Navn: faldende", - "APPLICATION-ASCENDING": "Applikation: stigende", - "APPLICATION-DESCENDING": "Applikation: faldende", - "BATTERY-ASCENDING": "Batteri: stigende", - "BATTERY-DESCENDING": "Batteri: faldende" - }, - "IOTDEVICE": { - "HEADING": { - "PROTOCOL": "Transmission Protokol", - "BASIC": "Basis info", - "OPTIONAL": "Yderligere info" - }, + "NAME": "Navn", + "TYPE": "Enhedstype", + "APPLICATION": "Applikation", + "LOCATION": "Placering", + "LONGITUDE": "Længdegrad", + "LATITUDE": "Breddegrad", + "COMMENTONLOCATION": "Kommentar om placering", + "COMMENT": "Kommentar", + "NOCOMMENT": "Ingen kommentar er angivet.", + "NOLOCATION": "Ingen placering er angivet", + "NOCOMMENTONLOCATION": "Ingen kommentar om placeringen er angivet", + "GENERIC_HTTP": { + "APIKEY": "API kald", + "INSTRUCTIONS": "Du kalder denne url:" + } + }, + "PROFILES": { + "SERVICE_PROFILE": { + "DROPDOWN": "Håndter service profil", + "EDIT": "Editer service profil", + "DELETE": "Slet service profil", "NAME": "Navn", - "TYPE": "Enhedstype", - "APPLICATION": "Applikation", - "LOCATION": "Placering", - "LONGITUDE": "Længdegrad", - "LATITUDE": "Breddegrad", - "COMMENTONLOCATION": "Kommentar om placering", - "COMMENT": "Kommentar", - "NOCOMMENT": "Ingen kommentar er angivet.", - "NOLOCATION": "Ingen placering er angivet", - "NOCOMMENTONLOCATION": "Ingen kommentar om placeringen er angivet", - "GENERIC_HTTP": { - "APIKEY": "API kald", - "INSTRUCTIONS": "Du kalder denne url:" - } + "REPORTBATTERYSTATUS": "Report battery status", + "ADDGWMETADATA": "Tilføjet GW meta data", + "DRRATEMIN": "Min date rate", + "DRRATEMAX": "Max date rate", + "REPORT_END_DEVICE": "Report end-device margin", + "SAVE": "Gem", + "CANCEL": "Annuller", + "GOBACK": "Gå tilbage", + "ADDSERVICEPROFILE": "Tilføj eller editer service profil" } -} \ No newline at end of file + } +} diff --git a/src/styles.scss b/src/styles.scss index f60b7aca..addae3cb 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -1,4 +1,3 @@ - // Custom Theming for Angular Material // For more information: https://material.angular.io/guide/theming @import '~@angular/material/theming'; @@ -31,18 +30,18 @@ $OS2IoT-frontend-theme: mat-light-theme($OS2IoT-frontend-primary, $OS2IoT-fronte // Fonts @font-face { - font-family: 'roboto-light'; - src: url('./assets/fonts/Roboto-Light.ttf') format('truetype'); + font-family: 'roboto-light'; + src: url('./assets/fonts/Roboto-Light.ttf') format('truetype'); } @font-face { - font-family: 'roboto'; - src: url('./assets/fonts/Roboto-Regular.ttf') format('truetype'); + font-family: 'roboto'; + src: url('./assets/fonts/Roboto-Regular.ttf') format('truetype'); } @font-face { - font-family: 'roboto-bold'; - src: url('./assets/fonts/Roboto-Bold.ttf') format('truetype'); + font-family: 'roboto-bold'; + src: url('./assets/fonts/Roboto-Bold.ttf') format('truetype'); } @@ -56,5 +55,12 @@ $OS2IoT-frontend-theme: mat-light-theme($OS2IoT-frontend-primary, $OS2IoT-fronte @import 'assets/scss/forms'; -html, body { height: 100%; } -body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } +html, +body { + height: 100%; +} + +body { + margin: 0; + font-family: Roboto, "Helvetica Neue", sans-serif; +} diff --git a/tsconfig.json b/tsconfig.json index ebe72c45..437e0730 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,21 +1,41 @@ { - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist/out-tsc", - "sourceMap": true, - "declaration": false, - "downlevelIteration": true, - "experimentalDecorators": true, - "module": "esnext", - "moduleResolution": "node", - "importHelpers": true, - "target": "es2015", - "lib": ["es2018", "dom"], - "typeRoots": ["node_modules/@types"] + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "downlevelIteration": true, + "experimentalDecorators": true, + "module": "esnext", + "moduleResolution": "node", + "importHelpers": true, + "target": "es2015", + "lib": ["es2018", "dom"], + "typeRoots": ["node_modules/@types"], + "paths": { + "@app/*": [ + "app/*" + ], + "@shared/*": [ + "app/shared/*" + ], + "@store/*": [ + "app/store/*" + ], + "@environments/*": [ + "environments/*" + ], + "@Material": [ + "app/shared/modules/material.module" + ], + "@Shared-Bootstrap": [ + "app/shared/modules/shared-bootstrap.module" + ] }, - "angularCompilerOptions": { - "fullTemplateTypeCheck": true, - "strictInjectionParameters": true - } + }, + "angularCompilerOptions": { + "fullTemplateTypeCheck": true, + "strictInjectionParameters": true + } } diff --git a/tslint.json b/tslint.json index 0577aa05..4f4dff57 100644 --- a/tslint.json +++ b/tslint.json @@ -1,151 +1,147 @@ { - "extends": [ - "tslint:recommended", - "tslint-angular", - "tslint-config-prettier" - ], - "rules": { - "align": { - "options": ["parameters", "statements"] - }, - "array-type": false, - "arrow-return-shorthand": true, - "callable-types": true, - "class-name": true, - "comment-format": [ - true, - "check-space" - ], - "component-class-suffix": true, - "component-selector": [true, "element", "app", "kebab-case"], - "curly": true, - "deprecation": { - "severity": "warning" - }, - "contextual-lifecycle": true, - "directive-class-suffix": true, - "directive-selector": [true, "attribute", "app", "camelCase"], - "eofline": true, - "forin": true, - "interface-over-type-literal": true, - "import-blacklist": [true, "rxjs/Rx"], - "import-spacing": true, - "indent": { - "options": ["spaces"] - }, - "label-position": true, - "max-classes-per-file": false, - "max-line-length": [true, 200], - "member-access": false, - "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"] - }, - "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, - "no-arg": true, - "no-bitwise": true, - "no-construct": true, - "no-debugger": true, - "no-duplicate-super": true, - "no-empty-interface": true, - "no-eval": true, - "no-misused-new": true, - "no-shadowed-variable": [ - false, - { - "class": true, - "enum": true, - "function": true, - "interface": false, - "namespace": true, - "typeAlias": false, - "typeParameter": false - } - ], - "no-string-literal": false, - "no-string-throw": true, - "no-trailing-whitespace": true, - "no-unnecessary-initializer": true, - "no-unused-expression": true, - "no-use-before-declare": true, - "no-var-keyword": true, - "object-literal-sort-keys": false, - "one-line": [ - true, - "check-open-brace", - "check-catch", - "check-else", - "check-whitespace" + "extends": [ + "tslint:recommended", + "tslint-angular", + "tslint-config-prettier" ], - "prefer-const": true, - "radix": true, - "space-before-function-paren": { - "options": { - "anonymous": "never", - "asyncArrow": "always", - "constructor": "never", - "method": "never", - "named": "never" - } - }, - "template-banana-in-box": true, - "template-no-negated-async": true, - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef-whitespace": { - "options": [{ - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - }] - }, - "unified-signatures": true, - "use-lifecycle-interface": true, - "use-pipe-transform-interface": true, - "variable-name": { - "options": ["ban-keywords", "check-format", "allow-pascal-case"] + "rules": { + "align": { + "options": ["parameters", "statements"] + }, + "array-type": false, + "arrow-return-shorthand": true, + "callable-types": true, + "class-name": true, + "comment-format": [true, "check-space"], + "component-class-suffix": true, + "component-selector": [true, "element", "app", "kebab-case"], + "curly": true, + "deprecation": { + "severity": "warning" + }, + "contextual-lifecycle": true, + "directive-class-suffix": true, + "directive-selector": [true, "attribute", "app", "camelCase"], + "eofline": true, + "forin": true, + "interface-over-type-literal": true, + "import-blacklist": [true, "rxjs/Rx"], + "import-spacing": true, + "indent": { + "options": ["spaces"] + }, + "label-position": true, + "max-classes-per-file": false, + "max-line-length": [true, 200], + "member-access": false, + "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"] + }, + "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, + "no-arg": true, + "no-bitwise": true, + "no-construct": true, + "no-debugger": true, + "no-duplicate-super": true, + "no-empty-interface": true, + "no-eval": true, + "no-misused-new": true, + "no-shadowed-variable": [ + false, + { + "class": true, + "enum": true, + "function": true, + "interface": false, + "namespace": true, + "typeAlias": false, + "typeParameter": false + } + ], + "no-string-literal": false, + "no-string-throw": true, + "no-trailing-whitespace": true, + "no-unnecessary-initializer": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "prefer-const": true, + "radix": true, + "space-before-function-paren": { + "options": { + "anonymous": "never", + "asyncArrow": "always", + "constructor": "never", + "method": "never", + "named": "never" + } + }, + "template-banana-in-box": true, + "template-no-negated-async": true, + "triple-equals": [true, "allow-null-check"], + "typedef-whitespace": { + "options": [ + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ] + }, + "unified-signatures": true, + "use-lifecycle-interface": true, + "use-pipe-transform-interface": true, + "variable-name": { + "options": ["ban-keywords", "check-format", "allow-pascal-case"] + }, + "whitespace": { + "options": [ + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type", + "check-typecast", + "check-module" + ] + } }, - "whitespace": { - "options": [ - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type", - "check-typecast", - "check-module" - ] - } - }, - "rulesDirectory": ["codelyzer"] + "rulesDirectory": ["codelyzer"] }