Skip to content

Commit 7faffbc

Browse files
committed
IOT-34 moved gateway and rename
1 parent 02c3c2e commit 7faffbc

File tree

46 files changed

+312
-681
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+312
-681
lines changed

src/app/app-routing.module.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import { NgModule } from '@angular/core';
22
import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
3-
import { MineLoraGatewaysComponent } from './views/administration-gateway/lora-gateways/lora-gateways.component';
4-
import { ListLoraGatewayComponent } from './views/administration-gateway/list-lora-gateway/list-lora-gateway.component';
5-
import { EditGatewayComponent } from './views/administration-gateway/edit-gateway/edit-gateway.component';
6-
import { GatewayComponent } from './views/administration-gateway/gateway/gateway.component';
73
import { DatatargetListComponent } from './views/datatarget/datatarget-list/datatarget-list.component';
84
import { AuthComponent } from './auth/auth.component';
95
import { DashboardComponent } from './dashboard/dashboard.component';
6+
import { GatewaysComponent } from './gateway/gateways/gateways.component';
7+
import { GatewayEditComponent } from './gateway/gateway-edit/gateway-edit.component';
8+
import { GatewayListComponent } from './gateway/gateway-list/gateway-list.component';
9+
import { GatewayDetailComponent } from './gateway/gateway-detail/gateway-detail.component';
1010

1111
const routes: Routes = [
1212
{ path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) },
1313
{ path: 'auth', component: AuthComponent },
1414
{ path: 'dashboard', component: DashboardComponent },
1515
{ path: 'my-applications', loadChildren: () => import('./my-applications/my-applications.module').then(m => m.MyApplicationsModule) },
1616
{
17-
path: 'lora-gateways', component: MineLoraGatewaysComponent,
17+
path: 'gateways', component: GatewaysComponent,
1818
children: [
19-
{ path: '', component: ListLoraGatewayComponent },
20-
{ path: 'edit-gateway/:id', component: EditGatewayComponent },
21-
{ path: 'edit-gateway', component: EditGatewayComponent },
22-
{ path: 'gateway/:id', component: GatewayComponent }
19+
{ path: '', component: GatewayListComponent },
20+
{ path: 'gateway-edit/:id', component: GatewayEditComponent },
21+
{ path: 'gateway-edit', component: GatewayEditComponent },
22+
{ path: 'gateway-detail/:id', component: GatewayDetailComponent }
2323
],
2424
},
2525
{ path: 'datatarget', component: DatatargetListComponent },

src/app/app.module.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ import { NavbarModule } from './navbar/navbar.module';
99
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
1010
import { ReactiveFormsModule } from '@angular/forms';
1111
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
12-
import { AdministrationGatewayModule } from './views/administration-gateway/administration-gateway.module';
1312
import { DatatargetModule } from './views/datatarget/datatarget.module';
1413
import { ProfilesModule } from './profiles/profiles.module';
1514
import { AuthJwtInterceptor } from '@shared/helpers/auth-jwt.interceptor';
1615
import { AuthModule } from './auth/auth.module';
17-
import { GlobalErrorHandler } from '@shared/helpers/global-error-handler';
1816
import { SharedVariableModule } from './shared-variable/shared-variable.module';
1917
import { DashboardModule } from './dashboard/dashboard.module';
18+
import { GatewayModule } from './gateway/gateway.module';
2019

