Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WFNEWS-1631 Add debug attributes to payload #1821

Merged
merged 8 commits into from
Apr 23, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class RoFTitlePage extends RoFPage implements OnInit {

if(!this.intervalRef) {
this.intervalRef = setInterval(async () => {
if(await this.checkStoredRoF())
if(await this.checkStoredRoF(this.intervalRef))
this.clearBackgroundInterval()
}, 30000);
}
Expand All @@ -87,7 +87,7 @@ export class RoFTitlePage extends RoFPage implements OnInit {
this.reportOfFirePage.selectPage('call-page', null, false);
}

async checkStoredRoF() {
async checkStoredRoF(intervalRef) {
let rofSubmitted = false;

// first check do 24 hour check in storage and remove offline RoF if timeframe has elapsed
Expand All @@ -96,7 +96,7 @@ export class RoFTitlePage extends RoFPage implements OnInit {
// check if the app is in the background and online and if so, check for saved offline RoF to be submitted
await this.commonUtilityService.checkOnlineStatus().then(async (result) => {
if (result) {
await this.reportOfFireService.syncDataWithServer().then(response => {
await this.reportOfFireService.syncDataWithServer(intervalRef).then(response => {
if(response) {
rofSubmitted = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,14 @@ export class ReportOfFireService {
return base64;
}

async submitOfflineReportToServer(offlineReport?): Promise<any> {
async submitOfflineReportToServer(rofJson?): Promise<any> {
// retrieve the offline RoF from the device's storage and convert to FormData for submission
// images will already to converted to base64 string from initial submission
const rofUrl = this.appConfigService.getConfig().rest['fire-report-api'];
const rofJson = JSON.parse(offlineReport);
const resource = rofJson.resource;
const image1 = rofJson.image1;
const image2 = rofJson.image2;
const image3 = rofJson.image3;
const resource = JSON.stringify(rofJson?.resource);
const image1 = rofJson?.image1;
const image2 = rofJson?.image2;
const image3 = rofJson?.image3;

const formData = new FormData();
if (resource) {
Expand Down Expand Up @@ -319,7 +318,7 @@ export class ReportOfFireService {
}
}

async syncDataWithServer() {
async syncDataWithServer(intervalRef) {
let dataSynced = false;
let submissionID = null;
let duplicateStored = false;
Expand All @@ -339,7 +338,12 @@ export class ReportOfFireService {
submissionID = resourceJson?.submissionID
if (submissionID && submissionIdList?.includes(submissionID)) {
duplicateStored = true;
}
}
resourceJson['duplicateStored'] = duplicateStored;
resourceJson['intervalRef'] = intervalRef;
let offlineReportJson = JSON.parse(offlineReport)
offlineReportJson['resource'] = resourceJson;
offlineReport = offlineReportJson
}

// Reject duplicate if submissionID has already been stored
Expand All @@ -353,7 +357,6 @@ export class ReportOfFireService {
// Remove the locally stored data if sync is successful
this.storageService.removeData('offlineReportData');
const rof = this.storageService.getData('offlineReportData')
console.log('rof: ' + rof)
// store submissionID for duplicate check
if (submissionID) {
submissionIdList = submissionIdList ? submissionIdList + ", " + submissionID : submissionID;
Expand Down
Loading