diff --git a/package.json b/package.json
index cf0553d..86a3a85 100644
--- a/package.json
+++ b/package.json
@@ -84,4 +84,4 @@
"android"
]
}
-}
\ No newline at end of file
+}
diff --git a/src/app/pages/login/login.page.html b/src/app/pages/login/login.page.html
index 83c2be3..1480f9a 100644
--- a/src/app/pages/login/login.page.html
+++ b/src/app/pages/login/login.page.html
@@ -44,5 +44,10 @@
+
+ Verificar
+ atualização
+
+
\ No newline at end of file
diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts
index 521b381..8cb6221 100644
--- a/src/app/pages/login/login.page.ts
+++ b/src/app/pages/login/login.page.ts
@@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { ThemeService } from 'src/app/services/theme/theme.service';
import { Router } from '@angular/router';
import { LoginService } from 'src/app/services/login/login.service';
+import { AtualizacaoService } from 'src/app/services/atualizacao/atualizacao.service';
+import { LoadingController, ToastController } from '@ionic/angular';
@Component({
selector: 'app-login',
@@ -20,7 +22,10 @@ export class LoginPage implements OnInit {
constructor(
private themeService: ThemeService,
private router: Router,
- private loginService: LoginService
+ private loginService: LoginService,
+ private atualizacaoService: AtualizacaoService,
+ public loadingController: LoadingController,
+ public toastController: ToastController
) { }
ngOnInit() {
@@ -82,4 +87,30 @@ export class LoginPage implements OnInit {
this.themeService.setTheme(theme);
}
+ verificarAtualizacao() {
+ this.presentLoading();
+ this.atualizacaoService.verificarAtualizacao().subscribe(data => {
+ window.location.href = data['link'];
+ }, error => {
+ this.presentToast('Seu app já está atualizado!');
+ });
+ }
+
+ async presentLoading() {
+ const loading = await this.loadingController.create({
+ message: 'Loading...',
+ duration: 1000
+ });
+ await loading.present();
+
+ const { role, data } = await loading.onDidDismiss();
+ }
+
+ async presentToast(msg: string) {
+ const toast = await this.toastController.create({
+ message: msg,
+ duration: 5000
+ });
+ toast.present();
+ }
}
diff --git a/src/app/services/api/api.service.ts b/src/app/services/api/api.service.ts
index ae4fd65..eb21d49 100644
--- a/src/app/services/api/api.service.ts
+++ b/src/app/services/api/api.service.ts
@@ -8,6 +8,7 @@ import { Storage } from '@ionic/storage';
})
export class ApiService {
public API_URL = 'https://api-tem-cafe.herokuapp.com';
+ public VERSAO = '1.0.0';
// private API_URL = 'http://localhost:3000';
constructor(
diff --git a/src/app/services/atualizacao/atualizacao.service.spec.ts b/src/app/services/atualizacao/atualizacao.service.spec.ts
new file mode 100644
index 0000000..92e39f9
--- /dev/null
+++ b/src/app/services/atualizacao/atualizacao.service.spec.ts
@@ -0,0 +1,12 @@
+import { TestBed } from '@angular/core/testing';
+
+import { AtualizacaoService } from './atualizacao.service';
+
+describe('AtualizacaoService', () => {
+ beforeEach(() => TestBed.configureTestingModule({}));
+
+ it('should be created', () => {
+ const service: AtualizacaoService = TestBed.get(AtualizacaoService);
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/src/app/services/atualizacao/atualizacao.service.ts b/src/app/services/atualizacao/atualizacao.service.ts
new file mode 100644
index 0000000..5a48fcb
--- /dev/null
+++ b/src/app/services/atualizacao/atualizacao.service.ts
@@ -0,0 +1,16 @@
+import { Injectable } from '@angular/core';
+import { ApiService } from '../api/api.service';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class AtualizacaoService {
+
+ constructor(
+ private api: ApiService
+ ) { }
+
+ verificarAtualizacao() {
+ return this.api.get(`/verificarAtt/${this.api.VERSAO}`);
+ }
+}