From 3178f105295c5d97f1c76f9723d9aac1e761ca58 Mon Sep 17 00:00:00 2001 From: Morgan Thompson Date: Wed, 10 Mar 2021 09:49:55 -0800 Subject: [PATCH] NRPT-619: implement admin component for LNG map updates (#797) * NRPT-619: implement admin component for LNG map info * fix cancel loading old values and alert return * fix unit test and cleanup code * allow empty segement description updates, remove unused code --- .../admin-nrpti/src/app/app-routing.module.ts | 6 +- .../communications.component.html | 21 ++- .../communications.component.ts | 6 +- .../communications/communications.module.ts | 16 +- .../lng-map-info/lng-map-info-resolver.ts | 25 +++ .../lng-map-info/lng-map-info.component.html | 43 +++++ .../lng-map-info/lng-map-info.component.scss | 2 + .../lng-map-info.component.spec.ts | 59 +++++++ .../lng-map-info/lng-map-info.component.ts | 147 ++++++++++++++++++ .../src/app/services/factory.service.ts | 19 +++ .../app/services/map-layer-info.service.ts | 62 ++++++++ .../src/app/utils/constants/misc.ts | 11 ++ .../models/master/common-models/map-info.ts | 26 ++++ .../20210303191902-addLngMapInfoData.js | 62 ++++++++ 14 files changed, 487 insertions(+), 18 deletions(-) create mode 100644 angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info-resolver.ts create mode 100644 angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.html create mode 100644 angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.scss create mode 100644 angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.spec.ts create mode 100644 angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.ts create mode 100644 angular/projects/admin-nrpti/src/app/services/map-layer-info.service.ts create mode 100644 angular/projects/common/src/app/models/master/common-models/map-info.ts create mode 100644 api/migrations/20210303191902-addLngMapInfoData.js diff --git a/angular/projects/admin-nrpti/src/app/app-routing.module.ts b/angular/projects/admin-nrpti/src/app/app-routing.module.ts index fe0f2e9e0..555368b7c 100644 --- a/angular/projects/admin-nrpti/src/app/app-routing.module.ts +++ b/angular/projects/admin-nrpti/src/app/app-routing.module.ts @@ -8,6 +8,7 @@ import { NewsResolver } from './news/news-resolver'; import { NewsListComponent } from './news/news-list.component'; import { CommunicationsComponent } from './communications/communications.component'; import { CommunicationsResolver } from './communications/communications.resolver'; +import { LngMapInfoResolver } from './communications/lng-map-info/lng-map-info-resolver'; const routes: Routes = [ { @@ -55,9 +56,10 @@ const routes: Routes = [ }, component: CommunicationsComponent, resolve: { - communicationsPackage: CommunicationsResolver + communicationsPackage: CommunicationsResolver, + lngMapData: LngMapInfoResolver } - }, + } ] }, { diff --git a/angular/projects/admin-nrpti/src/app/communications/communications.component.html b/angular/projects/admin-nrpti/src/app/communications/communications.component.html index 8a1821f61..7e80a0926 100644 --- a/angular/projects/admin-nrpti/src/app/communications/communications.component.html +++ b/angular/projects/admin-nrpti/src/app/communications/communications.component.html @@ -68,14 +68,19 @@

Application Communication Popup

+
+ + +
-
- - -
+ +
+ +
+ diff --git a/angular/projects/admin-nrpti/src/app/communications/communications.component.ts b/angular/projects/admin-nrpti/src/app/communications/communications.component.ts index a3ad6fab4..5635cfc29 100644 --- a/angular/projects/admin-nrpti/src/app/communications/communications.component.ts +++ b/angular/projects/admin-nrpti/src/app/communications/communications.component.ts @@ -1,9 +1,11 @@ +import { LngMapInfoComponent } from './lng-map-info/lng-map-info.component'; import { Component, OnInit, OnDestroy, ViewChild, EventEmitter } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { takeUntil } from 'rxjs/operators'; import { Subject } from 'rxjs/Subject'; import { FormGroup, FormControl } from '@angular/forms'; import { CommunicationsPackage } from '../../../../common/src/app/models/master/common-models/communications-package'; +import { MapInfo } from './../../../../common/src/app/models/master/common-models/map-info'; import { FactoryService } from '../services/factory.service'; import { DatePickerComponent, LoadingScreenService, Utils } from 'nrpti-angular-components'; @@ -14,13 +16,16 @@ import { DatePickerComponent, LoadingScreenService, Utils } from 'nrpti-angular- }) export class CommunicationsComponent implements OnInit, OnDestroy { @ViewChild(DatePickerComponent) DatePicker: DatePickerComponent; + @ViewChild(LngMapInfoComponent) LngMapInfoComponent: LngMapInfoComponent; private ngUnsubscribe: Subject = new Subject(); public resetDates: EventEmitter = new EventEmitter(); + public selectedApp: EventEmitter = new EventEmitter(); public myForm: FormGroup; public commPackage: CommunicationsPackage; + public lngMapInfo: MapInfo; public selectedApplication: string; public tinyMceSettings = { @@ -47,7 +52,6 @@ export class CommunicationsComponent implements OnInit, OnDestroy { this.route.data.pipe(takeUntil(this.ngUnsubscribe)).subscribe((res: any) => { this.commPackage = res.communicationsPackage.COMMUNICATIONS; this.selectedApplication = this.route.snapshot.params.application.toUpperCase(); - this.buildForm(); }); } diff --git a/angular/projects/admin-nrpti/src/app/communications/communications.module.ts b/angular/projects/admin-nrpti/src/app/communications/communications.module.ts index 852e5c337..debed55f3 100644 --- a/angular/projects/admin-nrpti/src/app/communications/communications.module.ts +++ b/angular/projects/admin-nrpti/src/app/communications/communications.module.ts @@ -1,3 +1,4 @@ +import { LngMapInfoComponent } from './lng-map-info/lng-map-info.component'; // modules import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; @@ -6,31 +7,32 @@ import { CommonModule } from '@angular/common'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { BrowserModule } from '@angular/platform-browser'; import { EditorModule } from '@tinymce/tinymce-angular'; - import { GlobalModule } from 'nrpti-angular-components'; -import { CommonModule as NrptiCommonModule } from '../../../../common/src/app/common.module'; +import { CommonModule as NrptiCommonModule } from '../../../../common/src/app/common.module'; import { CommunicationsComponent } from './communications.component'; +import { LngMapInfoResolver } from './lng-map-info/lng-map-info-resolver'; @NgModule({ imports: [ BrowserModule, + EditorModule, FormsModule, ReactiveFormsModule, - FormsModule, CommonModule, GlobalModule, - ReactiveFormsModule, NrptiCommonModule, RouterModule, NgbModule, - EditorModule, ], declarations: [ - CommunicationsComponent + CommunicationsComponent, + LngMapInfoComponent + ], + providers: [ + LngMapInfoResolver ], - providers: [], entryComponents: [ CommunicationsComponent ], diff --git a/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info-resolver.ts b/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info-resolver.ts new file mode 100644 index 000000000..413e9b86c --- /dev/null +++ b/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info-resolver.ts @@ -0,0 +1,25 @@ +import { Injectable } from '@angular/core'; +import { Resolve } from '@angular/router'; +import { Observable } from 'rxjs/Observable'; +import { FactoryService } from '../../services/factory.service'; + +@Injectable() +export class LngMapInfoResolver implements Resolve> { + constructor(private factoryService: FactoryService) {} + + resolve(): Observable { + return this.factoryService.getRecords( + '', + ['MapLayerInfo'], + [], + 1, + 10, + '-dateAdded', + {}, + false, + {}, + [], + {} + ); + } +} diff --git a/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.html b/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.html new file mode 100644 index 000000000..60f4a9baa --- /dev/null +++ b/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.html @@ -0,0 +1,43 @@ + +
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+ +
+ + +
diff --git a/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.scss b/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.scss new file mode 100644 index 000000000..b5ec26e80 --- /dev/null +++ b/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.scss @@ -0,0 +1,2 @@ +@import "assets/styles/base/base.scss"; +@import "assets/styles/components/add-edit.scss"; diff --git a/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.spec.ts b/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.spec.ts new file mode 100644 index 000000000..f1c19ed62 --- /dev/null +++ b/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.spec.ts @@ -0,0 +1,59 @@ +import { LoadingScreenService } from 'nrpti-angular-components'; +import { EditorModule } from '@tinymce/tinymce-angular'; +import { FactoryService } from './../../../../../public-nrpti/src/app/services/factory.service'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { KeycloakService } from '../../services/keycloak.service'; + +import { LngMapInfoComponent } from './lng-map-info.component'; +import { ActivatedRoute } from '@angular/router'; +import { ActivatedRouteStub } from '../../../../../common/src/app/spec/spec-utils'; + +describe('LngMapInfoComponent', () => { + let component: LngMapInfoComponent; + let fixture: ComponentFixture; + + const mockActivatedRoute = new ActivatedRouteStub(); + const mockFactoryService = jasmine.createSpyObj('FactoryService', [ + 'updateMapLayerInfo', + 'userInRole', + 'userInLngRole' + ]); + mockFactoryService.userInLngRole.and.returnValue(true); + + const mockKeycloakService = jasmine.createSpyObj('KeycloackService', ['isMenuEnabled', 'getToken']); + const mockLoadingScreenService = { + isLoading: false, + setLoadingState: () => { + return false; + } + }; + + beforeEach((() => { + TestBed.configureTestingModule({ + imports: [ + FormsModule, + ReactiveFormsModule, + EditorModule + ], + declarations: [ LngMapInfoComponent ], + providers: [ + { provide: ActivatedRoute, useValue: mockActivatedRoute}, + { provide: KeycloakService, useValue: mockKeycloakService}, + { provide: FactoryService, useValue: mockFactoryService }, + { provide: LoadingScreenService, useValue: mockLoadingScreenService } + ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(LngMapInfoComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.ts b/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.ts new file mode 100644 index 000000000..a925b286f --- /dev/null +++ b/angular/projects/admin-nrpti/src/app/communications/lng-map-info/lng-map-info.component.ts @@ -0,0 +1,147 @@ +import { Component, OnInit, ChangeDetectorRef, OnDestroy } from '@angular/core'; +import { FormGroup, FormControl } from '@angular/forms'; +import { FactoryService } from '../../services/factory.service'; +import { LoadingScreenService } from 'nrpti-angular-components'; +import { Constants } from '../../utils/constants/misc'; +import { ActivatedRoute } from '@angular/router'; +import { takeUntil } from 'rxjs/operators'; +import { Subject } from 'rxjs'; +@Component({ + selector: 'app-lng-map-info', + templateUrl: './lng-map-info.component.html', + styleUrls: ['./lng-map-info.component.scss'] +}) +export class LngMapInfoComponent implements OnInit, OnDestroy { + + private ngUnsubscribe: Subject = new Subject(); + + public loading = true; + public mapForm: FormGroup; + public currentSection = null; + public lngMapData = []; + + public sections = Constants.LngSectionPickList; + + public tinyMceSettings = { + base_url: '/tinymce', + suffix: '.min', + browser_spellcheck: true, + height: 240, + plugins: ['lists, advlist, link'], + toolbar: [ 'undo redo | formatselect | ' + + ' bold italic backcolor | alignleft aligncenter ' + + ' alignright alignjustify | bullist numlist outdent indent |' + + ' removeformat | help' ] + }; + + constructor( + public route: ActivatedRoute, + private factoryService: FactoryService, + private loadingScreenService: LoadingScreenService, + private _changeDetectionRef: ChangeDetectorRef + ) { } + + ngOnInit() { + this.route.data.pipe(takeUntil(this.ngUnsubscribe)).subscribe((res: any) => { + if (res && res.lngMapData && res.lngMapData[0] && res.lngMapData[0].data) { + this.lngMapData = res.lngMapData[0].data.searchResults; + } else { + alert('Error: could not load LNG Map data'); + } + }); + this.currentSection = this.lngMapData[0]; + this.buildForm(); + } + + checkRoles() { + if (this.factoryService.userInRole('sysadmin')) { + return true; + } else if (this.factoryService.userInLngRole()) { + return true; + } else { + return false; + } + } + + /** + * When selecting a segment, update the form with it's corresponding data + * + * @param {object} event + * @returns + * @memberof LngMapInfoComponent + */ + onSelectSegment(event) { + if (!event) { + return; + } + const segment = event.target.value.split(': '); + this.currentSection = this.lngMapData.find(elem => elem.segment === segment[1]); + this.buildForm(); + this._changeDetectionRef.detectChanges(); + } + + private buildForm() { + this.mapForm = new FormGroup({ + sectionNumber: new FormControl({ + value: (this.currentSection && this.currentSection.segment) || '', + disabled: !this.checkRoles() + }), + location: new FormControl({ + value: (this.currentSection && this.currentSection.location) || '', + disabled: !this.checkRoles() + }), + length: new FormControl({ + value: (this.currentSection && this.currentSection.length) || '', + disabled: !this.checkRoles() + }), + recentUpdates: new FormControl({ + value: (this.currentSection && this.currentSection.description) || '', + disabled: !this.checkRoles() + }) + }); + } + + async submit() { + this.loadingScreenService.setLoadingState(true, 'main'); + + if ( + !this.mapForm.get('location').value || + !this.mapForm.get('length').value + ) { + alert('Please ensure your updates to the Section info are complete'); + this.loadingScreenService.setLoadingState(false, 'main'); + return; + } + + const mapInfo = {}; + // currently we only allow edit on existing sections + mapInfo['_id'] = this.currentSection._id; + this.mapForm.controls.sectionNumber.dirty && (mapInfo['segment'] = this.mapForm.controls.sectionNumber.value); + this.mapForm.controls.location.dirty && (mapInfo['location'] = this.mapForm.controls.location.value); + this.mapForm.controls.length.dirty && (mapInfo['length'] = this.mapForm.controls.length.value); + this.mapForm.controls.recentUpdates.dirty && (mapInfo['description'] = this.mapForm.controls.recentUpdates.value); + + const res = await this.factoryService.updateMapLayerInfo(mapInfo); + if (!res || !res._id) { + alert('Failed to update the LNG Section'); + } else { + // success - make sure currentSection is update so cancel restores the correct data + this.currentSection.sectionNumber = this.mapForm.controls.sectionNumber.value; + this.currentSection.location = this.mapForm.controls.location.value; + this.currentSection.length = this.mapForm.controls.length.value; + this.currentSection.description = this.mapForm.controls.recentUpdates.value; + this.loadingScreenService.setLoadingState(false, 'main'); + } + } + + async cancel() { + // reset form values + this.buildForm(); + this._changeDetectionRef.detectChanges(); + } + + ngOnDestroy(): void { + this.ngUnsubscribe.next(); + this.ngUnsubscribe.complete(); + } +} diff --git a/angular/projects/admin-nrpti/src/app/services/factory.service.ts b/angular/projects/admin-nrpti/src/app/services/factory.service.ts index 3a4b93391..44132f320 100644 --- a/angular/projects/admin-nrpti/src/app/services/factory.service.ts +++ b/angular/projects/admin-nrpti/src/app/services/factory.service.ts @@ -12,6 +12,8 @@ import { Constants } from '../utils/constants/misc'; import { NewsService } from './news.service'; import { CollectionService } from './collection.service'; import { MineService } from './mine.service'; +import { MapLayerInfoService } from './map-layer-info.service'; + /** * Facade service for all admin-nrpti services. * @@ -32,6 +34,7 @@ export class FactoryService { private _taskService: TaskService; private _documentService: DocumentService; private _configService: ConfigService; + private _mapLayerInfoService: MapLayerInfoService; constructor(private injector: Injector) { // The following items are loaded by a file that is only present on cluster builds. @@ -147,6 +150,14 @@ export class FactoryService { } return this._configService; } + + public get mapLayerInfoService(): MapLayerInfoService { + if (!this._mapLayerInfoService) { + this._mapLayerInfoService = this.injector.get(MapLayerInfoService); + } + return this._mapLayerInfoService; + } + /** * True if the user is authenticated, false otherwise. * @@ -607,4 +618,12 @@ export class FactoryService { public createCommunicationPackage(communicationPackage): Observable { return this.configService.createCommunicationPackage(communicationPackage, this.apiService.pathAPI); } + + public getMapLayerInfo(mapInfoId): Observable { + return this.searchService.getItem(this.apiService.pathAPI, mapInfoId, 'MapLayerInfo', false); + } + + public updateMapLayerInfo(mapLayerInfo): Promise { + return this.mapLayerInfoService.updateMapLayerInfo(mapLayerInfo); + } } diff --git a/angular/projects/admin-nrpti/src/app/services/map-layer-info.service.ts b/angular/projects/admin-nrpti/src/app/services/map-layer-info.service.ts new file mode 100644 index 000000000..01244f196 --- /dev/null +++ b/angular/projects/admin-nrpti/src/app/services/map-layer-info.service.ts @@ -0,0 +1,62 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; + +import { ApiService } from './api.service'; + +@Injectable({ providedIn: 'root' }) +export class MapLayerInfoService { + + constructor(public apiService: ApiService, public http: HttpClient) { } + + /** + * @param {string} application targeted application eg. 'LNG' + * @param {*} mapInfo object payload of mapinfo data + * @returns {Promise} + * @memberof MapLayerInfoService + */ + public createMapLayerInfo(application: string, mapInfo: any): Promise { + if (!mapInfo) { + throw Error('MapLayerInfoService - createMapLayerInfo - missing required mapInfo param'); + } + + if (!application) { + throw Error('MapLayerInfoService - createMapLayerInfo - missing required application param'); + } + + const payload = { + application: application, + data: mapInfo + }; + const queryString = 'map-info/'; + return this.http.post(`${this.apiService.pathAPI}/${queryString}`, payload, {}).toPromise(); + } + + /** + * @param {*} mapInfo - mapinfo model object containing fields to update + * @returns {Promise} + * @memberof MapLayerInfoService + */ + public updateMapLayerInfo(mapInfo: any): Promise { + if (!mapInfo || !mapInfo._id) { + throw Error('MapLayerInfoService - updateMapLayerInfo - missing required mapInfo param'); + } + + const queryString = `map-info/${mapInfo._id}`; + return this.http.put(`${this.apiService.pathAPI}/${queryString}`, mapInfo, {}).toPromise(); + } + + /** + * @param {string} mapInfoId - objectId string of object to delete + * @returns {Promise} + * @memberof MapLayerInfoService + */ + public deleteMapLayerInfo(mapInfoId: string): Promise { + if (!mapInfoId) { + throw Error('MapLayerInfoService - deleteMapLayerInfo - missing required mapInfo param'); + } + + const queryString = `map-info/${mapInfoId}`; + return this.http.delete(`${this.apiService.pathAPI}/${queryString}`).toPromise(); + } +} + diff --git a/angular/projects/admin-nrpti/src/app/utils/constants/misc.ts b/angular/projects/admin-nrpti/src/app/utils/constants/misc.ts index 9a4a232a3..d4bf97f07 100644 --- a/angular/projects/admin-nrpti/src/app/utils/constants/misc.ts +++ b/angular/projects/admin-nrpti/src/app/utils/constants/misc.ts @@ -266,6 +266,17 @@ export class Constants { 'Agriculture Land Commission' ] }; + + public static readonly LngSectionPickList: string[] = [ + 'Section 1', + 'Section 2', + 'Section 3', + 'Section 4', + 'Section 5', + 'Section 6', + 'Section 7', + 'Section 8' + ]; } export class MiscUtils { diff --git a/angular/projects/common/src/app/models/master/common-models/map-info.ts b/angular/projects/common/src/app/models/master/common-models/map-info.ts new file mode 100644 index 000000000..89efd3daf --- /dev/null +++ b/angular/projects/common/src/app/models/master/common-models/map-info.ts @@ -0,0 +1,26 @@ +export class MapInfo { + _id: string; + _schemaName: string; + segment: string; + location: string; + length: string; + description: string; + dateAdded: Date; + dateUpdated: Date; + write: string[]; + read: string[]; + + constructor(obj?: any) { + this._id = (obj && obj._id) || null; + this._schemaName = (obj && obj._schemaName) || null; + this.segment = (obj && obj.segment) || null; + this.location = (obj && obj.location) || null; + this.length = (obj && obj.length) || null; + this.description = (obj && obj.description) || null; + this.dateAdded = (obj && obj.dateAdded) || null; + this.dateUpdated = (obj && obj.dateUpdated) || null; + + this.read = (obj && obj.read) || null; + this.write = (obj && obj.write) || null; + } +} diff --git a/api/migrations/20210303191902-addLngMapInfoData.js b/api/migrations/20210303191902-addLngMapInfoData.js new file mode 100644 index 000000000..bea0bfd61 --- /dev/null +++ b/api/migrations/20210303191902-addLngMapInfoData.js @@ -0,0 +1,62 @@ +'use strict'; + +var dbm; +var type; +var seed; + +const { ApplicationRoles } = require('../src/utils/constants/misc'); +const { mapLayerInfo: MapLayerInfo } = require('../src/models/index'); + +/** + * We receive the dbmigrate dependency from dbmigrate initially. + * This enables us to not have to rely on NODE_PATH. + */ +exports.setup = function(options, seedLink) { + dbm = options.dbmigrate; + type = dbm.dataType; + seed = seedLink; +}; + +exports.up = async function(db) { + console.log('**** Adding initial values for LNG map info data ****'); + const mClient = await db.connection.connect(db.connectionString, { native_parser: true }); + const nrpti = await mClient.collection('nrpti'); + + const readPerms = [ApplicationRoles.ADMIN, ApplicationRoles.ADMIN_LNG, ApplicationRoles.PUBLIC] + const writePerms = [ApplicationRoles.ADMIN, ApplicationRoles.ADMIN_LNG]; + const segmentData = [ + { segment: 'Section 1', location: 'West of Dawson Creek to south of Chetwynd', length: '92 Kilometres', read: readPerms, write: writePerms}, + { segment: 'Section 2', location: 'South of Chetwynd to east of McLeod Lake', length: '48 Kilometres', read: readPerms, write: writePerms}, + { segment: 'Section 3', location: 'East of McLeod Lake to north of Prince George', length: '104 Kilometres', read: readPerms, write: writePerms}, + { segment: 'Section 4', location: 'North of Prince George to northwest of Vanderhoof', length: '93 Kilometres', read: readPerms, write: writePerms}, + { segment: 'Section 5', location: 'North of Vanderhoof to south of Burns Lake', length: '82 Kilometres', read: readPerms, write: writePerms}, + { segment: 'Section 6', location: 'South of Burns Lake to south of Houston', length: '85 Kilometres', read: readPerms, write: writePerms}, + { segment: 'Section 7', location: 'South of Houston to north of Morice Lake', length: '78 Kilometres', read: readPerms, write: writePerms}, + { segment: 'Section 8', location: 'North of Morice Lake to Kitimat', length: '84 Kilometres', read: readPerms, write: writePerms}, + ] + for (let entry of segmentData) { + let mapInfo = new MapLayerInfo(); + mapInfo.segment = entry.segment; + mapInfo.location = entry.location; + mapInfo.length = entry.length; + mapInfo.read = entry.read; + mapInfo.write = entry.write; + try { + nrpti.insert(mapInfo) + } catch (err) { + mClient.close(); + } + } + + console.log('**** LNG Map Info insertion complete') + mClient.close(); + return null; +}; + +exports.down = function(db) { + return null; +}; + +exports._meta = { + "version": 1 +};