Add handling of runtime and shutdown phase. App-init renamed to init.

https://fedorahosted.org/freeipa/ticket/3236
This commit is contained in:
Petr Vobornik 2013-03-19 15:55:04 +01:00
parent 89635f1bc3
commit 8a0f60cf46
3 changed files with 26 additions and 6 deletions

View File

@ -27,6 +27,7 @@
define(['dojo/_base/declare',
'dojo/_base/lang',
'dojo/_base/array',
'dojo/Deferred',
'dojo/on',
'dojo/topic',
'dojo/query',
@ -37,7 +38,7 @@ define(['dojo/_base/declare',
'./navigation/Router',
'./navigation/menu_spec'
],
function(declare, lang, array, on, topic, query, dom_class,
function(declare, lang, array, Deferred, on, topic, query, dom_class,
App_widget, IPA, Menu, Router, menu_spec) {
/**
@ -113,6 +114,10 @@ define(['dojo/_base/declare',
this.app_widget.menu_widget.ignore_changes = false;
this.app_widget.menu_widget.render();
this.app_widget.menu_widget.select(this.menu.selected);
},
start_runtime: function() {
this.run_time = new Deferred();
// now we are ready for displaying a facet
// cat match a facet if hash is set
@ -120,12 +125,18 @@ define(['dojo/_base/declare',
// choose default facet if not defined by route
if (!this.current_facet) {
if (selfservice) {
if (IPA.is_selfservice) {
this.on_profile();
} else {
this.router.navigate_to_entity_facet('user', 'search');
}
}
return this.run_time.promise;
},
start_logout: function() {
IPA.logout();
},
is_selfservice: function() {
@ -162,7 +173,7 @@ define(['dojo/_base/declare',
},
on_logout: function(event) {
IPA.logout();
this.run_time.resolve();
},
on_phase_error: function(error) {

View File

@ -71,7 +71,7 @@ define([
*/
register_phases: function() {
phases.on('app-init', lang.hitch(this, function() {
phases.on('init', lang.hitch(this, function() {
var app = this.app = new this.App_class();
app.init();
return app;
@ -92,6 +92,14 @@ define([
phases.on('profile', lang.hitch(this, function() {
this.app.choose_profile();
}));
phases.on('runtime', lang.hitch(this, function() {
return this.app.start_runtime();
}));
phases.on('shutdown', lang.hitch(this, function() {
return this.app.start_logout();
}));
},
run: function() {

View File

@ -36,10 +36,11 @@ define([
//'resource-load', // implicit phase
'registration',
'alternation',
'app-init',
'init',
'metadata',
'profile',
'logout'
'runtime',
'shutdown'
]
};