webui: layer for standalone pages which use WebUI framework

Current compiled Web UI layer (app.js) contains every FreeIPA plugin and
not just the UI framework. It's not possible to start just a simple facet.

This commit creates a basis for a layer (core.js) which contains only
framework code and not entity related code.

Reviewed-By: Endi Sukma Dewata <edewata@redhat.com>
This commit is contained in:
Petr Vobornik
2014-06-30 12:27:05 +02:00
parent c2c1131a7a
commit 46a42de532
8 changed files with 67 additions and 16 deletions
+1
View File
@@ -714,6 +714,7 @@ fi
%{_usr}/share/ipa/ui/js/libs/*.js %{_usr}/share/ipa/ui/js/libs/*.js
%dir %{_usr}/share/ipa/ui/js/freeipa %dir %{_usr}/share/ipa/ui/js/freeipa
%{_usr}/share/ipa/ui/js/freeipa/app.js %{_usr}/share/ipa/ui/js/freeipa/app.js
%{_usr}/share/ipa/ui/js/freeipa/core.js
%dir %{_usr}/share/ipa/ui/js/plugins %dir %{_usr}/share/ipa/ui/js/plugins
%dir %{_usr}/share/ipa/ui/images %dir %{_usr}/share/ipa/ui/images
%{_usr}/share/ipa/ui/images/*.jpg %{_usr}/share/ipa/ui/images/*.jpg
+1
View File
@@ -3,6 +3,7 @@ NULL =
appdir = $(IPA_DATA_DIR)/ui/js/freeipa appdir = $(IPA_DATA_DIR)/ui/js/freeipa
app_DATA = \ app_DATA = \
app.js \ app.js \
core.js \
$(NULL) $(NULL)
EXTRA_DIST = \ EXTRA_DIST = \
+30 -1
View File
@@ -24,9 +24,10 @@ define([
'dojo/when', 'dojo/when',
'./plugin_loader', './plugin_loader',
'./phases', './phases',
'./reg',
'./Application_controller', './Application_controller',
'exports' 'exports'
],function(lang, Deferred, when, plugin_loader, phases, Application_controller, app) { ],function(lang, Deferred, when, plugin_loader, phases, reg, Application_controller, app) {
/** /**
* Application wrapper * Application wrapper
@@ -84,11 +85,39 @@ define([
})); }));
}, },
simple_mode_phases: function() {
phases.on('init', lang.hitch(this, function() {
var app = this.app = new this.App_class();
app.init();
return app;
}));
phases.on('runtime', lang.hitch(this, function() {
var d = new Deferred();
var facet = reg.facet.get(this.target_facet);
if (!facet) {
window.console.error('Target facet not found: '+this.target_facet);
} else {
this.app.show_facet(facet);
}
return d.promise;
}));
},
run: function() { run: function() {
when(plugin_loader.load_plugins(), lang.hitch(this, function() { when(plugin_loader.load_plugins(), lang.hitch(this, function() {
this.register_phases(); this.register_phases();
phases.controller.run(); phases.controller.run();
})); }));
},
run_simple: function(facet) {
this.target_facet = facet;
when(plugin_loader.load_plugins(), lang.hitch(this, function() {
this.simple_mode_phases();
phases.controller.run();
}));
} }
}); });
+27
View File
@@ -0,0 +1,27 @@
/* Authors:
* Petr Vobornik <pvoborni@redhat.com>
*
* Copyright (C) 2012 Red Hat
* see file 'COPYING' for use and warranty information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'./app_container',
'./plugins/sync_otp',
'./plugins/login'
],function(app_container) {
return app_container;
});
+4 -3
View File
@@ -32,6 +32,7 @@ define(['dojo/_base/array',
'dojo/topic', 'dojo/topic',
'./builder', './builder',
'./datetime', './datetime',
'./entity',
'./ipa', './ipa',
'./jquery', './jquery',
'./navigation', './navigation',
@@ -39,10 +40,11 @@ define(['dojo/_base/array',
'./reg', './reg',
'./rpc', './rpc',
'./text', './text',
'./util' './util',
'exports'
], ],
function(array, lang, Evented, has, keys, on, string, topic, builder, function(array, lang, Evented, has, keys, on, string, topic, builder,
datetime, IPA, $, navigation, phases, reg, rpc, text, util) { datetime, entity_mod, IPA, $, navigation, phases, reg, rpc, text, util, exp) {
/** /**
* Widget module * Widget module
@@ -54,7 +56,6 @@ define(['dojo/_base/array',
* @class widget * @class widget
* @singleton * @singleton
*/ */
var exp = {};
/** /**
* Width of column which contains only checkbox * Width of column which contains only checkbox
+3
View File
@@ -114,6 +114,9 @@ var profile = (function(){
], ],
layers: { layers: {
"freeipa/core": {
include: ["freeipa/core"]
},
"freeipa/app": { "freeipa/app": {
include: ["freeipa/app", "freeipa/extend"] include: ["freeipa/app", "freeipa/extend"]
} }
-12
View File
@@ -106,15 +106,3 @@ fi
# compile using uglify.js # compile using uglify.js
$DIR/uglifyjs/uglify $RDIR/$RELEASE/$LAYER.js $OUTPUT_FILE $DIR/uglifyjs/uglify $RDIR/$RELEASE/$LAYER.js $OUTPUT_FILE
# clean all other files
BUILD_DIR=$RDIR/$RELEASE/`echo $LAYER | cut -d/ -f 1`
LAYER_FILE=`echo $LAYER | cut -d/ -f 2`.js
rm -f $RDIR/$RELEASE/build-report.txt
pushd $BUILD_DIR
if [[ $? != 0 ]] ; then
echo "Invalid build dir: $BUILD_DIR"
exit 1
fi
ls -1 | grep -v -e "^$LAYER_FILE$" | xargs rm -rf
popd
+1
View File
@@ -31,5 +31,6 @@ fi
$DIR/clean.sh $DIR/clean.sh
$DIR/build.sh webui $DIR/build.sh webui
# don't stop at error. Some dependency errors are expected. # don't stop at error. Some dependency errors are expected.
$DIR/compile.sh --release lib --layer freeipa/core --output $IPA_DIR/core.js
$DIR/compile.sh --release lib --layer freeipa/app --output $IPA_DIR/app.js $DIR/compile.sh --release lib --layer freeipa/app --output $IPA_DIR/app.js
$DIR/clean.sh $DIR/clean.sh