diff --git a/angular.html b/angular.html
index 5deac33..fac6e12 100644
--- a/angular.html
+++ b/angular.html
@@ -25,7 +25,6 @@
-
@@ -49,6 +48,7 @@
+
@@ -63,6 +63,7 @@
+
@@ -158,9 +159,19 @@
-
+
+
+
+
+
+
Currently no downloads in line to display, use the Add download button to start downloading files!
@@ -295,8 +306,9 @@
+
+
-
diff --git a/js/ctrls/alert.js b/js/ctrls/alert.js
new file mode 100644
index 0000000..573321f
--- /dev/null
+++ b/js/ctrls/alert.js
@@ -0,0 +1,18 @@
+angular.module('webui.ctrls.alert', [
+ 'webui.services.alerts'
+])
+.controller('AlertCtrl', ['$scope', '$alerts', function(scope, alerts) {
+ scope.pendingAlerts = [];
+
+ scope.removeAlert = function(ind) {
+ this.pendingAlerts.splice(ind, 1);
+ };
+
+ alerts.addAlerter(function(msg, type) {
+ type = type || 'warning';
+ scope.pendingAlerts.push({ msg: msg, type: type });
+ scope.$digest();
+ });
+
+
+}]);
diff --git a/js/ctrls/download.js b/js/ctrls/download.js
index 5f370af..3028582 100644
--- a/js/ctrls/download.js
+++ b/js/ctrls/download.js
@@ -1,9 +1,10 @@
angular
.module('webui.ctrls.download', [
- 'webui.services.utils', 'webui.services.rpc', 'webui.services.settings'
+ 'webui.services.utils', 'webui.services.rpc', 'webui.services.settings',
+ 'webui.services.alerts'
])
-.controller('DownloadCtrl', [ '$scope', '$rpc', '$utils', '$settings',
-function(scope, rpc, utils, sett) {
+.controller('DownloadCtrl', [ '$scope', '$rpc', '$utils', '$settings', '$alerts',
+function(scope, rpc, utils, sett, alerts) {
console.log(sett);
scope.active = [], scope.waiting = [], scope.stopped = [];
diff --git a/js/init.js b/js/init.js
index bb8ea6d..bf87da4 100644
--- a/js/init.js
+++ b/js/init.js
@@ -1,17 +1,18 @@
angular.module('webui', [
'webui.services.utils', 'webui.services.deps', 'webui.services.base64',
- 'webui.services.constants', 'webui.services.rpc', 'webui.services.modals',
+ 'webui.services.constants', 'webui.services.rpc',
+ 'webui.services.modals', 'webui.services.alerts',
'webui.services.settings', 'webui.services.settings.filters',
'webui.filters.bytes', 'webui.filters.path',
'webui.directives.chunkbar', 'webui.directives.dgraph', 'webui.directives.fselect',
- 'webui.ctrls.download', 'webui.ctrls.nav', 'webui.ctrls.modal'
+ 'webui.ctrls.download', 'webui.ctrls.nav', 'webui.ctrls.modal', 'webui.ctrls.alert'
]);
$(function() {
angular.bootstrap(document, [
// external deps
'ui.bootstrap.collapse', 'ui.bootstrap.dropdownToggle',
- 'ui.bootstrap.modal',
+ 'ui.bootstrap.modal', 'ui.bootstrap.alert',
'webui'
])
});
diff --git a/js/services/alerts.js b/js/services/alerts.js
new file mode 100644
index 0000000..24850b7
--- /dev/null
+++ b/js/services/alerts.js
@@ -0,0 +1,17 @@
+angular.module('webui.services.alerts', ['webui.services.deps'])
+.factory('$alerts', ['$_', function(_) {
+ var alerters = [];
+ return {
+ addAlert: function() {
+ var args = Array.prototype.slice.call(arguments, 0);
+ setTimeout(function() {
+ _.each(alerters, function(alt) {
+ alt.apply({}, args);
+ });
+ }, 0);
+ },
+ addAlerter: function(cb) {
+ alerters.push(cb);
+ }
+ };
+}]);
diff --git a/js/services/rpc/rpc.js b/js/services/rpc/rpc.js
index 590d9e7..4c48bc2 100644
--- a/js/services/rpc/rpc.js
+++ b/js/services/rpc/rpc.js
@@ -1,8 +1,8 @@
angular
.module('webui.services.rpc', [
- 'webui.services.rpc.syscall', 'webui.services.constants'
+ 'webui.services.rpc.syscall', 'webui.services.constants', 'webui.services.alerts'
])
- .factory('$rpc', ['$syscall', '$globalTimeout', function(syscall, time) {
+ .factory('$rpc', ['$syscall', '$globalTimeout', '$alerts', function(syscall, time, alerts) {
var subscriptions = []
, configurations = [{ host: 'localhost', port: 6800 }]
, timeout = null
@@ -28,6 +28,10 @@ angular
};
});
+
+ clearTimeout(timeout);
+ timeout = null;
+
syscall.invoke({
name: 'system.multicall',
params: [params],
@@ -54,7 +58,7 @@ angular
// If some proposed configurations are still in the pipeline then retry
if (configurations.length) update();
else {
- console.log('cannot connect!!!');
+ alerts.addAlert('Oh Snap! Could not connect to the aria2 server, retrying after ' + time / 1000 + ' secs', 'error');
timeout = setTimeout(update, time);
}
}
@@ -119,13 +123,14 @@ angular
// force the global syscall update
forceUpdate: function() {
if (timeout) {
+
clearTimeout(timeout);
timeout = null;
+
update();
+
}
- else if (subscriptions.length) {
- update();
- }
+ else if (configurations.length) update();
else {
// a batch call is already in progress,
// wait till it returns and force the next one