2120
export function HttpLoaderFactory(http: HttpClient) {
2221
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
@@ -46,7 +45,7 @@ export function HttpLoaderFactory(http: HttpClient) {
4645
NgbModule,
4746
ReactiveFormsModule,
4847
BrowserAnimationsModule,
49-
AdministrationGatewayModule,
48+
GatewayModule,
5049
],
5150
bootstrap: [AppComponent],
5251
exports: [TranslateModule],
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<app-top-bar-single [data]="gateway" [backButton]="backButton"></app-top-bar-single>
2+
<div class="application-component">
3+
<div class="col-12 mb-4 py-3 bottom-separator">
4+
<div class="col-12 col-sm-12">
5+
<div class="col-12 col-sm-12">
6+
<h4>{{ 'GATEWAY.NAME' | translate }}</h4>
7+
</div>
8+
<div class="col-12 pt-2 col-sm-8">
9+
<p>{{gateway.name}}</p>
10+
</div>
11+
</div>
12+
<div class="col-12 py-4">
13+
<div class="col-12 col-sm-12">
14+
<h4>{{ 'GATEWAY.DESCRIPTION' | translate }}</h4>
15+
</div>
16+
<div class="col-12 pt-2 col-sm-8">
17+
<p>{{gateway.description}}</p>
18+
</div>
19+
</div>
20+
<div class="col-12 py-4">
21+
<div class="col-12 col-sm-4">
22+
<h4>{{ 'GATEWAY.ID' | translate }}</h4>
23+
</div>
24+
<div class="col-12 pt-2 col-sm-8">
25+
<p>{{gateway.id}}</p>
26+
</div>
27+
</div>
28+
<div class="col-12 py-4">
29+
<div class="col-12 col-sm-4 pb-2">
30+
<h4>{{ 'GATEWAY.LOCATION' | translate }}</h4>
31+
</div>
32+
<div *ngIf="gateway.location; then locationThenBlock else locationElseBlock"></div>
33+
<ng-template #locationThenBlock>
34+
<div class="col-4">
35+
<h5>{{ 'GATEWAY.LONGITUDE' | translate }}</h5>
36+
<p>{{gateway.location?.longitude}}</p>
37+
</div>
38+
<div class="col-4">
39+
<h5>{{ 'GATEWAY.LATITUDE' | translate }}</h5>
40+
<p>{{gateway.location.latitude}}</p>
41+
</div>
42+
<div class="col-4">
43+
<h5>{{ 'GATEWAY.ALTITUDE' | translate }}</h5>
44+
<p>{{gateway.location.altitude}}</p>
45+
</div>
46+
</ng-template>
47+
<ng-template #locationElseBlock>
48+
<p>{{ 'GATEWAY.NOLOCATION' | translate}}</p>
49+
</ng-template>
50+
</div>
51+
<div class="col-12 py-4">
52+
<div class="col-12 col-sm-4">
53+
<h4>{{ 'GATEWAY.TAGS' | translate }}</h4>
54+
</div>
55+
<div class="col-12 pt-2 col-sm-8">
56+
<p>{{gateway.tagsString}}</p>
57+
</div>
58+
</div>
59+
</div>
60+
</div>

src/app/shared/form/form-body-lora-gateway/form-body-lora-gateway.component.scss renamed to src/app/gateway/gateway-detail/gateway-detail.component.scss

File renamed without changes.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Component, OnDestroy, OnInit } from '@angular/core';
2+
import { Gateway } from 'src/app/models/gateway';
3+
import { Subscription } from 'rxjs';
4+
import { ChirpstackGatewayService } from 'src/app/shared/services/chirpstack-gateway.service';
5+
import { ActivatedRoute } from '@angular/router';
6+
import { TranslateService } from '@ngx-translate/core';
7+
import { BackButton } from 'src/app/models/back-button';
8+
9+
@Component({
10+
selector: 'app-gateway-detail',
11+
templateUrl: './gateway-detail.component.html',
12+
styleUrls: ['./gateway-detail.component.scss']
13+
})
14+
export class GatewayDetailComponent implements OnInit, OnDestroy {
15+
16+
public gatewaySubscription: Subscription;
17+
public gateway: Gateway;
18+
public backButton: BackButton = { label: '', routerLink: '/gateways' };
19+
private id: string;
20+
constructor(
21+
private gatewayService: ChirpstackGatewayService,
22+
private route: ActivatedRoute,
23+
private translate: TranslateService,
24+
) { }
25+
26+
ngOnInit(): void {
27+
this.translate.use('da');
28+
this.id = this.route.snapshot.paramMap.get('id');
29+
if (this.id) {
30+
this.bindGateway(this.id);
31+
}
32+
this.translate.get(['NAV.LORA-GATEWAYS'])
33+
.subscribe(translations => {
34+
this.backButton.label = translations['NAV.LORA-GATEWAYS'];
35+
});
36+
}
37+
38+
bindGateway(id: string): void {
39+
this.gatewayService.get(id).subscribe((result: any) => {
40+
result.gateway.tagsString = JSON.stringify(result.gateway.tags);
41+
this.gateway = result.gateway;
42+
console.log('gateway', this.gateway);
43+
});
44+
}
45+
46+
ngOnDestroy() {
47+
if (this.gatewaySubscription) {
48+
this.gatewaySubscription.unsubscribe();
49+
}
50+
}
51+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<app-form-header [backButton]="backButton" [title]="title"></app-form-header>
2+
<form (ngSubmit)="onSubmit()" class="os2-form p-3 mt-4">
3+
<div *ngIf="errorMessages" class="error-messages p-3">
4+
<ul class="mb-0">
5+
<li *ngFor="let error of errorMessages">
6+
{{error}}
7+
</li>
8+
</ul>
9+
</div>
10+
11+
<div class="row">
12+
<div class="form-group mt-3">
13+
<label class="form-label" for="name">{{'QUESTION-LORA-GATEWAY.NAME' | translate}}</label>*
14+
<input type="text" class="form-control" id="name" name="name"
15+
[placeholder]="'QUESTION-LORA-GATEWAY.NAME-PLACEHOLDER' | translate" maxlength="50" required
16+
[(ngModel)]="gateway.name"
17+
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('name'), 'is-valid' : formFailedSubmit && !errorFields.includes('name')}">
18+
</div>
19+
20+
<div class="form-group mt-3">
21+
<label class="form-label" for="description">{{'QUESTION-LORA-GATEWAY.DESCRIPTION' | translate}}</label>
22+
<textarea id="description" name="description"
23+
[placeholder]="'QUESTION-LORA-GATEWAY.DESCRIPTION-PLACEHOLDER' | translate" [maxLength]="1024" [rows]="6"
24+
class="form-control" [(ngModel)]="gateway.description"
25+
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('description'), 'is-valid' : formFailedSubmit && !errorFields.includes('description')}"></textarea>
26+
</div>
27+
28+
<div class="form-group mt-3">
29+
<label class="form-label" for="id">{{'QUESTION-LORA-GATEWAY.GATEWAYID' | translate}}</label>*
30+
<input type="text" class="form-control" id="id" name="id"
31+
[placeholder]="'QUESTION-LORA-GATEWAY.GATEWAYID-PLACEHOLDER' | translate" maxlength="16" required
32+
[(ngModel)]="gateway.id"
33+
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('id'), 'is-valid' : formFailedSubmit && !errorFields.includes('id')}">
34+
</div>
35+
36+
<div class="row mb-5">
37+
<div class="form-group mt-3 col-6">
38+
<label class="form-label" for="longitude">{{'GATEWAY.LONGITUDE' | translate}}</label>
39+
<input type="number" class="form-control" id="longitude" name="longitude" [placeholder]="00" required
40+
[(ngModel)]="gateway.location.longitude" step=".000001" min="-180" max="180" maxlength="9"
41+
(keyup)="onCoordinateKey($event)"
42+
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('longitude'), 'is-valid' : formFailedSubmit && !errorFields.includes('longitude')}">
43+
</div>
44+
45+
<div class="form-group mt-3 col-6">
46+
<label class="form-label" for="latitude">{{'GATEWAY.LATITUDE' | translate}}</label>
47+
<input type="number" class="form-control" id="location.latitude" name="location.latitude" [placeholder]="00"
48+
required [(ngModel)]="gateway.location.latitude" step=".000001" min="-180" max="180" maxlength="9"
49+
(keyup)="onCoordinateKey($event)"
50+
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('longitude'), 'is-valid' : formFailedSubmit && !errorFields.includes('longitude')}">
51+
</div>
52+
53+
<div class="form-group mt-3 col-6">
54+
<label class="form-label" for="altitude">{{'GATEWAY.ALTITUDE' | translate}}</label>
55+
<input type="number" class="form-control" id="altitude" name="altitude" [placeholder]="00" required
56+
[(ngModel)]="gateway.location.altitude" step=".000001" min="-180" max="180" maxlength="9"
57+
(keyup)="onCoordinateKey($event)"
58+
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('longitude'), 'is-valid' : formFailedSubmit && !errorFields.includes('longitude')}">
59+
</div>
60+
</div>
61+
<div class="form-group mt-3">
62+
<label class="form-label" for="tagsString">{{'QUESTION-LORA-GATEWAY.METADATA' | translate}}</label>
63+
<input type="text" class="form-control" id="tagsString" name="tagsString"
64+
[placeholder]="'QUESTION-LORA-GATEWAY.METADATA-PLACEHOLDER' | translate" required
65+
[(ngModel)]="gateway.tagsString"
66+
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('tagsString'), 'is-valid' : formFailedSubmit && !errorFields.includes('tagsString')}">
67+
</div>
68+
69+
</div>
70+
71+
<div class="form-group mt-5">
72+
<button (click)="routeBack()" class="btn btn-secondary" type="button">{{ 'GEN.CANCEL' | translate}}</button>
73+
<button class="btn btn-primary ml-2" type="submit">{{ submitButton }}</button>
74+
</div>
75+
</form>
76+
<!-- test app-form-iot--gateway -->

