mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-19 16:13:06 +00:00
refactor: migrate all cordova plugins to capacitor
This commit is contained in:
committed by
Rainer Killinger
parent
cdb6ac4084
commit
75f4644940
@@ -20,7 +20,7 @@ import {
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {AlertController, ModalController, Platform} from '@ionic/angular';
|
||||
import {AlertController, ModalController} from '@ionic/angular';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {
|
||||
SCBuilding,
|
||||
@@ -43,13 +43,11 @@ import {Subscription} from 'rxjs';
|
||||
import {DataRoutingService} from '../../data/data-routing.service';
|
||||
import {ContextMenuService} from '../../menu/context/context-menu.service';
|
||||
import {MapProvider} from '../map.provider';
|
||||
import {
|
||||
LocationStatus,
|
||||
MapPosition,
|
||||
PositionService,
|
||||
} from '../position.service';
|
||||
import {MapPosition, PositionService} from '../position.service';
|
||||
import {MapListModalComponent} from './modals/map-list-modal.component';
|
||||
import {MapSingleModalComponent} from './modals/map-single-modal.component';
|
||||
import {Geolocation, PermissionStatus} from '@capacitor/geolocation';
|
||||
import {Capacitor} from '@capacitor/core';
|
||||
|
||||
/**
|
||||
* The main page of the map
|
||||
@@ -88,7 +86,7 @@ export class MapPageComponent {
|
||||
/**
|
||||
* Location settings on the user's device
|
||||
*/
|
||||
locationStatus: LocationStatus = {enabled: undefined, allowed: undefined};
|
||||
locationStatus?: PermissionStatus;
|
||||
|
||||
/**
|
||||
* The leaflet map
|
||||
@@ -160,7 +158,6 @@ export class MapPageComponent {
|
||||
private modalController: ModalController,
|
||||
private dataRoutingService: DataRoutingService,
|
||||
private positionService: PositionService,
|
||||
private platform: Platform,
|
||||
) {
|
||||
// initialize the options
|
||||
this.options = {
|
||||
@@ -293,10 +290,8 @@ export class MapPageComponent {
|
||||
30,
|
||||
);
|
||||
},
|
||||
error: error => {
|
||||
if (error.code === 1) {
|
||||
this.locationStatus.allowed = false;
|
||||
}
|
||||
error: async _error => {
|
||||
this.locationStatus = await Geolocation.checkPermissions();
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
this.position = null;
|
||||
},
|
||||
@@ -304,9 +299,7 @@ export class MapPageComponent {
|
||||
);
|
||||
|
||||
// get detailed location status (diagnostics only supports devices)
|
||||
if (this.platform.is('cordova')) {
|
||||
this.locationStatus = await this.positionService.getLocationStatus();
|
||||
}
|
||||
this.locationStatus = await Geolocation.checkPermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -360,6 +353,10 @@ export class MapPageComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
this.locationStatus = await (!Capacitor.isNativePlatform()
|
||||
? Geolocation.checkPermissions()
|
||||
: Geolocation.requestPermissions());
|
||||
|
||||
this.translateService
|
||||
.get(['map.page.geolocation', 'app.errors.UNKNOWN'])
|
||||
.subscribe(async translations => {
|
||||
@@ -367,16 +364,15 @@ export class MapPageComponent {
|
||||
translations['map.page.geolocation'],
|
||||
translations['app.errors.UNKNOWN'],
|
||||
];
|
||||
const {enabled, allowed} = this.locationStatus;
|
||||
await (
|
||||
await this.alertController.create({
|
||||
header: location.TITLE,
|
||||
subHeader: location.SUBTITLE,
|
||||
message: `${
|
||||
enabled === false
|
||||
? location.NOT_ENABLED
|
||||
: allowed === false
|
||||
this.locationStatus?.location === 'denied'
|
||||
? location.NOT_ALLOWED
|
||||
: this.locationStatus?.location !== 'granted'
|
||||
? location.NOT_ENABLED
|
||||
: unknownError
|
||||
}.`,
|
||||
buttons: ['OK'],
|
||||
|
||||
Reference in New Issue
Block a user