Skip to content

Commit

Permalink
WFNEWS-1780 use http ionic (#1528)
Browse files Browse the repository at this point in the history
* WFNEWS-1780 use ionic-native http for iOS

* WFNEWS-1780 use http ionic
  • Loading branch information
ssylver93 authored Dec 20, 2023
1 parent cac3f86 commit 7d13f31
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 24 deletions.
23 changes: 23 additions & 0 deletions client/wfnews-war/src/main/angular/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions client/wfnews-war/src/main/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@
"angular2-uuid": "1.1.1",
"assert": "2.0.0",
"capacitor-native-settings": "^5.0.1",
"cordova-plugin-screen-orientation": "^3.0.4",
"cordova-plugin-advanced-http": "^3.3.1",
"cordova-plugin-file": "^8.0.1",
"cordova-plugin-screen-orientation": "^3.0.4",
"core-js": "2.5.7",
"crypto-browserify": "^3.12.0",
"d3-ease": "^3.0.1",
Expand Down Expand Up @@ -135,9 +136,7 @@
"tslib": "2.0.0",
"vanilla-text-mask": "5.1.1",
"video.js": "7.15.4",
"zone.js": "0.11.4",
"@ionic-native/core": "^5.36.0",
"@ionic-native/http": "^5.36.0"
"zone.js": "0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "15.2.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class SavedLocationFullDetailsComponent implements OnInit {
{ latitude: minLatitude, longitude: minLongitude }, // Bottom-left corner
{ latitude: maxLatitude, longitude: minLongitude } // Closing the polygon
];
this.notificationService.getFireCentreByLocation(rectangleCoordinates).subscribe(
this.notificationService.getFireCentreByLocation(rectangleCoordinates).then(
response => {
if (response.features) {
const fireCentre = response.features[0].properties.MOF_FIRE_CENTRE_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class SavedComponent implements OnInit {
this.notificationService.getDangerRatingByLocation(
rectangleCoordinates
)
.subscribe(dangerRatings => {
.then(dangerRatings => {
if (dangerRatings.features) {
const element = dangerRatings.features[0].properties.DANGER_RATING_DESC;
this.savedLocations[outerIndex].dangerRatings = (element)
Expand Down Expand Up @@ -130,7 +130,7 @@ export class SavedComponent implements OnInit {
try {
locations.forEach((location, outerIndex) => {
const rectangleCoordinates = this.bboxHelper(location)
this.notificationService.getFireCentreByLocation(rectangleCoordinates).subscribe(
this.notificationService.getFireCentreByLocation(rectangleCoordinates).then(
response => {
if (response.features) {
const fireCentre = response.features[0].properties.MOF_FIRE_CENTRE_NAME;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { CapacitorService } from '@app/services/capacitor-service';
import { HTTP } from "@ionic-native/http/ngx";
import { AppConfigService } from "@wf1/core-ui";
import { Observable } from 'rxjs';
import { HTTP, HTTPResponse } from "@ionic-native/http/ngx";
import { HttpResponse } from '@capacitor/core';


export interface NotificationSettingRsrc {
Expand Down Expand Up @@ -97,40 +95,46 @@ export class NotificationService {
})
}

public getFireCentreByLocation(bbox: BoundingBox[]): Observable<any> {
public getFireCentreByLocation(bbox: BoundingBox[]): Promise<any> {
const formattedString = bbox.map(pair => `${pair.longitude} ${pair.latitude}`).join(',');
let url = (this.appConfigService.getConfig() as any).mapServices['openmapsBaseUrl'] as string
url += "?service=WFS&version=1.1.0&request=GetFeature&srsName=EPSG:4326&typename=pub:WHSE_LEGAL_ADMIN_BOUNDARIES.DRP_MOF_FIRE_CENTRES_SP&outputformat=application/json&cql_filter=INTERSECTS(GEOMETRY,SRID=4326;POLYGON(("
url += formattedString + ')))'
let headers = new HttpHeaders();
headers.append('Access-Control-Allow-Origin', '*');
headers.append('Accept', '*/*');
if (this.capacitorService.isIOSPlatform)
this.http.get(encodeURI(url), null, { headers }).then(response => {
return response
});
else return this.httpClient.get<any>(encodeURI(url), { headers })

return this.capacitorService.isMobile.then( b => {
if ( b ) return this.http.get( url, null, {'Access-Control-Allow-Origin': '*', 'Accept': '*/*'} )
.then( function( resp ) {
if ( resp.error ) throw resp.error
return JSON.parse( resp.data )
} )

return this.httpClient.get( url, { params: null, headers: headers } ).toPromise()
} )
}

public getDangerRatingByLocation(bbox: BoundingBox[]): Observable<any> {
public getDangerRatingByLocation(bbox: BoundingBox[]): Promise<any> {
const formattedString = bbox.map(pair => `${pair.longitude} ${pair.latitude}`).join(',');
let url = (this.appConfigService.getConfig() as any).mapServices['openmapsBaseUrl'] as string
url += "?service=WFS&version=1.1.0&request=GetFeature&srsName=EPSG:4326&typename=pub:WHSE_LAND_AND_NATURAL_RESOURCE.PROT_DANGER_RATING_SP&outputformat=application/json&cql_filter=INTERSECTS(SHAPE,SRID=4326;POLYGON(("
url += formattedString + ')))'
let headers = new HttpHeaders();
headers.append('Access-Control-Allow-Origin', '*');
headers.append('Accept', '*/*');
if (this.capacitorService.isIOSPlatform)
this.http.get(encodeURI(url), null, { headers }).then(response => {
return response
});
return this.httpClient.get<any>(encodeURI(url), { headers })
return this.capacitorService.isMobile.then( b => {
if ( b ) return this.http.get( url, null, {'Access-Control-Allow-Origin': '*', 'Accept': '*/*'} )
.then( function( resp ) {
if ( resp.error ) throw resp.error
return JSON.parse( resp.data )
} )

return this.httpClient.get( url, { params: null, headers: headers } ).toPromise()
} )

}
}


export function convertToNotificationSettingRsrc(np: any): NotificationSettingRsrc {
let notificationTopics = [];
if (np?.pushNotificationsFireBans) {
Expand Down

0 comments on commit 7d13f31

Please sign in to comment.