src/app/views/administration-gateway/admin-lora-table-row/admin-lora-table-row.component.scss renamed to src/app/gateway/gateway-edit/gateway-edit.component.scss

File renamed without changes.

src/app/shared/form/form-body-lora-gateway/form-body-lora-gateway.component.ts renamed to src/app/gateway/gateway-edit/gateway-edit.component.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
import { Component, OnInit, Input } from '@angular/core';
2-
import { FormGroup } from '@angular/forms';
3-
import { Router, ActivatedRoute } from '@angular/router';
4-
1+
import { HttpErrorResponse } from '@angular/common/http';
2+
import { Component, OnDestroy, OnInit } from '@angular/core';
3+
import { ActivatedRoute, Router } from '@angular/router';
54
import { TranslateService } from '@ngx-translate/core';
6-
import { Gateway, GatewayResponse } from '../../../../app/models/gateway';
75
import { Subscription } from 'rxjs';
8-
import { HttpErrorResponse } from '@angular/common/http';
9-
import { ChirpstackGatewayService } from '../../services/chirpstack-gateway.service';
6+
import { BackButton } from 'src/app/models/back-button';
7+
import { Gateway, GatewayResponse } from 'src/app/models/gateway';
8+
import { ChirpstackGatewayService } from 'src/app/shared/services/chirpstack-gateway.service';
109

