2020-02-11 06:39:47 +00:00
|
|
|
import {Component, Input, OnInit} from '@angular/core';
|
2020-02-09 12:08:25 +00:00
|
|
|
import {Router} from '@angular/router';
|
|
|
|
import {ApiService} from '../../service/api.service';
|
2020-10-13 12:54:14 +00:00
|
|
|
import {PopoverController} from '@ionic/angular';
|
2020-10-29 04:48:46 +00:00
|
|
|
import {DatabaseService} from '../../service/db/database.service';
|
2020-02-09 12:08:25 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-option-picker',
|
|
|
|
templateUrl: './option-picker.component.html',
|
|
|
|
styleUrls: ['./option-picker.component.scss'],
|
|
|
|
})
|
|
|
|
export class OptionPickerComponent implements OnInit {
|
2020-02-11 06:39:47 +00:00
|
|
|
@Input() toggleDark: () => void;
|
|
|
|
@Input() isDark: () => boolean;
|
2020-10-13 12:54:14 +00:00
|
|
|
@Input() showSearch: () => void | Promise<void>;
|
2020-10-29 04:48:46 +00:00
|
|
|
@Input() isPrefetch: () => boolean;
|
|
|
|
@Input() togglePrefetch: () => void;
|
|
|
|
@Input() doPrefetch: () => any;
|
2020-02-09 12:08:25 +00:00
|
|
|
|
|
|
|
constructor(
|
2020-02-11 06:39:47 +00:00
|
|
|
protected api: ApiService,
|
|
|
|
protected router: Router,
|
2020-10-13 12:54:14 +00:00
|
|
|
protected popover: PopoverController,
|
2020-10-22 04:12:57 +00:00
|
|
|
protected db: DatabaseService,
|
2020-02-09 12:08:25 +00:00
|
|
|
) { }
|
|
|
|
|
|
|
|
ngOnInit() {}
|
|
|
|
|
2020-10-22 04:12:57 +00:00
|
|
|
async onSelect(key) {
|
2020-02-09 12:08:25 +00:00
|
|
|
if ( key === 'html_export' ) {
|
|
|
|
window.open(this.api._build_url('/data/export/html'), '_blank');
|
2020-02-11 06:39:47 +00:00
|
|
|
} else if ( key === 'logout' ) {
|
2020-10-22 04:12:57 +00:00
|
|
|
await this.db.purge();
|
2020-02-11 06:39:47 +00:00
|
|
|
window.location.href = '/auth/logout';
|
|
|
|
} else if ( key === 'toggle_darkmode' ) {
|
|
|
|
this.toggleDark();
|
2020-10-13 12:54:14 +00:00
|
|
|
} else if ( key === 'search_everywhere' ) {
|
|
|
|
this.showSearch();
|
|
|
|
this.popover.dismiss();
|
2020-10-29 04:48:46 +00:00
|
|
|
} else if ( key === 'toggle_auto_prefetch' ) {
|
|
|
|
this.togglePrefetch();
|
|
|
|
} else if ( key === 'prefetch_data' ) {
|
|
|
|
this.popover.dismiss();
|
|
|
|
this.doPrefetch();
|
2020-02-09 12:08:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|