diff --git a/app/app.js b/app/app.js index 222d6decd..acc9c0f7f 100644 --- a/app/app.js +++ b/app/app.js @@ -1,4 +1,26 @@ -angular.module('dockerui', ['dockerui.templates', 'ngRoute', 'dockerui.services', 'dockerui.filters', 'masthead', 'footer', 'dashboard', 'container', 'containers', 'containersNetwork', 'images', 'image', 'pullImage', 'startContainer', 'sidebar', 'info', 'builder', 'containerLogs', 'containerTop', 'events', 'stats']) +angular.module('dockerui', [ + 'dockerui.templates', + 'ngRoute', + 'dockerui.services', + 'dockerui.filters', + 'masthead', + 'footer', + 'dashboard', + 'container', + 'containers', + 'containersNetwork', + 'images', + 'image', + 'pullImage', + 'startContainer', + 'sidebar', + 'info', + 'builder', + 'containerLogs', + 'containerTop', + 'events', + 'stats', + 'networks']) .config(['$routeProvider', function ($routeProvider) { 'use strict'; $routeProvider.when('/', { diff --git a/app/components/masthead/masthead.html b/app/components/masthead/masthead.html index c7246c80f..3bb8a0267 100644 --- a/app/components/masthead/masthead.html +++ b/app/components/masthead/masthead.html @@ -5,6 +5,7 @@
  • Containers
  • Containers Network
  • Images
  • +
  • Networks
  • Info
  • diff --git a/app/components/networks/networks.html b/app/components/networks/networks.html new file mode 100644 index 000000000..d6958146a --- /dev/null +++ b/app/components/networks/networks.html @@ -0,0 +1,80 @@ +

    Networks:

    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    SelectNameIdScopeDriverIPAM DriverIPAM SubnetIPAM Gateway
    {{ network.Name|truncate:20}}{{ network.Id }}{{ network.Scope }}{{ network.Driver }}{{ network.IPAM.Driver }}{{ network.IPAM.Config[0].Subnet }}{{ network.IPAM.Config[0].Gateway }}
    +
    +
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    + +
    +
    +
    \ No newline at end of file diff --git a/app/components/networks/networksController.js b/app/components/networks/networksController.js new file mode 100644 index 000000000..c2a10c7e6 --- /dev/null +++ b/app/components/networks/networksController.js @@ -0,0 +1,50 @@ +angular.module('networks', []).config(['$routeProvider', function ($routeProvider) { + $routeProvider.when('/networks', { + templateUrl: 'app/components/networks/networks.html', + controller: 'NetworksController' + }); +}]).controller('NetworksController', ['$scope', 'Network', 'ViewSpinner', 'Messages', + function ($scope, Network, ViewSpinner, Messages) { + $scope.toggle = false; + //$scope.predicate = '-Created'; + + $scope.removeAction = function () { + ViewSpinner.spin(); + var counter = 0; + var complete = function () { + counter = counter - 1; + if (counter === 0) { + ViewSpinner.stop(); + } + }; + angular.forEach($scope.networks, function (network) { + if (network.Checked) { + counter = counter + 1; + Network.remove({id: network.Id}, function (d) { + Messages.send("Network deleted", resource.Deleted); + var index = $scope.networks.indexOf(network); + $scope.networks.splice(index, 1); + complete(); + }, function (e) { + Messages.error("Failure", e.data); + complete(); + }); + } + }); + }; + + $scope.toggleSelectAll = function () { + angular.forEach($scope.images, function (i) { + i.Checked = $scope.toggle; + }); + }; + + ViewSpinner.spin(); + Network.query({}, function (d) { + $scope.networks = d; + ViewSpinner.stop(); + }, function (e) { + Messages.error("Failure", e.data); + ViewSpinner.stop(); + }); + }]); diff --git a/app/components/stats/statsController.js b/app/components/stats/statsController.js index 272ed6939..40d0b4159 100644 --- a/app/components/stats/statsController.js +++ b/app/components/stats/statsController.js @@ -1,21 +1,7 @@ angular.module('stats', []) .controller('StatsController', ['Settings', '$scope', 'Messages', '$timeout', 'Container', '$routeParams', 'humansizeFilter', '$sce', function (Settings, $scope, Messages, $timeout, Container, $routeParams, humansizeFilter, $sce) { - // TODO: Implement memory chart, force scale to 0-100 for cpu, 0 to limit for memory, fix charts on dashboard, + // TODO: Force scale to 0-100 for cpu, fix charts on dashboard, // TODO: Force memory scale to 0 - max memory - //var initialStats = {}; // Used to set scale of memory graph. - // - //Container.stats({id: $routeParams.id}, function (d) { - // var arr = Object.keys(d).map(function (key) { - // return d[key]; - // }); - // if (arr.join('').indexOf('no such id') !== -1) { - // Messages.error('Unable to retrieve stats', 'Is this container running?'); - // return; - // } - // initialStats = d; - //}, function () { - // Messages.error('Unable to retrieve stats', 'Is this container running?'); - //}); var cpuLabels = []; var cpuData = []; diff --git a/app/shared/services.js b/app/shared/services.js index 780726fd5..c19e20304 100644 --- a/app/shared/services.js +++ b/app/shared/services.js @@ -117,6 +117,16 @@ angular.module('dockerui.services', ['ngResource']) get: {method: 'GET'} }); }]) + .factory('Network', ['$resource', 'Settings', function NetworksFactory($resource, Settings) { + 'use strict'; + // http://docs.docker.com/reference/api/docker_remote_api_<%= remoteApiVersion %>/#2-5-networks + return $resource(Settings.url + '/networks/:id/:action', {}, { + query: {method: 'GET', isArray: true}, + get: {method: 'GET'}, + create: {method: 'POST', params: {action: 'create'}}, + remove: {method: 'DELETE', params: {id: '@id'}} + }); + }]) .factory('Settings', ['DOCKER_ENDPOINT', 'DOCKER_PORT', 'DOCKER_API_VERSION', 'UI_VERSION', function SettingsFactory(DOCKER_ENDPOINT, DOCKER_PORT, DOCKER_API_VERSION, UI_VERSION) { 'use strict'; var url = DOCKER_ENDPOINT;