alert timeouts and error codes from ari2 now show as alerts

This commit is contained in:
hamza zia 2013-02-22 20:44:10 +01:00
parent 3c86459004
commit 7d1129275b
4 changed files with 17 additions and 8 deletions

View File

@ -10,7 +10,14 @@ angular.module('webui.ctrls.alert', [
alerts.addAlerter(function(msg, type) { alerts.addAlerter(function(msg, type) {
type = type || 'warning'; type = type || 'warning';
scope.pendingAlerts.push({ msg: msg, type: type }); var obj = { msg: msg, type: type };
scope.pendingAlerts.push(obj);
setTimeout(function() {
var ind = scope.pendingAlerts.indexOf(obj);
if (ind != -1) scope.removeAlert(ind);
}, 5000);
scope.$digest(); scope.$digest();
}); });

View File

@ -5,7 +5,6 @@ angular
]) ])
.controller('DownloadCtrl', [ '$scope', '$rpc', '$utils', '$settings', '$alerts', .controller('DownloadCtrl', [ '$scope', '$rpc', '$utils', '$settings', '$alerts',
function(scope, rpc, utils, sett, alerts) { function(scope, rpc, utils, sett, alerts) {
console.log(sett);
scope.active = [], scope.waiting = [], scope.stopped = []; scope.active = [], scope.waiting = [], scope.stopped = [];
// pause the download // pause the download
@ -52,7 +51,6 @@ function(scope, rpc, utils, sett, alerts) {
// start filling in the model of active, // start filling in the model of active,
// waiting and stopped download // waiting and stopped download
rpc.subscribe('tellActive', [], function(data) { rpc.subscribe('tellActive', [], function(data) {
console.log('got active data');
scope.$apply(function() { scope.$apply(function() {
utils.mergeMap(data[0], scope.active, scope.getCtx); utils.mergeMap(data[0], scope.active, scope.getCtx);
}); });

View File

@ -1,11 +1,11 @@
angular.module('webui.services.rpc.helpers', [ angular.module('webui.services.rpc.helpers', [
'webui.services.deps', 'webui.services.rpc' 'webui.services.deps', 'webui.services.rpc', 'webui.services.alerts'
]) ])
.factory('$rpchelpers', ['$_', '$rpc', function(_, rpc) { .factory('$rpchelpers', ['$_', '$rpc', '$alerts', function(_, rpc, alerts) {
return { return {
addUris: function(uris) { addUris: function(uris) {
var cnt = 0; var cnt = 0;
var cb = function(ret) { var cb = function(data) {
cnt--; cnt--;
if (!cnt) { if (!cnt) {
// close modal // close modal
@ -23,7 +23,7 @@ angular.module('webui.services.rpc.helpers', [
}, },
addTorrents: function(txts) { addTorrents: function(txts) {
var cnt = 0; var cnt = 0;
var cb = function(ret) { var cb = function(data) {
cnt--; cnt--;
if (!cnt) { if (!cnt) {
// close modal // close modal
@ -41,7 +41,7 @@ angular.module('webui.services.rpc.helpers', [
}, },
addMetalinks: function(txts) { addMetalinks: function(txts) {
var cnt = 0; var cnt = 0;
var cb = function(ret) { var cb = function(data) {
cnt--; cnt--;
if (!cnt) { if (!cnt) {
// close modal // close modal

View File

@ -36,11 +36,15 @@ angular
name: 'system.multicall', name: 'system.multicall',
params: [params], params: [params],
success: function(data) { success: function(data) {
// configuration worked, leave this as it is // configuration worked, leave this as it is
configurations = []; configurations = [];
_.each(data.result, function(d, i) { _.each(data.result, function(d, i) {
var handle = subscriptions[i]; var handle = subscriptions[i];
if (handle) { if (handle) {
if (d.code) {
alerts.addAlert(d.message, 'error');
}
handle.cb(d); handle.cb(d);
if (handle.once) { if (handle.once) {
subscriptions[i] = null; subscriptions[i] = null;