Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Merge branch 'fix/init_flow' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jornane committed Oct 23, 2020
2 parents f70b94d + ec90a7a commit ba821d9
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 67 deletions.
37 changes: 11 additions & 26 deletions src/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Config, Events, Nav, Platform} from 'ionic-angular';
import {Component, ViewChild} from '@angular/core';
import { ReconfigurePage } from '../pages/welcome/reconfigure';
import { ProfilePage } from '../pages/profile/profile';
import { ConfigurationScreen } from '../pages/configScreen/configScreen';
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
Expand Down Expand Up @@ -44,6 +43,7 @@ export class GeteduroamApp {
lastTimeBackPress = 0;

timePeriodToExit = 2000;

/**
* @constructor
*
Expand Down Expand Up @@ -84,21 +84,7 @@ export class GeteduroamApp {
this.enableWifi();
}
if (!this.checkExtFile) {
const isAssociated = await this.isAssociatedNetwork();

if (!!isAssociated.success) {
// this.rootPage = !!isAssociated.success ? ConfigurationScreen : ReconfigurePage;
this.rootPage = ConfigurationScreen;
} else{
if (!isAssociated.message.includes('alreadyAssociated')) {
this.rootPage = ConfigurationScreen;
} else {
this.rootPage = ReconfigurePage;
this.getAssociation(isAssociated);

!isAssociated.success && !isAssociated.overridable ? this.removeAssociatedManually() : '';
}
}
this.rootPage = ConfigurationScreen;
}
}
async checkExternalOpen() {
Expand Down Expand Up @@ -148,7 +134,7 @@ export class GeteduroamApp {
this.platform.registerBackButtonAction(() => {
// get current active page
let view = this.navCtrl.getActive();
if (view.component.name == "ConfigurationScreen" || view.component.name == "ReconfigurePage") {
if (view.component.name == "ConfigurationScreen") {
//Double check to exit app
if (new Date().getTime() - this.lastTimeBackPress < this.timePeriodToExit) {
this.platform.exitApp(); //Exit from app
Expand Down Expand Up @@ -177,13 +163,11 @@ export class GeteduroamApp {
const method = await this.getEduroamServices.eapValidation(this.profile);
if (method) {
this.profile.oauth = Number(this.global.getAuthenticationMethod().eapMethod.type) === 13;
if (!this.rootPage) {
this.rootPage = !!this.profile.oauth ? ConfigFilePage : ProfilePage;
} else {
await this.navCtrl.push( !!this.profile.oauth ? ConfigFilePage : ProfilePage );
}
}
if (!this.rootPage) {
this.rootPage = !!this.profile.oauth ? ConfigFilePage : ProfilePage;
} else {
await this.errorHandler.handleError(this.dictionary.getTranslation('error', 'invalid-eap'), true, '');
await this.navCtrl.push( !!this.profile.oauth ? ConfigFilePage : ProfilePage );
}
}
}
Expand All @@ -200,12 +184,11 @@ export class GeteduroamApp {
*/
async notConnectionNetwork() {
if (!this.checkExtFile) {
this.rootPage = ReconfigurePage;
this.rootPage = ConfigurationScreen;

const isAssociated = await this.isAssociatedNetwork();
this.getAssociation(isAssociated);


if (!isAssociated.success && !isAssociated.overridable) {
this.removeAssociatedManually();

Expand All @@ -232,8 +215,10 @@ export class GeteduroamApp {
if (!this.checkExtFile) {
this.connectionEvent(connectionStatus);

if (!connectionStatus.connected){
if (!connectionStatus.connected) {
this.notConnectionNetwork();
} else {
this.global.setDiscovery(await this.getEduroamServices.discovery());
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule } from 'ionic-angular';
import { GeteduroamApp } from './app.component';
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';

import { StatusBar } from '@ionic-native/status-bar/ngx';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
Expand All @@ -18,15 +17,18 @@ import { StoringProvider } from '../providers/storing/storing';
import { GlobalProvider } from '../providers/global/global';
import { ErrorServiceProvider } from "../providers/error-service/error-service";
import { OauthConfProvider } from '../providers/oauth-conf/oauth-conf';
import { InstitutionSearch } from '../pages/institutionSearch/institutionSearch';
import { ReactiveFormsModule } from '@angular/forms';

@NgModule({
declarations: [
GeteduroamApp
],
imports: [
BrowserModule,
ReactiveFormsModule,
PagesModule,
IonicModule.forRoot(GeteduroamApp)
IonicModule.forRoot(GeteduroamApp, { preload: InstitutionSearch }),
],
bootstrap: [IonicApp],
entryComponents: [
Expand All @@ -48,7 +50,7 @@ import { OauthConfProvider } from '../providers/oauth-conf/oauth-conf';
OauthConfProvider,
ErrorServiceProvider
],
exports:[]
exports:[],
})
export class AppModule {

Expand Down
5 changes: 2 additions & 3 deletions src/src/pages/configScreen/configScreen.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ <h1>{{getString('header', 'config')}}</h1>
<div class="content-form" margin-top padding-top text-center>
<ion-label class="label-conf" no-margin padding-top text-left>{{getString('label', 'institution')}}</ion-label>

<div class="row" padding-top>
<div *ngIf="this.instances" class="row" padding-top>

<ion-searchbar (click)="showModal($event)" [(ngModel)]="instanceName" cancelButtonText
<ion-searchbar (click)="showModal($event)" [(ngModel)]="instanceName" cancelButtonText debounce="500"
class="searchbar-input" no-padding placeholder="{{getString('placeholder', 'institution')}}">

</ion-searchbar>
Expand Down Expand Up @@ -44,4 +44,3 @@ <h1>{{getString('header', 'config')}}</h1>
</div>
</div>
</div>

47 changes: 33 additions & 14 deletions src/src/pages/configScreen/configScreen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, NgZone } from '@angular/core';
import {Events, ModalController, NavController} from 'ionic-angular';
import { Component, NgModule, NgZone } from '@angular/core';
import { Events, Modal, ModalController, NavController, NavParams, ViewController } from 'ionic-angular';
import {GeteduroamServices} from "../../providers/geteduroam-services/geteduroam-services";
import { ProfilePage } from '../profile/profile';
import { OauthFlow } from '../oauthFlow/oauthFlow';
Expand All @@ -20,7 +20,6 @@ declare var window;
selector: 'page-config-screen',
templateUrl: 'configScreen.html',
})

export class ConfigurationScreen extends BasePage{

showAll: boolean = false;
Expand Down Expand Up @@ -80,7 +79,6 @@ export class ConfigurationScreen extends BasePage{
*/
showButton: boolean = true;


/**
* Constructor
* */
Expand All @@ -89,34 +87,45 @@ export class ConfigurationScreen extends BasePage{
protected dictionary: DictionaryServiceProvider, protected global: GlobalProvider,
private errorHandler: ErrorHandlerProvider) {
super(loading, dictionary, event, global);
Keyboard.addListener('keyboardWillShow', async () => {
await Keyboard.hide();
});

this.event.subscribe('connection', async (res: any) => {
if (!!res.connected && !this.global.discovery) {
this.chargeDiscovery()
}
});
}


/**
* Method executes when the search bar is tapped.
* */
async showModal(e: any) {
e.preventDefault();
await Keyboard.hide();
if (!!this.instances) {
let searchModal = this.modalCtrl.create(InstitutionSearch, {
instances: this.instances,
instanceName: this.instanceName}
);
instanceName: this.instanceName
});

searchModal.onDidDismiss((data) => {

data = this.instances.filter((res: any) => {
if (res.name === data) return res
});

if (data !== undefined) {
this.instance = data;
this.instanceName = data.name;
this.instance = data[0];
this.instanceName = data[0].name;

this.initializeProfiles(this.instance);

}
});

return await searchModal.present();
} else {
await this.getDiscovery();
await this.chargeDiscovery();
this.showModal(e);
}
}
Expand Down Expand Up @@ -226,12 +235,18 @@ export class ConfigurationScreen extends BasePage{
this.resetValues();
}

async ngOnInit() {
this.instances = this.global.discovery;
}

ionViewWillEnter() {
this.loading.create();
}
/**
* Lifecycle when entering a page, before it becomes the active one
* Load the discovery data and show the spinner
*/
async ionViewDidEnter() {
await this.getDiscovery();
this.removeSpinner();
this.showAll = true;
}
Expand All @@ -251,7 +266,6 @@ export class ConfigurationScreen extends BasePage{
this.instanceName = '';

});

}

async checkEap(profile: ProfileModel) {
Expand All @@ -276,6 +290,11 @@ export class ConfigurationScreen extends BasePage{
}
}

async chargeDiscovery() {
await this.getDiscovery();
this.global.setDiscovery(this.instances)
}

/**
*
*/
Expand Down
11 changes: 9 additions & 2 deletions src/src/pages/institutionSearch/institutionSearch.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
</ion-toolbar>
</ion-header>
<ion-content fullscreen>
<ion-list *ngFor="let institution of filteredInstances" no-margin>
<ion-item (click)="selectInstitution(institution)">{{institution.name}}</ion-item>
<ion-list no-margin class="list list-ios list-institution">
<div *ngFor="let institution of filteredInstances;" class="item item-block">
<div class="item-inner" (click)="selectInstitution(institution)">
<div class="input-wrapper">
<div class="label label-ios label-institution">{{ institution }} </div>
</div>
</div>
<div class="button-effect"></div>
</div>
</ion-list>
</ion-content>
12 changes: 6 additions & 6 deletions src/src/pages/institutionSearch/institutionSearch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ page-institution-search {
//---------------------------
// ion-item custom style
//---------------------------
ion-item {
background-color: unset;
div.item-inner {
padding: 0 !important;
border-bottom: 0 !important;
}
.list-institution {
background-color: white;
}
.label-institution {
font-size: 20px;
padding-left: 16px
}
}
14 changes: 9 additions & 5 deletions src/src/pages/institutionSearch/institutionSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class InstitutionSearch extends BasePage{
protected dictionary: DictionaryServiceProvider,
protected event: Events, protected global: GlobalProvider) {
super(loading, dictionary, event, global);
Keyboard.removeAllListeners();
}

/**
Expand Down Expand Up @@ -91,9 +92,8 @@ export class InstitutionSearch extends BasePage{
*/
filterInstances(stringAux: string){
if (stringAux && stringAux.trim() != '') {

this.filteredInstances = this.instances.filter((item:any) => {
return (item.name.toLowerCase().indexOf(stringAux.toLowerCase()) > -1);
return (item.toLowerCase().indexOf(stringAux.toLowerCase()) > -1);
})
} else {
this.clearInstance();
Expand Down Expand Up @@ -131,16 +131,20 @@ export class InstitutionSearch extends BasePage{
this.selectedProfileId = '';
}

ngOnInit() {
this.instances = Object.values(this.global.getInstitutionNames());
this.filteredInstances = Object.values(this.instances);
}
/**
* Lifecycle when entering a page, after it becomes the active page.
* this sets focus on search bar
*/
ionViewDidEnter() {
ionViewWillEnter() {
this.ios = !!this.platform.is('ios');
this.instances = this.navParams.get('instances');
this.instanceName = this.navParams.get('instanceName');
this.filterInstances(this.instanceName);

}
ionViewDidEnter() {
setTimeout(() => {
this.searchBar.setFocus()
}, 10);
Expand Down
10 changes: 2 additions & 8 deletions src/src/pages/wifiConfirmation/wifiConfirmation.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
<div *ngIf="!global.isAndroid() && viewCtrl.enableBack() && showAll" class="arrow-back">
<button ion-button class="arrow-btn" (click)="backToConfig()" id="btn-back">
<span class="button-inner"><span class="caret"></span>
Back
</span>
</button>
</div>
<div *ngIf="showAll" class="container-content" id="dismissable-back">
<div *ngIf="showAll" class="container-content">
<div class="header-content" margin padding-top>
<img #imgLogo [ngClass]="!!logo ? 'imgLogo' : ''" [src]="converted_image" alt="setting" margin />
<h1>{{getString('header', 'confirmation')}}</h1>
Expand All @@ -27,3 +20,4 @@ <h1>{{getString('header', 'confirmation')}}</h1>
</div>
</div>
</div>

22 changes: 22 additions & 0 deletions src/src/providers/global/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export class GlobalProvider {

private externalOpen: boolean = false;

discovery: any;
institutionNames: string[] = [];

constructor(public platform: Platform) {}

/**
Expand Down Expand Up @@ -116,4 +119,23 @@ export class GlobalProvider {
getExternalOpen() {
return this.externalOpen;
}

setDiscovery(list: any) {
this.discovery = list;
if (!!list) {
list.map((res) => {
if (res.name) {
this.institutionNames.push(res.name);
}
})
}
}

getDiscovery() {
return this.discovery;
}

getInstitutionNames() {
return this.institutionNames;
}
}

0 comments on commit ba821d9

Please sign in to comment.