Commit cd0c73ee by Matteo

Passaggio a 2P2 funzionante sotto Android

parent 7965bdae
<?xml version='1.0' encoding='utf-8'?> <?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"> <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>Intranet</name> <name>"2P2 App"</name>
<description>An awesome Ionic/Cordova app.</description> <description>An awesome Ionic/Cordova app.</description>
<author email="hi@ionicframework.com" href="http://ionicframework.com/">Ionic Framework Team</author> <author email="hi@ionicframework.com" href="http://ionicframework.com/">Ionic Framework Team</author>
<content src="index.html" /> <content src="index.html" />
......
{ {
"name": "Intranet", "name": "2P2 App",
"integrations": { "integrations": {
"cordova": {} "cordova": {}
}, },
......
{ {
"name": "Intranet", "name": "2P2 App",
"version": "0.0.1", "version": "0.0.2",
"author": "Ionic Framework", "author": "Ionic Framework",
"homepage": "https://ionicframework.com/", "homepage": "https://ionicframework.com/",
"scripts": { "scripts": {
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
"@ionic-native/file": "^5.6.0", "@ionic-native/file": "^5.6.0",
"@ionic-native/file-opener": "^5.7.0", "@ionic-native/file-opener": "^5.7.0",
"@ionic-native/in-app-browser": "^5.8.0", "@ionic-native/in-app-browser": "^5.8.0",
"@ionic-native/push": "^5.24.0",
"@ionic-native/social-sharing": "^5.9.0", "@ionic-native/social-sharing": "^5.9.0",
"@ionic-native/splash-screen": "^5.0.0", "@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0", "@ionic-native/status-bar": "^5.0.0",
...@@ -47,9 +48,12 @@ ...@@ -47,9 +48,12 @@
"cordova-plugin-inappbrowser": "3.0.0", "cordova-plugin-inappbrowser": "3.0.0",
"cordova-plugin-x-socialsharing": "5.4.7", "cordova-plugin-x-socialsharing": "5.4.7",
"cordova-sqlite-storage": "3.2.0", "cordova-sqlite-storage": "3.2.0",
"cordova-support-google-services": "^1.3.2",
"core-js": "^2.5.4", "core-js": "^2.5.4",
"es6-promise-plugin": "4.2.2", "es6-promise-plugin": "4.2.2",
"ionic-angular": "^3.9.5", "ionic-angular": "^3.9.5",
"phonegap-plugin-multidex": "^1.0.0",
"phonegap-plugin-push": "^2.3.0",
"rxjs": "~6.5.1", "rxjs": "~6.5.1",
"rxjs-compat": "^6.5.2", "rxjs-compat": "^6.5.2",
"tslib": "^1.9.0", "tslib": "^1.9.0",
...@@ -109,7 +113,8 @@ ...@@ -109,7 +113,8 @@
"cordova-plugin-inappbrowser": {}, "cordova-plugin-inappbrowser": {},
"cordova-plugin-x-socialsharing": { "cordova-plugin-x-socialsharing": {
"ANDROID_SUPPORT_V4_VERSION": "24.1.1+" "ANDROID_SUPPORT_V4_VERSION": "24.1.1+"
} },
"phonegap-plugin-push": {}
}, },
"platforms": [ "platforms": [
"android", "android",
......
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; 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' }, @NgModule({
{ path: 'reset', loadChildren: '../app/auth/pages/reset/reset.module#ResetPageModule' }, imports: [
{ path: 'businesscall', loadChildren: '../app/pages/businesscall/businesscall.module#BusinesscallPageModule' }, RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
{ path: 'privacy', loadChildren: '../app/pages/privacy/privacy.module#PrivacyPageModule' } ],
exports: [RouterModule]
})
]; export class AppRoutingModule {}
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule {}
......
...@@ -29,45 +29,7 @@ export class AppComponent { ...@@ -29,45 +29,7 @@ export class AppComponent {
async initializeApp() { async initializeApp() {
this.utilService.loadLingua(); this.utilService.loadLingua();
var state = await this.authService.syncIsLoggedIn(); this.utilService.initConfig(false, 'notifiche');
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']);
}
});*/
}
});
} }
async logout(){ async logout(){
......
...@@ -21,6 +21,7 @@ import { SocialSharing } from '@ionic-native/social-sharing/ngx'; ...@@ -21,6 +21,7 @@ import { SocialSharing } from '@ionic-native/social-sharing/ngx';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader'; 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';
export function createTranslateLoader(http: HttpClient) { export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json'); return new TranslateHttpLoader(http, './assets/i18n/', '.json');
...@@ -54,6 +55,7 @@ export function createTranslateLoader(http: HttpClient) { ...@@ -54,6 +55,7 @@ export function createTranslateLoader(http: HttpClient) {
EmailComposer, EmailComposer,
InAppBrowser, InAppBrowser,
SocialSharing, SocialSharing,
Push,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy } { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
......
...@@ -5,4 +5,5 @@ export interface AuthResponse { ...@@ -5,4 +5,5 @@ export interface AuthResponse {
error: boolean; error: boolean;
nome: string; nome: string;
clienti: Cliente[]; clienti: Cliente[];
cliente: boolean;
} }
...@@ -35,6 +35,11 @@ ...@@ -35,6 +35,11 @@
</ion-row> </ion-row>
<ion-row color="primary" justify-content-center> <ion-row color="primary" justify-content-center>
<div text-center class="forgot"> <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> <a (click)='reset()' tappable>{{ 'lost_password' | translate }}</a>
</div> </div>
</ion-row> </ion-row>
...@@ -121,9 +126,13 @@ ...@@ -121,9 +126,13 @@
</div> </div>
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row color="primary"> <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> <a (click)='reset()' tappable>{{ 'lost_password' | translate }}</a>
</div> </div>
</ion-row> </ion-row>
......
...@@ -60,10 +60,11 @@ export class LoginPage implements OnInit { ...@@ -60,10 +60,11 @@ export class LoginPage implements OnInit {
} }
else else
{ {
this.utilService.pushNotification(AuthService.idReferente);
UtilService.titoloPagina = ''; UtilService.titoloPagina = '';
this.router.navigateByUrl('home'); this.utilService.redirectToFirstPage('notifiche');
this.events.publish('functionCall:startup', null); this.events.publish('functionCall:startup', null);
this.events.publish('functionCall:updateStrutture', null);
} }
}, },
(error: ErrorResponse) => { (error: ErrorResponse) => {
...@@ -83,6 +84,10 @@ export class LoginPage implements OnInit { ...@@ -83,6 +84,10 @@ export class LoginPage implements OnInit {
this.router.navigateByUrl('reset'); this.router.navigateByUrl('reset');
} }
registrazione(){
this.router.navigateByUrl('registrazione');
}
ngOnInit() { 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 @@ ...@@ -32,7 +32,7 @@
<ion-col align-self-center> <ion-col align-self-center>
<ion-row *ngIf="platform.is('desktop')"> <ion-row *ngIf="platform.is('desktop')">
<ion-buttons (click)="back()" title="{{ 'back_login' | translate }}" class="back-button-desktop back-button-desktop-reset"> <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-buttons>
<ion-title class="logo-piccolo"> <ion-title class="logo-piccolo">
......
...@@ -9,7 +9,7 @@ import { Storage } from '@ionic/storage'; ...@@ -9,7 +9,7 @@ import { Storage } from '@ionic/storage';
import { AuthResponse } from '../interface/auth-response'; import { AuthResponse } from '../interface/auth-response';
import { UtilService } from '../../service/util.service'; import { UtilService } from '../../service/util.service';
import { HttpClientDataService } from '../../service/http-client-data.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'; import { environment } from '../../../environments/environment';
@Injectable({ @Injectable({
...@@ -23,7 +23,8 @@ export class AuthService { ...@@ -23,7 +23,8 @@ export class AuthService {
private httpClient: HttpClient, private httpClient: HttpClient,
private storage: Storage, private storage: Storage,
private httpClientDataService: HttpClientDataService, private httpClientDataService: HttpClientDataService,
private events: Events private events: Events,
private utilService: UtilService
) )
{ {
this.errorRespose = { this.errorRespose = {
...@@ -62,6 +63,8 @@ export class AuthService { ...@@ -62,6 +63,8 @@ export class AuthService {
} }
static idReferente:string; static idReferente:string;
static idCliente:string;
static isClienteLoggato: boolean;
static clienti:Cliente[]; static clienti:Cliente[];
static clienteSelezionato: Cliente; static clienteSelezionato: Cliente;
private idClienteSelezionato; private idClienteSelezionato;
...@@ -80,6 +83,20 @@ export class AuthService { ...@@ -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) setCliente(id)
{ {
this.idClienteSelezionato = id; this.idClienteSelezionato = id;
...@@ -141,6 +158,40 @@ export class AuthService { ...@@ -141,6 +158,40 @@ export class AuthService {
return this.clientiSalvati; 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>{ login(value) : Observable<ErrorResponse>{
this.tipoStruttura = environment.struttura; this.tipoStruttura = environment.struttura;
var param = UtilService.encodeBody({utente: value.username, password: value.password, tipostruttura: this.tipoStruttura}); var param = UtilService.encodeBody({utente: value.username, password: value.password, tipostruttura: this.tipoStruttura});
...@@ -151,11 +202,15 @@ export class AuthService { ...@@ -151,11 +202,15 @@ export class AuthService {
tap( (res: AuthResponse ) => { tap( (res: AuthResponse ) => {
if (!res.error) { if (!res.error) {
this.authSubject.next(true); 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)=>{ this.storage.set("idUser",res.id).then((successData)=>{
console.log("Data Stored"); console.log("Data Stored");
console.log(successData); console.log(successData);
}); });
this.storage.set("name",res.nome); this.storage.set("name",res.nome);
this.storage.set("isCliente", res.cliente);
this.storage.set("clienti", res.clienti).then((successData)=>{ this.storage.set("clienti", res.clienti).then((successData)=>{
this.clientiSalvati = true; this.clientiSalvati = true;
this.events.publish('functionCall:startup', null); this.events.publish('functionCall:startup', null);
...@@ -192,6 +247,7 @@ export class AuthService { ...@@ -192,6 +247,7 @@ export class AuthService {
console.log(successData); console.log(successData);
}) })
this.authSubject.next(false); this.authSubject.next(false);
this.utilService.sendRegistration(AuthService.idReferente, '', '', !AuthService.isClienteLoggato);
} }
isLoggedIn(){ isLoggedIn(){
......
...@@ -4,5 +4,6 @@ export interface NotificheRequest { ...@@ -4,5 +4,6 @@ export interface NotificheRequest {
cliente: number; cliente: number;
referente: number; referente: number;
limite: number; limite: number;
gruppoStruttura: string;
filtri: Pair[]; filtri: Pair[];
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<ion-row justify-content-center> <ion-row justify-content-center>
<ion-col align-self-center size-lg="7"> <ion-col align-self-center size-lg="7">
<ion-toolbar class="business-toolbar" color="#2b94d1"> <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-icon name="menu" color="light" class="menu-show" tappable></ion-icon>
</ion-buttons> </ion-buttons>
<ion-title class="logo-piccolo titolo-home" (click)="gotoPreview()"> <ion-title class="logo-piccolo titolo-home" (click)="gotoPreview()">
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
</ion-tabs> </ion-tabs>
</ion-content> </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-header no-border class="header">
<ion-toolbar class="menu-toolbar" color="#2b94d1"> <ion-toolbar class="menu-toolbar" color="#2b94d1">
<ion-item class="menu-title item-no-border">{{ 'menu_principale' | translate }}</ion-item> <ion-item class="menu-title item-no-border">{{ 'menu_principale' | translate }}</ion-item>
...@@ -172,6 +172,16 @@ ...@@ -172,6 +172,16 @@
</div> </div>
</ion-row> </ion-row>
</div> </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> </div>
<!--<ion-list> <!--<ion-list>
<div> <div>
...@@ -199,7 +209,7 @@ ...@@ -199,7 +209,7 @@
<div id="layout" *ngIf="platform.is('desktop')" class="layout"> <div id="layout" *ngIf="platform.is('desktop')" class="layout">
<ion-grid> <ion-grid>
<ion-row class="layout-row"> <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> <div class="logo-grande2" (click)="gotoPreview()" tappable>
<img src="assets/icon/2p2-logo-medium.svg" /> <img src="assets/icon/2p2-logo-medium.svg" />
</div> </div>
......
...@@ -28,6 +28,11 @@ export class HomePage { ...@@ -28,6 +28,11 @@ export class HomePage {
public translate: TranslateService, public translate: TranslateService,
public platform: Platform public platform: Platform
) { ) {
this.caricaDati(true);
}
caricaDati(startUp: boolean)
{
this.clienti = []; this.clienti = [];
this.titoloPagina = ""; this.titoloPagina = "";
this.clienteSelezionato = { this.clienteSelezionato = {
...@@ -40,9 +45,13 @@ export class HomePage { ...@@ -40,9 +45,13 @@ export class HomePage {
this.router.navigate(['login']); 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(this.clienteSelezionato.id == null) {
if(!authService.areClientiSalvati()) if(!this.authService.areClientiSalvati())
{ {
setTimeout(() => { setTimeout(() => {
this.loadClienti() this.loadClienti()
...@@ -52,7 +61,7 @@ export class HomePage { ...@@ -52,7 +61,7 @@ export class HomePage {
} }
}); });
this.events.subscribe('functionCall:linguaCambiata', eventData => { this.events.subscribe('functionCall:linguaCambiata', eventData => {
translate = utilService.translate; this.translate = this.utilService.translate;
}); });
this.events.subscribe('functionCall:parere', eventData => { this.events.subscribe('functionCall:parere', eventData => {
this.router.navigateByUrl('home/parere'); this.router.navigateByUrl('home/parere');
...@@ -69,15 +78,15 @@ export class HomePage { ...@@ -69,15 +78,15 @@ export class HomePage {
this.events.subscribe('functionCall:cambiaTitolo', eventData => { this.events.subscribe('functionCall:cambiaTitolo', eventData => {
this.titoloPagina = UtilService.titoloPagina; this.titoloPagina = UtilService.titoloPagina;
}); });
this.lingue = utilService.getLanguageList(); this.lingue = this.utilService.getLanguageList();
if(utilService.getLingua() == "") { if(this.utilService.getLingua() == "") {
this.linguaSel = this.lingue[0].key; this.linguaSel = this.lingue[0].key;
utilService.setLingua(this.linguaSel); this.utilService.setLingua(this.linguaSel);
utilService.translate.setDefaultLang(this.linguaSel); this.utilService.translate.setDefaultLang(this.linguaSel);
utilService.translate.use(this.linguaSel); this.utilService.translate.use(this.linguaSel);
} }
else this.linguaSel = utilService.getLingua(); else this.linguaSel = this.utilService.getLingua();
translate = utilService.translate; this.translate = this.utilService.translate;
this.platform.backButton.subscribeWithPriority(0, () => { this.platform.backButton.subscribeWithPriority(0, () => {
let defaultUrl: string []=[ let defaultUrl: string []=[
"/home", "/home",
...@@ -88,38 +97,43 @@ export class HomePage { ...@@ -88,38 +97,43 @@ export class HomePage {
"/home/index", "/home/index",
"/home/documenti", "/home/documenti",
"/home/change-pwd", "/home/change-pwd",
"/home/segreteria" "/home/segreteria",
"/home/notifiche"
]; ];
if(defaultUrl.indexOf(this.router.url) != -1) if(defaultUrl.indexOf(this.router.url) != -1)
{ {
switch(this.router.url) if(!AuthService.isClienteLoggato)
{ {
case "/login": switch(this.router.url)
{
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":
{ {
this.router.navigateByUrl('home/index'); case "/login":
break; {
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 { ...@@ -132,23 +146,59 @@ export class HomePage {
return this.titoloPagina != ''; return this.titoloPagina != '';
} }
loadStrutture() async loadStrutture()
{ {
var id = await this.authService.getId();
//this.utilService.showLoading(); //this.utilService.showLoading();
this.segreteriaService.getStrutture(AuthService.clienteSelezionato.id, this.tipoStruttura).subscribe((res: StruttureResponse)=>{ if(AuthService.clienteSelezionato != null) id = AuthService.clienteSelezionato.id.toString();
//this.utilService.closeLoading(); this.segreteriaService.getStrutture(id, this.tipoStruttura).subscribe((res: StruttureResponse)=>{
UtilService.strutture = res.strutture; //this.utilService.closeLoading();
this.events.publish('functionCall:updateStrutture', null); UtilService.strutture = res.strutture;
this.setStrutture(); UtilService.strutturaSegreteria = res.strutture[0];
if(!UtilService.strutture.includes(this.utilService.getStrutturaSel())) /*this.events.publish('functionCall:updateStrutture', null);
this.router.navigateByUrl('home/preview-home'); this.setStrutture();*/
}, if(!AuthService.isClienteLoggato)
(error: ErrorResponse) => { this.segreteriaService.getStruttureByReferente(AuthService.idReferente, this.tipoStruttura).subscribe((res: StruttureResponse)=>{
//this.utilService.closeLoading(); //this.utilService.closeLoading();
var text = "Errore durante la richiesta lista strutture"; UtilService.strutture = this.concat(UtilService.strutture, res.strutture);
this.utilService.stampaErrore(text, error); 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[]; clienti: Cliente[];
clienteSel; clienteSel;
...@@ -162,10 +212,12 @@ export class HomePage { ...@@ -162,10 +212,12 @@ export class HomePage {
realEstateBrokerage: Struttura; realEstateBrokerage: Struttura;
idStrutturaSel: number; idStrutturaSel: number;
titoloPagina: string; titoloPagina: string;
isClienteLoggato: boolean;
selectStruttura(struttura:String) selectStruttura(struttura:string)
{ {
let ok = false; let ok = false;
let nostruttura = false;
switch(struttura) switch(struttura)
{ {
case "servizi": case "servizi":
...@@ -195,6 +247,12 @@ export class HomePage { ...@@ -195,6 +247,12 @@ export class HomePage {
} }
break; break;
} }
case "notifiche":
{
nostruttura = true;
this.utilService.apriPagina(struttura);
break;
}
} }
if(ok) if(ok)
{ {
...@@ -202,7 +260,8 @@ export class HomePage { ...@@ -202,7 +260,8 @@ export class HomePage {
this.events.publish('functionCall:strutturaSelectedHome', null); this.events.publish('functionCall:strutturaSelectedHome', null);
} }
else{ 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 { ...@@ -219,6 +278,7 @@ export class HomePage {
gotoPreview() gotoPreview()
{ {
if(AuthService.isClienteLoggato) return;
UtilService.titoloPagina = ''; UtilService.titoloPagina = '';
this.events.publish('functionCall:cambiaTitolo', null); this.events.publish('functionCall:cambiaTitolo', null);
this.router.navigateByUrl('home/preview-home'); this.router.navigateByUrl('home/preview-home');
...@@ -242,8 +302,9 @@ export class HomePage { ...@@ -242,8 +302,9 @@ export class HomePage {
async loadClienti() async loadClienti()
{ {
this.authService.loadClienti().then(state => { this.authService.loadClienti().then(async state => {
this.clienti = AuthService.clienti; this.clienti = AuthService.clienti;
this.isClienteLoggato = AuthService.isClienteLoggato;
this.clienteSelezionato = AuthService.clienteSelezionato; this.clienteSelezionato = AuthService.clienteSelezionato;
this.events.publish('functionCall:clienteCambiato', null); this.events.publish('functionCall:clienteCambiato', null);
this.loadStrutture(); this.loadStrutture();
......
...@@ -10,6 +10,9 @@ import { Notifica } from 'src/app/interface/notifica'; ...@@ -10,6 +10,9 @@ import { Notifica } from 'src/app/interface/notifica';
import { NotificheService } from 'src/app/service/notifiche.service'; import { NotificheService } from 'src/app/service/notifiche.service';
import { NotificheResponse } from 'src/app/interface/notifiche-response'; import { NotificheResponse } from 'src/app/interface/notifiche-response';
import { ArchiviaNotificaResponse } from 'src/app/interface/archivia-notifica-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({ @Component({
selector: 'app-notifiche', selector: 'app-notifiche',
...@@ -26,12 +29,17 @@ export class NotifichePage implements OnInit { ...@@ -26,12 +29,17 @@ export class NotifichePage implements OnInit {
private notificheService: NotificheService, private notificheService: NotificheService,
public httpClientDataService: HttpClientDataService, public httpClientDataService: HttpClientDataService,
public translate: TranslateService, public translate: TranslateService,
public router: Router public router: Router,
public authService: AuthService
) { ) {
this.events.publish('functionCall:startup', null); this.events.publish('functionCall:startup', null);
this.initPage(); this.initPage();
if(AuthService.clienteSelezionato.id != null) this.loadNotifiche(); setTimeout(() => {
this.events.subscribe('functionCall:clienteCambiato', eventData => { this.loadNotifiche();
}, 3000);
this.isClienteLoggato = AuthService.isClienteLoggato;
this.events.subscribe('functionCall:clienteCambiato', eventData => {
this.isClienteLoggato = AuthService.isClienteLoggato;
this.loadNotifiche(); this.loadNotifiche();
}); });
this.events.subscribe('functionCall:linguaCambiata', eventData => { this.events.subscribe('functionCall:linguaCambiata', eventData => {
...@@ -42,10 +50,12 @@ export class NotifichePage implements OnInit { ...@@ -42,10 +50,12 @@ export class NotifichePage implements OnInit {
{ {
if(this.notifica == "lista") if(this.notifica == "lista")
{ {
if(!AuthService.isClienteLoggato)
UtilService.titoloPagina = ''; {
this.events.publish('functionCall:cambiaTitolo', null); UtilService.titoloPagina = '';
this.router.navigateByUrl('home/index'); this.events.publish('functionCall:cambiaTitolo', null);
this.router.navigateByUrl('home/index');
}
} }
else else
{ {
...@@ -77,6 +87,16 @@ export class NotifichePage implements OnInit { ...@@ -77,6 +87,16 @@ export class NotifichePage implements OnInit {
initPage() initPage()
{ {
var allegati = new Array(); var allegati = new Array();
this.clienti = AuthService.clienti;
this.setStrutture();
this.strSel = {
denominazione: null,
id: null
};
this.clienteSel = {
denominazione: null,
id: null
};
this.notificaAttiva = { this.notificaAttiva = {
id: null, id: null,
allegati:allegati, allegati:allegati,
...@@ -95,8 +115,21 @@ export class NotifichePage implements OnInit { ...@@ -95,8 +115,21 @@ export class NotifichePage implements OnInit {
this.notificheSelezionate = new Array(); this.notificheSelezionate = new Array();
this.error = ""; this.error = "";
this.titolo = ""; 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[]; notifiche: Notifica[];
notificaAttiva: Notifica; notificaAttiva: Notifica;
idCliente; idCliente;
...@@ -105,6 +138,8 @@ export class NotifichePage implements OnInit { ...@@ -105,6 +138,8 @@ export class NotifichePage implements OnInit {
bottoneVisibile: boolean; bottoneVisibile: boolean;
archiviati: boolean; archiviati: boolean;
titolo: string; titolo: string;
strSel:Struttura;
clienteSel:Cliente;
idSelected: number; idSelected: number;
selection: boolean = false; selection: boolean = false;
...@@ -114,6 +149,24 @@ export class NotifichePage implements OnInit { ...@@ -114,6 +149,24 @@ export class NotifichePage implements OnInit {
notificaId; notificaId;
notificheSelezionate: Array<number>; notificheSelezionate: Array<number>;
error: string; 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) toggleGroup(id : number)
{ {
...@@ -189,12 +242,12 @@ export class NotifichePage implements OnInit { ...@@ -189,12 +242,12 @@ export class NotifichePage implements OnInit {
{ {
this.hideButtons(); this.hideButtons();
var titolo = null; var titolo = null;
this.utilService.showLoading(); //this.utilService.showLoading();
this.idCliente = AuthService.clienteSelezionato.id; AuthService.idReferente = await this.authService.getId();
let referente = AuthService.idReferente; let referente = AuthService.idReferente;
if(this.titolo != null && this.titolo != "") titolo = this.titolo; if(this.titolo != null && this.titolo != "") titolo = this.titolo;
this.notificheService.getListaNotifiche(this.idCliente, referente, this.archiviati, titolo).subscribe((res: NotificheResponse)=>{ this.notificheService.getListaNotifiche(this.clienteSelezionato, referente, this.archiviati, titolo, this.tipoStruttura, this.strutturaSelezionata).subscribe((res: NotificheResponse)=>{
this.utilService.closeLoading(); //this.utilService.closeLoading();
if(res.error){ if(res.error){
this.utilService.presentAlert("Errore", "", res.error, ["OK"]); this.utilService.presentAlert("Errore", "", res.error, ["OK"]);
} }
...@@ -205,7 +258,7 @@ export class NotifichePage implements OnInit { ...@@ -205,7 +258,7 @@ export class NotifichePage implements OnInit {
} }
}, },
(error: ErrorResponse) => { (error: ErrorResponse) => {
this.utilService.closeLoading(); //this.utilService.closeLoading();
var text = "Errore durante la procedura di richiesta Topic"; var text = "Errore durante la procedura di richiesta Topic";
this.utilService.stampaErrore(text, error); this.utilService.stampaErrore(text, error);
} }
...@@ -298,4 +351,8 @@ export class NotifichePage implements OnInit { ...@@ -298,4 +351,8 @@ export class NotifichePage implements OnInit {
this.router.navigateByUrl('home/index'); this.router.navigateByUrl('home/index');
} }
logout(){
this.utilService.logout();
}
} }
...@@ -30,6 +30,12 @@ export class PreviewHomePage implements OnInit { ...@@ -30,6 +30,12 @@ export class PreviewHomePage implements OnInit {
}); });
this.events.subscribe('functionCall:updateStrutture', eventData => { this.events.subscribe('functionCall:updateStrutture', eventData => {
this.setStrutture(); this.setStrutture();
if(this.startup)
if(UtilService.redirectToNotifiche)
{
UtilService.redirectToNotifiche = false;
this.utilService.apriPagina("notifiche");
}
}); });
translate = utilService.translate; translate = utilService.translate;
} }
...@@ -39,9 +45,11 @@ export class PreviewHomePage implements OnInit { ...@@ -39,9 +45,11 @@ export class PreviewHomePage implements OnInit {
realEstateBrokerage: Struttura; realEstateBrokerage: Struttura;
name: String; name: String;
pageReady: boolean = false; pageReady: boolean = false;
startup: boolean = true;
setStrutture() setStrutture()
{ {
this.authService.getId();
this.authService.getName().then(state => { this.authService.getName().then(state => {
this.name = state; this.name = state;
this.pageReady = true; this.pageReady = true;
......
...@@ -9,6 +9,9 @@ import { HttpClientDataService } from '../service/http-client-data.service'; ...@@ -9,6 +9,9 @@ import { HttpClientDataService } from '../service/http-client-data.service';
import { NotificheResponse } from '../interface/notifiche-response'; import { NotificheResponse } from '../interface/notifiche-response';
import { ArchiviaNotificaResponse } from '../interface/archivia-notifica-response'; import { ArchiviaNotificaResponse } from '../interface/archivia-notifica-response';
import { ArchiviaNotificaRequest } from '../interface/archivia-notifica-request'; 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({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -94,9 +97,12 @@ export class NotificheService { ...@@ -94,9 +97,12 @@ export class NotificheService {
return of(this.errorRespose); 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); var param = this.encodeBody(richiesta);
return this.httpClient.post<NotificheResponse>(this.httpClientDataService.BASE_ADDRESS+'/intranet/notifiche.do', param, this.httpClientDataService.httpOptionsJson) return this.httpClient.post<NotificheResponse>(this.httpClientDataService.BASE_ADDRESS+'/intranet/notifiche.do', param, this.httpClientDataService.httpOptionsJson)
.pipe( .pipe(
...@@ -115,7 +121,44 @@ export class NotificheService { ...@@ -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 request:NotificheRequest;
var pair:Pair; var pair:Pair;
...@@ -140,12 +183,33 @@ export class NotificheService { ...@@ -140,12 +183,33 @@ export class NotificheService {
} }
pairs.push(pair); 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 = { request = {
cliente: id, cliente: id,
referente: referente, referente: referente,
limite: limite, limite: limite,
gruppoStruttura: tipostruttura,
filtri: pairs filtri: pairs
}; };
...@@ -153,7 +217,7 @@ export class NotificheService { ...@@ -153,7 +217,7 @@ export class NotificheService {
} }
encodeBody(params: NotificheRequest) { 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 filtro;
var first = true; var first = true;
var i; var i;
......
...@@ -146,6 +146,26 @@ export class SegreteriaService { ...@@ -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) encodeBody(params)
{ {
var request = "{\"cliente\" : "+params.cliente+",\"limite\" : "+params.limite+",\"struttura\" : "+params.struttura+",\"filtri\" : {"; var request = "{\"cliente\" : "+params.cliente+",\"limite\" : "+params.limite+",\"struttura\" : "+params.struttura+",\"filtri\" : {";
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
"a":"a", "a":"a",
"seleziona_data":"Seleziona una data", "seleziona_data":"Seleziona una data",
"titolo":"titolo", "titolo":"titolo",
"cliente":"cliente",
"struttura":"struttura",
"ricerca_titolo":"Ricerca per titolo", "ricerca_titolo":"Ricerca per titolo",
"cerca_documenti":"Cerca documenti", "cerca_documenti":"Cerca documenti",
"condividi":"Condividi", "condividi":"Condividi",
...@@ -33,8 +35,11 @@ ...@@ -33,8 +35,11 @@
"condividi_documento":"Condividi documento", "condividi_documento":"Condividi documento",
"interviste_titolo":"Domande / Risposte", "interviste_titolo":"Domande / Risposte",
"visualizza_archiviati":"Visualizza archiviati", "visualizza_archiviati":"Visualizza archiviati",
"visualizza_notifiche_archiviate":"Visualizza notifiche archiviate",
"archivia_interviste":"Archivia Domande/Risposte", "archivia_interviste":"Archivia Domande/Risposte",
"archivia_notifiche":"Archivia Notifiche Selezionate",
"undo_archivio_interviste":"Togli Domande/Risposte dall'archivio", "undo_archivio_interviste":"Togli Domande/Risposte dall'archivio",
"undo_archivio_notifiche":"Togli le Notifiche dall'archivio",
"riattiva_interviste":"Riattiva Domande/Risposte", "riattiva_interviste":"Riattiva Domande/Risposte",
"visualizza_dettagli":"Visualizza dettagli", "visualizza_dettagli":"Visualizza dettagli",
"aggiorna":"Aggiorna", "aggiorna":"Aggiorna",
...@@ -79,6 +84,7 @@ ...@@ -79,6 +84,7 @@
"repeat_new_pwd":"ripeti nuova password", "repeat_new_pwd":"ripeti nuova password",
"back_login":"Torna alla login", "back_login":"Torna alla login",
"reset_pwd":"Reset Password", "reset_pwd":"Reset Password",
"registrazione":"Registrazione",
"email":"email", "email":"email",
"prenota":"Prenota subito la tua", "prenota":"Prenota subito la tua",
"business_call":"Business Call", "business_call":"Business Call",
...@@ -94,6 +100,8 @@ ...@@ -94,6 +100,8 @@
"campi_obbligatori":"Tutti i campi seguiti da * sono obbligatori", "campi_obbligatori":"Tutti i campi seguiti da * sono obbligatori",
"username":"Username *", "username":"Username *",
"password":"Password *", "password":"Password *",
"pwd":"Password",
"repeat_pwd":"Ripeti password",
"accedi":"ACCEDI", "accedi":"ACCEDI",
"lost_password":"Password dimenticata?", "lost_password":"Password dimenticata?",
"hai_account":"Non hai ancora un account?", "hai_account":"Non hai ancora un account?",
...@@ -122,5 +130,6 @@ ...@@ -122,5 +130,6 @@
"creditizia":"Mediazione creditizia", "creditizia":"Mediazione creditizia",
"cerca_interventi":"Cerca interventi", "cerca_interventi":"Cerca interventi",
"nuovo_parere":"Nuovo parere", "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{ ...@@ -194,6 +194,23 @@ ion-tab-bar{
bottom: 0; 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 .title-bianca
{ {
color:white; color:white;
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
export const environment = { export const environment = {
production: false, 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://localhost:8080/stman",
BASE_ADDRESS: "http://192.168.1.126:8080/stman",
P2PTokenUrl: "https://www.2p2.it/auth-request", P2PTokenUrl: "https://www.2p2.it/auth-request",
P2PSingleSignOnUrl: "https://www.2p2.it/?token=", P2PSingleSignOnUrl: "https://www.2p2.it/?token=",
struttura:'2p2', struttura:'2p2',
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8" /> <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--> <!--Non funziona con il deploy desktop ma permette di ripartire da qualsiasi pagina, non solo dalla home-->
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<!--In caso di deploy per Desktop--> <!--In caso di deploy per Desktop-->
<!--<base href="/intranet/" />--> <!--<base href="/2p2-app/" />-->
<!--In tutti i casi--> <!--In tutti i casi-->
<base href="." /> <base href="." />
......
...@@ -564,6 +564,31 @@ $grigio-superlite: #e5e5ea; ...@@ -564,6 +564,31 @@ $grigio-superlite: #e5e5ea;
input{ input{
color: $celeste; 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 > * .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