Commit 5c1f5ba8 by Matteo

Gestione versione app + validazione pagina di registrazione

parent 056d81ff
...@@ -22,6 +22,7 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader'; ...@@ -22,6 +22,7 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
//import { Push } from '@ionic-native/push/ngx'; //import { Push } from '@ionic-native/push/ngx';
import { IonicStorageModule } from '@ionic/storage-angular'; import { IonicStorageModule } from '@ionic/storage-angular';
import { AppVersion } from '@awesome-cordova-plugins/app-version/ngx';
export function createTranslateLoader(http: HttpClient) { export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json'); return new TranslateHttpLoader(http, './assets/i18n/', '.json');
...@@ -55,6 +56,7 @@ export function createTranslateLoader(http: HttpClient) { ...@@ -55,6 +56,7 @@ export function createTranslateLoader(http: HttpClient) {
EmailComposer, EmailComposer,
InAppBrowser, InAppBrowser,
SocialSharing, SocialSharing,
AppVersion,
//Push, //Push,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy } { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
], ],
......
...@@ -68,12 +68,47 @@ ...@@ -68,12 +68,47 @@
</ion-row> </ion-row>
<ion-row color="primary" justify-content-center> <ion-row color="primary" justify-content-center>
<div class="validation-errors" justify-content-center> <div class="validation-errors" justify-content-center>
<ng-container *ngFor="let validation of validation_messages.nome">
<div class="error-message" *ngIf="matching_email_group.get('nome').hasError(validation.type) && (matching_email_group.get('nome').dirty
|| matching_email_group.get('nome').touched)">
{{ validation.message }}
</div>
</ng-container>
<ng-container *ngFor="let validation of validation_messages.cognome">
<div class="error-message" *ngIf="matching_email_group.get('cognome').hasError(validation.type) && (matching_email_group.get('cognome').dirty
|| matching_email_group.get('cognome').touched)">
{{ validation.message }}
</div>
</ng-container>
<ng-container *ngFor="let validation of validation_messages.cellulare">
<div class="error-message" *ngIf="matching_email_group.get('cellulare').hasError(validation.type) && (matching_email_group.get('cellulare').dirty
|| matching_email_group.get('cellulare').touched)">
{{ validation.message }}
</div>
</ng-container>
<ng-container *ngFor="let validation of validation_messages.email"> <ng-container *ngFor="let validation of validation_messages.email">
<div class="error-message" *ngIf="matching_email_group.get('email').hasError(validation.type) && (matching_email_group.get('email').dirty <div class="error-message" *ngIf="matching_email_group.get('email').hasError(validation.type) && (matching_email_group.get('email').dirty
|| matching_email_group.get('email').touched)"> || matching_email_group.get('email').touched)">
{{ validation.message }} {{ validation.message }}
</div> </div>
</ng-container> </ng-container>
<ng-container *ngFor="let validation of validation_messages.newpassword">
<div class="error-message" *ngIf="matching_email_group.get('newpassword').hasError(validation.type) && (matching_email_group.get('newpassword').dirty
|| matching_email_group.get('newpassword').touched)">
{{ validation.message }}
</div>
</ng-container>
<ng-container *ngFor="let validation of validation_messages.newpasswordbis">
<div class="error-message" *ngIf="matching_email_group.get('newpasswordbis').hasError(validation.type) && (matching_email_group.get('newpasswordbis').dirty
|| matching_email_group.get('newpasswordbis').touched)">
{{ validation.message }}
</div>
</ng-container>
<ng-container *ngFor="let validation of validation_messages.newpasswordbis">
<div class="error-message" *ngIf="matching_email_group.hasError('areEqual')">
{{ validation.message }}
</div>
</ng-container>
</div> </div>
</ion-row> </ion-row>
</ion-grid> </ion-grid>
......
...@@ -100,7 +100,7 @@ export class RegistrazionePage implements OnInit { ...@@ -100,7 +100,7 @@ export class RegistrazionePage implements OnInit {
], ],
'email': [ 'email': [
{ type: 'required', message: 'Email e\' richiesta.' }, { type: 'required', message: 'Email e\' richiesta.' },
{ type: 'pattern', message: 'Deve essere composta da numeri e lettere' } { type: 'email', message: 'Deve essere un indirizzo email valido' }
], ],
'cellulare': [ 'cellulare': [
{ type: 'pattern', message: 'Deve essere composto da numeri' } { type: 'pattern', message: 'Deve essere composto da numeri' }
......
...@@ -13,6 +13,7 @@ import { environment } from '../../../environments/environment'; ...@@ -13,6 +13,7 @@ import { environment } from '../../../environments/environment';
import { Struttura } from 'src/app/interface/struttura'; import { Struttura } from 'src/app/interface/struttura';
import { ParereResponse } from 'src/app/interface/parere-response'; import { ParereResponse } from 'src/app/interface/parere-response';
import { EventsService } from 'src/app/service/events.service'; import { EventsService } from 'src/app/service/events.service';
import { AppVersion } from '@awesome-cordova-plugins/app-version/ngx';
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
...@@ -27,9 +28,29 @@ export class HomePage { ...@@ -27,9 +28,29 @@ export class HomePage {
public menuCtrl: MenuController, public menuCtrl: MenuController,
private utilService: UtilService, private utilService: UtilService,
public translate: TranslateService, public translate: TranslateService,
public platform: Platform public platform: Platform,
private appVersion: AppVersion
) { ) {
this.caricaDati(true); this.caricaDati(true);
this.getVersion();
}
async getVersion()
{
if(UtilService.getVersion) return;
let version = await this.appVersion.getVersionNumber();
this.utilService.getVersion().subscribe((lastVersion: String)=>{
var numeri = lastVersion.split('.');
for(let i : number = 0; i < numeri.length; i++)
{
Number.parseInt(numeri[i]);
}
if(version != lastVersion)
{
this.utilService.presentAlert("Avviso", "", "E' presente una nuova versione dell'app sullo store ("+lastVersion+"), aggiorna la app", ["OK"]);
}
UtilService.getVersion = true;
});
} }
caricaDati(startUp: boolean) caricaDati(startUp: boolean)
......
...@@ -124,6 +124,26 @@ export class UtilService { ...@@ -124,6 +124,26 @@ export class UtilService {
public static pushRegistrationId:string; public static pushRegistrationId:string;
public static redirectToNotifiche:boolean = false; public static redirectToNotifiche:boolean = false;
public startup :boolean = true; public startup :boolean = true;
public static getVersion: boolean = false;
getVersion()
{
var piattaforma = this.platform.is("android")?"android":"ios;"
var param = UtilService.encodeBody({app: environment.struttura, piattaforma: piattaforma});
return this.httpClient.post<String>(this.httpClientDataService.BASE_ADDRESS+'/intranet/ultimaVersione.do', param, this.httpClientDataService.httpOptions)
.pipe(
catchError(this.handleError),
tap( (res: String ) => {
if (res != null && res != "") {
return res;
}
else{
return null;
}
})
);
}
static setStruttura(id:number) static setStruttura(id:number)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment