11import {
2- Component ,
3- ChangeDetectionStrategy ,
42 AfterViewInit ,
3+ ChangeDetectionStrategy ,
54 ChangeDetectorRef ,
6- OnInit ,
5+ Component
76} from '@angular/core' ;
8- import { RoFPage } from '../rofPage' ;
9- import { ReportOfFire } from '../reportOfFireModel' ;
10- import ConfigJson from '../report-of-fire.config.json' ;
11- import * as L from 'leaflet' ;
7+ import { MatSnackBar } from '@angular/material/snack-bar' ;
128import { ReportOfFirePage } from '@app/components/report-of-fire/report-of-fire.component' ;
139import { CommonUtilityService } from '@app/services/common-utility.service' ;
14- import { MatSnackBar } from '@angular/material/snack-bar' ;
1510import {
1611 ReportOfFireService ,
1712 ReportOfFireType ,
1813} from '@app/services/report-of-fire-service' ;
19- import { equalsIgnoreCase } from '../../../utils' ;
20- import offlineMapJson from '../../../../assets/maps/british-columbia.json' ;
2114import { SmkApi } from '@app/utils/smk' ;
15+ import * as L from 'leaflet' ;
2216import { LatLng } from 'leaflet' ;
2317import { v5 as uuidv5 } from 'uuid' ;
18+ import offlineMapJson from '../../../../assets/maps/british-columbia.json' ;
19+ import { equalsIgnoreCase } from '../../../utils' ;
20+ import ConfigJson from '../report-of-fire.config.json' ;
21+ import { ReportOfFire } from '../reportOfFireModel' ;
22+ import { RoFPage } from '../rofPage' ;
2423
2524@Component ( {
2625 selector : 'rof-review-page' ,
@@ -34,6 +33,7 @@ export class RoFReviewPage extends RoFPage implements AfterViewInit {
3433 smkApi : SmkApi ;
3534 isOffLine : boolean ;
3635 currentLocation : any ;
36+ submitting : boolean = false ;
3737 public constructor (
3838 private reportOfFirePage : ReportOfFirePage ,
3939 private commonUtilityService : CommonUtilityService ,
@@ -79,7 +79,7 @@ export class RoFReviewPage extends RoFPage implements AfterViewInit {
7979 case 'contact-page' :
8080 return this . reportOfFire . consentToCall
8181 ? this . reportOfFire . consentToCall . charAt ( 0 ) . toUpperCase ( ) +
82- this . reportOfFire . consentToCall . slice ( 1 )
82+ this . reportOfFire . consentToCall . slice ( 1 )
8383 : null ;
8484 case 'location-page' :
8585 return this . reportOfFire . fireLocation ;
@@ -88,8 +88,8 @@ export class RoFReviewPage extends RoFPage implements AfterViewInit {
8888 case 'smoke-color-page' :
8989 return this . reportOfFire . smokeColor
9090 ? this . reportOfFire . smokeColor
91- . map ( ( item ) => this . findLabelByValue ( page . id , item ) )
92- . join ( ', ' )
91+ . map ( ( item ) => this . findLabelByValue ( page . id , item ) )
92+ . join ( ', ' )
9393 : null ;
9494 case 'fire-size-page' :
9595 return this . reportOfFire . fireSize
@@ -99,12 +99,12 @@ export class RoFReviewPage extends RoFPage implements AfterViewInit {
9999 //make the first letter of a string uppercase
100100 return this . reportOfFire . ifSignsOfResponse
101101 ? this . reportOfFire . ifSignsOfResponse . charAt ( 0 ) . toUpperCase ( ) +
102- this . reportOfFire . ifSignsOfResponse . slice ( 1 )
102+ this . reportOfFire . ifSignsOfResponse . slice ( 1 )
103103 : null ;
104104 case 'visible-flame-page' :
105105 return this . reportOfFire . visibleFlame
106106 ? this . reportOfFire . visibleFlame . charAt ( 0 ) . toUpperCase ( ) +
107- this . reportOfFire . visibleFlame . slice ( 1 )
107+ this . reportOfFire . visibleFlame . slice ( 1 )
108108 : null ;
109109 case 'fire-spread-page' :
110110 return this . reportOfFire . rateOfSpread
@@ -113,13 +113,13 @@ export class RoFReviewPage extends RoFPage implements AfterViewInit {
113113 case 'what-is-burning-page' :
114114 return this . reportOfFire . burning
115115 ? this . reportOfFire . burning
116- . map ( ( item ) => this . findLabelByValue ( page . id , item ) )
117- . join ( ', ' )
116+ . map ( ( item ) => this . findLabelByValue ( page . id , item ) )
117+ . join ( ', ' )
118118 : null ;
119119 case 'infrastructure-details-page' :
120120 return this . reportOfFire . ifAssetsAtRisk
121121 ? this . reportOfFire . ifAssetsAtRisk . charAt ( 0 ) . toUpperCase ( ) +
122- this . reportOfFire . ifAssetsAtRisk . slice ( 1 )
122+ this . reportOfFire . ifAssetsAtRisk . slice ( 1 )
123123 : null ;
124124 case 'comments-page' :
125125 return this . reportOfFire . otherInfo ;
@@ -152,14 +152,14 @@ export class RoFReviewPage extends RoFPage implements AfterViewInit {
152152 case 'response-details-page' :
153153 return this . reportOfFire . signsOfResponse
154154 ? this . reportOfFire . signsOfResponse
155- . map ( ( item ) => this . findLabelByValue ( page . id , item ) )
156- . join ( ', ' )
155+ . map ( ( item ) => this . findLabelByValue ( page . id , item ) )
156+ . join ( ', ' )
157157 : null ;
158158 case 'infrastructure-details-page' :
159159 return this . reportOfFire . assetsAtRisk
160160 ? this . reportOfFire . assetsAtRisk
161- . map ( ( item ) => this . findLabelByValue ( page . id , item ) )
162- . join ( ', ' )
161+ . map ( ( item ) => this . findLabelByValue ( page . id , item ) )
162+ . join ( ', ' )
163163 : null ;
164164 }
165165 }
@@ -314,8 +314,8 @@ export class RoFReviewPage extends RoFPage implements AfterViewInit {
314314 const newLongitude =
315315 initialFirePoint . lng +
316316 ( offSet * Math . sin ( angleInRadians ) ) /
317- ( ( Math . PI * 6378137 ) / 180 ) /
318- Math . cos ( ( initialFirePoint . lat * Math . PI ) / 180 ) ;
317+ ( ( Math . PI * 6378137 ) / 180 ) /
318+ Math . cos ( ( initialFirePoint . lat * Math . PI ) / 180 ) ;
319319 const newFirePoint = [ newLatitude , newLongitude ] ;
320320
321321 latlngs . push ( newFirePoint ) ;
@@ -419,15 +419,22 @@ export class RoFReviewPage extends RoFPage implements AfterViewInit {
419419 submissionID : uniqueID
420420 } ;
421421
422+ if ( this . submitting ) {
423+ return ;
424+ }
425+
426+ this . submitting = true ;
427+
422428 try {
423- this . reportOfFireService . saveReportOfFire (
429+ await this . reportOfFireService . saveReportOfFire (
424430 rofResource ,
425431 this . reportOfFire . image1 ,
426432 this . reportOfFire . image2 ,
427433 this . reportOfFire . image3 ,
428434 ) ;
429435 this . next ( ) ;
430436 } catch ( err ) {
437+ this . submitting = false ;
431438 this . snackbarService . open (
432439 'Failed to submit Report Of Fire: ' + JSON . stringify ( err . message ) ,
433440 'OK' ,
0 commit comments