diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-13 10:58:05 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-13 10:58:05 +0100 |
commit | 694e8b03515f25e36cef855eddb835355eff4c51 (patch) | |
tree | e16af178da1aa9148cd5f5e63d861d4871a2c9ba /src/main/resources/webapp/apps/core/PagingTableService.js | |
parent | 27d74ce4423d2ec48a9289169c97958526fed77b (diff) | |
download | esper-testing-694e8b03515f25e36cef855eddb835355eff4c51.tar.gz esper-testing-694e8b03515f25e36cef855eddb835355eff4c51.tar.bz2 esper-testing-694e8b03515f25e36cef855eddb835355eff4c51.tar.xz esper-testing-694e8b03515f25e36cef855eddb835355eff4c51.zip |
PagingTableService:
o Adding support for showing a spinner if the query takes more than 500ms.
o Adding a spinner when searching for people.
Diffstat (limited to 'src/main/resources/webapp/apps/core/PagingTableService.js')
-rwxr-xr-x | src/main/resources/webapp/apps/core/PagingTableService.js | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/main/resources/webapp/apps/core/PagingTableService.js b/src/main/resources/webapp/apps/core/PagingTableService.js index f38b6f1..86d08f1 100755 --- a/src/main/resources/webapp/apps/core/PagingTableService.js +++ b/src/main/resources/webapp/apps/core/PagingTableService.js @@ -7,15 +7,29 @@ function PagingTableService() { query: "", startIndex: options.startIndex || 0, count: options.count || 10, - currentlySearching: false + currentlySearching: false, + queryStart: 0 }; var update = function(){ self.currentlySearching = true; + self.queryStart = new Date().getTime(); + + // This will update the spinner if the user want to show it. + var interval = setInterval(function () { + $scope.$apply(); + }, 500); + fetchCallback(self.startIndex, self.count, self.query, function(data) { + var now = new Date().getTime(); + console.log("Query took " + (now - self.queryStart) + "ms"); + + clearInterval(interval); + self.rows = data.rows; watcher(); self.currentlySearching = false; + self.queryStart = 0; }); }; @@ -56,6 +70,20 @@ function PagingTableService() { update(); }; + /* + * UI State queries + * + * TODO: the results should only be shown if the last query was successful. Add an 'error' state too. + */ + + self.showSpinner = function () { + return self.currentlySearching && new Date().getTime() - self.queryStart > 500; + }; + + self.showResults = function () { + return !self.currentlySearching; + }; + self.showPrev = function () { return self.startIndex > 0; }; |