Commit cd0c73ee by Matteo

Passaggio a 2P2 funzionante sotto Android

parent 7965bdae
<?xml version='1.0' encoding='utf-8'?>
<widget id="it.aimconsulting.intranet" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Intranet</name>
<widget id="it.aimconsulting.intranet" version="0.0.6" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>"2P2 App"</name>
<description>An awesome Ionic/Cordova app.</description>
<author email="hi@ionicframework.com" href="http://ionicframework.com/">Ionic Framework Team</author>
<content src="index.html" />
......
{
"name": "Intranet",
"name": "2P2 App",
"integrations": {
"cordova": {}
},
......
{
"name": "Intranet",
"version": "0.0.1",
"name": "2P2 App",
"version": "0.0.2",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
......@@ -29,6 +29,7 @@
"@ionic-native/file": "^5.6.0",
"@ionic-native/file-opener": "^5.7.0",
"@ionic-native/in-app-browser": "^5.8.0",
"@ionic-native/push": "^5.24.0",
"@ionic-native/social-sharing": "^5.9.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
......@@ -47,9 +48,12 @@
"cordova-plugin-inappbrowser": "3.0.0",
"cordova-plugin-x-socialsharing": "5.4.7",
"cordova-sqlite-storage": "3.2.0",
"cordova-support-google-services": "^1.3.2",
"core-js": "^2.5.4",
"es6-promise-plugin": "4.2.2",
"ionic-angular": "^3.9.5",
"phonegap-plugin-multidex": "^1.0.0",
"phonegap-plugin-push": "^2.3.0",
"rxjs": "~6.5.1",
"rxjs-compat": "^6.5.2",
"tslib": "^1.9.0",
......@@ -109,7 +113,8 @@
"cordova-plugin-inappbrowser": {},
"cordova-plugin-x-socialsharing": {
"ANDROID_SUPPORT_V4_VERSION": "24.1.1+"
}
},
"phonegap-plugin-push": {}
},
"platforms": [
"android",
......
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
const routes: Routes = [
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'home', loadChildren: '../app/pages/home/home.module#HomePageModule' },
{ path: 'login', loadChildren: '../app/auth/pages/login/login.module#LoginPageModule' },
{ path: 'reset', loadChildren: '../app/auth/pages/reset/reset.module#ResetPageModule' },
{ path: 'businesscall', loadChildren: '../app/pages/businesscall/businesscall.module#BusinesscallPageModule' },
{ path: 'privacy', loadChildren: '../app/pages/privacy/privacy.module#PrivacyPageModule' }, { path: 'registrazione', loadChildren: './auth/pages/registrazione/registrazione.module#RegistrazionePageModule' }
const routes: Routes = [
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'home', loadChildren: '../app/pages/home/home.module#HomePageModule' },
{ path: 'login', loadChildren: '../app/auth/pages/login/login.module#LoginPageModule' },
{ path: 'reset', loadChildren: '../app/auth/pages/reset/reset.module#ResetPageModule' },
{ path: 'businesscall', loadChildren: '../app/pages/businesscall/businesscall.module#BusinesscallPageModule' },
{ path: 'privacy', loadChildren: '../app/pages/privacy/privacy.module#PrivacyPageModule' }
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule {}
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule {}
......
......@@ -29,45 +29,7 @@ export class AppComponent {
async initializeApp() {
this.utilService.loadLingua();
var state = await this.authService.syncIsLoggedIn();
if (state) {
this.router.navigate(['home']);
}
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
if(!navigator.onLine)
{
this.router.navigate(['error']);
this.utilService.presentAlert("Errore", "", "Dispositivo non connesso alla rete", ["OK"]);
}
else
{
if(this.platform.is("android"))
{
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.INTERNET).then(
result => {
console.log('Has permission?',result.hasPermission);
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.INTERNET, this.androidPermissions.PERMISSION.ACCESS_NETWORK_STATE, this.androidPermissions.PERMISSION.GET_ACCOUNTS]);
/*if(!result.hasPermission)
{
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.INTERNET, this.androidPermissions.PERMISSION.ACCESS_NETWORK_STATE, this.androidPermissions.PERMISSION.GET_ACCOUNTS]);
}*/
},
err =>
{
this.utilService.presentAlert("Messaggio", "", "Richiesta Permesso", ["OK"]);
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.INTERNET, this.androidPermissions.PERMISSION.GET_ACCOUNTS]);
}
);
}
/*this.authService.isLoggedIn().then(state => {
if (!state) {
this.router.navigate(['login']);
}
});*/
}
});
this.utilService.initConfig(false, 'notifiche');
}
async logout(){
......
......@@ -21,6 +21,7 @@ import { SocialSharing } from '@ionic-native/social-sharing/ngx';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient } from '@angular/common/http';
import { Push } from '@ionic-native/push/ngx';
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
......@@ -54,6 +55,7 @@ export function createTranslateLoader(http: HttpClient) {
EmailComposer,
InAppBrowser,
SocialSharing,
Push,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
......
......@@ -5,4 +5,5 @@ export interface AuthResponse {
error: boolean;
nome: string;
clienti: Cliente[];
cliente: boolean;
}
......@@ -35,6 +35,11 @@
</ion-row>
<ion-row color="primary" justify-content-center>
<div text-center class="forgot">
<a (click)='registrazione()' tappable>{{ 'registrati' | translate }}</a>
</div>
</ion-row>
<ion-row color="primary" justify-content-center>
<div text-center class="forgot">
<a (click)='reset()' tappable>{{ 'lost_password' | translate }}</a>
</div>
</ion-row>
......@@ -121,9 +126,13 @@
</div>
</ion-col>
</ion-row>
<ion-row color="primary">
<div class="text-center" class="forgot">
<div class="text-center forgot">
<a (click)='registrazione()' tappable>{{ 'registrati' | translate }}</a>
</div>
</ion-row>
<ion-row color="primary">
<div class="text-center forgot">
<a (click)='reset()' tappable>{{ 'lost_password' | translate }}</a>
</div>
</ion-row>
......
......@@ -60,10 +60,11 @@ export class LoginPage implements OnInit {
}
else
{
this.utilService.pushNotification(AuthService.idReferente);
UtilService.titoloPagina = '';
this.router.navigateByUrl('home');
this.utilService.redirectToFirstPage('notifiche');
this.events.publish('functionCall:startup', null);
this.events.publish('functionCall:updateStrutture', null);
}
},
(error: ErrorResponse) => {
......@@ -83,6 +84,10 @@ export class LoginPage implements OnInit {
this.router.navigateByUrl('reset');
}
registrazione(){
this.router.navigateByUrl('registrazione');
}
ngOnInit() {
}
......
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { RegistrazionePage } from './registrazione.page';
import { TranslateModule } from '@ngx-translate/core';
const routes: Routes = [
{
path: '',
component: RegistrazionePage
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes),
ReactiveFormsModule,
TranslateModule
],
declarations: [RegistrazionePage]
})
export class RegistrazionePageModule {}
<ion-header>
<title>2p2</title>
</ion-header>
<ion-content>
<div class="background-blu rp-height" *ngIf="!platform.is('desktop')">
<ion-grid>
<ion-row color="primary" justify-content-center>
<ion-col align-self-center>
<ion-toolbar class="business-toolbar">
<ion-buttons (click)="back()" slot="start" title="{{ 'back_login' | translate }}">
<ion-icon name="arrow-round-back" color="#2b94d1" class="back-white" tappable></ion-icon>
<!--<ion-icon name="arrow-dropleft-circle" color="#2b94d1" class="back"></ion-icon>-->
</ion-buttons>
<img src="assets/img/LogoBianco.svg" class="immagine-piccola">
</ion-toolbar>
</ion-col>
</ion-row>
</ion-grid>
<div class="messaggio-bianco">
{{ 'registrazione' | translate }}
</div>
</div>
<ion-grid class="transparent bc-grid">
<ion-row class="transparent">
<ion-col align-self-end size-md="6" size-lg="6" size-xs="12" class="transparent">
<div class="body-form body-img12">
<form #form="ngForm" (ngSubmit)="registra(form)" [formGroup]="matching_email_group">
<ion-grid>
<ion-row color="primary" justify-content-center>
<ion-col align-self-center>
<ion-row class="margin-top" *ngIf="platform.is('desktop')">
<ion-buttons (click)="back()" title="{{ 'back_login' | translate }}" class="back-button-desktop back-button-desktop-reset">
<ion-icon name="arrow-round-back" color="#232D4B" class="back" tappable></ion-icon>
</ion-buttons>
<ion-title class="logo-piccolo">
<img src="assets/icon/2p2-logo-color.svg">
</ion-title>
</ion-row>
<div text-center *ngIf="platform.is('desktop')">
<h3>{{ 'registrazione' | translate }}</h3>
</div>
<div padding>
<ion-item>
<ion-input formControlName="nome" type="text" placeholder="{{ 'nome' | translate }}" ngModel required></ion-input>
</ion-item>
<ion-item>
<ion-input formControlName="cognome" type="text" placeholder="{{ 'cognome' | translate }}" ngModel required></ion-input>
</ion-item>
<ion-item>
<ion-input formControlName="email" type="email" placeholder="{{ 'email' | translate }}" ngModel required></ion-input>
</ion-item>
<ion-item>
<ion-input formControlName="password" type="password" placeholder="{{ 'pwd' | translate }}" ngModel required></ion-input>
</ion-item>
<ion-item>
<ion-input formControlName="passwordbis" type="password" placeholder="{{ 'repeat_pwd' | translate }}" ngModel required></ion-input>
</ion-item>
</div>
<div padding>
<ion-button type="submit" [disabled]="form.invalid" class="bc-invia">{{ 'registrati' | translate }}</ion-button>
</div>
</ion-col>
</ion-row>
<ion-row color="primary" justify-content-center>
<div class="validation-errors" justify-content-center>
<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
|| matching_email_group.get('email').touched)">
{{ validation.message }}
</div>
</ng-container>
</div>
</ion-row>
</ion-grid>
</form>
</div>
</ion-col>
<ion-col align-self-end size-md="6" size-lg="6" size-xs="12">
<div class="body-blue2"></div>
<div class="body-img22"></div>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RegistrazionePage } from './registrazione.page';
describe('RegistrazionePage', () => {
let component: RegistrazionePage;
let fixture: ComponentFixture<RegistrazionePage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ RegistrazionePage ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(RegistrazionePage);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { UtilService } from 'src/app/service/util.service';
import { Platform, Events } from '@ionic/angular';
import { Router } from '@angular/router';
import { AuthService } from '../../service/auth.service';
import { ErrorResponse } from '../../interface/error-response';
import { FormControl, Validators, FormGroup } from '@angular/forms';
@Component({
selector: 'app-registrazione',
templateUrl: './registrazione.page.html',
styleUrls: ['./registrazione.page.scss'],
})
export class RegistrazionePage implements OnInit {
constructor(
private authService: AuthService,
private router: Router,
public events: Events,
public platform: Platform,
private utilService: UtilService,
public translate: TranslateService
) {
this.events.subscribe('functionCall:linguaCambiata', eventData => {
translate = utilService.translate;
});
translate = utilService.translate;
}
ngOnInit() {
}
registra(form){
this.utilService.showLoading();
this.authService.registra(form.value).subscribe((res: ErrorResponse)=>{
this.utilService.closeLoading();
if(res.error){
this.utilService.presentAlert("Errore", "", res.errorMsg, ["OK"]);
}
else
{
this.utilService.presentAlert("Info", "", "Registrazione effettuata con successo", ["OK"]);
this.utilService.pushNotification(AuthService.idReferente);
UtilService.titoloPagina = '';
this.utilService.redirectToFirstPage('notifiche');
this.events.publish('functionCall:startup', null);
this.events.publish('functionCall:updateStrutture', null);
}
},
(error: ErrorResponse) => {
this.utilService.closeLoading();
var text = "Errore durante la procedura di registrazione";
this.utilService.stampaErrore(text, error);
});
}
matching_email_group = new FormGroup({
nome: new FormControl('', Validators.compose([
Validators.required,
])),
cognome: new FormControl('', Validators.compose([
Validators.required,
])),
email: new FormControl('', Validators.compose([
Validators.required,
Validators.pattern('^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$')
])),
password: new FormControl('', Validators.compose([
Validators.minLength(5),
Validators.required,
Validators.pattern('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]+$') //this is for the letters (both uppercase and lowercase) and numbers validation
])),
passwordbis: new FormControl('', Validators.compose([
Validators.required
]))
});
validation_messages = {
'nome': [
{ type: 'required', message: 'Email richiesta.' },
{ type: 'pattern', message: 'Deve essere composta da numeri e lettere' }
],
'cognome': [
{ type: 'required', message: 'Email richiesta.' },
{ type: 'pattern', message: 'Deve essere composta da numeri e lettere' }
],
'email': [
{ type: 'required', message: 'Email richiesta.' },
{ type: 'pattern', message: 'Deve essere composta da numeri e lettere' }
],
'newpassword': [
{ type: 'required', message: 'Password richiesta.' },
{ type: 'minlength', message: 'La lunghezza minima 5 caratteri' },
{ type: 'pattern', message: 'Deve essere composta da numeri e lettere, minimo una maiuscola e una minuscola' }
],
'newpasswordbis': [
{ type: 'areEqual', message: 'La password deve essere uguale a quella nuova' },
{ type: 'required', message: 'Il Repeat Password richiesto.' }
]
}
}
......@@ -32,7 +32,7 @@
<ion-col align-self-center>
<ion-row *ngIf="platform.is('desktop')">
<ion-buttons (click)="back()" title="{{ 'back_login' | translate }}" class="back-button-desktop back-button-desktop-reset">
<ion-icon name="arrow-round-back" color="#2b94d1" class="back" tappable></ion-icon>
<ion-icon name="arrow-round-back" color="#232D4B" class="back" tappable></ion-icon>
</ion-buttons>
<ion-title class="logo-piccolo">
......
......@@ -9,7 +9,7 @@ import { Storage } from '@ionic/storage';
import { AuthResponse } from '../interface/auth-response';
import { UtilService } from '../../service/util.service';
import { HttpClientDataService } from '../../service/http-client-data.service';
import { Events } from '@ionic/angular';
import { Platform, Events } from '@ionic/angular';
import { environment } from '../../../environments/environment';
@Injectable({
......@@ -23,7 +23,8 @@ export class AuthService {
private httpClient: HttpClient,
private storage: Storage,
private httpClientDataService: HttpClientDataService,
private events: Events
private events: Events,
private utilService: UtilService
)
{
this.errorRespose = {
......@@ -62,6 +63,8 @@ export class AuthService {
}
static idReferente:string;
static idCliente:string;
static isClienteLoggato: boolean;
static clienti:Cliente[];
static clienteSelezionato: Cliente;
private idClienteSelezionato;
......@@ -80,6 +83,20 @@ export class AuthService {
});
}
clienteSel;
public clienteTrovato: Cliente;
getCliente(id)
{
this.clienteSel = id;
AuthService.clienti.forEach(this.getClienteSel, this);
}
getClienteSel(cliente, index)
{
if(cliente.id == this.clienteSel) this.clienteTrovato = cliente;
}
setCliente(id)
{
this.idClienteSelezionato = id;
......@@ -141,6 +158,40 @@ export class AuthService {
return this.clientiSalvati;
}
registra(value) : Observable<ErrorResponse>{
this.tipoStruttura = environment.struttura;
var param = UtilService.encodeBody({nome: value.nome, cognome: value.cognome, email: value.email, password: value.password, tipostruttura: this.tipoStruttura});
this.clientiSalvati = false;
return this.httpClient.post<ErrorResponse>(this.httpClientDataService.BASE_ADDRESS+'/autenticazione/registrazione.do', param, this.httpClientDataService.httpOptions)
.pipe(
catchError(this.handleError),
tap( (res: AuthResponse ) => {
if (!res.error) {
this.authSubject.next(true);
AuthService.isClienteLoggato = res.cliente;
if(!res.cliente) AuthService.idReferente = res.toString();
else AuthService.idCliente = res.id.toString();
this.storage.set("idUser",res.id).then((successData)=>{
console.log("Data Stored");
console.log(successData);
});
this.storage.set("name",res.nome);
this.storage.set("isCliente", res.cliente);
this.storage.set("clienti", res.clienti).then((successData)=>{
this.clientiSalvati = true;
this.events.publish('functionCall:startup', null);
});
this.storage.set("logged",true);
this.errorRespose.error = false;
}
else{
this.errorRespose.error = true;
this.errorRespose.errorMsg = res.errorMsg;
}
})
);
}
login(value) : Observable<ErrorResponse>{
this.tipoStruttura = environment.struttura;
var param = UtilService.encodeBody({utente: value.username, password: value.password, tipostruttura: this.tipoStruttura});
......@@ -151,11 +202,15 @@ export class AuthService {
tap( (res: AuthResponse ) => {
if (!res.error) {
this.authSubject.next(true);
AuthService.isClienteLoggato = res.cliente;
if(!res.cliente) AuthService.idReferente = res.id.toString();
else AuthService.idCliente = res.id.toString();
this.storage.set("idUser",res.id).then((successData)=>{
console.log("Data Stored");
console.log(successData);
});
this.storage.set("name",res.nome);
this.storage.set("isCliente", res.cliente);
this.storage.set("clienti", res.clienti).then((successData)=>{
this.clientiSalvati = true;
this.events.publish('functionCall:startup', null);
......@@ -192,6 +247,7 @@ export class AuthService {
console.log(successData);
})
this.authSubject.next(false);
this.utilService.sendRegistration(AuthService.idReferente, '', '', !AuthService.isClienteLoggato);
}
isLoggedIn(){
......
......@@ -4,5 +4,6 @@ export interface NotificheRequest {
cliente: number;
referente: number;
limite: number;
gruppoStruttura: string;
filtri: Pair[];
}
......@@ -9,7 +9,7 @@
<ion-row justify-content-center>
<ion-col align-self-center size-lg="7">
<ion-toolbar class="business-toolbar" color="#2b94d1">
<ion-buttons (click)="openSideBar()" slot="start" title="{{'apri_menu' | translate}}">
<ion-buttons (click)="openSideBar()" slot="start" title="{{'apri_menu' | translate}}" *ngIf="!isClienteLoggato">
<ion-icon name="menu" color="light" class="menu-show" tappable></ion-icon>
</ion-buttons>
<ion-title class="logo-piccolo titolo-home" (click)="gotoPreview()">
......@@ -78,7 +78,7 @@
</ion-tabs>
</ion-content>
<ion-menu side="start" menu-id="mainmenu" content-id="content" class="menu" *ngIf="!platform.is('desktop')">
<ion-menu side="start" menu-id="mainmenu" content-id="content" class="menu" *ngIf="!platform.is('desktop') && !isClienteLoggato">
<ion-header no-border class="header">
<ion-toolbar class="menu-toolbar" color="#2b94d1">
<ion-item class="menu-title item-no-border">{{ 'menu_principale' | translate }}</ion-item>
......@@ -172,6 +172,16 @@
</div>
</ion-row>
</div>
<ion-row class="row-content" tappable>
<div class="div-Consulting background-transparent" tappable>
<div tappable class="icon2" (click)="selectStruttura('notifiche')">
<img src="assets/img/notifiche.png" tappable/>
</div>
<div tappable class="section-title title-bianca" (click)="selectStruttura('notifiche')">
{{ 'notifiche' | translate }}
</div>
</div>
</ion-row>
</div>
<!--<ion-list>
<div>
......@@ -199,7 +209,7 @@
<div id="layout" *ngIf="platform.is('desktop')" class="layout">
<ion-grid>
<ion-row class="layout-row">
<ion-col class="menu menu-desktop" size-md="2" size-lg="2" size-xs="2" align-self-center>
<ion-col class="menu menu-desktop" size-md="2" size-lg="2" size-xs="2" align-self-center *ngIf="!isClienteLoggato">
<div class="logo-grande2" (click)="gotoPreview()" tappable>
<img src="assets/icon/2p2-logo-medium.svg" />
</div>
......
......@@ -28,6 +28,11 @@ export class HomePage {
public translate: TranslateService,
public platform: Platform
) {
this.caricaDati(true);
}
caricaDati(startUp: boolean)
{
this.clienti = [];
this.titoloPagina = "";
this.clienteSelezionato = {
......@@ -40,9 +45,13 @@ export class HomePage {
this.router.navigate(['login']);
}
});*/
this.events.subscribe('functionCall:startup', eventData => {
if(startUp)
this.events.subscribe('functionCall:caricaDati', async eventData => {
this.caricaDati(false);
});
this.events.subscribe('functionCall:startup', async eventData => {
if(this.clienteSelezionato.id == null) {
if(!authService.areClientiSalvati())
if(!this.authService.areClientiSalvati())
{
setTimeout(() => {
this.loadClienti()
......@@ -52,7 +61,7 @@ export class HomePage {
}
});
this.events.subscribe('functionCall:linguaCambiata', eventData => {
translate = utilService.translate;
this.translate = this.utilService.translate;
});
this.events.subscribe('functionCall:parere', eventData => {
this.router.navigateByUrl('home/parere');
......@@ -69,15 +78,15 @@ export class HomePage {
this.events.subscribe('functionCall:cambiaTitolo', eventData => {
this.titoloPagina = UtilService.titoloPagina;
});
this.lingue = utilService.getLanguageList();
if(utilService.getLingua() == "") {
this.lingue = this.utilService.getLanguageList();
if(this.utilService.getLingua() == "") {
this.linguaSel = this.lingue[0].key;
utilService.setLingua(this.linguaSel);
utilService.translate.setDefaultLang(this.linguaSel);
utilService.translate.use(this.linguaSel);
this.utilService.setLingua(this.linguaSel);
this.utilService.translate.setDefaultLang(this.linguaSel);
this.utilService.translate.use(this.linguaSel);
}
else this.linguaSel = utilService.getLingua();
translate = utilService.translate;
else this.linguaSel = this.utilService.getLingua();
this.translate = this.utilService.translate;
this.platform.backButton.subscribeWithPriority(0, () => {
let defaultUrl: string []=[
"/home",
......@@ -88,38 +97,43 @@ export class HomePage {
"/home/index",
"/home/documenti",
"/home/change-pwd",
"/home/segreteria"
"/home/segreteria",
"/home/notifiche"
];
if(defaultUrl.indexOf(this.router.url) != -1)
{
switch(this.router.url)
if(!AuthService.isClienteLoggato)
{
case "/login":
{
navigator['app'].exitApp();
break;
}
case "/home":
case "/home/index":
case "/reset":
case "/businesscall":
case "/home/preview-home":
{
this.router.navigateByUrl('login');
break;
}
case "/privacy":
{
this.router.navigateByUrl('businesscall');
break;
}
case "/home/documenti":
case "/home/change-pwd":
case "/home/segreteria":
switch(this.router.url)
{
this.router.navigateByUrl('home/index');
break;
case "/login":
{
navigator['app'].exitApp();
break;
}
case "/home":
case "/home/index":
case "/reset":
case "/businesscall":
case "/home/preview-home":
{
this.router.navigateByUrl('login');
break;
}
case "/privacy":
{
this.router.navigateByUrl('businesscall');
break;
}
case "/home/documenti":
case "/home/change-pwd":
case "/home/segreteria":
case "/home/notifiche":
{
this.router.navigateByUrl('home/index');
break;
}
}
}
}
......@@ -132,23 +146,59 @@ export class HomePage {
return this.titoloPagina != '';
}
loadStrutture()
async loadStrutture()
{
var id = await this.authService.getId();
//this.utilService.showLoading();
this.segreteriaService.getStrutture(AuthService.clienteSelezionato.id, this.tipoStruttura).subscribe((res: StruttureResponse)=>{
//this.utilService.closeLoading();
UtilService.strutture = res.strutture;
this.events.publish('functionCall:updateStrutture', null);
this.setStrutture();
if(!UtilService.strutture.includes(this.utilService.getStrutturaSel()))
this.router.navigateByUrl('home/preview-home');
},
(error: ErrorResponse) => {
//this.utilService.closeLoading();
var text = "Errore durante la richiesta lista strutture";
this.utilService.stampaErrore(text, error);
});
if(AuthService.clienteSelezionato != null) id = AuthService.clienteSelezionato.id.toString();
this.segreteriaService.getStrutture(id, this.tipoStruttura).subscribe((res: StruttureResponse)=>{
//this.utilService.closeLoading();
UtilService.strutture = res.strutture;
UtilService.strutturaSegreteria = res.strutture[0];
/*this.events.publish('functionCall:updateStrutture', null);
this.setStrutture();*/
if(!AuthService.isClienteLoggato)
this.segreteriaService.getStruttureByReferente(AuthService.idReferente, this.tipoStruttura).subscribe((res: StruttureResponse)=>{
//this.utilService.closeLoading();
UtilService.strutture = this.concat(UtilService.strutture, res.strutture);
this.events.publish('functionCall:updateStrutture', null);
this.setStrutture();
this.isClienteLoggato = AuthService.isClienteLoggato;
if(!AuthService.isClienteLoggato && !UtilService.strutture.includes(this.utilService.getStrutturaSel()))
this.router.navigateByUrl('home/preview-home');
},
(error: ErrorResponse) => {
//this.utilService.closeLoading();
var text = "Errore durante la richiesta lista strutture";
this.utilService.stampaErrore(text, error);
});
else{
this.events.publish('functionCall:updateStrutture', null);
this.isClienteLoggato = AuthService.isClienteLoggato;
this.utilService.apriPagina('notifiche');
}
},
(error: ErrorResponse) => {
//this.utilService.closeLoading();
var text = "Errore durante la richiesta lista strutture";
this.utilService.stampaErrore(text, error);
});
}
concat(str1: Struttura[], str2: Struttura[]): Struttura[] {
let strFinale: Struttura[] = [];
for(let struttura of str1)
{
let trovato: boolean = false;
for(let struttura2 of str2)
{
if(struttura.id == struttura2.id) trovato = true;
}
if(!trovato) strFinale.push(struttura);
}
return strFinale.concat(str2);
}
clienti: Cliente[];
clienteSel;
......@@ -162,10 +212,12 @@ export class HomePage {
realEstateBrokerage: Struttura;
idStrutturaSel: number;
titoloPagina: string;
isClienteLoggato: boolean;
selectStruttura(struttura:String)
selectStruttura(struttura:string)
{
let ok = false;
let nostruttura = false;
switch(struttura)
{
case "servizi":
......@@ -195,6 +247,12 @@ export class HomePage {
}
break;
}
case "notifiche":
{
nostruttura = true;
this.utilService.apriPagina(struttura);
break;
}
}
if(ok)
{
......@@ -202,7 +260,8 @@ export class HomePage {
this.events.publish('functionCall:strutturaSelectedHome', null);
}
else{
this.utilService.stampaAvviso("Struttura non presente in questo profilo");
if(!nostruttura) this.utilService.stampaAvviso("Struttura non presente in questo profilo");
else if(!this.platform.is("desktop")) this.closeSideMenu();
}
}
......@@ -219,6 +278,7 @@ export class HomePage {
gotoPreview()
{
if(AuthService.isClienteLoggato) return;
UtilService.titoloPagina = '';
this.events.publish('functionCall:cambiaTitolo', null);
this.router.navigateByUrl('home/preview-home');
......@@ -242,8 +302,9 @@ export class HomePage {
async loadClienti()
{
this.authService.loadClienti().then(state => {
this.authService.loadClienti().then(async state => {
this.clienti = AuthService.clienti;
this.isClienteLoggato = AuthService.isClienteLoggato;
this.clienteSelezionato = AuthService.clienteSelezionato;
this.events.publish('functionCall:clienteCambiato', null);
this.loadStrutture();
......
......@@ -72,12 +72,12 @@
'struttura-immobiliare-smart': isImmobiliareSelected(),
'struttura-creditizia-smart': isCreditiziaSelected() }" class="struttura-sel" tappable *ngIf="consultingService != null">
<div tappable class="icon">
<img src="assets/img/segreteriaRosso.png" (click)="apriPagina('segreteria')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/segreteriaGiallo.png" (click)="apriPagina('segreteria')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/segreteriaVerde.png" (click)="apriPagina('segreteria')" tappable *ngIf="isCreditiziaSelected()"/>
<img src="assets/img/parereRosso.png" (click)="apriPagina('pareri')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/parereGiallo.png" (click)="apriPagina('pareri')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/parereVerde.png" (click)="apriPagina('pareri')" tappable *ngIf="isCreditiziaSelected()"/>
</div>
<div tappable class="section-title" (click)="apriPagina('segreteria')">
{{ 'segreteria' | translate }}
<div tappable class="section-title" (click)="apriPagina('pareri')">
{{ 'pareri' | translate }}
</div>
</div>
<div
......@@ -85,12 +85,12 @@
'struttura-immobiliare-smart': isImmobiliareSelected(),
'struttura-creditizia-smart': isCreditiziaSelected() }" class="struttura-sel" tappable *ngIf="consultingService != null">
<div tappable class="icon">
<img src="assets/img/notificheRosso.png" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/notificheGiallo.png" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/notificheVerde.png" tappable *ngIf="isCreditiziaSelected()"/>
<img src="assets/img/domandeRosso.png" (click)="apriPagina('interviste')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/domandeGiallo.png" (click)="apriPagina('interviste')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/domandeVerde.png" (click)="apriPagina('interviste')" tappable *ngIf="isCreditiziaSelected()"/>
</div>
<div tappable class="section-title">
{{ 'notifiche' | translate }}
<div tappable class="section-title" (click)="apriPagina('interviste')">
{{ 'interviste' | translate }}
</div>
</div>
<div
......@@ -98,40 +98,41 @@
'struttura-immobiliare-smart': isImmobiliareSelected(),
'struttura-creditizia-smart': isCreditiziaSelected() }" class="struttura-sel" tappable *ngIf="consultingService != null">
<div tappable class="icon">
<img src="assets/img/businessRosso.png" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/businessGiallo.png" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/businessVerde.png" tappable *ngIf="isCreditiziaSelected()"/>
<img src="assets/img/segreteriaRosso.png" (click)="apriPagina('segreteria')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/segreteriaGiallo.png" (click)="apriPagina('segreteria')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/segreteriaVerde.png" (click)="apriPagina('segreteria')" tappable *ngIf="isCreditiziaSelected()"/>
</div>
<div tappable class="section-title">
{{ 'business' | translate }}
<div tappable class="section-title" (click)="apriPagina('segreteria')">
{{ 'segreteria' | translate }}
</div>
</div>
<div
<!--<div
[ngClass]="{'struttura-servizio-smart': isServizioSelected(),
'struttura-immobiliare-smart': isImmobiliareSelected(),
'struttura-creditizia-smart': isCreditiziaSelected() }" class="struttura-sel" tappable *ngIf="consultingService != null">
<div tappable class="icon">
<img src="assets/img/parereRosso.png" (click)="apriPagina('pareri')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/parereGiallo.png" (click)="apriPagina('pareri')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/parereVerde.png" (click)="apriPagina('pareri')" tappable *ngIf="isCreditiziaSelected()"/>
<img src="assets/img/notificheRosso.png" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/notificheGiallo.png" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/notificheVerde.png" tappable *ngIf="isCreditiziaSelected()"/>
</div>
<div tappable class="section-title" (click)="apriPagina('pareri')">
{{ 'pareri' | translate }}
<div tappable class="section-title" (click)="apriPagina('notifiche')">
{{ 'notifiche' | translate }}
</div>
</div>
</div>-->
<div
[ngClass]="{'struttura-servizio-smart': isServizioSelected(),
'struttura-immobiliare-smart': isImmobiliareSelected(),
'struttura-creditizia-smart': isCreditiziaSelected() }" class="struttura-sel" tappable *ngIf="consultingService != null">
<div tappable class="icon">
<img src="assets/img/domandeRosso.png" (click)="apriPagina('interviste')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/domandeGiallo.png" (click)="apriPagina('interviste')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/domandeVerde.png" (click)="apriPagina('interviste')" tappable *ngIf="isCreditiziaSelected()"/>
<img src="assets/img/businessRosso.png" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/businessGiallo.png" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/businessVerde.png" tappable *ngIf="isCreditiziaSelected()"/>
</div>
<div tappable class="section-title" (click)="apriPagina('interviste')">
{{ 'interviste' | translate }}
<div tappable class="section-title">
{{ 'business' | translate }}
</div>
</div>
</div>
</ion-content>
......@@ -160,12 +161,12 @@
'struttura-immobiliare': isImmobiliareSelected(),
'struttura-creditizia': isCreditiziaSelected() }" class="struttura-sel" tappable *ngIf="consultingService != null">
<div tappable class="icon">
<img src="assets/img/segreteriaRosso.png" (click)="apriPagina('segreteria')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/segreteriaGiallo.png" (click)="apriPagina('segreteria')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/segreteriaVerde.png" (click)="apriPagina('segreteria')" tappable *ngIf="isCreditiziaSelected()"/>
<img src="assets/img/parereRosso.png" (click)="apriPagina('pareri')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/parereGiallo.png" (click)="apriPagina('pareri')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/parereVerde.png" (click)="apriPagina('pareri')" tappable *ngIf="isCreditiziaSelected()"/>
</div>
<div tappable class="section-title" (click)="apriPagina('segreteria')">
{{ 'segreteria' | translate }}
<div tappable class="section-title" (click)="apriPagina('pareri')">
{{ 'pareri' | translate }}
</div>
</div>
<div
......@@ -173,12 +174,12 @@
'struttura-immobiliare': isImmobiliareSelected(),
'struttura-creditizia': isCreditiziaSelected() }" class="struttura-sel" tappable *ngIf="consultingService != null">
<div tappable class="icon">
<img src="assets/img/notificheRosso.png" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/notificheGiallo.png" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/notificheVerde.png" tappable *ngIf="isCreditiziaSelected()"/>
<img src="assets/img/domandeRosso.png" (click)="apriPagina('interviste')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/domandeGiallo.png" (click)="apriPagina('interviste')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/domandeVerde.png" (click)="apriPagina('interviste')" tappable *ngIf="isCreditiziaSelected()"/>
</div>
<div tappable class="section-title" (click)="apriPagina('notifiche')">
{{ 'notifiche' | translate }}
<div tappable class="section-title" (click)="apriPagina('interviste')">
{{ 'interviste' | translate }}
</div>
</div>
<div
......@@ -186,38 +187,38 @@
'struttura-immobiliare': isImmobiliareSelected(),
'struttura-creditizia': isCreditiziaSelected() }" class="struttura-sel" tappable *ngIf="consultingService != null">
<div tappable class="icon">
<img src="assets/img/businessRosso.png" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/businessGiallo.png" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/businessVerde.png" tappable *ngIf="isCreditiziaSelected()"/>
<img src="assets/img/segreteriaRosso.png" (click)="apriPagina('segreteria')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/segreteriaGiallo.png" (click)="apriPagina('segreteria')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/segreteriaVerde.png" (click)="apriPagina('segreteria')" tappable *ngIf="isCreditiziaSelected()"/>
</div>
<div tappable class="section-title">
{{ 'business' | translate }}
<div tappable class="section-title" (click)="apriPagina('segreteria')">
{{ 'segreteria' | translate }}
</div>
</div>
<div
<!--<div
[ngClass]="{'struttura-servizio': isServizioSelected(),
'struttura-immobiliare': isImmobiliareSelected(),
'struttura-creditizia': isCreditiziaSelected() }" class="struttura-sel" tappable *ngIf="consultingService != null">
<div tappable class="icon">
<img src="assets/img/parereRosso.png" (click)="apriPagina('pareri')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/parereGiallo.png" (click)="apriPagina('pareri')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/parereVerde.png" (click)="apriPagina('pareri')" tappable *ngIf="isCreditiziaSelected()"/>
<img src="assets/img/notificheRosso.png" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/notificheGiallo.png" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/notificheVerde.png" tappable *ngIf="isCreditiziaSelected()"/>
</div>
<div tappable class="section-title" (click)="apriPagina('pareri')">
{{ 'pareri' | translate }}
<div tappable class="section-title" (click)="apriPagina('notifiche')">
{{ 'notifiche' | translate }}
</div>
</div>
</div>-->
<div
[ngClass]="{'struttura-servizio': isServizioSelected(),
'struttura-immobiliare': isImmobiliareSelected(),
'struttura-creditizia': isCreditiziaSelected() }" class="struttura-sel" tappable *ngIf="consultingService != null">
<div tappable class="icon">
<img src="assets/img/domandeRosso.png" (click)="apriPagina('interviste')" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/domandeGiallo.png" (click)="apriPagina('interviste')" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/domandeVerde.png" (click)="apriPagina('interviste')" tappable *ngIf="isCreditiziaSelected()"/>
<img src="assets/img/businessRosso.png" tappable *ngIf="isServizioSelected()"/>
<img src="assets/img/businessGiallo.png" tappable *ngIf="isImmobiliareSelected()"/>
<img src="assets/img/businessVerde.png" tappable *ngIf="isCreditiziaSelected()"/>
</div>
<div tappable class="section-title" (click)="apriPagina('interviste')">
{{ 'interviste' | translate }}
<div tappable class="section-title">
{{ 'business' | translate }}
</div>
</div>
</div>
......
......@@ -7,7 +7,9 @@
<ion-row>
<div class="search-date-smart">
<ion-row>
<span class="riga"><strong>{{ 'cerca' | translate }}</strong> {{ 'titolo' | translate }} <input type="text" name="calendar" [(ngModel)]="titolo" title="{{ 'ricerca_titolo' | translate }}" class="cerca-titolo-doc">
<span class="riga">
<strong>{{ 'cerca' | translate }}</strong> {{ 'titolo' | translate }}
<input type="text" name="calendar" [(ngModel)]="titolo" title="{{ 'ricerca_titolo' | translate }}" class="cerca-titolo-doc">
</span>
<ion-button (click)="cercaNotifiche()" class="search-arrow" title="{{ 'cerca' | translate }}">
<ion-icon class="button-icon-documenti-smart ios-icon" slot="icon-only" name="ios-arrow-dropright-circle" title="{{ 'cerca' | translate }}"></ion-icon>
......@@ -20,7 +22,7 @@
<ion-row>
<span class="riga">
<ion-checkbox name="privacy" [(ngModel)]="archiviati" class="check2"> </ion-checkbox>
<ion-label>{{ 'visualizza_archiviati' | translate }}</ion-label>
<ion-label>{{ 'visualizza_notifiche_archiviate' | translate }}</ion-label>
</span>
<ion-button (click)="cercaNotifiche()" class="search-arrow" title="{{ 'cerca' | translate }}">
<ion-icon class="button-icon-documenti-smart ios-icon" slot="icon-only" name="ios-arrow-dropright-circle" title="{{ 'cerca' | translate }}"></ion-icon>
......@@ -28,6 +30,42 @@
</ion-row>
</div>
</ion-row>
<ion-row *ngIf="!isClienteLoggato">
<div class="search-date-smart">
<ion-row>
<span class="riga">
<span class="testo-ricerca">
<span class="testo-ricerca-select"><strong>{{ 'cerca' | translate }}</strong> {{ 'cliente' | translate }}</span>
<ion-select value="clienteSelezionato" class="cerca-titolo-doc testo-ricerca-select" [(ngModel)]="clienteSelezionato" (ionChange)="cambiaCliente()" interface="popover" [placeholder]="clienteSel ? clienteSel.denominazione : 'Seleziona Cliente ...'" title="Seleziona un cliente">
<ion-select-option value="-1"></ion-select-option>
<ion-select-option *ngFor="let cliente of clienti; let i=index;" value="{{cliente.id}}">{{cliente.denominazione}}</ion-select-option>
</ion-select>
</span>
</span>
<ion-button (click)="cercaNotifiche()" class="search-arrow" title="{{ 'cerca' | translate }}">
<ion-icon class="button-icon-documenti-smart ios-icon" slot="icon-only" name="ios-arrow-dropright-circle" title="{{ 'cerca' | translate }}"></ion-icon>
</ion-button>
</ion-row>
</div>
</ion-row>
<ion-row>
<div class="search-date-smart">
<ion-row>
<span class="riga">
<span class="testo-ricerca">
<span class="testo-ricerca-select"><strong>{{ 'cerca' | translate }}</strong> {{ 'struttura' | translate }}</span>
<ion-select value="strutturaSelezionata" class="cerca-titolo-doc testo-ricerca-select" [(ngModel)]="strutturaSelezionata" (ionChange)="cambiaStruttura()" interface="popover" [placeholder]="strSel.denominazione ? strSel.denominazione : 'Seleziona struttura ...'" title="Seleziona un cliente">
<ion-select-option value="-1"></ion-select-option>
<ion-select-option *ngFor="let struttura of strutture; let i=index;" value="{{struttura.id}}">{{struttura.denominazione}}</ion-select-option>
</ion-select>
</span>
</span>
<ion-button (click)="cercaNotifiche()" class="search-arrow" title="{{ 'cerca' | translate }}">
<ion-icon class="button-icon-documenti-smart ios-icon" slot="icon-only" name="ios-arrow-dropright-circle" title="{{ 'cerca' | translate }}"></ion-icon>
</ion-button>
</ion-row>
</div>
</ion-row>
<span id="buttonsNotifiche" style="display:none">
<ion-row>
<div class="search-date-smart" *ngIf="!archiviati">
......@@ -56,16 +94,16 @@
</span>
<ion-row class="search-date-border-smart">
</ion-row>
<ion-list *ngFor="let notifica of notifiche; trackBy: trackByDoc" class="row-results-smart" (click)="selection?toggleGroup(notifica.idRichiesta):selectItem(notifica.idRichiesta)"
(press)="selectItem(notifica.idRichiesta)" [ngStyle]="{'background-color': notifica.checked ? '#c3ddec' : '#ffffff'}">
<ion-checkbox name="privacy" [(ngModel)]="notifica.checked" class="check" (click)="checkSelected(notifica.idRichiesta)"> </ion-checkbox>
<ion-list *ngFor="let notifica of notifiche; trackBy: trackByDoc" class="row-results-smart" (click)="selection?toggleGroup(notifica.id):selectItem(notifica.id)"
(press)="selectItem(notifica.id)" [ngStyle]="{'background-color': notifica.checked ? '#c3ddec' : '#ffffff'}">
<ion-checkbox name="privacy" [(ngModel)]="notifica.checked" class="check" (click)="checkSelected(notifica.id)"> </ion-checkbox>
<div class="table-row">
<div class="row-text data" text-wrap>
<div text-wrap>{{notifica.titolo}}</div>
{{notifica.data}}
</div>
<div class="row-download item-no-border">
<ion-icon class="button-icon-documenti-smart ios-icon" name="ios-arrow-dropright-circle" (click)="apriNotifica(notifica.idRichiesta)" tappable title="{{ 'visualizza_dettagli' | translate }}"></ion-icon>
<ion-icon class="button-icon-documenti-smart ios-icon" name="ios-arrow-dropright-circle" (click)="apriNotifica(notifica.id)" tappable title="{{ 'visualizza_dettagli' | translate }}"></ion-icon>
</div>
</div>
</ion-list>
......@@ -75,9 +113,12 @@
<span *ngIf="platform.is('desktop')">
<div *ngSwitchCase="'lista'">
<ion-row class="title-row">
<ion-buttons class="back-button-desktop" (click)="back()" title="{{ 'back_login' | translate }}">
<ion-buttons class="back-button-desktop" (click)="back()" title="{{ 'back_login' | translate }}" *ngIf="!isClienteLoggato">
<ion-icon name="arrow-round-back" color="#2b94d1" class="back" tappable></ion-icon>
</ion-buttons>
<ion-buttons class="back-button-desktop" (click)="logout()" title="{{'uscita' | translate}}" *ngIf="isClienteLoggato">
<ion-icon name="exit" color="#2b94d1" class="back" tappable></ion-icon>
</ion-buttons>
<div class="pareri-title">
<ion-title>{{ 'notifiche_titolo' | translate }}</ion-title>
</div>
......@@ -92,9 +133,35 @@
<ion-icon class="button-icon-documenti ios-icon" slot="icon-only" name="ios-arrow-dropright-circle" title="{{ 'cerca_documenti' | translate }}"></ion-icon>
</ion-button>
</div>
<div class="riga" *ngIf="!isClienteLoggato">
<span class="testo-ricerca-select">
<strong>{{ 'cerca' | translate }}</strong>
{{ 'cliente' | translate }}
</span>
<ion-select value="clienteSelezionato" class=" testo-ricerca-select cerca-titolo-doc" [(ngModel)]="clienteSelezionato" (ionChange)="cambiaCliente()" interface="popover" [placeholder]="clienteSel ? clienteSel.denominazione : 'Tap to select..'" title="Seleziona un cliente">
<ion-select-option value="-1"></ion-select-option>
<ion-select-option *ngFor="let cliente of clienti; let i=index;" value="{{cliente.id}}">{{cliente.denominazione}}</ion-select-option>
</ion-select>
<ion-button (click)="cercaNotifiche()" class="search-arrow" title="{{ 'cerca_documenti' | translate }}">
<ion-icon class="button-icon-documenti ios-icon" slot="icon-only" name="ios-arrow-dropright-circle" title="{{ 'cerca_documenti' | translate }}"></ion-icon>
</ion-button>
</div>
<div class="riga">
<span class="testo-ricerca-select">
<strong>{{ 'cerca' | translate }}</strong>
{{ 'struttura' | translate }}
</span>
<ion-select value="strutturaSelezionata" class="testo-ricerca-select cerca-titolo-doc" [(ngModel)]="strutturaSelezionata" (ionChange)="cambiaStruttura()" interface="popover" [placeholder]="strSel.denominazione ? strSel.denominazione : 'Tap to select..'" title="Seleziona un cliente">
<ion-select-option value="-1"></ion-select-option>
<ion-select-option *ngFor="let struttura of strutture; let i=index;" value="{{struttura.id}}">{{struttura.denominazione}}</ion-select-option>
</ion-select>
<ion-button (click)="cercaNotifiche()" class="search-arrow" title="{{ 'cerca_documenti' | translate }}">
<ion-icon class="button-icon-documenti ios-icon" slot="icon-only" name="ios-arrow-dropright-circle" title="{{ 'cerca_documenti' | translate }}"></ion-icon>
</ion-button>
</div>
<div class="riga">
<ion-checkbox name="privacy" [(ngModel)]="archiviati" class="check"> </ion-checkbox>
<ion-label class="archivio-text"><span class="text">{{ 'visualizza_archiviati' | translate }}</span></ion-label>
<ion-label class="archivio-text"><span class="text">{{ 'visualizza_notifiche_archiviate' | translate }}</span></ion-label>
<ion-button (click)="cercaNotifiche()" class="search-arrow" title="{{ 'cerca' | translate }}">
<ion-icon class="button-icon-documenti ios-icon" slot="icon-only" name="ios-arrow-dropright-circle" title="{{ 'cerca' | translate }}"></ion-icon>
</ion-button>
......@@ -121,18 +188,18 @@
<div class="documento-text">
<ion-row class="title">
<div class="checkbox-desktop">
<ion-checkbox name="privacy" [(ngModel)]="notifica.checked" class="check" (click)="checkSelected(notifica.idRichiesta)"> </ion-checkbox>
<ion-checkbox name="privacy" [(ngModel)]="notifica.checked" class="check" (click)="checkSelected(notifica.id)"> </ion-checkbox>
</div>
<div class="title" (click)="apriNotifica(notifica.idRichiesta)">
<div class="title" (click)="apriNotifica(notifica.id)">
<strong>{{notifica.titolo}}</strong>
</div>
</ion-row>
<div class="data" (click)="apriNotifica(notifica.idRichiesta)">
<div class="data" (click)="apriNotifica(notifica.id)">
{{notifica.data}}
</div>
</div>
</ion-col>
<ion-col (click)="apriNotifica(notifica.idRichiesta)">
<ion-col (click)="apriNotifica(notifica.id)">
<div tappable class="icon3">
<img src="assets/img/notificheNero.png" tappable/>
</div>
......@@ -145,7 +212,7 @@
</span>
<div *ngSwitchCase="'dettaglio'">
<div>
<!--<div>
Titolo:
</div>
<div>
......@@ -156,7 +223,40 @@
</div>
<div>
<strong>{{notificaAttiva.contenuto}}</strong>
</div>
</div>-->
<span *ngIf="platform.is('desktop')">
<ion-row class="title-row">
<ion-buttons class="back-button-desktop" (click)="apriLista()" title="{{ 'back_pareri' | translate }}">
<ion-icon name="arrow-round-back" color="#232D4B" class="back" tappable></ion-icon>
</ion-buttons>
<div class="pareri-title">
<ion-title>{{notificaAttiva.titolo}}</ion-title>
</div>
</ion-row>
<ion-row>
<div >
<ion-label>{{notificaAttiva.contenuto}}</ion-label>
</div>
</ion-row>
</span>
<span *ngIf="!platform.is('desktop')">
<ion-row class="title-row">
<ion-buttons class="back-button-desktop" (click)="apriLista()" title="{{ 'back_pareri' | translate }}">
<ion-icon name="arrow-round-back" color="#232D4B" class="back" tappable></ion-icon>
</ion-buttons>
<div class="pareri-title-smart2">
<ion-title>{{notificaAttiva.titolo}}</ion-title>
</div>
</ion-row>
<ion-row>
<div>
<span class="question-extended item-no-border2" no-lines>
<ion-textarea class="notifica-content" readonly>{{notificaAttiva.contenuto}}</ion-textarea >
</span>
</div>
</ion-row>
</span>
</div>
<div *ngSwitchCase="'documenti'">
......
......@@ -10,6 +10,9 @@ import { Notifica } from 'src/app/interface/notifica';
import { NotificheService } from 'src/app/service/notifiche.service';
import { NotificheResponse } from 'src/app/interface/notifiche-response';
import { ArchiviaNotificaResponse } from 'src/app/interface/archivia-notifica-response';
import { environment } from '../../../environments/environment';
import { Cliente } from 'src/app/auth/interface/cliente';
import { Struttura } from 'src/app/interface/struttura';
@Component({
selector: 'app-notifiche',
......@@ -26,12 +29,17 @@ export class NotifichePage implements OnInit {
private notificheService: NotificheService,
public httpClientDataService: HttpClientDataService,
public translate: TranslateService,
public router: Router
public router: Router,
public authService: AuthService
) {
this.events.publish('functionCall:startup', null);
this.initPage();
if(AuthService.clienteSelezionato.id != null) this.loadNotifiche();
this.events.subscribe('functionCall:clienteCambiato', eventData => {
setTimeout(() => {
this.loadNotifiche();
}, 3000);
this.isClienteLoggato = AuthService.isClienteLoggato;
this.events.subscribe('functionCall:clienteCambiato', eventData => {
this.isClienteLoggato = AuthService.isClienteLoggato;
this.loadNotifiche();
});
this.events.subscribe('functionCall:linguaCambiata', eventData => {
......@@ -42,10 +50,12 @@ export class NotifichePage implements OnInit {
{
if(this.notifica == "lista")
{
UtilService.titoloPagina = '';
this.events.publish('functionCall:cambiaTitolo', null);
this.router.navigateByUrl('home/index');
if(!AuthService.isClienteLoggato)
{
UtilService.titoloPagina = '';
this.events.publish('functionCall:cambiaTitolo', null);
this.router.navigateByUrl('home/index');
}
}
else
{
......@@ -77,6 +87,16 @@ export class NotifichePage implements OnInit {
initPage()
{
var allegati = new Array();
this.clienti = AuthService.clienti;
this.setStrutture();
this.strSel = {
denominazione: null,
id: null
};
this.clienteSel = {
denominazione: null,
id: null
};
this.notificaAttiva = {
id: null,
allegati:allegati,
......@@ -95,8 +115,21 @@ export class NotifichePage implements OnInit {
this.notificheSelezionate = new Array();
this.error = "";
this.titolo = "";
this.tipoStruttura = environment.struttura;
}
setStrutture() {
if(UtilService.strutture != null) this.strutture = UtilService.strutture;
else
{
setTimeout(() => {
this.setStrutture()
}, 3000)
}
}
clienti: Cliente[];
strutture: Struttura[];
notifiche: Notifica[];
notificaAttiva: Notifica;
idCliente;
......@@ -105,6 +138,8 @@ export class NotifichePage implements OnInit {
bottoneVisibile: boolean;
archiviati: boolean;
titolo: string;
strSel:Struttura;
clienteSel:Cliente;
idSelected: number;
selection: boolean = false;
......@@ -114,6 +149,24 @@ export class NotifichePage implements OnInit {
notificaId;
notificheSelezionate: Array<number>;
error: string;
tipoStruttura: string;
clienteSelezionato;
strutturaSelezionata;
isClienteLoggato: boolean;
cambiaCliente()
{
this.authService.getCliente(this.clienteSelezionato);
this.clienteSel = this.authService.clienteTrovato;
}
cambiaStruttura()
{
this.utilService.getStruttura(this.strutturaSelezionata).then(struttura =>
{
this.strSel = struttura;
});
}
toggleGroup(id : number)
{
......@@ -189,12 +242,12 @@ export class NotifichePage implements OnInit {
{
this.hideButtons();
var titolo = null;
this.utilService.showLoading();
this.idCliente = AuthService.clienteSelezionato.id;
//this.utilService.showLoading();
AuthService.idReferente = await this.authService.getId();
let referente = AuthService.idReferente;
if(this.titolo != null && this.titolo != "") titolo = this.titolo;
this.notificheService.getListaNotifiche(this.idCliente, referente, this.archiviati, titolo).subscribe((res: NotificheResponse)=>{
this.utilService.closeLoading();
this.notificheService.getListaNotifiche(this.clienteSelezionato, referente, this.archiviati, titolo, this.tipoStruttura, this.strutturaSelezionata).subscribe((res: NotificheResponse)=>{
//this.utilService.closeLoading();
if(res.error){
this.utilService.presentAlert("Errore", "", res.error, ["OK"]);
}
......@@ -205,7 +258,7 @@ export class NotifichePage implements OnInit {
}
},
(error: ErrorResponse) => {
this.utilService.closeLoading();
//this.utilService.closeLoading();
var text = "Errore durante la procedura di richiesta Topic";
this.utilService.stampaErrore(text, error);
}
......@@ -298,4 +351,8 @@ export class NotifichePage implements OnInit {
this.router.navigateByUrl('home/index');
}
logout(){
this.utilService.logout();
}
}
......@@ -30,6 +30,12 @@ export class PreviewHomePage implements OnInit {
});
this.events.subscribe('functionCall:updateStrutture', eventData => {
this.setStrutture();
if(this.startup)
if(UtilService.redirectToNotifiche)
{
UtilService.redirectToNotifiche = false;
this.utilService.apriPagina("notifiche");
}
});
translate = utilService.translate;
}
......@@ -39,9 +45,11 @@ export class PreviewHomePage implements OnInit {
realEstateBrokerage: Struttura;
name: String;
pageReady: boolean = false;
startup: boolean = true;
setStrutture()
{
this.authService.getId();
this.authService.getName().then(state => {
this.name = state;
this.pageReady = true;
......
......@@ -9,6 +9,9 @@ import { HttpClientDataService } from '../service/http-client-data.service';
import { NotificheResponse } from '../interface/notifiche-response';
import { ArchiviaNotificaResponse } from '../interface/archivia-notifica-response';
import { ArchiviaNotificaRequest } from '../interface/archivia-notifica-request';
import { ParereResponse } from '../interface/parere-response';
import { UtilService } from './util.service';
import { AuthService } from '../auth/service/auth.service';
@Injectable({
providedIn: 'root'
......@@ -94,9 +97,12 @@ export class NotificheService {
return of(this.errorRespose);
};
getListaNotifiche(idCliente: string, idReferente: string, archiviati: boolean, titolo: string): Observable<NotificheResponse>
getListaNotifiche(idCliente: string, idReferente: string, archiviati: boolean, titolo: string, tipoStruttura: string, strutturaSelezionata: string): Observable<NotificheResponse>
{
var richiesta = this.creaRichiesta(idCliente, idReferente, 10, null, null, archiviati, titolo);
var richiesta = null;
if(AuthService.isClienteLoggato) richiesta = this.creaRichiesta(idReferente, -1, 10, null, null, archiviati, titolo, tipoStruttura, strutturaSelezionata);
else richiesta = this.creaRichiesta(idCliente, idReferente, 10, null, null, archiviati, titolo, tipoStruttura, strutturaSelezionata);
var param = this.encodeBody(richiesta);
return this.httpClient.post<NotificheResponse>(this.httpClientDataService.BASE_ADDRESS+'/intranet/notifiche.do', param, this.httpClientDataService.httpOptionsJson)
.pipe(
......@@ -115,7 +121,44 @@ export class NotificheService {
);
}
creaRichiesta(id, referente, limite, dataDa, dataA, archiviati, titolo): NotificheRequest
resetNotifiche(idReferente: string, struttura: string) : Observable<Boolean> {
var param = "";
if(!AuthService.isClienteLoggato) param = UtilService.encodeBody({clienteId: -1, referenteId: idReferente, gruppoStrutture: struttura});
else param = UtilService.encodeBody({clienteId: idReferente, referenteId: -1, gruppoStrutture: struttura});
return this.httpClient.post<Boolean>(this.httpClientDataService.BASE_ADDRESS+'/intranet/resetNotificheNonLette.do', param, this.httpClientDataService.httpOptions)
.pipe(
catchError(this.handleError),
tap( (res: Boolean ) => {
console.log("Reset Eseguito");
return res;
})
);
}
isNotificheNonViste(idReferente: string, tipoStruttura: string): Observable<ParereResponse>
{
var richiesta = null;
if(AuthService.isClienteLoggato) richiesta = this.creaRichiesta(idReferente, -1, 10, null, null, false, null, tipoStruttura, null);
else richiesta = this.creaRichiesta(-1, idReferente, 10, null, null, false, null, tipoStruttura, null);
var param = this.encodeBody(richiesta);
return this.httpClient.post<ParereResponse>(this.httpClientDataService.BASE_ADDRESS+'/intranet/notificheNonLette.do', param, this.httpClientDataService.httpOptionsJson)
.pipe(
catchError(this.handleError),
tap( (res: ParereResponse) => {
if (!res.error) {
this.errorRespose.error = false;
return res;
}
else{
this.errorRespose.error = true;
this.errorRespose.errorMsg = res.error;
}
})
);
}
creaRichiesta(id, referente, limite, dataDa, dataA, archiviati, titolo, tipostruttura, strutturaSelezionata): NotificheRequest
{
var request:NotificheRequest;
var pair:Pair;
......@@ -140,12 +183,33 @@ export class NotificheService {
}
pairs.push(pair);
}
pairs.push(pair);
if(strutturaSelezionata != null)
{
pair = {
key: "struttura",
value: strutturaSelezionata,
type: "int"
}
pairs.push(pair);
}
if(id != null)
{
pair = {
key: "cliente",
value: id,
type: "int"
}
pairs.push(pair);
}
if(id == null) id = "-1";
request = {
cliente: id,
referente: referente,
limite: limite,
gruppoStruttura: tipostruttura,
filtri: pairs
};
......@@ -153,7 +217,7 @@ export class NotificheService {
}
encodeBody(params: NotificheRequest) {
var request = "{\"cliente\" : "+params.cliente+",\"referente\" : "+params.referente+",\"limite\" : "+params.limite+",\"filtri\" : {";
var request = "{\"cliente\" : "+params.cliente+",\"referente\" : "+params.referente+",\"limite\" : "+params.limite+",\"gruppoStruttura\" : \""+params.gruppoStruttura+"\",\"filtri\" : {";
var filtro;
var first = true;
var i;
......
......@@ -146,6 +146,26 @@ export class SegreteriaService {
);
}
getStruttureByReferente(idUser, tipoStruttura)
{
var param = UtilService.encodeBody({idreferente: idUser, tipostruttura: tipoStruttura});
return this.httpClient.post<StruttureResponse>(this.httpClientDataService.BASE_ADDRESS+'/intranet/struttureByReferente.do', param, this.httpClientDataService.httpOptions)
.pipe(
catchError(this.handleError),
tap( (res: StruttureResponse) => {
if (!res.error) {
this.errorRespose.error = false;
return res;
}
else{
this.errorRespose.error = true;
this.errorRespose.errorMsg = res.error;
}
})
);
}
encodeBody(params)
{
var request = "{\"cliente\" : "+params.cliente+",\"limite\" : "+params.limite+",\"struttura\" : "+params.struttura+",\"filtri\" : {";
......
import { Pair } from './../interface/pair';
import { Injectable } from '@angular/core';
import { LoadingController, AlertController, Platform, Events } from '@ionic/angular';
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { File} from '@ionic-native/file/ngx';
import { FileOpener } from '@ionic-native/file-opener/ngx';
import { Router } from "@angular/router";
import { SocialSharing } from '@ionic-native/social-sharing/ngx';
import { TranslateService } from '@ngx-translate/core';
import { Storage } from '@ionic/storage';
import { BehaviorSubject} from 'rxjs';
import { BehaviorSubject, of} from 'rxjs';
import { Struttura } from '../interface/struttura';
import { ParereResponse } from '../interface/parere-response';
import { catchError, tap } from 'rxjs/operators';
import { HttpClientDataService } from './http-client-data.service';
import { PushObject, PushOptions, Push } from '@ionic-native/push/ngx';
import { ErrorResponse } from '../auth/interface/error-response';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { NotificheService } from './notifiche.service';
import { environment } from '../../environments/environment';
import { AuthService } from '../auth/service/auth.service';
const delay = ms => new Promise(res => setTimeout(res, ms));
......@@ -34,7 +45,13 @@ export class UtilService {
private socialSharing: SocialSharing,
private storage: Storage,
public translate: TranslateService,
public events: Events
private httpClientDataService: HttpClientDataService,
public events: Events,
public push: Push,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private androidPermissions: AndroidPermissions,
private notificheService: NotificheService
) {
this.loaders = new Array();
this.loader = this.loadingCtrl.create({
......@@ -42,6 +59,10 @@ export class UtilService {
});
this.loaders.push(this.loader);
this.languageSelected = "";
this.errorRespose = {
error: true,
errorMsg: ""
};
}
async logout() {
......@@ -75,6 +96,7 @@ export class UtilService {
console.log(successData);
})
this.authSubject.next(false);
this.sendRegistration(AuthService.idReferente, '', '', !AuthService.isClienteLoggato).subscribe((res: ParereResponse)=>{});
}
async presentAlert(headerPar, subtitlePar, messagePar, buttonsPar) {
......@@ -94,6 +116,10 @@ export class UtilService {
private static strutturaSel:Struttura;
public static strutture: Struttura[];
public static titoloPagina:string = "";
public static strutturaSegreteria:Struttura;
public static pushRegistrationId:string;
public static redirectToNotifiche:boolean = false;
public static startup = true;
static setStruttura(id:number)
{
......@@ -413,6 +439,11 @@ export class UtilService {
this.presentAlert("Avviso", "", text, ["OK"]);
}
stampaSuccesso(text: string)
{
this.presentAlert("Successo", "", text, ["OK"]);
}
download(url)
{
return this.httpClient.get(url, {responseType: "blob"});
......@@ -420,6 +451,7 @@ export class UtilService {
async apriPagina(pagina:string)
{
if(AuthService.isClienteLoggato && pagina != 'notifiche') return;
switch(pagina)
{
case "home":
......@@ -487,6 +519,8 @@ export class UtilService {
}
case "notifiche":
{
var idReferente = await this.getIdUser();
this.notificheService.resetNotifiche(idReferente, environment.struttura).subscribe((res: Boolean)=>{});
this.translate.get('notifiche_titolo').subscribe(
value => {
UtilService.titoloPagina = value;
......@@ -495,6 +529,277 @@ export class UtilService {
this.router.navigateByUrl('home/notifiche');
break;
}
case "calendarioCorsi":
{
this.translate.get('calendario_corsi_titolo').subscribe(
value => {
UtilService.titoloPagina = value;
this.events.publish('functionCall:cambiaTitolo', null);
});
this.router.navigateByUrl('home/calendario-corsi');
break;
}
case "mieiCorsi":
{
this.translate.get('miei_corsi_titolo').subscribe(
value => {
UtilService.titoloPagina = value;
this.events.publish('functionCall:cambiaTitolo', null);
});
this.router.navigateByUrl('home/miei-corsi');
break;
}
}
}
pushNotification(idReferente)
{
if(this.platform.is("desktop")) return;
this.push.hasPermission()
.then((res: any) => {
if (res.isEnabled) {
this.continuePush(idReferente);
} else {
this.presentAlert("Errore", "", "Non hai il permesso di accedere alle push notification", ["OK"]);
console.log('We do not have permission to send push notifications');
}
});
}
continuePush(idReferente)
{
/*this.push.createChannel({
id: "it.aimconsulting.leonardomannelli",
description: "Canale",
// The importance property goes from 1 = Lowest, 2 = Low, 3 = Normal, 4 = High and 5 = Highest.
importance: 3
});*/
const options: PushOptions = {
android: {
//senderID:''
},
ios: {
alert: 'true',
badge: true,
sound: 'false'
},
windows: {},
browser: {}
}
const pushObject: PushObject = this.push.init(options);
pushObject.on('registration').subscribe((registration: any) =>{
this.getPushRegistrationId().then(id => {
this.savePushRegistrationId(registration.registrationId, idReferente);
});
}
);
pushObject.on('notification').subscribe((data: any) =>{
/*console.log(data.message);
console.log(data.title);
console.log(data.count);
console.log(data.sound);
console.log(data.image);
console.log(data.additionalData);*/
this.presentAlert(data.title, "", data.message, ["OK"]);
});
pushObject.on('error').subscribe((error: any) =>{
console.log("Errore durante le notifiche: "+error);
});
}
savePushRegistrationId(id:string, idReferente)
{
//Spedizione registrationId al gestionale insieme al sapere se android o iphone
let piattaforma:String = "";
if(this.platform.is("android")) piattaforma = "android";
else if(this.platform.is("ios")) piattaforma ="ios";
else return;
if(AuthService.isClienteLoggato) this.sendRegistration(idReferente, piattaforma, id, false).subscribe((res: ParereResponse)=>{});
else this.sendRegistration(idReferente, piattaforma, id, true).subscribe((res: ParereResponse)=>{});
UtilService.pushRegistrationId = id;
this.storage.set("push_registration_id", id);
}
sendRegistration(idReferente: string, piattaforma:String, registrationId: String, is_referente: boolean)
{
var param = UtilService.encodeBody({referenteId: idReferente, tipoCellulare:piattaforma, registrationId: registrationId, is_referente: is_referente});
return this.httpClient.post<ParereResponse>(this.httpClientDataService.BASE_ADDRESS+'/intranet/pushRegistration.do', param, this.httpClientDataService.httpOptions)
.pipe(
catchError(this.handleError),
tap( (res: ParereResponse ) => {
if (!res.error) {
this.errorRespose.error = false;
return res;
}
else{
this.errorRespose.error = true;
this.errorRespose.errorMsg = res.error;
}
})
);
}
errorRespose: ErrorResponse;
handleError(error: HttpErrorResponse) {
this.errorRespose = {
error: true,
errorMsg: ""
};
if (error.error instanceof ErrorEvent) {
this.errorRespose.errorMsg = error.error.message;
} else {
this.errorRespose.errorMsg = error.error;
}
return of(this.errorRespose);
};
getPushRegistrationId()
{
return this.storage.get("push_registration_id").then((data)=>{
UtilService.pushRegistrationId = data;
return data;
});
}
onResumeSubscription;
firstResume : boolean = true;
firstPause : boolean = true;
setResume() {
this.onResumeSubscription = this.platform.resume.subscribe(async () => {
if(!this.firstResume) {
this.initConfig(true, "notifiche");
this.onResumeSubscription.unsubscribe();
console.log('resumed');
this.firstPause = true;
}
});
}
async initConfig(resume:boolean, nextPage)
{
var state = await this.syncIsLoggedIn();
if(this.firstResume)
{
if(this.platform.is("android"))
this.platform.pause.subscribe(async () => {
if(!this.firstPause) this.setResume();
this.firstPause = false;
this.firstResume = false;
console.log('paused');
});
}
if (state) {
AuthService.isClienteLoggato = await this.getIsCliente();
if(!this.platform.is('desktop') && !resume)
{
var idReferente = await this.getIdUser();
this.pushNotification(idReferente);
}
this.redirectToFirstPage(nextPage);
}
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
if(!navigator.onLine)
{
this.router.navigate(['error']);
this.presentAlert("Errore", "", "Dispositivo non connesso alla rete", ["OK"]);
}
else
{
if(this.platform.is("android"))
{
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.INTERNET).then(
result => {
console.log('Has permission?',result.hasPermission);
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.INTERNET,
this.androidPermissions.PERMISSION.ACCESS_NETWORK_STATE, this.androidPermissions.PERMISSION.GET_ACCOUNTS,
this.androidPermissions.PERMISSION.RECEIVE_WAP_PUSH]);
/*if(!result.hasPermission)
{
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.INTERNET, this.androidPermissions.PERMISSION.ACCESS_NETWORK_STATE, this.androidPermissions.PERMISSION.GET_ACCOUNTS]);
}*/
},
err =>
{
this.presentAlert("Messaggio", "", "Richiesta Permesso", ["OK"]);
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.INTERNET, this.androidPermissions.PERMISSION.GET_ACCOUNTS]);
}
);
}
/*this.authService.isLoggedIn().then(state => {
if (!state) {
this.router.navigate(['login']);
}
});*/
}
});
}
async redirectToFirstPage(nextPage) {
var idReferente = await this.getIdUser();
AuthService.isClienteLoggato = await this.getIsCliente();
if(AuthService.isClienteLoggato) this.apriPagina(nextPage);
else
this.notificheService.isNotificheNonViste(idReferente, environment.struttura).subscribe((res: ParereResponse)=>{
if(res.error){
this.router.navigate(['home']);
this.events.publish('functionCall:caricaDati', null);
}
else
{
if(res.autorizzato && !UtilService.startup) this.apriPagina(nextPage);
else{
if(res.autorizzato && UtilService.startup)
{
UtilService.startup = false;
UtilService.redirectToNotifiche = true;
this.router.navigate(['home']);
this.events.publish('functionCall:caricaDati', null);
}
else{
this.router.navigate(['home']);
this.events.publish('functionCall:caricaDati', null);
}
}
}
},
(error: ErrorResponse) => {
this.router.navigate(['home']);
this.events.publish('functionCall:caricaDati', null);
});
}
async syncIsLoggedIn()
{
return await this.storage.get("logged");
}
async getIdUser()
{
return await this.storage.get("idUser");
}
async isNotResume()
{
return await this.storage.get("notResume");
}
async getIsCliente()
{
return await this.storage.get("isCliente");
}
}
......@@ -24,6 +24,8 @@
"a":"a",
"seleziona_data":"Seleziona una data",
"titolo":"titolo",
"cliente":"cliente",
"struttura":"struttura",
"ricerca_titolo":"Ricerca per titolo",
"cerca_documenti":"Cerca documenti",
"condividi":"Condividi",
......@@ -33,8 +35,11 @@
"condividi_documento":"Condividi documento",
"interviste_titolo":"Domande / Risposte",
"visualizza_archiviati":"Visualizza archiviati",
"visualizza_notifiche_archiviate":"Visualizza notifiche archiviate",
"archivia_interviste":"Archivia Domande/Risposte",
"archivia_notifiche":"Archivia Notifiche Selezionate",
"undo_archivio_interviste":"Togli Domande/Risposte dall'archivio",
"undo_archivio_notifiche":"Togli le Notifiche dall'archivio",
"riattiva_interviste":"Riattiva Domande/Risposte",
"visualizza_dettagli":"Visualizza dettagli",
"aggiorna":"Aggiorna",
......@@ -79,6 +84,7 @@
"repeat_new_pwd":"ripeti nuova password",
"back_login":"Torna alla login",
"reset_pwd":"Reset Password",
"registrazione":"Registrazione",
"email":"email",
"prenota":"Prenota subito la tua",
"business_call":"Business Call",
......@@ -94,6 +100,8 @@
"campi_obbligatori":"Tutti i campi seguiti da * sono obbligatori",
"username":"Username *",
"password":"Password *",
"pwd":"Password",
"repeat_pwd":"Ripeti password",
"accedi":"ACCEDI",
"lost_password":"Password dimenticata?",
"hai_account":"Non hai ancora un account?",
......@@ -122,5 +130,6 @@
"creditizia":"Mediazione creditizia",
"cerca_interventi":"Cerca interventi",
"nuovo_parere":"Nuovo parere",
"nuova_domanda":"Nuova domanda"
"nuova_domanda":"Nuova domanda",
"registrati":"Registrati"
}
\ No newline at end of file
......@@ -194,6 +194,23 @@ ion-tab-bar{
bottom: 0;
}
}
.icon2 {
margin:auto;
background: transparent;
min-height: 20px;
img {
max-width: 180px;
width: 20px;
margin: auto;
display: block;
padding-top: 10px;
background: transparent !important;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
}
.title-bianca
{
color:white;
......
......@@ -4,8 +4,9 @@
export const environment = {
production: false,
BASE_ADDRESS: 'https://gestionale2.2p2.it/stman',
//BASE_ADDRESS: 'https://gestionale2.2p2.it/stman',
//BASE_ADDRESS: "http://localhost:8080/stman",
BASE_ADDRESS: "http://192.168.1.126:8080/stman",
P2PTokenUrl: "https://www.2p2.it/auth-request",
P2PSingleSignOnUrl: "https://www.2p2.it/?token=",
struttura:'2p2',
......
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<title>Intranet</title>
<title>2P2 App</title>
<!--Non funziona con il deploy desktop ma permette di ripartire da qualsiasi pagina, non solo dalla home-->
......@@ -11,7 +11,7 @@
<!--In caso di deploy per Desktop-->
<!--<base href="/intranet/" />-->
<!--<base href="/2p2-app/" />-->
<!--In tutti i casi-->
<base href="." />
......
......@@ -564,6 +564,31 @@ $grigio-superlite: #e5e5ea;
input{
color: $celeste;
}
.testo-ricerca > *
{
border: 0px;
//margin-top: 8px;
margin-top: 2px;
margin-left: 2px;
}
.testo-ricerca2
{
display: inline-block;
margin-top: 10px;
margin-left: 2px;
max-width: 200px;
}
ion-label > *
{
border: 0px;
margin-top: 8px;
margin-left: 2px;
}
.testo-ricerca-select{
padding-top: 0px;
padding-bottom: 0px;
float:left;
}
}
.riga > *
{
......
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