Commit 58ca378f by Matteo

Initial commit

parents
# Specifies intentionally untracked files to ignore when using Git
# http://git-scm.com/docs/gitignore
*~
*.sw[mnpcod]
*.log
*.tmp
*.tmp.*
log.txt
*.sublime-project
*.sublime-workspace
.vscode/
npm-debug.log*
.idea/
.ionic/
.sourcemaps/
.sass-cache/
.tmp/
.versions/
coverage/
www/
node_modules/
tmp/
temp/
platforms/
plugins/
plugins/android.json
plugins/ios.json
$RECYCLE.BIN/
.DS_Store
Thumbs.db
UserInterfaceState.xcuserstate
{
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"defaultProject": "app",
"newProjectRoot": "projects",
"projects": {
"app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "www",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "src/assets",
"output": "assets"
},
{
"glob": "**/*.svg",
"input": "node_modules/ionicons/dist/ionicons/svg",
"output": "./svg"
}
],
"styles": [
{
"input": "src/theme/variables.scss"
},
{
"input": "src/global.scss"
}
],
"scripts": [],
"es5BrowserSupport": true
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"ci": {
"progress": false
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app:build"
},
"configurations": {
"production": {
"browserTarget": "app:build:production"
},
"ci": {
"progress": false
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [],
"scripts": [],
"assets": [
{
"glob": "favicon.ico",
"input": "src/",
"output": "/"
},
{
"glob": "**/*",
"input": "src/assets",
"output": "/assets"
}
]
},
"configurations": {
"ci": {
"progress": false,
"watch": false
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"ionic-cordova-build": {
"builder": "@ionic/angular-toolkit:cordova-build",
"options": {
"browserTarget": "app:build"
},
"configurations": {
"production": {
"browserTarget": "app:build:production"
}
}
},
"ionic-cordova-serve": {
"builder": "@ionic/angular-toolkit:cordova-serve",
"options": {
"cordovaBuildTarget": "app:ionic-cordova-build",
"devServerTarget": "app:serve"
},
"configurations": {
"production": {
"cordovaBuildTarget": "app:ionic-cordova-build:production",
"devServerTarget": "app:serve:production"
}
}
}
}
},
"app-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "app:serve"
},
"configurations": {
"ci": {
"devServerTarget": "app:serve:ci"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": ["**/node_modules/**"]
}
}
}
}
},
"cli": {
"defaultCollection": "@ionic/angular-toolkit"
},
"schematics": {
"@ionic/angular-toolkit:component": {
"styleext": "scss"
},
"@ionic/angular-toolkit:page": {
"styleext": "scss"
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Intranet</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" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<preference name="ScrollEnabled" value="false" />
<preference name="android-minSdkVersion" value="19" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<platform name="android">
<allow-intent href="market:*" />
<icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
<icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
<icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
<icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
<icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
<icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
<splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
<splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
<splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
<splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
<splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
<splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
<splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
<splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
<splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
<splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
<splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
<splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<allow-navigation href="*" />
<icon height="57" src="resources/ios/icon/icon.png" width="57" />
<icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
<icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
<icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
<icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
<icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
<icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
<icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
<icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
<icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
<icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
<icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
<icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
<icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
<icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
<icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
<icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
<icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
<icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
<splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
<splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
<splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
<splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
<splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
<splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
<splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
<splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
<splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
<splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
<splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
<splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
<splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
</platform>
<plugin name="cordova-plugin-whitelist" spec="1.3.3" />
<plugin name="cordova-plugin-statusbar" spec="2.4.2" />
<plugin name="cordova-plugin-device" spec="2.0.2" />
<plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^4.0.0" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
</widget>
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
import { AppPage } from './app.po';
describe('new App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getPageTitle()).toContain('Tab One');
});
});
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get('/');
}
getPageTitle() {
return element(by.css('ion-title')).getText();
}
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}
{
"name": "Intranet",
"integrations": {
"cordova": {}
},
"type": "angular"
}
{
"name": "proxy-example",
"app_id": "",
"proxies": [
{
"path": "/stman",
"proxyUrl": "http://localhost:8080/stman"
}
]
}
\ No newline at end of file
{
"name": "Tabs Starter",
"baseref": "master",
"tarignore": [
"node_modules",
"package-lock.json",
"www"
],
"scripts": {
"test": "npm run lint && npm run ng -- build --configuration=ci && npm run ng -- build --prod --progress=false && npm run ng -- test --configuration=ci && npm run ng -- e2e --configuration=ci && npm run ng -- g pg my-page --dry-run && npm run ng -- g c my-component --dry-run"
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "Intranet",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/cdk": "^7.3.7",
"@angular/common": "^7.2.2",
"@angular/core": "^7.2.2",
"@angular/forms": "^7.2.2",
"@angular/http": "^7.2.2",
"@angular/material": "^7.3.7",
"@angular/platform-browser": "^7.2.2",
"@angular/platform-browser-dynamic": "^7.2.2",
"@angular/router": "^7.2.2",
"@ionic-native/android-permissions": "^5.6.1",
"@ionic-native/core": "^5.0.0",
"@ionic-native/date-picker": "^5.6.0",
"@ionic-native/diagnostic": "^5.7.0",
"@ionic-native/email-composer": "^5.8.0",
"@ionic-native/file": "^5.6.0",
"@ionic-native/file-opener": "^5.7.0",
"@ionic-native/file-transfer": "^5.6.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^4.1.0",
"@ionic/pro": "2.0.4",
"@ionic/storage": "^2.2.0",
"cordova-android": "8.0.0",
"cordova-browser": "6.0.0",
"cordova-plugin-android-permissions": "1.0.0",
"cordova-plugin-datepicker": "0.9.3",
"cordova-plugin-email-composer": "0.9.2",
"cordova-plugin-file": "6.0.1",
"cordova-plugin-file-opener2": "2.2.0",
"cordova-plugin-file-transfer": "1.7.1",
"cordova-sqlite-storage": "3.2.0",
"cordova.plugins.diagnostic": "4.0.12",
"core-js": "^2.5.4",
"ionic-angular": "^3.9.5",
"rxjs": "~6.5.1",
"rxjs-compat": "^6.5.2",
"tslib": "^1.9.0",
"zone.js": "~0.8.29"
},
"devDependencies": {
"@angular-devkit/architect": "~0.13.8",
"@angular-devkit/build-angular": "~0.13.8",
"@angular-devkit/core": "~7.3.8",
"@angular-devkit/schematics": "~7.3.8",
"@angular/cli": "~7.3.8",
"@angular/compiler": "~7.2.2",
"@angular/compiler-cli": "~7.2.2",
"@angular/language-service": "~7.2.2",
"@ionic/angular-toolkit": "~1.5.1",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~12.0.0",
"codelyzer": "~4.5.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^4.0.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.1.0",
"tslint": "~5.16.0",
"typescript": "~3.1.6"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"cordova-plugin-ionic-keyboard": {},
"cordova-sqlite-storage": {},
"cordova-plugin-datepicker": {},
"cordova-plugin-file": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-file-opener2": {},
"cordova-plugin-android-permissions": {},
"cordova.plugins.diagnostic": {
"ANDROID_SUPPORT_VERSION": "28.+"
},
"cordova-plugin-email-composer": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
}
},
"platforms": [
"android",
"browser"
]
}
}
\ No newline at end of file
These are Cordova resources. You can replace icon.png and splash.png and run
`ionic cordova resources` to generate custom icons and splash screens for your
app. See `ionic cordova resources --help` for details.
Cordova reference documentation:
- Icons: https://cordova.apache.org/docs/en/latest/config_ref/images.html
- Splash Screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
const routes: Routes = [
{ path: '', loadChildren: './pages/home/home.module#HomePageModule' },
{ path: 'login', loadChildren: './auth/pages/login/login.module#LoginPageModule' },
{ path: 'reset', loadChildren: './auth/pages/reset/reset.module#ResetPageModule' },
{ path: 'documenti', loadChildren: './pages/documenti/documenti.module#DocumentiPageModule'},
{ path: 'businesscall', loadChildren: './pages/businesscall/businesscall.module#BusinesscallPageModule' }
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule {}
<ion-app>
<!--<ion-toolbar color="dark">
<ion-buttons (click)="openSideBar()">
<ion-icon src="../assets/img/uscita.svg" style="zoom:4.0;"></ion-icon>
</ion-buttons>
<ion-title>
<img src="../assets/img/logo.png">
</ion-title>
<ion-buttons (click)="logout()" slot="end">
<ion-icon src="../assets/img/uscita.svg" style="zoom:4.0;"></ion-icon>
</ion-buttons>
</ion-toolbar>
<ion-item>
<ion-label>Clicca per selezionare un nuovo Cliente</ion-label>
<ion-select value="clienteSel" [(ngModel)]="clienteSel" (ionChange)="cambiaCliente()">
<ion-select-option *ngFor="let cliente of clienti;" value="{{cliente.id}}">{{cliente.denominazione}}</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<p>Il Cliente Selezionato è {{clienteSelezionato.denominazione}}</p>
</ion-item>-->
<ion-router-outlet>
<ion-content>
<ion-menu side="start" menu-id="mainmenu2" content-id="content">
<ion-header>
<ion-toolbar color="primary">
<ion-title>Menu Principale</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<div>
<ion-item (click)="apriPagina('home')">Home</ion-item>
</div>
<div>
<ion-item (click)="apriPagina('documenti')">Documenti</ion-item>
</div>
<div>
<ion-item (click)="apriPagina('interviste')">Domande/Risposte</ion-item>
</div>
<div>
<ion-item (click)="apriPagina('pareri')">Pareri</ion-item>
</div>
<div>
<ion-item (click)="apriPagina('segreteria')">Segreteria</ion-item>
</div>
<div>
<ion-item (click)="apriPagina('change-password')">Cambia Password</ion-item>
</div>
</ion-list>
</ion-content>
</ion-menu>
<ion-content id="content2"></ion-content>
<div id="modal"></div>
<div id="content"></div>
</ion-content>
</ion-router-outlet>
</ion-app>
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TestBed, async } from '@angular/core/testing';
import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy;
beforeEach(async(() => {
statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']);
splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']);
platformReadySpy = Promise.resolve();
platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy });
TestBed.configureTestingModule({
declarations: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
{ provide: StatusBar, useValue: statusBarSpy },
{ provide: SplashScreen, useValue: splashScreenSpy },
{ provide: Platform, useValue: platformSpy },
],
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it('should initialize the app', async () => {
TestBed.createComponent(AppComponent);
expect(platformSpy.ready).toHaveBeenCalled();
await platformReadySpy;
expect(statusBarSpy.styleDefault).toHaveBeenCalled();
expect(splashScreenSpy.hide).toHaveBeenCalled();
});
// TODO: add more tests!
});
import { Component } from '@angular/core';
import { Platform, MenuController } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AuthService } from './auth/service/auth.service';
import { Router } from '@angular/router';
import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
import { UtilService } from './service/util.service';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
})
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private router: Router,
private authService: AuthService,
private utilService: UtilService,
private androidPermissions: AndroidPermissions,
public menuCtrl: MenuController
) {
this.initializeApp();
}
initializeApp() {
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']);
}
});
}
});
}
logout(){
this.authService.logout();
this.router.navigateByUrl('login');
}
apriPagina(pagina:string)
{
switch(pagina)
{
case "home":
{
this.router.navigateByUrl('index');
break;
}
case "documenti":
{
this.router.navigateByUrl('documenti');
break;
}
case "interviste":
{
this.router.navigateByUrl('interviste');
break;
}
case "pareri":
{
this.router.navigateByUrl('pareri');
break;
}
case "segreteria":
{
this.router.navigateByUrl('segreteria');
break;
}
case "change-password":
{
this.router.navigateByUrl('change-pwd');
break;
}
}
}
openSideBar()
{
this.menuCtrl.open('mainmenu');
}
closeSideMenu() {
this.menuCtrl.close();
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { IonicStorageModule } from '@ionic/storage';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { DatePicker } from '@ionic-native/date-picker/ngx';
import { File } from '@ionic-native/file/ngx';
import { FileTransfer, FileTransferObject } from '@ionic-native/file-transfer/ngx';
import { FileOpener } from '@ionic-native/file-opener/ngx';
import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
import { EmailComposer } from '@ionic-native/email-composer/ngx';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [
BrowserModule,
IonicModule.forRoot(),
AppRoutingModule,
IonicStorageModule.forRoot(),
FormsModule,
HttpClientModule
],
providers: [
StatusBar,
SplashScreen,
DatePicker,
File,
FileTransfer,
FileTransferObject,
FileOpener,
AndroidPermissions,
EmailComposer,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}
import { Cliente } from './cliente';
export interface AuthResponse {
id: number;
errorMsg: string;
error: boolean;
nome: string;
clienti: Cliente[];
}
export interface Cliente {
id: number;
denominazione: string;
}
export interface ErrorResponse {
error: boolean,
errorMsg: string
}
/*export class ErrorResponse{
public object: {};
constructor(
public error: boolean,
public errorMsg: string
) {
this.object = {
error: this.error,
errorMsg: this.errorMsg,
};
}
}*/
export interface User {
email: string;
password: string;
}
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 { ChangePwdPage } from './change-pwd.page';
const routes: Routes = [
{
path: '',
component: ChangePwdPage
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes),
ReactiveFormsModule
],
declarations: [ChangePwdPage]
})
export class ChangePwdPageModule {}
<ion-header>
<ion-toolbar>
<ion-title>Change Password</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<form #form="ngForm" (ngSubmit)="change(form)" [formGroup]="matching_passwords_group">
<ion-grid>
<ion-row color="primary" justify-content-center>
<ion-col align-self-center size-md="6" size-lg="5" size-xs="12">
<div text-center>
<h3>Change Password</h3>
</div>
<div padding>
<ion-item>
<ion-input formControlName="oldpassword" type="password" placeholder="old password" ngModel required></ion-input>
</ion-item>
<ion-item>
<ion-input formControlName="newpassword" type="password" placeholder="new password" ngModel required></ion-input>
</ion-item>
<ion-item>
<ion-input formControlName="newpasswordbis" type="password" placeholder="repeat new password" ngModel required></ion-input>
</ion-item>
</div>
<div padding>
<ion-button size="large" type="submit" [disabled]="form.invalid" expand="block">Reset Password</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.newpassword">
<div class="error-message" *ngIf="matching_passwords_group.get('newpassword').hasError(validation.type) && (matching_passwords_group.get('newpassword').dirty
|| matching_passwords_group.get('newpassword').touched)">
{{ validation.message }}
</div>
</ng-container>
<ng-container *ngFor="let validation of validation_messages.newpasswordbis">
<div class="error-message" *ngIf="matching_passwords_group.get('newpasswordbis').hasError(validation.type) && (matching_passwords_group.get('newpasswordbis').dirty
|| matching_passwords_group.get('newpasswordbis').touched)">
{{ validation.message }}
</div>
</ng-container>
<ng-container *ngFor="let validation of validation_messages.newpasswordbis">
<div class="error-message" *ngIf="matching_passwords_group.hasError('areEqual')">
{{ validation.message }}
</div>
</ng-container>
</div>
</ion-row>
</ion-grid>
</form>
</ion-content>
\ No newline at end of file
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangePwdPage } from './change-pwd.page';
describe('ChangePwdPage', () => {
let component: ChangePwdPage;
let fixture: ComponentFixture<ChangePwdPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ChangePwdPage ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ChangePwdPage);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { PasswordValidator } from '../../validators/password.validator';
import { Validators, FormControl, FormGroup } from '@angular/forms';
import { Router } from "@angular/router";
import { AuthService } from '../../service/auth.service';
import { ErrorResponse } from '../../interface/error-response';
import { UtilService } from '../../../service/util.service';
@Component({
selector: 'app-change-pwd',
templateUrl: './change-pwd.page.html',
styleUrls: ['./change-pwd.page.scss'],
})
export class ChangePwdPage implements OnInit {
constructor(private authService: AuthService, private router: Router, private utilService: UtilService) { }
change(form){
this.utilService.showLoading();
this.authService.getId().then(state => {
this.authService.changePwd(form.value).subscribe((res: ErrorResponse)=>{
this.utilService.closeLoading();
if(res.error){
this.utilService.presentAlert("Errore", "", res.errorMsg, ["OK"]);
}
else
{
this.utilService.presentAlert("Info", "", "La Password è stata cambiata correttamente", ["OK"]);
this.router.navigateByUrl('');
}
},
(error: ErrorResponse) => {
this.utilService.closeLoading();
this.utilService.presentAlert("Errore", "", error.errorMsg, ["OK"]);
});
});
}
matching_passwords_group = new FormGroup({
oldpassword: new FormControl('', Validators.required),
newpassword: 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
])),
newpasswordbis: new FormControl('', Validators.compose([
Validators.required
]))
},(formGroup: FormGroup) => {
return PasswordValidator.areEqual(formGroup);
});
validation_messages = {
'newpassword': [
{ type: 'required', message: 'Password è richiesta.' },
{ type: 'minlength', message: 'La lunghezza minima è 5 caratteri' },
{ type: 'pattern', message: 'Deve essere composta da numeri e lettere' }
],
'newpasswordbis': [
{ type: 'areEqual', message: 'La password deve essere uguale a quella nuova' },
{ type: 'required', message: 'Il Repeat Password è richiesto.' }
]
}
ngOnInit() {
}
}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { LoginPage } from './login.page';
const routes: Routes = [
{
path: '',
component: LoginPage
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes)
],
declarations: [LoginPage]
})
export class LoginPageModule {}
<!--<ion-header>
<ion-toolbar>
<ion-title>Login Page</ion-title>
</ion-toolbar>
</ion-header>-->
<ion-content class="prova" forceOverscroll=true scroll-y=false scroll=false>
<div class="body" fullscreen>
<div class="contenitore">
<div class="logo-grande">
<img src="../../../../assets/icon/2p2-logo-color.svg" />
</div>
<form #form="ngForm" (ngSubmit)="login(form)" class="form">
<ion-grid>
<ion-row justify-content-center>
<ion-col align-self-center size-md="6" size-lg="5" size-xs="12">
<div>
<ion-item>
<ion-icon item-left name="person" color="light"></ion-icon>
<ion-input name="username" type="text" placeholder="Inserisci il tuo username" ngModel required></ion-input>
</ion-item>
<ion-item>
<ion-icon item-left name="lock" color="light"></ion-icon>
<ion-input name="password" type="password" placeholder="Password" ngModel required></ion-input>
</ion-item>
</div>
<div class="accedi" >
<ion-button size="large" type="submit" [disabled]="form.invalid" expand="block">ACCEDI</ion-button>
</div>
</ion-col>
</ion-row>
<ion-row color="primary" justify-content-center>
<div text-center class="forgot">
<a (click)='reset()'>Hai perso la password?</a>
</div>
</ion-row>
<ion-row color="primary" justify-content-center>
<ion-col align-self-center size-md="6" size-lg="5" size-xs="12">
<div class="business-call">
<div class="non-account">
Non hai ancora un account?
</div>
<div class="title-call">
Prenota subito<br />la tua <span class="giallo">Business Call</span>
</div>
<div class="descr-call">
I nostro consulenti pianificheranno una Business Call <strong>gratuita</strong> su misura per te e la tua azienda
</div>
<div class="appuntamento">
<a (click)='redirectBusiness()'>PRENOTA IL TUO APPUNTAMENTO!</a>
</div>
</div>
</ion-col>
</ion-row>
</ion-grid>
</form>
</div>
</div>
</ion-content>
\ No newline at end of file
/*** questo è il css per caricare le web fonts della comunicazione 2p2, ovvero la font Futura PT ***/
@import url("https://use.typekit.net/okc2ngl.css");
$bianco: #fff;
$celeste: #2b94d1;
$giallo: #fcc73d;
$grigio: #515151;
$nero: #000000;
.body {
font-family: 'futura-pt', sans-serif;
font-style: normal;
font-weight: 400;
padding-top: 45px;
margin:0px;
background: url('../../../../assets/img/cover-login.jpg') no-repeat;
background-size: cover;
background-position: top center;
color: $grigio;
font-size: 24px;
height: 100%;
width: 100%;
position: fixed;
}
.css-class-login-inner-scroll {
background-color: transparent!important;
--background: transparent!important;
}
.body > * {
background-color: transparent!important;
--ion-background-color: transparent!important;
}
ion-button, ion-input {
--ion-font-family: 'futura-pt', sans-serif;
}
ion-item {
--border-color: rgb(255, 255, 255);
}
strong {
font-style: normal;
font-weight: 700;
}
ion-icon {
margin: 20px 10px 0 0 !important;
background-color: transparent;
}
.contenitore {
//max-width: 320px;
margin:auto;
display:block;
.logo-grande {
width: 180px;
margin: auto;
display: block;
text-align: center;
margin-top: 20px;
margin-bottom: 50px;
}
.form {
ion-input[type=text], ion-input[type=password] {
//width: 290px;
border: 0px;
color: $bianco;
padding: 8px 0px 8px 30px;
background-position: left center;
background-size: 18px 18px;
font-size: 22px;
margin-top: 20px;
//margin-bottom: 20px;
outline: none;
}
::-webkit-input-placeholder {
font-family: 'futura-pt', sans-serif;
color: $bianco;
}
::-moz-placeholder {
font-family: 'futura-pt', sans-serif;
color: $bianco;
}
:-ms-input-placeholder {
font-family: 'futura-pt', sans-serif;
color: $bianco;
}
::placeholder {
font-family: 'futura-pt', sans-serif;
color: $bianco;
}
.ricordami {
color: $bianco;
text-transform: uppercase;
font-size: 18px;
}
.accedi {
ion-button {
width: 100%;
//padding: 8px 0px;
text-align: center;
background: $celeste;
border: 1px solid $bianco;
margin-top: 30px;
text-transform: uppercase;
font-weight: 700;
color: #fff;
font-size: 22px;
margin-bottom: 15px;
}
}
.forgot {
text-align: center;
a {
color: $bianco;
text-decoration: none;
font-weight: 700;
font-size: 16px;
}
}
}
.business-call {
background: rgba(255, 255, 255, 0.33);
//width: 280px;
padding: 20px;
margin-top: 30px;
text-align: center;
color: $bianco;
.non-account {
font-size: 14px;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
}
.title-call {
font-weight: 700;
font-size: 24px;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
.giallo {
color: $giallo;
}
}
.descr-call {
color: $grigio;
font-size: 18px;
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}
.appuntamento {
margin-top: 10px;
a {
background: $giallo;
padding: 8px 5px;
font-size: 15px;
text-transform: uppercase;
color: $grigio;
font-weight: 700;
text-decoration: none;
}
}
}
}
\ No newline at end of file
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginPage } from './login.page';
describe('LoginPage', () => {
let component: LoginPage;
let fixture: ComponentFixture<LoginPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoginPage ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginPage);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ErrorResponse } from './../../interface/error-response';
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { Router } from "@angular/router";
import { AuthService } from '../../service/auth.service';
import { UtilService } from '../../../service/util.service';
import { Events } from '@ionic/angular';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
encapsulation: ViewEncapsulation.None
})
export class LoginPage implements OnInit {
constructor(private authService: AuthService, private router: Router, private utilService: UtilService, public events: Events,) { }
async login(form){
await this.utilService.showLoading();
this.authService.login(form.value).subscribe((res: ErrorResponse)=>{
res = this.authService.errorRespose;
this.utilService.closeLoading();
if(res.error){
this.utilService.presentAlert("Errore", "", res.errorMsg, ["OK"]);
}
else
{
this.events.publish('functionCall:startup', null);
this.router.navigateByUrl('');
}
},
(error: ErrorResponse) => {
this.utilService.closeLoading();
this.utilService.presentAlert("Errore", "", error.errorMsg, ["OK"]);
}
);
}
redirectBusiness()
{
this.router.navigateByUrl('businesscall');
}
reset(){
this.router.navigateByUrl('reset');
}
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 { ResetPage } from './reset.page';
const routes: Routes = [
{
path: '',
component: ResetPage
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes),
ReactiveFormsModule
],
declarations: [ResetPage]
})
export class ResetPageModule {}
<ion-header>
<ion-toolbar>
<ion-title>Reset Page</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<form #form="ngForm" (ngSubmit)="reset(form)" [formGroup]="matching_email_group">
<ion-grid>
<ion-row color="primary" justify-content-center>
<ion-col align-self-center size-md="6" size-lg="5" size-xs="12">
<div text-center>
<h3>Reset Password</h3>
</div>
<div padding>
<ion-item>
<ion-input formControlName="email" type="email" placeholder="email" ngModel required></ion-input>
</ion-item>
</div>
<div padding>
<ion-button size="large" type="submit" [disabled]="form.invalid" expand="block">Reset Password</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>
</ion-content>
\ No newline at end of file
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ResetPage } from './reset.page';
describe('ResetPage', () => {
let component: ResetPage;
let fixture: ComponentFixture<ResetPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ResetPage ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ResetPage);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { Validators, FormControl, FormGroup } from '@angular/forms';
import { Router } from "@angular/router";
import { AuthService } from '../../service/auth.service';
import { ErrorResponse } from './../../interface/error-response';
import { UtilService } from '../../../service/util.service';
@Component({
selector: 'app-reset',
templateUrl: './reset.page.html',
styleUrls: ['./reset.page.scss'],
})
export class ResetPage implements OnInit {
constructor(private authService: AuthService, private router: Router, private utilService: UtilService) { }
reset(form){
this.utilService.showLoading();
this.authService.reset(form.value).subscribe((res: ErrorResponse)=>{
this.utilService.closeLoading();
if(res.error){
this.utilService.presentAlert("Errore", "", res.errorMsg, ["OK"]);
}
else
{
this.utilService.presentAlert("Info", "", "Una mail è stata spedita all'indirizzo comunicato con una password temporanea.", ["OK"]);
this.router.navigateByUrl('/login');
}
},
(error: ErrorResponse) => {
this.utilService.closeLoading();
this.utilService.presentAlert("Errore", "", error.errorMsg, ["OK"]);
});
}
matching_email_group = new FormGroup({
email: new FormControl('', Validators.compose([
Validators.required,
Validators.pattern('^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$')
]))
});
validation_messages = {
'email': [
{ type: 'required', message: 'Email è richiesta.' },
{ type: 'pattern', message: 'Deve essere composta da numeri e lettere' }
]
}
ngOnInit() {
}
}
import { TestBed } from '@angular/core/testing';
import { AuthService } from './auth.service';
describe('AuthService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: AuthService = TestBed.get(AuthService);
expect(service).toBeTruthy();
});
});
import { Cliente } from './../interface/cliente';
import { ErrorResponse } from './../interface/error-response';
import { Injectable } from '@angular/core';
import { HttpClient, HttpErrorResponse} from '@angular/common/http';
import { tap, catchError } from 'rxjs/operators';
import { Observable, BehaviorSubject, of} from 'rxjs';
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 { Platform } from '@ionic/angular';
@Injectable({
providedIn: 'root'
})
export class AuthService {
public result;
constructor(
private httpClient: HttpClient,
private storage: Storage,
private utilService: UtilService,
private httpClientDataService: HttpClientDataService,
private platform: Platform
)
{
this.errorRespose = {
error: true,
errorMsg: ""
};
AuthService.clienti = [];
AuthService.clienteSelezionato = {
denominazione: null,
id: null
};
}
authSubject = new BehaviorSubject(false);
errorRespose : ErrorResponse;
reset(value): Observable<ErrorResponse>{
this.errorRespose.error = true;
var param = UtilService.encodeBody({email: value.email});
return this.httpClient.post<AuthResponse>(this.httpClientDataService.BASE_ADDRESS+'/autenticazione/resetpwd.do', param, this.httpClientDataService.httpOptions)
.pipe(
catchError(this.handleError),
tap( (res: AuthResponse ) => {
if (!res.error) {
this.errorRespose.error = false;
}
else{
this.errorRespose.error = true;
this.errorRespose.errorMsg = res.errorMsg;
}
})
);
}
static idReferente:string;
static clienti:Cliente[];
static clienteSelezionato: Cliente;
private idClienteSelezionato;
loadClienti()
{
return this.storage.get("clienti").then((data)=>{
AuthService.clienti = data;
AuthService.clienteSelezionato = AuthService.clienti[0];
return data;
});
}
setCliente(id)
{
this.idClienteSelezionato = id;
AuthService.clienti.forEach(this.findCliente, this);
}
findCliente(cliente, index)
{
if(cliente.id == this.idClienteSelezionato) AuthService.clienteSelezionato = cliente;
}
getId()
{
return this.getFromStorageAsync("idUser").then(state => {
return state;
});
}
getFromStorageAsync(param){
return this.storage.get(param).then((data)=>{
AuthService.idReferente = data;
return data;
});
}
changePwd(value): Observable<ErrorResponse>{
var param = UtilService.encodeBody({
idutente: AuthService.idReferente,
oldpassword: value.oldpassword,
newpassword: value.newpassword
});
return this.httpClient.post<AuthResponse>(this.httpClientDataService.BASE_ADDRESS+'/autenticazione/changepwd.do', param, this.httpClientDataService.httpOptions)
.pipe(
catchError(this.handleError),
tap( (res: AuthResponse ) => {
if (!res.error) {
this.errorRespose.error = false;
}
else{
this.errorRespose.error = true;
this.errorRespose.errorMsg = res.errorMsg;
}
})
);
}
login(value) : Observable<ErrorResponse>{
var param = UtilService.encodeBody({utente: value.username, password: value.password});
//return this.httpClient.post<ErrorResponse>('https://www.google.com/', param, this.httpClientDataService.httpOptions)
return this.httpClient.post<ErrorResponse>(this.httpClientDataService.BASE_ADDRESS+'/autenticazione/login.do', param, this.httpClientDataService.httpOptions)
.pipe(
catchError(this.handleError),
tap( (res: AuthResponse ) => {
if (!res.error) {
this.authSubject.next(true);
if(this.platform.is('desktop')){
this.storage.set("idUser",res.id).then((successData)=>{
console.log("Data Stored");
console.log(successData);
});
this.storage.set("name",res.nome);
this.storage.set("clienti", res.clienti);
this.storage.set("logged",true);
}
else
{
}
this.errorRespose.error = false;
}
else{
this.errorRespose.error = true;
this.errorRespose.errorMsg = res.errorMsg;
}
})
);
}
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);
};
async logout() {
this.storage.set("logged",false).then((successData)=>{
console.log("Data Stored");
console.log(successData);
})
this.authSubject.next(false);
}
isLoggedIn(){
return this.storage.get("logged").then((data)=>{
return data;
});
}
}
import { AbstractControl, ValidatorFn, FormControl, FormGroup } from '@angular/forms';
export class PasswordValidator {
// Inspired on: http://plnkr.co/edit/Zcbg2T3tOxYmhxs7vaAm?p=preview
static equals = (newpasswordControl: AbstractControl): ValidatorFn => {
let equal: boolean = false;
return (passwordBisControl: AbstractControl): {[key: string]: boolean} => {
if(newpasswordControl.value == passwordBisControl.value) {
return {
equals: true
};
}
else return null;
};
}
static areEqual(formGroup: FormGroup) {
let val;
let valid = true;
for (let key in formGroup.controls) {
if (formGroup.controls.hasOwnProperty(key)) {
if(key == "oldpassword") continue;
let control: FormControl = <FormControl>formGroup.controls[key];
if (val === undefined) {
val = control.value
} else {
if (val !== control.value) {
valid = false;
break;
}
}
}
}
if (!valid) /*{
return null;
return {
areEqual: false
}
}*/
return {
areEqual: true
}
}
}
\ No newline at end of file
<div>
<form #form="ngForm" (ngSubmit)="dismiss(form)">
<ion-grid>
<ion-row color="primary" justify-content-center>
<ion-col align-self-center size-md="6" size-lg="5" size-xs="12">
<div text-center>
<h3>Login</h3>
</div>
<div padding>
<ion-item>
<ion-textarea name="question" placeholder="Inserisci una domanda" ngModel required></ion-textarea>
</ion-item>
</div>
<div padding>
<ion-button size="large" type="submit" [disabled]="form.invalid" expand="block">Salva</ion-button>
</div>
<div padding>
<ion-button size="large" expand="block" (click)="close()">Cancel</ion-button>
</div>
</ion-col>
</ion-row>
</ion-grid>
</form>
</div>
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ModalQuestionComponent } from './modal-question.component';
describe('ModalQuestionComponent', () => {
let component: ModalQuestionComponent;
let fixture: ComponentFixture<ModalQuestionComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ModalQuestionComponent ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ModalQuestionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import {ModalController} from '@ionic/angular';
@Component({
selector: 'app-modal-question',
templateUrl: './modal-question.component.html',
styleUrls: ['./modal-question.component.scss'],
})
export class ModalQuestionComponent implements OnInit {
constructor(private modalController: ModalController) { }
async dismiss(form)
{
await this.modalController.dismiss(form.value.question);
}
async close()
{
await this.modalController.dismiss();
}
ngOnInit() {}
}
<div>
<form #form="ngForm" (ngSubmit)="dismiss(form)">
<ion-grid>
<ion-row color="primary" justify-content-center>
<ion-col align-self-center size-md="6" size-lg="5" size-xs="12">
<div text-center>
<h3>Crea Parere</h3>
</div>
<div padding>
<ion-item>
<ion-input name="title" type="text" placeholder="Titolo Parere" ngModel required></ion-input>
</ion-item>
</div>
<div padding>
<ion-item>
<ion-textarea name="question" placeholder="Inserisci una domanda" ngModel required></ion-textarea>
</ion-item>
</div>
<ion-item>
<h4>Aggiungi Allegato</h4>
<ion-input id="file" type="file" name="file" ngModel (ionChange)="loadFile();"></ion-input>
</ion-item>
<div padding>
<ion-button size="large" type="submit" [disabled]="form.invalid" expand="block">Salva</ion-button>
</div>
<div padding>
<ion-button size="large" expand="block" (click)="close()">Cancel</ion-button>
</div>
</ion-col>
</ion-row>
</ion-grid>
</form>
</div>
\ No newline at end of file
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ParereModalComponent } from './parere-modal.component';
describe('ParereModalComponent', () => {
let component: ParereModalComponent;
let fixture: ComponentFixture<ParereModalComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ParereModalComponent ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ParereModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { DataWithFileUploaded } from './../../interface/data-with-file-uploaded';
import { Component, OnInit } from '@angular/core';
import {ModalController} from '@ionic/angular';
@Component({
selector: 'app-parere-modal',
templateUrl: './parere-modal.component.html',
styleUrls: ['./parere-modal.component.scss'],
})
export class ParereModalComponent implements OnInit {
constructor(private modalController: ModalController) {
result = {dati: null, file: null};
}
ngOnInit() {}
loadFile()
{
var element : HTMLInputElement = document.querySelector('input[type=file]');
var file: Blob = element.files[0];
var reader = new FileReader();
reader.onloadend = function () {
result.file = reader.result;
};
/*reader.addEventListener("load", function () {
result.file = reader.result;
}, false);*/
if (file) {
reader.readAsDataURL(file);
}
}
async dismiss(form)
{
result.dati = form.value;
await this.modalController.dismiss(result);
}
async close()
{
await this.modalController.dismiss();
}
fileName;
}
var result: DataWithFileUploaded;
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
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