2016-12-01 15:21:07 -05:00
|
|
|
/// <reference path="../../types.ts" />
|
2016-12-02 13:00:55 -05:00
|
|
|
import { Component } from '@angular/core';
|
|
|
|
import { NavController } from 'ionic-angular';
|
|
|
|
import { Storage } from '@ionic/storage';
|
2016-12-28 15:57:16 -05:00
|
|
|
import {UserHelpers} from '../../Helpers';
|
2016-12-02 13:00:55 -05:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'settings',
|
|
|
|
templateUrl: 'settings.html'
|
|
|
|
})
|
2016-12-27 21:10:00 -05:00
|
|
|
export class SettingsPage
|
|
|
|
{
|
2016-12-28 15:57:16 -05:00
|
|
|
user: User = { strongs_modal: true, clear_search_after_query: true, items: [], append_to_bottom: false };
|
2016-12-27 21:10:00 -05:00
|
|
|
|
|
|
|
constructor(public navCtrl: NavController, public local: Storage)
|
|
|
|
{
|
2016-12-01 15:21:07 -05:00
|
|
|
// Check if there is a profile saved in local storage
|
2016-12-27 21:10:00 -05:00
|
|
|
this.local.get('profile').then(profile =>
|
|
|
|
{
|
2016-12-28 15:57:16 -05:00
|
|
|
let t = this.user;
|
|
|
|
|
|
|
|
if (profile !== null)
|
|
|
|
t = JSON.parse(profile);
|
|
|
|
|
|
|
|
new UserHelpers(local).validate(this.user, t);
|
|
|
|
this.user = t;
|
2016-12-27 21:10:00 -05:00
|
|
|
}).catch(error =>
|
|
|
|
{
|
2016-12-01 15:21:07 -05:00
|
|
|
console.log(error);
|
2016-12-02 13:00:55 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-12-27 21:10:00 -05:00
|
|
|
save()
|
|
|
|
{
|
2016-12-02 13:00:55 -05:00
|
|
|
this.local.set('profile', JSON.stringify(this.user));
|
|
|
|
}
|
|
|
|
|
2016-12-27 21:10:00 -05:00
|
|
|
reset()
|
|
|
|
{
|
2016-12-28 15:57:16 -05:00
|
|
|
this.user = { strongs_modal: true, clear_search_after_query: true, items: [], append_to_bottom: false };
|
2016-12-27 21:10:00 -05:00
|
|
|
this.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
ionViewDidLoad()
|
|
|
|
{
|
2016-12-02 13:00:55 -05:00
|
|
|
console.log('Hello SettingsPage Page');
|
|
|
|
}
|
2016-12-01 15:21:07 -05:00
|
|
|
}
|