diff --git a/dashboard/src/js/index.js b/dashboard/src/js/index.js index f89462089..0933ae4fd 100644 --- a/dashboard/src/js/index.js +++ b/dashboard/src/js/index.js @@ -16,6 +16,22 @@ if (search.accessToken) { window.location.search = encodeURIComponent(Object.keys(search).map(function (key) { return key + '=' + search[key]; }).join('&')); } +// poor man's async in the global namespace +function asyncForEach(items, handler, callback) { + var cur = 0; + + if (items.length === 0) return callback(); + + (function iterator() { + handler(items[cur], function (error) { + if (error) return callback(error); + if (cur >= items.length-1) return callback(); + ++cur; + + iterator(); + }); + })(); +} // create main application module var app = angular.module('Application', ['ngFitText', 'ngRoute', 'ngAnimate', 'ngSanitize', 'angular-md5', 'base64', 'slick', 'ui-notification', 'ui.bootstrap', 'ui.bootstrap-slider', 'ngTld', 'ui.multiselect']); diff --git a/dashboard/src/views/account.js b/dashboard/src/views/account.js index 12be51572..8843b27df 100644 --- a/dashboard/src/views/account.js +++ b/dashboard/src/views/account.js @@ -1,5 +1,7 @@ 'use strict'; +/* global asyncForEach:false */ + angular.module('Application').controller('AccountController', ['$scope', 'Client', function ($scope, Client) { $scope.user = Client.getUserInfo(); $scope.config = Client.getConfig(); @@ -208,23 +210,6 @@ angular.module('Application').controller('AccountController', ['$scope', 'Client } }; - // poor man's async - function asyncForEach(items, handler, callback) { - var cur = 0; - - if (items.length === 0) return callback(); - - (function iterator() { - handler(items[cur], function (error) { - if (error) return callback(error); - if (cur >= items.length-1) return callback(); - ++cur; - - iterator(); - }); - })(); - } - function revokeTokensByClient(client, callback) { Client.delTokensByClientId(client.id, function (error) { if (error) console.error(error); diff --git a/dashboard/src/views/email.js b/dashboard/src/views/email.js index c0db86dce..3d3dacff6 100644 --- a/dashboard/src/views/email.js +++ b/dashboard/src/views/email.js @@ -1,5 +1,7 @@ 'use strict'; +/* global asyncForEach:false */ + angular.module('Application').controller('EmailController', ['$scope', '$location', '$timeout', '$rootScope', 'Client', 'AppStore', function ($scope, $location, $timeout, $rootScope, Client, AppStore) { Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); }); @@ -42,23 +44,6 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio return $scope.mailRelay.relay.provider === provider; }; - // poor man's async - function asyncForEach(items, handler, callback) { - var cur = 0; - - if (items.length === 0) return callback(); - - (function iterator() { - handler(items[cur], function (error) { - if (error) return callback(error); - if (cur >= items.length-1) return callback(); - ++cur; - - iterator(); - }); - })(); - } - $scope.catchall = { addresses: [], availableAddresses: [], diff --git a/dashboard/src/views/graphs.js b/dashboard/src/views/graphs.js index c64aabf12..963a926c1 100644 --- a/dashboard/src/views/graphs.js +++ b/dashboard/src/views/graphs.js @@ -1,4 +1,5 @@ -/* global Chart:true */ +/* global Chart:false */ +/* global asyncForEach:false */ 'use strict'; @@ -123,7 +124,7 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati // /dev/sda1 -> sda1 // /dev/mapper/foo -> mapper_foo (see #348) - var appDataDiskName = disks.appsDataDisk.slice(disks.appsDataDisk.indexOf('/', 1) + 1) + var appDataDiskName = disks.appsDataDisk.slice(disks.appsDataDisk.indexOf('/', 1) + 1); appDataDiskName = appDataDiskName.replace(/\//g, '_'); Client.graphs([ @@ -172,23 +173,6 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati }); }; - // poor man's async - function asyncForEach(items, handler, callback) { - var cur = 0; - - if (items.length === 0) return callback(); - - (function iterator() { - handler(items[cur], function (error) { - if (error) return callback(error); - if (cur >= items.length-1) return callback(); - ++cur; - - iterator(); - }); - })(); - } - $scope.updateMemoryAppsChart = function () { var targets = []; var targetsInfo = []; diff --git a/dashboard/src/views/users.js b/dashboard/src/views/users.js index be857690a..4bbd7af0e 100644 --- a/dashboard/src/views/users.js +++ b/dashboard/src/views/users.js @@ -1,23 +1,7 @@ 'use strict'; -/* global Clipboard */ - -// poor man's async -function asyncForEach(items, handler, callback) { - var cur = 0; - - if (items.length === 0) return callback(); - - (function iterator() { - handler(items[cur], function (error) { - if (error) return callback(error); - if (cur >= items.length-1) return callback(); - ++cur; - - iterator(); - }); - })(); -} +/* global Clipboard:false */ +/* global asyncForEach:false */ angular.module('Application').controller('UsersController', ['$scope', '$location', '$timeout', 'Client', function ($scope, $location, $timeout, Client) { Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });