mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-19 08:02:55 +00:00
121 lines
3.1 KiB
TypeScript
121 lines
3.1 KiB
TypeScript
/*
|
|
* Copyright (C) 2022 StApps
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
* Software Foundation, version 3.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with
|
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
import {Component} from '@angular/core';
|
|
import {MapPosition} from '../../map/position.service';
|
|
import {SearchPageComponent} from './search-page.component';
|
|
import {Geolocation} from '@capacitor/geolocation';
|
|
|
|
/**
|
|
* Presents a list of places for eating/drinking
|
|
*/
|
|
@Component({
|
|
templateUrl: 'search-page.html',
|
|
styleUrls: ['../../data/list/search-page.scss'],
|
|
})
|
|
export class FoodDataListComponent extends SearchPageComponent {
|
|
title = 'canteens.title';
|
|
|
|
showNavigation = false;
|
|
|
|
/**
|
|
* Sets the forced filter to present only places for eating/drinking
|
|
*/
|
|
initialize() {
|
|
this.showDefaultData = true;
|
|
|
|
this.sortQuery = [
|
|
{
|
|
arguments: {field: 'name'},
|
|
order: 'asc',
|
|
type: 'ducet',
|
|
},
|
|
];
|
|
|
|
this.forcedFilter = {
|
|
arguments: {
|
|
filters: [
|
|
{
|
|
arguments: {
|
|
field: 'categories',
|
|
value: 'canteen',
|
|
},
|
|
type: 'value',
|
|
},
|
|
{
|
|
arguments: {
|
|
field: 'categories',
|
|
value: 'student canteen',
|
|
},
|
|
type: 'value',
|
|
},
|
|
{
|
|
arguments: {
|
|
field: 'categories',
|
|
value: 'cafe',
|
|
},
|
|
type: 'value',
|
|
},
|
|
{
|
|
arguments: {
|
|
field: 'categories',
|
|
value: 'restaurant',
|
|
},
|
|
type: 'value',
|
|
},
|
|
],
|
|
operation: 'or',
|
|
},
|
|
type: 'boolean',
|
|
};
|
|
|
|
if (this.positionService.position) {
|
|
this.sortQuery = [
|
|
{
|
|
type: 'distance',
|
|
order: 'asc',
|
|
arguments: {
|
|
field: 'geo',
|
|
position: [this.positionService.position.longitude, this.positionService.position.latitude],
|
|
},
|
|
},
|
|
];
|
|
}
|
|
}
|
|
|
|
async ionViewWillEnter() {
|
|
await super.ionViewWillEnter();
|
|
this.subscriptions.push(
|
|
this.positionService
|
|
.watchCurrentLocation(this.constructor.name, {enableHighAccuracy: false, maximumAge: 1000})
|
|
.subscribe({
|
|
next: (position: MapPosition) => {
|
|
this.positionService.position = position;
|
|
},
|
|
error: async _error => {
|
|
this.positionService.position = undefined;
|
|
await Geolocation.checkPermissions();
|
|
},
|
|
}),
|
|
);
|
|
}
|
|
|
|
ionViewWillLeave() {
|
|
void this.positionService.clearWatcher(this.constructor.name);
|
|
for (const sub of this.subscriptions) {
|
|
sub.unsubscribe();
|
|
}
|
|
}
|
|
}
|