Skip to content

Commit

Permalink
NOISSUE - Renaming mac, gw password (#92)
Browse files Browse the repository at this point in the history
* change path for export config

Signed-off-by: Mirko Teodorovic <[email protected]>

* rename mac->externa_id, gw_password->external_key

Signed-off-by: Mirko Teodorovic <[email protected]>

* rename mac->externa_id, gw_password->external_key

Signed-off-by: Mirko Teodorovic <[email protected]>

* rename mac->externa_id, gw_password->external_key

Signed-off-by: Mirko Teodorovic <[email protected]>

* var rename

Signed-off-by: Mirko Teodorovic <[email protected]>

* var rename

Signed-off-by: Mirko Teodorovic <[email protected]>
  • Loading branch information
mteodor authored May 6, 2020
1 parent 8df1153 commit edf531b
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 36 deletions.
5 changes: 2 additions & 3 deletions src/app/common/interfaces/gateway.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export interface GatewayMetadata {
data_channel_id?: string;
export_channel_id?: string;
export_thing_id?: string;
gw_password?: string;
mac?: string;
external_key?: string;
external_id?: string;
cfg_id?: string;
type?: string;
}
Expand All @@ -14,5 +14,4 @@ export interface Gateway {
key?: string;
name?: string;
metadata?: GatewayMetadata;
mac?: string;
}
8 changes: 4 additions & 4 deletions src/app/common/services/bootstrap/bootstrap.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export class BootstrapService {
thing_id: gw.id,
thing_key: gw.key,
channels: [gw.metadata.ctrl_channel_id, gw.metadata.data_channel_id],
external_id: gw.metadata.mac,
external_key: gw.metadata.gw_password,
external_id: gw.metadata.external_id,
external_key: gw.metadata.external_key,
content: JSON.stringify(this.content),
state: 0,
};
Expand Down Expand Up @@ -77,10 +77,10 @@ export class BootstrapService {

getConfig(gateway: Gateway) {
const headers = new HttpHeaders({
'Authorization': gateway.metadata.gw_password,
'Authorization': gateway.metadata.external_key,
});

return this.http.get(`${environment.bootstrapUrl}/${gateway.metadata.mac}`, { headers: headers });
return this.http.get(`${environment.bootstrapUrl}/${gateway.metadata.external_id}`, { headers: headers });
}

updateConfig(configUpdate: ConfigUpdate, gateway: Gateway) {
Expand Down
10 changes: 5 additions & 5 deletions src/app/common/services/gateways/gateways.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export class GatewaysService {
return this.channelsService.getChannels(offset, limit, this.typeDataChan);
}

addGateway(name: string, mac: string) {
addGateway(name: string, externalID: string) {
const gateway: Gateway = {
name: name,
metadata: {
type: this.typeGateway,
mac: mac,
external_id: externalID,
},
};

Expand Down Expand Up @@ -97,7 +97,7 @@ export class GatewaysService {
gateway.metadata.ctrl_channel_id = ctrlChanID;
gateway.metadata.data_channel_id = dataChanID;
gateway.metadata.export_channel_id = exportChanID;
gateway.metadata.gw_password = uuid();
gateway.metadata.external_key = uuid();
gateway.id = gwID;

this.thingsService.editThing(gateway).subscribe(
Expand Down Expand Up @@ -147,8 +147,8 @@ export class GatewaysService {
);
}

editGateway(name: string, mac: string, gateway: Gateway) {
gateway.metadata.mac = mac;
editGateway(name: string, externalID: string, gateway: Gateway) {
gateway.metadata.external_id = externalID;

return this.thingsService.editThing(gateway).map(
resp => {
Expand Down
8 changes: 4 additions & 4 deletions src/app/common/store/gateways.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export class GatewaysStore {
}

@action
addGateway(name: string, mac: string) {
addGateway(name: string, externalID: string) {
this.uiState.loading = true;
this.gatewaysService.addGateway(name, mac)
this.gatewaysService.addGateway(name, externalID)
.subscribe(() => {
this.uiState.loading = false;
this.getGateways(this.offset, this.limit);
Expand All @@ -43,9 +43,9 @@ export class GatewaysStore {
}

@action
editGateway(name: string, mac: string, gw: Gateway) {
editGateway(name: string, externalID: string, gw: Gateway) {
this.uiState.loading = true;
this.gatewaysService.editGateway(name, mac, gw)
this.gatewaysService.editGateway(name, externalID, gw)
.subscribe(() => {
this.uiState.loading = false;
this.getGateways(this.offset, this.limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class GatewaysConfigComponent implements OnInit, OnChanges {
}

ngOnChanges() {
if (!this.gateway.metadata.gw_password) {
if (!this.gateway.metadata.external_key) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<div class="col-md-3"> Name: </div><div class="col-md-9"> {{ gateway.name }} </div>
<div class="col-md-3"> ID: </div><div class="col-md-9"> {{ gateway.id }} </div>
<div class="col-md-3"> Key: </div><div class="col-md-9"> {{ gateway.key }} </div>
<div class="col-md-3"> External ID: </div><div class="col-md-9"> {{ gateway.metadata.mac }} </div>
<div class="col-md-3"> External key: </div><div class="col-md-9"> {{ gateway.metadata.gw_password }} </div>
<div class="col-md-3"> External ID: </div><div class="col-md-9"> {{ gateway.metadata.external_id }} </div>
<div class="col-md-3"> External key: </div><div class="col-md-9"> {{ gateway.metadata.external_key }} </div>
<div class="col-md-3"> Ctrl Chan ID: </div><div class="col-md-9"> {{ gateway.metadata.ctrl_channel_id }} </div>
<div class="col-md-3"> Data Chan ID: </div><div class="col-md-9"> {{ gateway.metadata.data_channel_id }} </div>
<div class="col-md-3"> BS Config ID: </div><div class="col-md-9"> {{ gateway.metadata.cfg_id }} </div>
Expand Down
27 changes: 13 additions & 14 deletions src/app/pages/things/gateways/gateways.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ export class GatewaysComponent implements OnInit {
type: 'string',
filter: false,
},
mac: {
title: 'MAC',
placeholder: 'Search MAC',
external_id: {
title: 'External ID',
type: 'text',
editable: true,
addable: true,
Expand Down Expand Up @@ -127,7 +126,7 @@ export class GatewaysComponent implements OnInit {
this.total = resp.total;

resp.things.forEach(gw => {
gw.mac = gw.metadata.mac;
gw.external_id = gw.metadata.external_id;

const data_channel_id: string = gw.metadata ? gw.metadata.data_channel_id : '';
this.messagesService.getMessages(data_channel_id, gw.key, gw.id).subscribe(
Expand All @@ -154,10 +153,10 @@ export class GatewaysComponent implements OnInit {


validate(row: any): boolean {
const gws = this.gateways.map(g => g.mac);
if (gws.includes(row.mac)) {
const gws = this.gateways.map(g => g.metadata.external_id);
if (gws.includes(row.external_id)) {
this.notificationsService.warn(
'MAC already exist.', '');
'External ID already exist.', '');
return false;
}
if (row.name === '' || row.name.length > 32) {
Expand All @@ -166,9 +165,9 @@ export class GatewaysComponent implements OnInit {
return false;
}

if (row.mac === '' || row.mac.length < 8) {
if (row.external_id === '' || row.external_id.length < 8) {
this.notificationsService.warn(
'MAC is required and must be at least 8 characters long.', '');
'External ID is required and must be at least 8 characters long.', '');
return false;
}

Expand All @@ -185,7 +184,7 @@ export class GatewaysComponent implements OnInit {
// close edditable row
event.confirm.resolve();

this.gatewaysService.addGateway(event.newData.name, event.newData.mac).subscribe(
this.gatewaysService.addGateway(event.newData.name, event.newData.external_id).subscribe(
resp => {
setTimeout(
() => {
Expand All @@ -198,9 +197,9 @@ export class GatewaysComponent implements OnInit {

onEditConfirm(event): void {
// Check if the row have been modified
const macs = this.gateways.map(g => g.mac);
const extIDs = this.gateways.map(g => g.metadata.external_id);
const names = this.gateways.map(g => g.name);
if (macs.includes(event.newData.mac) && names.includes(event.newData.name)) {
if (extIDs.includes(event.newData.external_id) && names.includes(event.newData.name)) {
// close edditable row
event.confirm.resolve();
return;
Expand All @@ -215,10 +214,10 @@ export class GatewaysComponent implements OnInit {
event.confirm.resolve();

const name = event.newData.name;
const mac = event.newData.mac;
const external_id = event.newData.external_id;
const gw = event.newData;

this.gatewaysService.editGateway(name, mac, gw).subscribe(
this.gatewaysService.editGateway(name, external_id, gw).subscribe(
resp => {
this.getGateways();
},
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/map/leaflet/map.leaflet.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class MapComponent implements OnChanges {
const msg = `
<h5><b>${ gw.name }</b></h5>
<div>ID: ${ gw.id }</div>
<div>MAC: ${ gw.metadata.mac }</div>
<div>External ID: ${ gw.metadata.external_id }</div>
`;
const marker: L.Marker = L.marker(
[lon, lat], {
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export const environment = {
loraServer: 'http://lora.mainflux.io/#/',

mqttWsUrl: 'ws://localhost:80/mqtt',
exportConfigFile: 'export.toml',
exportConfigFile: '/configs/export/config.toml',
};
2 changes: 1 addition & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ export const environment = {
loraServer: 'http://lora.mainflux.io/#/',

mqttWsUrl: 'ws://localhost/mqtt',
exportConfigFile: 'export.toml',
exportConfigFile: '/configs/export/config.toml',
};

0 comments on commit edf531b

Please sign in to comment.