diff --git a/luciexpress/Gruntfile.js b/luciexpress/Gruntfile.js
index 95db80927..121db88a2 100644
--- a/luciexpress/Gruntfile.js
+++ b/luciexpress/Gruntfile.js
@@ -2,6 +2,7 @@ module.exports = function(grunt){
var glob = require("glob");
var async = require("async");
var fs = require("fs");
+ var uglifyjs = require("uglify-js");
grunt.loadNpmTasks('grunt-angular-gettext');
grunt.initConfig({
@@ -91,7 +92,7 @@ module.exports = function(grunt){
spawn('mocha', files.concat(['--host', grunt.option("host"), "--user", grunt.option("user"), "--pass", grunt.option("pass")]), { customFds: [0,1,2] })
.on("exit", function(code){
if(code != 0 && !grunt.option("ignore-errors")) throw new Error("A test has failed. To run all tests without exiting, specify --ignore-errors option");
- else next();
+ else done();
});
console.log(files);
});
@@ -129,46 +130,53 @@ module.exports = function(grunt){
"htdocs/js/theme.js",
"htdocs/js/timeout.js"
];
-
+ var cssfiles = [
+ "htdocs/css/normalize.css",
+ "htdocs/lib/css/bootstrap.min.css",
+ "htdocs/lib/css/bootstrap-select.min.css",
+ "htdocs/lib/css/font-awesome.min.css",
+ "htdocs/lib/css/angular-ui.min.css",
+ "htdocs/lib/css/select.min.css",
+ "htdocs/lib/css/angular-ui-switch.min.css",
+ "htdocs/lib/css/awesome-bootstrap-checkbox.css",
+ "htdocs/css/nga.min.css",
+ "htdocs/css/app.css",
+ "htdocs/themes/vodafone/css/theme.css",
+ "htdocs/themes/vodafone/css/bootstrap.min.css"
+ ];
+
+ var pluginfiles = grunt.file.expand(["htdocs/plugins/**/plugin.json"]);
var otherfiles = grunt.file.expand(["./htdocs/plugins/**/*.js", "./htdocs/themes/vodafone/**/*.js"]).filter(function(x){
return !x.match(/.*\/test-.*\.js/) && !x.match(/.*\.test\.js/);
});
var htmlfiles = grunt.file.expand(["htdocs/**/*.html"]);
-
+ var css = cssfiles.map(function(file){
+ return String(fs.readFileSync(file));
+ }).join("\n");
var all = libfiles.concat(appfiles).concat(otherfiles);
- var templates = {};
+ var templates = {}; var plugins = {};
htmlfiles.map(function(name){
templates[name.replace("htdocs/", "")] = String(fs.readFileSync(name));
});
- fs.writeFileSync("htdocs/__all.js", "var JUCI_COMPILED = 1; var JUCI_TEMPLATES = "+JSON.stringify(templates)+";"+all.map(function(name){ return fs.readFileSync(name); }).join("\n")); // REALLY?
+ pluginfiles.map(function(name){
+ plugins[name.replace(/^htdocs\//, "")] = JSON.parse(String(fs.readFileSync(name)));
+ });
+ fs.writeFileSync("htdocs/__all.css", css);
+ // TODO: really do not do it in memory!
+ fs.writeFileSync("htdocs/__all.js",
+ //uglifyjs.minify(
+ "var JUCI_COMPILED = 1; var JUCI_TEMPLATES = "+
+ JSON.stringify(templates)+";"+
+ "var JUCI_PLUGINS = "+JSON.stringify(plugins)+";"+
+ all.map(function(name){
+ return fs.readFileSync(name);
+ })
+ .join(";\n")
+ //, {fromString: true }).code
+ );
+
//fs.writeFileSync("htdocs/__templates.js", JSON.stringify(templates));
});
grunt.registerTask('default', ['nggettext_extract', 'nggettext_compile', "extract_titles", "compile_pot"]);
}
-/*
-
-LIBFILES=(htdocs/lib/js/async.js htdocs/lib/js/js-schema.min.js htdocs/lib/js/require.js htdocs/lib/js/jquery.min.js htdocs/lib/js/angular.min.js htdocs/lib/js/angular-ui.min.js htdocs/lib/js/angular-ui-router.min.js htdocs/lib/js/angular-gettext.min.js htdocs/lib/js/bootstrap-select.min.js htdocs/lib/js/select.min.js htdocs/lib/js/angular-animate.min.js htdocs/lib/js/angular-ui-bootstrap-luci.min.js htdocs/lib/js/jquery-jsonrpc.js htdocs/lib/js/translations.js htdocs/lib/js/bootstrap.min.js htdocs/lib/js/angular-ui-switch.min.js htdocs/lib/js/angular-modal-service.min.js htdocs/lib/js/angular-checklist-model.js)
-PLUGINFILES=$(find htdocs/plugins -type f -name "*js" | grep -v "test-" | grep -v ".test.js" | grep -v ".notest.js")
-THEMEFILES=$(find htdocs/themes -type f -name "*js" | grep -v "test-" | grep -v ".test.js" | grep -v ".notest.js")
-COREFILES=(htdocs/js/rpc.js htdocs/js/uci.js htdocs/js/juci.js htdocs/js/app.js htdocs/js/localStorage.js htdocs/js/config.js htdocs/js/navigation.js htdocs/js/status.js htdocs/js/session.js htdocs/js/tr.js htdocs/js/theme.js htdocs/js/timeout.js)
-FILES=("${LIBFILES[@]}" "${COREFILES[@]}" "${PLUGINFILES[@]}" "${THEMEFILES[@]}");
-
-echo "var JUCI_COMPILED = 1;" > htdocs/__all.js
-for file in ${FILES[@]}; do
- echo "FILE: $file";
- echo ";" >> htdocs/__all.js;
- cat $file >> htdocs/__all.js;
-done;
-
-HTMLFILES=$(find htdocs -type f -name "*html"|grep -v "index.html" | grep -v "__all.html")
-
-echo "" > htdocs/__all.html
-for file in ${HTMLFILES[@]}; do
- file=$(echo $file | sed 's/htdocs\///gi')
- echo "HTML: $file";
- echo "' >> htdocs/__all.html;
-done;
-*/
diff --git a/luciexpress/bootstrap.sh b/luciexpress/bootstrap.sh
index 2adcb3ee5..ef23e855a 100755
--- a/luciexpress/bootstrap.sh
+++ b/luciexpress/bootstrap.sh
@@ -4,3 +4,4 @@ npm install
sudo npm install -g grunt-cli
sudo npm install -g mocha
sudo npm install -g bower
+sudo npm install -g uglify-js
diff --git a/luciexpress/htdocs/devgui.html b/luciexpress/htdocs/devgui.html
new file mode 100644
index 000000000..f426aff1c
--- /dev/null
+++ b/luciexpress/htdocs/devgui.html
@@ -0,0 +1,53 @@
+
+
+
+
+ LuCi Express
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/luciexpress/htdocs/fonts/FontAwesome.otf b/luciexpress/htdocs/fonts/FontAwesome.otf
new file mode 100644
index 000000000..f7936cc1e
Binary files /dev/null and b/luciexpress/htdocs/fonts/FontAwesome.otf differ
diff --git a/luciexpress/htdocs/fonts/fontawesome-webfont.eot b/luciexpress/htdocs/fonts/fontawesome-webfont.eot
new file mode 100644
index 000000000..33b2bb800
Binary files /dev/null and b/luciexpress/htdocs/fonts/fontawesome-webfont.eot differ
diff --git a/luciexpress/htdocs/fonts/fontawesome-webfont.svg b/luciexpress/htdocs/fonts/fontawesome-webfont.svg
new file mode 100644
index 000000000..1ee89d436
--- /dev/null
+++ b/luciexpress/htdocs/fonts/fontawesome-webfont.svg
@@ -0,0 +1,565 @@
+
+
+
\ No newline at end of file
diff --git a/luciexpress/htdocs/fonts/fontawesome-webfont.ttf b/luciexpress/htdocs/fonts/fontawesome-webfont.ttf
new file mode 100644
index 000000000..ed9372f8e
Binary files /dev/null and b/luciexpress/htdocs/fonts/fontawesome-webfont.ttf differ
diff --git a/luciexpress/htdocs/fonts/fontawesome-webfont.woff b/luciexpress/htdocs/fonts/fontawesome-webfont.woff
new file mode 100644
index 000000000..8b280b98f
Binary files /dev/null and b/luciexpress/htdocs/fonts/fontawesome-webfont.woff differ
diff --git a/luciexpress/htdocs/fonts/fontawesome-webfont.woff2 b/luciexpress/htdocs/fonts/fontawesome-webfont.woff2
new file mode 100644
index 000000000..3311d5851
Binary files /dev/null and b/luciexpress/htdocs/fonts/fontawesome-webfont.woff2 differ
diff --git a/luciexpress/htdocs/index.html b/luciexpress/htdocs/index.html
index 4c3ee6809..dede50efb 100644
--- a/luciexpress/htdocs/index.html
+++ b/luciexpress/htdocs/index.html
@@ -4,7 +4,8 @@
LuCi Express
-
+
+
-
-
+ -->
diff --git a/luciexpress/htdocs/js/app.js b/luciexpress/htdocs/js/app.js
index 4b25f5574..047f2e7a9 100644
--- a/luciexpress/htdocs/js/app.js
+++ b/luciexpress/htdocs/js/app.js
@@ -1,7 +1,8 @@
//! Author: Martin K. Schröder
// TODO: make this automatic
-//var JUCI_COMPILED = 0;
+if(!window.JUCI_COMPILED) window.JUCI_COMPILED = 0;
+//if(!global.JUCI_PLUGINS) global.JUCI_COMPILED = 0;
$.jsonRPC.setup({
endPoint: '/ubus',
@@ -58,7 +59,8 @@ JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $
$juci.$urlRouterProvider = $urlRouterProvider;
$juci.redirect = function(page){
- window.location.href = "#!/"+page;
+ var DEVMODE = (JUCI_COMPILED)?"":"devgui.html";
+ window.location.href = DEVMODE+"#!/"+page;
}
$stateProvider.state("404", {
@@ -110,7 +112,7 @@ JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $
.run(function($rootScope, $state, gettextCatalog, $tr, gettext, $rpc, $config, $location, $navigation, $templateCache){
console.log("RUN");
- if(JUCI_TEMPLATES !== undefined){
+ if(JUCI_COMPILED && JUCI_TEMPLATES !== undefined){
Object.keys(JUCI_TEMPLATES).map(function(x){
$templateCache.put(x, JUCI_TEMPLATES[x]);
});
@@ -198,43 +200,6 @@ JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $
}
}}]);
-/*
-JUCI.app.factory('$templateCache', function($cacheFactory, $http, $injector) {
- var cache = $cacheFactory('templates');
- var allTplPromise;
-
- return {
- get: function(url) {
- var fromCache = cache.get(url);
-
- // already have required template in the cache
- if (fromCache) {
- return fromCache;
- }
-
- // first template request ever - get the all tpl file
- if (!allTplPromise) {
- allTplPromise = $http.get('__all.html').then(function(response) {
- // compile the response, which will put stuff into the cache
- $injector.get('$compile')(response.data);
- return response;
- });
- }
-
- // return the all-tpl promise to all template requests
- return allTplPromise.then(function(response) {
- return {
- status: response.status,
- data: cache.get(url)
- };
- });
- },
-
- put: function(key, value) {
- cache.put(key, value);
- }
- };
-});*/
// make autofocus directive work as expected
JUCI.app.directive('autofocus', ['$timeout', function($timeout) {
return {
diff --git a/luciexpress/htdocs/js/juci.js b/luciexpress/htdocs/js/juci.js
index f360988e8..b3f30b765 100644
--- a/luciexpress/htdocs/js/juci.js
+++ b/luciexpress/htdocs/js/juci.js
@@ -57,6 +57,18 @@
},
function(next){
var count = 0;
+ if(JUCI_COMPILED && JUCI_PLUGINS) {
+ function dirname(path) { var dir = path.split("/"); dir.pop(); return dir.join("/");}
+ Object.keys(JUCI_PLUGINS).map(function(plugin){
+ var dir = dirname(plugin);
+ var name = dir.split("/").pop();
+ console.log("Registering builtin plugin: "+name+": "+dir+" "+JUCI_PLUGINS[plugin]);
+ JUCI.module(name, dir, JUCI_PLUGINS[plugin]);
+ JUCI.plugins[name] = JUCI_PLUGINS[plugin];
+ });
+ next();
+ return;
+ }
async.each($juci.config.plugins, function(id, next){
count++;
console.log(".."+id, 10+((80/$juci.config.plugins.length) * count));
@@ -64,8 +76,8 @@
$.getJSON(plugin_root + "/plugin.json")
.done(function(data){
console.log("found plugin "+id);
- $juci.module(id, plugin_root, {});
- $juci.plugins[id] = data;
+ $juci.module(id, plugin_root, data);
+ //$juci.plugins[id] = data;
if(data && data.scripts){
data.scripts.map(function(x){scripts.push(plugin_root + "/" + x); });
}
@@ -79,34 +91,6 @@
var name = url.replace(/\//g, "_").replace(/-/g, "_");
//console.log("Registering state "+name+" at "+url);
scripts.push(plugin_root + "/" + page.view);
- // TODO: there is still a problem with state changes where template gets loaded before the dependencies so controller is not found
- /*$juci.$stateProvider.state(name, {
- url: "/"+url,
- views: {
- "content": {
- templateUrl: plugin_root + "/" + page.view + ".html",
- }
- },
- // Perfect! This loads our controllers on demand! :)
- resolve: {
- deps : function ($q, $rootScope) {
- var deferred = $q.defer();
- require([plugin_root + "/" + page.view], function (tt) {
- $rootScope.$apply(function () {
- deferred.resolve();
- });
- deferred.resolve()
- });
- return deferred.promise;
- }
- },
- onEnter: function($window){
- document.title = $tr(k+".title")+" - "+$tr(gettext("application.name"));
- // TODO: all these redirects seem to load page multiple times.
- //if(item.redirect) $window.location.href = "#!"+item.redirect;
- },
- //luci_config: item
- }); */
}
});
}
@@ -116,17 +100,7 @@
});
}, function(){
next();
- /*async.each(scripts, function(script, next){
- console.log("...."+script);
- //progress("...."+script, 10 + ((80 / $config.plugins.length) * count));
- require([script], function(module){
- next();
- });
- }, function(){
- // goto next plugin
- next();
- }); */
- });
+ });
},
function(next){
$rpc.$authenticate().done(function(){
@@ -146,6 +120,8 @@
});
},
function(next){
+
+
// TODO: this will be moved somewhere else. What we want to do is
// pick both a theme and plugins based on the router model.
//console.log("Detected hardware model: "+$juci.config.system.hardware);
@@ -159,11 +135,15 @@
$config.theme = "vodafone";
- $juci.theme.changeTheme($config.theme).done(function(){
+ if(!JUCI_COMPILED){
+ $juci.theme.changeTheme($config.theme).done(function(){
+ next();
+ }).fail(function(){
+ next();
+ });
+ } else {
next();
- }).fail(function(){
- next();
- });
+ }
},
function(next){
if(!JUCI_COMPILED){
diff --git a/luciexpress/htdocs/plugins/core/widgets/luci.login.js b/luciexpress/htdocs/plugins/core/widgets/luci.login.js
index 585c377a6..84d89b5c8 100644
--- a/luciexpress/htdocs/plugins/core/widgets/luci.login.js
+++ b/luciexpress/htdocs/plugins/core/widgets/luci.login.js
@@ -93,7 +93,7 @@ JUCI.app
$rpc.$logout().done(function(){
console.log("Logged out!");
//$state.go("home", {}, {reload: true});
- $window.location.href="/";
+ $juci.redirect("overview"); //$window.location.href="/";
deferred.resolve();
}).fail(function(){
console.error("Error logging out!");
diff --git a/luciexpress/htdocs/plugins/internet/internet.js b/luciexpress/htdocs/plugins/internet/internet.js
index d8a5ed50f..34274c890 100644
--- a/luciexpress/htdocs/plugins/internet/internet.js
+++ b/luciexpress/htdocs/plugins/internet/internet.js
@@ -25,3 +25,12 @@ UCI.network.$registerSectionType("interface", {
"peerdns": { dvalue: false, type: String },
"dns": { dvalue: [], type: Array }
});
+
+UCI.$registerConfig("dhcp");
+UCI.dhcp.$registerSectionType("dhcp", {
+ "interface": { dvalue: "", type: String },
+ "start": { dvalue: 0, type: Number },
+ "limit": { dvalue: 0, type: Number },
+ "leasetime": { dvalue: 60, type: Number },
+ "ignore": { dvalue: false, type: Boolean }
+});
diff --git a/luciexpress/htdocs/plugins/internet/widgets/uci.network.interface.edit.html b/luciexpress/htdocs/plugins/internet/widgets/uci.network.interface.edit.html
index d244ef784..7c6a5a86f 100644
--- a/luciexpress/htdocs/plugins/internet/widgets/uci.network.interface.edit.html
+++ b/luciexpress/htdocs/plugins/internet/widgets/uci.network.interface.edit.html
@@ -17,8 +17,8 @@
-
-
+
+
diff --git a/luciexpress/htdocs/plugins/internet/widgets/uci.network.interface.edit.js b/luciexpress/htdocs/plugins/internet/widgets/uci.network.interface.edit.js
index 745635e3e..fdb429aff 100644
--- a/luciexpress/htdocs/plugins/internet/widgets/uci.network.interface.edit.js
+++ b/luciexpress/htdocs/plugins/internet/widgets/uci.network.interface.edit.js
@@ -13,6 +13,12 @@ JUCI.app
}).controller("uciNetworkInterfaceEdit", function($scope, $uci, $rpc, $log){
$scope.expanded = true;
$scope.$watch("interface", function(interface){
-
+ $uci.sync("dhcp").done(function(){
+ if($uci.dhcp && interface[".name"] in $uci.dhcp){
+ //alert($scope.interface[".name"]);
+ $scope.dhcp = $uci.dhcp[interface[".name"] ];
+ $scope.$apply();
+ }
+ });
});
});
diff --git a/luciexpress/htdocs/themes/vodafone/css/theme.css b/luciexpress/htdocs/themes/vodafone/css/theme.css
index fcba31ace..b8045b6a9 100644
--- a/luciexpress/htdocs/themes/vodafone/css/theme.css
+++ b/luciexpress/htdocs/themes/vodafone/css/theme.css
@@ -1,6 +1,6 @@
@font-face {
font-family: "vodafont";
- src: url("../fonts/vodafonelt-webfont.woff") format('woff');
+ src: url("/themes/vodafone/fonts/vodafonelt-webfont.woff") format('woff');
}
body {
@@ -75,7 +75,7 @@ h1, h2, h3, h4, h5, .navbar-nav {
}
div.logo {
- background-image: url('../img/vf-logo.png');
+ background-image: url('/themes/vodafone/img/vf-logo.png');
background-size: 100%;
height: 32px;
width: 32px;
@@ -93,7 +93,7 @@ div.logo {
#logo {
background: scroll;
background-color: transparent;
- background-image: url("../img/vf-logo.png");
+ background-image: url("/themes/vodafone/img/vf-logo.png");
background-origin: padding-box;
background-position: 0 30px;
background-repeat: no-repeat;