diff --git a/src/app/component/import-vessels/import-vessels.component.ts b/src/app/component/import-vessels/import-vessels.component.ts index dcefb9f..33274d0 100644 --- a/src/app/component/import-vessels/import-vessels.component.ts +++ b/src/app/component/import-vessels/import-vessels.component.ts @@ -1,6 +1,6 @@ import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; import {VesselsService} from '../../service/vessels.service'; -import {Vessel} from '../../model/vessel'; +import {Message} from '../../model/message'; @Component({ selector: 'app-import-vessels', @@ -8,7 +8,7 @@ import {Vessel} from '../../model/vessel'; styleUrls: ['./import-vessels.component.scss'] }) export class ImportVesselsComponent implements OnInit { - vessels: Map; + vessels: Map; constructor(private vesselsService: VesselsService) { @@ -56,7 +56,7 @@ export class ImportVesselsComponent implements OnInit { nbLine = lines.length; for (const line of lines) { const splitLine = line.split(','); - const newVessel = new Vessel(splitLine); + const newVessel = new Message(splitLine); this.vessels.set(Number(newVessel.mmsi), newVessel); } this.vesselsService.changeVesselsSet(this.vessels); diff --git a/src/app/component/list-vessel/list-vessel.component.ts b/src/app/component/list-vessel/list-vessel.component.ts index 3b24893..3b7ebd5 100644 --- a/src/app/component/list-vessel/list-vessel.component.ts +++ b/src/app/component/list-vessel/list-vessel.component.ts @@ -1,5 +1,5 @@ import {Component, OnInit} from '@angular/core'; -import {Vessel} from '../../model/vessel'; +import {Message} from '../../model/message'; import {VesselsService} from '../../service/vessels.service'; @Component({ @@ -8,7 +8,7 @@ import {VesselsService} from '../../service/vessels.service'; styleUrls: ['./list-vessel.component.scss'] }) export class ListVesselComponent implements OnInit { - vessels: Map; + vessels: Map; constructor(private vesselsService: VesselsService) { diff --git a/src/app/model/message.ts b/src/app/model/message.ts new file mode 100644 index 0000000..1566007 --- /dev/null +++ b/src/app/model/message.ts @@ -0,0 +1,38 @@ +export class Message { + mmsi: string; + time: string; + latitude: string; + longitude: string; + speedOverGround: string; + courseOverGround: string; + heading: string; + vesselName: string; + imo: string; + callSign: string; + vesselType: string; + status: string; + length: string; + width: string; + draft: string; + cargo: string; + + + constructor(splitLine: string[]) { + this.mmsi = splitLine[0]; + this.time = splitLine[1]; + this.latitude = splitLine[2]; + this.longitude = splitLine[3]; + this.speedOverGround = splitLine[4]; + this.courseOverGround = splitLine[5]; + this.heading = splitLine[6]; + this.vesselName = splitLine[7]; + this.imo = splitLine[8]; + this.callSign = splitLine[9]; + this.vesselType = splitLine[10]; + this.status = splitLine[11]; + this.length = splitLine[12]; + this.width = splitLine[13]; + this.draft = splitLine[14]; + this.cargo = splitLine[15]; + } +} diff --git a/src/app/model/vessel.spec.ts b/src/app/model/vessel.spec.ts index 08fc35e..de775d8 100644 --- a/src/app/model/vessel.spec.ts +++ b/src/app/model/vessel.spec.ts @@ -1,4 +1,4 @@ -import { Vessel } from './vessel'; +import { Message } from './message'; describe('Vessel', () => { // it('should create an instance', () => { diff --git a/src/app/model/vessel.ts b/src/app/model/vessel.ts deleted file mode 100644 index 8780293..0000000 --- a/src/app/model/vessel.ts +++ /dev/null @@ -1,38 +0,0 @@ -export class Vessel { - mmsi: string; - time: string; - latitude: string; - longitude: string; - speedOverGround: string; - courseOverGround: string; - heading: string; - vesselName: string; - imo: string; - callSign: string; - vesselType: string; - status: string; - length: string; - width: string; - draft: string; - cargo: string; - - - constructor(splitLine: string[]) { - this.mmsi = splitLine[0]; - this.time = splitLine[1]; - this.latitude = splitLine[2]; - this.longitude = splitLine[3]; - this.speedOverGround = splitLine[4]; - this.courseOverGround = splitLine[5]; - this.heading = splitLine[6]; - this.vesselName = splitLine[7]; - this.imo = splitLine[8]; - this.callSign = splitLine[9]; - this.vesselType = splitLine[10]; - this.status = splitLine[11]; - this.length = splitLine[12]; - this.width = splitLine[13]; - this.draft = splitLine[14]; - this.cargo = splitLine[15]; - } -} diff --git a/src/app/service/vessels.service.ts b/src/app/service/vessels.service.ts index b41d249..d504774 100644 --- a/src/app/service/vessels.service.ts +++ b/src/app/service/vessels.service.ts @@ -1,6 +1,6 @@ import {Injectable} from '@angular/core'; import {BehaviorSubject, Observable} from 'rxjs'; -import {Vessel} from '../model/vessel'; +import {Message} from '../model/message'; @Injectable({ providedIn: 'root' @@ -12,7 +12,7 @@ export class VesselsService { constructor() { } - changeVesselsSet(newVessels: Map): void { + changeVesselsSet(newVessels: Map): void { this.vessels.next(newVessels); } }