1110
@Component({
12-
selector: 'app-form-body-lora-gateway',
13-
templateUrl: './form-body-lora-gateway.component.html',
14-
styleUrls: ['./form-body-lora-gateway.component.scss']
11+
selector: 'app-gateway-edit',
12+
templateUrl: './gateway-edit.component.html',
13+
styleUrls: ['./gateway-edit.component.scss']
1514
})
16-
export class FormBodyLoraGatewayComponent implements OnInit {
15+
export class GatewayEditComponent implements OnInit, OnDestroy {
16+
17+
public backButton: BackButton = { label: '', routerLink: '/gateways' };
18+
public multiPage = false;
19+
public title = '';
20+
public sectionTitle = '';
21+
public submitButton = '';
1722

18-
@Input() submitButton: string;
19-
public form: FormGroup;
20-
public payLoad = '';
2123
public gatewaySubscription: Subscription;
2224
public errorMessage: string;
2325
public errorMessages: any;
@@ -40,6 +42,12 @@ export class FormBodyLoraGatewayComponent implements OnInit {
4042
if (this.id) {
4143
this.getGateway(this.id);
4244
}
45+
this.translate.get(['NAV.LORA-GATEWAYS', 'FORM.EDIT-NEW-GATEWAY', 'GATEWAY.SAVE'])
46+
.subscribe(translations => {
47+
this.backButton.label = translations['NAV.LORA-GATEWAYS'];
48+
this.title = translations['FORM.EDIT-NEW-GATEWAY'];
49+
this.submitButton = translations['GATEWAY.SAVE'];
50+
});
4351
}
4452

4553
getGateway(id: string): void {
@@ -85,7 +93,7 @@ export class FormBodyLoraGatewayComponent implements OnInit {
8593
}
8694

8795
routeBack(): void {
88-
this.router.navigateByUrl('/lora-gateways');
96+
this.router.navigateByUrl('/gateways');
8997
}
9098

9199
ngOnDestroy() {
@@ -117,4 +125,5 @@ export class FormBodyLoraGatewayComponent implements OnInit {
117125
}
118126
this.formFailedSubmit = true;
119127
}
128+
120129
}

src/app/views/administration-gateway/list-lora-gateway/list-lora-gateway.component.html renamed to src/app/gateway/gateway-list/gateway-list.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<div class="px-sm-5 py-sm-4">
22
<div class="row mb-5">
33
<app-top-bar [pageLimit]="pageLimit" [title]="'NAV.LORA-GATEWAYS' | translate"
4-
[ctaLabel]="'FORM.CREATE-NEW-LORA-GATEWAY' | translate" [ctaRouterLink]="'edit-gateway'">
4+
[ctaLabel]="'FORM.CREATE-NEW-LORA-GATEWAY' | translate" [ctaRouterLink]="'gateway-edit'">
55
</app-top-bar>
66
</div>
77
<div class="row">
8-
<app-admin-lora-table [selectedSortObject]="selectedSortObject" [pageLimit]="pageLimit"></app-admin-lora-table>
8+
<app-gateway-table [selectedSortObject]="selectedSortObject" [pageLimit]="pageLimit"></app-gateway-table>
99
</div>
1010
</div>

src/app/views/administration-gateway/admin-lora-table/admin-lora-table.component.scss renamed to src/app/gateway/gateway-list/gateway-list.component.scss

File renamed without changes.

0 commit comments

Comments
 (0)