Bri Prebilic Cole

ONOS-2143 - GUI -- Tabular views display a loading wheel while waiting for a server response.

Change-Id: I2e2dbb4189a76c168aaa0cc03871eacc3ffd8d12
......@@ -144,6 +144,45 @@
'83.5,37.7c0-2.1-1.2-3.8-2.7-3.8h-0.7c-1.5,0-2.7,1.7-2.7,3.8v55.9' +
'c0,2.1,1.2,3.8,2.7,3.8h0.7c1.5,0,2.7-1.7,2.7-3.8V37.7z',
loading: 'M103.1,53.1c0,0,0,0.2,0,0.5c0,0.2,0,0.4,0,0.7c0,0.3,0,0' +
'.6,0,0.9c-0.1,1.3-0.2,3-0.5,4.8c-0.5,3.4-1.6,6.8-1.6,6.8l-9.2-2.' +
'7c0,0,0.8-2.7,1.1-5.5c0.2-1.4,0.3-2.8,0.3-3.8c0-0.3,0-0.5,0-0.7c' +
'0-0.2,0-0.4,0-0.6c0-0.3,0-0.5,0-0.5L103.1,53.1z M87.3,74.3c0,0-0' +
'.1,0.2-0.3,0.5c-0.2,0.3-0.4,0.6-0.7,1.1c-0.6,0.9-1.4,2-2.3,3.1c-' +
'1.8,2.2-3.9,4.1-3.9,4.1l5.7,6.5c0,0,0.7-0.5,1.6-1.4c1-0.9,2.2-2.' +
'1,3.3-3.4c1.1-1.3,2.2-2.6,3-3.7c0.4-0.5,0.7-1,0.9-1.3c0.2-0.3,0.' +
'3-0.4,0.3-0.4L87.3,74.3z M70.8,89.2c0,0-0.2,0.1-0.5,0.2c-0.3,0.2' +
'-0.6,0.3-1.2,0.5c-1,0.4-2.3,0.9-3.7,1.4c-2.7,0.9-5.5,1.3-5.5,1.3' +
'l1.1,7.6c0,0,0.8-0.1,2.1-0.3c1.3-0.2,2.9-0.6,4.6-1c1.6-0.5,3.3-1' +
',4.5-1.5c0.6-0.2,1.2-0.5,1.5-0.6c0.3-0.1,0.5-0.2,0.5-0.2L70.8,89' +
'.2z M48.6,92.9c0,0-0.2,0-0.5-0.1c-0.4,0-0.7-0.1-1.3-0.2c-1.1-0.2' +
'-2.5-0.5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.9,2.2c-1.4,0.9-2.7,1.8-3' +
'.7,2.5c-0.5,0.4-0.9,0.7-1.2,0.9c-0.3,0.2-0.4,0.3-0.4,0.3L26.7,21' +
'.3z M48.2,11c0,0,0.2,0,0.5-0.1c0.3,0,0.8-0.1,1.4-0.2c1.1-0.1,2.6' +
'-0.3,4.2-0.3c3-0.1,6.1,0.3,6.1,0.3l0.3-2.3c0,0-0.8-0.1-2-0.3C57.' +
'4,8.1,55.8,8,54.2,8c-1.6,0-3.2,0-4.4,0.1c-0.6,0-1.1,0.1-1.5,0.1c' +
'-0.3,0-0.5,0.1-0.5,0.1L48.2,11z M72,14c0,0,0.7,0.3,1.7,0.8c1,0.5' +
',2.4,1.2,3.7,2c2.6,1.6,5,3.6,5,3.6l0.9-1c0,0-2.4-2.1-5-3.9c-1.3-' +
'0.9-2.7-1.7-3.8-2.3c-1.1-0.6-1.8-0.9-1.8-0.9L72,14zM90.7,29.6c0,' +
'0,0.4,0.6,1,1.6c0.6,1,1.4,2.3,2,3.7c0.7,1.4,1.3,2.8,1.7,3.9c0.4,' +
'1.1,0.6,1.8,0.6,1.8l0.4-0.1c0,0-0.2-0.8-0.6-1.9c-0.4-1.1-0.9-2.6' +
'-1.5-4c-0.6-1.4-1.3-2.9-1.9-3.9c-0.6-1-1-1.7-1-1.7L90.7,29.6z',
// --- Navigation glyphs ------------------------------------
flowTable: 'M15.9,19.1h-8v-13h8V19.1z M90.5,6.1H75.6v13h14.9V6.1z' +
......
......@@ -43,6 +43,8 @@
upArrow: 'triangleUp',
downArrow: 'triangleDown',
loading: 'loading',
appInactive: 'unknown',
devIcon_SWITCH: 'switch',
......
......@@ -22,6 +22,31 @@ div.summary-list {
border-spacing: 0;
}
div.loading-wheel {
display: inline-block;
position: absolute;
margin-top: 40px;
left: 47%;
animation: spin reverse 2s ease infinite;
z-index: 1000;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
div.loading-wheel svg.embeddedIcon g.icon .glyph {
opacity: .8;
}
.light div.loading-wheel svg.embeddedIcon g.icon .glyph {
fill: #964949;
}
.dark div.loading-wheel svg.embeddedIcon g.icon .glyph {
fill: whitesmoke;
}
div.summary-list table {
border-collapse: collapse;
table-layout: fixed;
......
......@@ -21,10 +21,11 @@
'use strict';
// injected refs
var $log, $interval, fs, wss;
var $log, $interval, $timeout, fs, wss;
// constants
var refreshInterval = 2000;
var refreshInterval = 2000,
loadingWait = 500;
// example params to buildTable:
// {
......@@ -47,17 +48,21 @@
onSel = fs.isF(o.selCb),
onResp = fs.isF(o.respCb),
oldTableData = [],
promise;
loaded = false,
refreshPromise, loadingPromise;
o.scope.tableData = [];
o.scope.changedData = [];
o.scope.sortParams = {};
o.scope.loading = true;
o.scope.autoRefresh = true;
o.scope.autoRefreshTip = 'Toggle auto refresh';
// === websocket functions --------------------
// response
function respCb(data) {
loaded = true;
o.scope.loading = false;
o.scope.tableData = data[root];
onResp && onResp();
......@@ -83,9 +88,20 @@
function sortCb(params) {
var p = angular.extend({}, params, o.query);
wss.sendEvent(req, p);
stillLoading();
}
o.scope.sortCallback = sortCb;
// show loading wheel if it's taking a while for the server to respond
function stillLoading() {
loaded = false;
loadingPromise = $timeout(function () {
if (!loaded) {
o.scope.loading = true;
}
}, loadingWait);
}
// === selecting a row functions ----------------
function selCb($event, selRow) {
o.scope.selId = (o.scope.selId === selRow.id) ? null : selRow.id;
......@@ -95,7 +111,7 @@
// === autoRefresh functions ------------------
function startRefresh() {
promise = $interval(function () {
refreshPromise = $interval(function () {
if (fs.debugOn('widget')) {
$log.debug('Refreshing ' + root + ' page');
}
......@@ -104,9 +120,9 @@
}
function stopRefresh() {
if (angular.isDefined(promise)) {
$interval.cancel(promise);
promise = undefined;
if (angular.isDefined(refreshPromise)) {
$interval.cancel(refreshPromise);
refreshPromise = undefined;
}
}
......@@ -120,6 +136,10 @@
o.scope.$on('$destroy', function () {
wss.unbindHandlers(handlers);
stopRefresh();
if (angular.isDefined(loadingPromise)) {
$timeout.cancel(loadingPromise);
loadingPromise = undefined;
}
});
sortCb();
......@@ -128,11 +148,12 @@
angular.module('onosWidget')
.factory('TableBuilderService',
['$log', '$interval', 'FnService', 'WebSocketService',
['$log', '$interval', '$timeout', 'FnService', 'WebSocketService',
function (_$log_, _$interval_, _fs_, _wss_) {
function (_$log_, _$interval_, _$timeout_, _fs_, _wss_) {
$log = _$log_;
$interval = _$interval_;
$timeout = _$timeout_;
fs = _fs_;
wss = _wss_;
......
......@@ -37,6 +37,8 @@
</div>
<div class="summary-list" onos-table-resize>
<div ng-show="loading" class="loading-wheel"
icon icon-id="loading" icon-size="75"></div>
<div class="table-header" onos-sortable-header>
<table>
......
......@@ -27,6 +27,8 @@
</div>
<div class="summary-list" onos-table-resize>
<div ng-show="loading" class="loading-wheel"
icon icon-id="loading" icon-size="75"></div>
<div class="table-header" onos-sortable-header>
<table>
......
......@@ -27,6 +27,8 @@
</div>
<div class="summary-list" onos-table-resize>
<div ng-show="loading" class="loading-wheel"
icon icon-id="loading" icon-size="75"></div>
<div class="table-header" onos-sortable-header>
<table>
......
......@@ -29,6 +29,8 @@
</div>
<div class="summary-list" onos-table-resize>
<div ng-show="loading" class="loading-wheel"
icon icon-id="loading" icon-size="75"></div>
<div class="table-header" onos-sortable-header>
<table>
......
......@@ -45,6 +45,8 @@
</div>
<div class="summary-list" onos-table-resize>
<div ng-show="loading" class="loading-wheel"
icon icon-id="loading" icon-size="75"></div>
<div class="table-header" onos-sortable-header>
<table>
......
......@@ -11,6 +11,8 @@
</div>
<div class="summary-list" onos-table-resize>
<div ng-show="loading" class="loading-wheel"
icon icon-id="loading" icon-size="75"></div>
<div class="table-header" onos-sortable-header>
<table>
......
......@@ -27,6 +27,8 @@
</div>
<div class="summary-list" onos-table-resize>
<div ng-show="loading" class="loading-wheel"
icon icon-id="loading" icon-size="75"></div>
<div class="table-header" onos-sortable-header>
<table>
......
......@@ -27,6 +27,8 @@
</div>
<div class="summary-list" onos-table-resize>
<div ng-show="loading" class="loading-wheel"
icon icon-id="loading" icon-size="75"></div>
<div class="table-header" onos-sortable-header>
<table>
......
......@@ -45,6 +45,8 @@
</div>
<div class="summary-list" onos-table-resize>
<div ng-show="loading" class="loading-wheel"
icon icon-id="loading" icon-size="75"></div>
<div class="table-header" onos-sortable-header>
<table>
......
......@@ -11,6 +11,8 @@
</div>
<div class="summary-list" onos-table-resize>
<div ng-show="loading" class="loading-wheel"
icon icon-id="loading" icon-size="75"></div>
<div class="table-header" onos-sortable-header>
<table>
......