File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/src/app/services/city.service.ts
import { Injectable } from "@angular/core";
import { StorageService } from './storage.service';
import { UtilsService } from "./utils.service";
import { ApiMainService } from "./api-main.service";
import { TranslateService } from "@ngx-translate/core";
@Injectable({
providedIn: "root",
})
export class CityService {
_listCities: any = [];
_urlGallery: string = "";
_urlApi: string = "";
_urlAdmin: string = "";
constructor(
public apiMain: ApiMainService,
public utilsService: UtilsService,
private translate: TranslateService,
private storage: StorageService
) { }
getListCitiesConnection() {
return new Promise(async (resolve, reject) => {
this.utilsService.presentLoading(this.translate.instant("all.loading")).then(() => {
this.apiMain.getFree("listCitiesConnection").subscribe(
(res: any) => {
this.utilsService.dismissLoading();
if (res) {
this._listCities = res.listCities;
this.storage.set("listCities", this._listCities);
}
resolve(res);
},
(err) => {
this.utilsService.dismissLoading();
console.error("Erro provider getListCitiesConnection", err);
reject(err);
}
);
});
});
}
public async getApiUrl() {
return new Promise((resolve, reject) => {
this.storage.get("infoHost").then((infoHost) => {
resolve(infoHost.url_api);
});
});
}
public async getGalleryUrl() {
return new Promise((resolve, reject) => {
this.storage.get("infoHost").then((infoHost) => {
resolve(infoHost.url_gallery);
});
});
}
public async getAdminUrl() {
return new Promise((resolve, reject) => {
this.storage.get("infoHost").then((infoHost) => {
resolve(infoHost.url_admin);
});
});
}
async getInfoHost() {
return this.storage.get("infoHost").then((infoHost) => {
this._urlApi = infoHost.url_api;
this._urlAdmin = infoHost.url_admin;
this._urlGallery = infoHost.url_gallery;
});
}
}