/* * Copyright (C) 2018, 2019 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 . */ import {Component, OnInit} from '@angular/core'; import {ActivatedRoute} from '@angular/router'; import {Network} from '@ionic-native/network/ngx'; import {TranslateService} from '@ngx-translate/core'; import {SCUuid} from '@openstapps/core'; import {FavoritesService} from '../../favorites/favorites.service'; import {DataProvider} from '../../data/data.provider'; import {DataDetailComponent} from '../../data/detail/data-detail.component'; import {DaiaDataProvider} from '../daia-data.provider'; import {SCDaiaHoldings} from '../protocol/response'; /** * A Component to display an SCThing detailed */ @Component({ selector: 'stapps-daia-availability', styleUrls: ['daia-availability.scss'], templateUrl: 'daia-availability.html', }) export class DaiaAvailabilityComponent extends DataDetailComponent implements OnInit { holdings: SCDaiaHoldings[]; /** * * @param route the route the page was accessed from * @param dataProvider the data provider * @param network the network provider * @param favoritesService the favorites provider * @param translateService he translate provider * @param daiaDataProvider DaiaDataProvider */ constructor( route: ActivatedRoute, dataProvider: DataProvider, network: Network, favoritesService: FavoritesService, translateService: TranslateService, private daiaDataProvider: DaiaDataProvider, ) { super(route, dataProvider, network, favoritesService, translateService); } /** * Check if we have internet */ isDisconnected(): boolean { return this.network.type === this.network.Connection.NONE; } /** * Initialize */ async ngOnInit() { const uid = this.route.snapshot.paramMap.get('uid') || ''; await this.getAvailability(uid ?? ''); } /** * Provides data item with given UID * * @param uid Unique identifier of a thing */ async getAvailability(uid: SCUuid) { this.daiaDataProvider.getAvailability(uid).then(holdings => { this.holdings = holdings; }); } }