Skip to content

Commit

Permalink
Item13069: first page is delivered by server
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MichaelDaum committed Dec 16, 2014
1 parent f5ecb24 commit 40f7cf5
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 12 deletions.
6 changes: 6 additions & 0 deletions pub/System/AngularSkin/app.uncompressed.css
@@ -1,3 +1,9 @@
.ngLoadTime {
position:fixed;
bottom:0.5em;
right:0.5em;
color:#a1a1a1;
}
.natBusy {
display:none;
}
Expand Down
17 changes: 12 additions & 5 deletions pub/System/AngularSkin/controller.uncompressed.js
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions pub/System/AngularSkin/pkg.uncompressed.css
Expand Up @@ -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;
}
Expand Down
26 changes: 20 additions & 6 deletions pub/System/AngularSkin/pkg.uncompressed.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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);
})
Expand All @@ -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);
});
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion pub/System/AngularSkin/services.uncompressed.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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);
})
Expand All @@ -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);
});
Expand Down
2 changes: 2 additions & 0 deletions templates/foswiki.angular.tmpl
Expand Up @@ -41,3 +41,5 @@ jQuery.extend(foswiki.preferences, {
id="ANGULARPLUGIN::CSS"
text="<link rel='stylesheet' type='text/css' href='%PUBURLPATH%/%SYSTEMWEB%/AngularSkin/pkg.css' media='all' >"
}%%TMPL:END%

%TMPL:DEF{"ng::loadtime"}%<div class="ngLoadTime" ng-if="loadTime" ng-bind-template="{{loadTime}} ms"></div>%TMPL:END%

0 comments on commit 40f7cf5

Please sign in to comment.