2014-08-06 22:11:39 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* JavaScript for SOGoRootPage (mobile) */
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
2014-11-27 15:24:26 +01:00
|
|
|
angular.module('SOGo.MainUI', ['SOGo.Authentication', 'SOGo.UIMobile', 'ionic'])
|
2014-08-06 22:11:39 +02:00
|
|
|
|
|
|
|
.constant('sgSettings', {
|
2014-11-27 15:24:26 +01:00
|
|
|
baseURL: ApplicationBaseURL
|
2014-08-06 22:11:39 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
.run(function($ionicPlatform) {
|
|
|
|
$ionicPlatform.ready(function() {
|
|
|
|
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
|
|
|
|
// for form inputs)
|
|
|
|
if(window.cordova && window.cordova.plugins.Keyboard) {
|
|
|
|
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
|
|
|
|
}
|
|
|
|
if(window.StatusBar) {
|
|
|
|
// org.apache.cordova.statusbar required
|
|
|
|
StatusBar.styleDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
.config(function($stateProvider, $urlRouterProvider) {
|
|
|
|
$stateProvider
|
|
|
|
|
|
|
|
.state('app', {
|
2014-11-27 15:24:26 +01:00
|
|
|
url: '/app',
|
2014-08-06 22:11:39 +02:00
|
|
|
abstract: true,
|
2014-11-27 15:24:26 +01:00
|
|
|
templateUrl: 'menu.html',
|
2014-08-06 22:11:39 +02:00
|
|
|
controller: 'AppCtrl'
|
|
|
|
})
|
|
|
|
|
|
|
|
.state('app.login', {
|
2014-11-27 15:24:26 +01:00
|
|
|
url: '/login',
|
2014-08-06 22:11:39 +02:00
|
|
|
views: {
|
2014-11-27 15:24:26 +01:00
|
|
|
menuContent: {
|
|
|
|
templateUrl: 'login.html',
|
2014-08-06 22:11:39 +02:00
|
|
|
controller: 'LoginCtrl'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// if none of the above states are matched, use this as the fallback
|
|
|
|
$urlRouterProvider.otherwise('/app/login');
|
|
|
|
})
|
|
|
|
|
2014-08-13 22:11:28 +02:00
|
|
|
.controller('AppCtrl', ['$scope', 'sgSettings', function($scope, Settings) {
|
2014-08-11 16:10:25 +02:00
|
|
|
$scope.ApplicationBaseURL = Settings.baseURL;
|
|
|
|
}])
|
2014-08-06 22:11:39 +02:00
|
|
|
|
|
|
|
.controller('LoginCtrl', ['$scope', 'Authentication', 'sgDialog', function($scope, Authentication, Dialog) {
|
|
|
|
$scope.creds = { 'username': null, 'password': null };
|
|
|
|
$scope.login = function(creds) {
|
|
|
|
Authentication.login(creds)
|
|
|
|
.then(function(url) {
|
|
|
|
window.location.href = url;
|
|
|
|
}, function(msg) {
|
|
|
|
Dialog.alert(l('Warning'), msg.error);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}]);
|
|
|
|
})();
|