From 40f7cf523d10d40933fc9d7c5994655dc067d27b Mon Sep 17 00:00:00 2001 From: MichaelDaum Date: Tue, 16 Dec 2014 12:27:49 +0100 Subject: [PATCH] Item13069: first page is delivered by server only the following are loaded into the client using angular also: - added load time indicator to right bottom of page - fixed default web.topic location --- pub/System/AngularSkin/app.uncompressed.css | 6 +++++ .../AngularSkin/controller.uncompressed.js | 17 ++++++++---- pub/System/AngularSkin/pkg.uncompressed.css | 6 +++++ pub/System/AngularSkin/pkg.uncompressed.js | 26 ++++++++++++++----- .../AngularSkin/services.uncompressed.js | 9 ++++++- templates/foswiki.angular.tmpl | 2 ++ 6 files changed, 54 insertions(+), 12 deletions(-) diff --git a/pub/System/AngularSkin/app.uncompressed.css b/pub/System/AngularSkin/app.uncompressed.css index ca80451..08069b4 100644 --- a/pub/System/AngularSkin/app.uncompressed.css +++ b/pub/System/AngularSkin/app.uncompressed.css @@ -1,3 +1,9 @@ +.ngLoadTime { + position:fixed; + bottom:0.5em; + right:0.5em; + color:#a1a1a1; +} .natBusy { display:none; } diff --git a/pub/System/AngularSkin/controller.uncompressed.js b/pub/System/AngularSkin/controller.uncompressed.js index 7085035..94b9d50 100644 --- a/pub/System/AngularSkin/controller.uncompressed.js +++ b/pub/System/AngularSkin/controller.uncompressed.js @@ -44,18 +44,25 @@ app.controller("ViewCtrl", [ if (match) { $scope.script = match[1] || 'view'; - web = match[2] || foswikiAppSettings.defaultWebName; - topic = match[3] || foswikiAppSettings.homeTopicName; + web = match[2]; + topic = match[3]; } else { $scope.script = 'view'; - web = foswikiAppSettings.defaultWebName; - topic = foswikiAppSettings.homeTopicName; + } + + if (isFirst) { + // if undefined get it from foswiki.preferences + web = web || foswiki.preferences.WEB; + topic = topic || foswiki.preferences.TOPIC; + } else { + // if undefined use default web.topic + web = web || foswikiAppSettings.defaultWebName; + topic = topic || foswikiAppSettings.homeTopicName; } web = web.replace(/^\/|\/$/g, ""); topic = topic.replace(/^\/|\/$/g, ""); - // notify foswiki foswiki.preferences.WEB = web; foswiki.preferences.TOPIC = topic; diff --git a/pub/System/AngularSkin/pkg.uncompressed.css b/pub/System/AngularSkin/pkg.uncompressed.css index a2ecc39..40a7b1f 100644 --- a/pub/System/AngularSkin/pkg.uncompressed.css +++ b/pub/System/AngularSkin/pkg.uncompressed.css @@ -3156,6 +3156,12 @@ Copyright (c) 2014 Daniel Eden -webkit-animation-name: slideOutUp; animation-name: slideOutUp; } +.ngLoadTime { + position:fixed; + bottom:0.5em; + right:0.5em; + color:#a1a1a1; +} .natBusy { display:none; } diff --git a/pub/System/AngularSkin/pkg.uncompressed.js b/pub/System/AngularSkin/pkg.uncompressed.js index 7f1e012..e9be544 100644 --- a/pub/System/AngularSkin/pkg.uncompressed.js +++ b/pub/System/AngularSkin/pkg.uncompressed.js @@ -45,7 +45,8 @@ app.factory("foswikiService", [ var cache = {}, templateRequests = {}, canceler, - prevWeb; + prevWeb, + loadStart; // request a specific template and poll them to be loaded in a batch function _requestTemplate(name, reload) { @@ -139,6 +140,7 @@ app.factory("foswikiService", [ canceler = $q.defer(); // do the request + loadStart = (new Date()).getTime(); $http({ method: 'post', url: '/bin/jsonrpc/AngularPlugin/tmpl', @@ -174,6 +176,9 @@ app.factory("foswikiService", [ $rootScope.preferences = data.result.preferences; //$log.debug("preferences=",$rootScope.preferences); + $rootScope.loadTime = ((new Date()).getTime() - loadStart); + $log.log(params.topic+" took "+$rootScope.loadTime+"ms to load"); + // send to promise deferred.resolve(data); }) @@ -183,6 +188,8 @@ app.factory("foswikiService", [ // finish request canceler = undefined; + $log.log("loading time: "+(new Date()).getTime() - loadStart); + // send to promise deferred.reject(data); }); @@ -245,18 +252,25 @@ app.controller("ViewCtrl", [ if (match) { $scope.script = match[1] || 'view'; - web = match[2] || foswikiAppSettings.defaultWebName; - topic = match[3] || foswikiAppSettings.homeTopicName; + web = match[2]; + topic = match[3]; } else { $scope.script = 'view'; - web = foswikiAppSettings.defaultWebName; - topic = foswikiAppSettings.homeTopicName; + } + + if (isFirst) { + // if undefined get it from foswiki.preferences + web = web || foswiki.preferences.WEB; + topic = topic || foswiki.preferences.TOPIC; + } else { + // if undefined use default web.topic + web = web || foswikiAppSettings.defaultWebName; + topic = topic || foswikiAppSettings.homeTopicName; } web = web.replace(/^\/|\/$/g, ""); topic = topic.replace(/^\/|\/$/g, ""); - // notify foswiki foswiki.preferences.WEB = web; foswiki.preferences.TOPIC = topic; diff --git a/pub/System/AngularSkin/services.uncompressed.js b/pub/System/AngularSkin/services.uncompressed.js index 71f000c..a4d7eb0 100644 --- a/pub/System/AngularSkin/services.uncompressed.js +++ b/pub/System/AngularSkin/services.uncompressed.js @@ -24,7 +24,8 @@ app.factory("foswikiService", [ var cache = {}, templateRequests = {}, canceler, - prevWeb; + prevWeb, + loadStart; // request a specific template and poll them to be loaded in a batch function _requestTemplate(name, reload) { @@ -118,6 +119,7 @@ app.factory("foswikiService", [ canceler = $q.defer(); // do the request + loadStart = (new Date()).getTime(); $http({ method: 'post', url: '/bin/jsonrpc/AngularPlugin/tmpl', @@ -153,6 +155,9 @@ app.factory("foswikiService", [ $rootScope.preferences = data.result.preferences; //$log.debug("preferences=",$rootScope.preferences); + $rootScope.loadTime = ((new Date()).getTime() - loadStart); + $log.log(params.topic+" took "+$rootScope.loadTime+"ms to load"); + // send to promise deferred.resolve(data); }) @@ -162,6 +167,8 @@ app.factory("foswikiService", [ // finish request canceler = undefined; + $log.log("loading time: "+(new Date()).getTime() - loadStart); + // send to promise deferred.reject(data); }); diff --git a/templates/foswiki.angular.tmpl b/templates/foswiki.angular.tmpl index 31964a8..992daa1 100644 --- a/templates/foswiki.angular.tmpl +++ b/templates/foswiki.angular.tmpl @@ -41,3 +41,5 @@ jQuery.extend(foswiki.preferences, { id="ANGULARPLUGIN::CSS" text="" }%%TMPL:END% + +%TMPL:DEF{"ng::loadtime"}%
%TMPL:END%