mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
Move dashboard to its own submodule.
This commit is contained in:
parent
20b7e16ed4
commit
3b0ea539b8
5 changed files with 75 additions and 74 deletions
|
@ -1,8 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('dockerui', ['ngRoute', 'dockerui.services', 'dockerui.filters', 'masthead', 'footer'])
|
angular.module('dockerui', ['ngRoute', 'dockerui.services', 'dockerui.filters', 'masthead', 'footer', 'dashboard'])
|
||||||
.config(['$routeProvider', function ($routeProvider) {
|
.config(['$routeProvider', function ($routeProvider) {
|
||||||
$routeProvider.when('/', {templateUrl: 'partials/dashboard.html', controller: 'DashboardController'});
|
$routeProvider.when('/', {templateUrl: 'app/components/dashboard/dashboard.html', controller: 'DashboardController'});
|
||||||
$routeProvider.when('/containers/', {templateUrl: 'partials/containers.html', controller: 'ContainersController'});
|
$routeProvider.when('/containers/', {templateUrl: 'partials/containers.html', controller: 'ContainersController'});
|
||||||
$routeProvider.when('/containers/:id/', {templateUrl: 'partials/container.html', controller: 'ContainerController'});
|
$routeProvider.when('/containers/:id/', {templateUrl: 'partials/container.html', controller: 'ContainerController'});
|
||||||
$routeProvider.when('/images/', {templateUrl: 'partials/images.html', controller: 'ImagesController'});
|
$routeProvider.when('/images/', {templateUrl: 'partials/images.html', controller: 'ImagesController'});
|
||||||
|
|
72
app/components/dashboard/dashboardController.js
Normal file
72
app/components/dashboard/dashboardController.js
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
angular.module('dashboard', [])
|
||||||
|
.controller('DashboardController', ['$scope', 'Container', 'Image', 'Settings', function($scope, Container, Image, Settings) {
|
||||||
|
$scope.predicate = '-Created';
|
||||||
|
$scope.containers = [];
|
||||||
|
|
||||||
|
var getStarted = function(data) {
|
||||||
|
$scope.totalContainers = data.length;
|
||||||
|
newLineChart('#containers-started-chart', data, function(c) { return new Date(c.Created * 1000).toLocaleDateString(); });
|
||||||
|
var s = $scope;
|
||||||
|
Image.query({}, function(d) {
|
||||||
|
s.totalImages = d.length;
|
||||||
|
newLineChart('#images-created-chart', d, function(c) { return new Date(c.Created * 1000).toLocaleDateString(); });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var opts = {animation:false};
|
||||||
|
if (Settings.firstLoad) {
|
||||||
|
$('#stats').hide();
|
||||||
|
opts.animation = true;
|
||||||
|
Settings.firstLoad = false;
|
||||||
|
$('#masthead').show();
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
$('#masthead').slideUp('slow');
|
||||||
|
$('#stats').slideDown('slow');
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
Container.query({all: 1}, function(d) {
|
||||||
|
var running = 0
|
||||||
|
var ghost = 0;
|
||||||
|
var stopped = 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < d.length; i++) {
|
||||||
|
var item = d[i];
|
||||||
|
|
||||||
|
if (item.Status === "Ghost") {
|
||||||
|
ghost += 1;
|
||||||
|
} else if (item.Status.indexOf('Exit') !== -1) {
|
||||||
|
stopped += 1;
|
||||||
|
} else {
|
||||||
|
running += 1;
|
||||||
|
$scope.containers.push(new ContainerViewModel(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getStarted(d);
|
||||||
|
|
||||||
|
var c = getChart('#containers-chart');
|
||||||
|
var data = [
|
||||||
|
{
|
||||||
|
value: running,
|
||||||
|
color: '#5bb75b',
|
||||||
|
title: 'Running'
|
||||||
|
}, // running
|
||||||
|
{
|
||||||
|
value: stopped,
|
||||||
|
color: '#C7604C',
|
||||||
|
title: 'Stopped'
|
||||||
|
}, // stopped
|
||||||
|
{
|
||||||
|
value: ghost,
|
||||||
|
color: '#E2EAE9',
|
||||||
|
title: 'Ghost'
|
||||||
|
} // ghost
|
||||||
|
];
|
||||||
|
|
||||||
|
c.Doughnut(data, opts);
|
||||||
|
var lgd = $('#chart-legend').get(0);
|
||||||
|
legend(lgd, data);
|
||||||
|
});
|
||||||
|
}]);
|
|
@ -42,78 +42,6 @@ function newLineChart(id, data, getkey) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function DashboardController($scope, Container, Image, Settings) {
|
|
||||||
$scope.predicate = '-Created';
|
|
||||||
$scope.containers = [];
|
|
||||||
|
|
||||||
var getStarted = function(data) {
|
|
||||||
$scope.totalContainers = data.length;
|
|
||||||
newLineChart('#containers-started-chart', data, function(c) { return new Date(c.Created * 1000).toLocaleDateString(); });
|
|
||||||
var s = $scope;
|
|
||||||
Image.query({}, function(d) {
|
|
||||||
s.totalImages = d.length;
|
|
||||||
newLineChart('#images-created-chart', d, function(c) { return new Date(c.Created * 1000).toLocaleDateString(); });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var opts = {animation:false};
|
|
||||||
if (Settings.firstLoad) {
|
|
||||||
$('#stats').hide();
|
|
||||||
opts.animation = true;
|
|
||||||
Settings.firstLoad = false;
|
|
||||||
$('#masthead').show();
|
|
||||||
|
|
||||||
setTimeout(function() {
|
|
||||||
$('#masthead').slideUp('slow');
|
|
||||||
$('#stats').slideDown('slow');
|
|
||||||
}, 5000);
|
|
||||||
}
|
|
||||||
|
|
||||||
Container.query({all: 1}, function(d) {
|
|
||||||
var running = 0
|
|
||||||
var ghost = 0;
|
|
||||||
var stopped = 0;
|
|
||||||
|
|
||||||
for (var i = 0; i < d.length; i++) {
|
|
||||||
var item = d[i];
|
|
||||||
|
|
||||||
if (item.Status === "Ghost") {
|
|
||||||
ghost += 1;
|
|
||||||
} else if (item.Status.indexOf('Exit') !== -1) {
|
|
||||||
stopped += 1;
|
|
||||||
} else {
|
|
||||||
running += 1;
|
|
||||||
$scope.containers.push(new ContainerViewModel(item));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getStarted(d);
|
|
||||||
|
|
||||||
var c = getChart('#containers-chart');
|
|
||||||
var data = [
|
|
||||||
{
|
|
||||||
value: running,
|
|
||||||
color: '#5bb75b',
|
|
||||||
title: 'Running'
|
|
||||||
}, // running
|
|
||||||
{
|
|
||||||
value: stopped,
|
|
||||||
color: '#C7604C',
|
|
||||||
title: 'Stopped'
|
|
||||||
}, // stopped
|
|
||||||
{
|
|
||||||
value: ghost,
|
|
||||||
color: '#E2EAE9',
|
|
||||||
title: 'Ghost'
|
|
||||||
} // ghost
|
|
||||||
];
|
|
||||||
|
|
||||||
c.Doughnut(data, opts);
|
|
||||||
var lgd = $('#chart-legend').get(0);
|
|
||||||
legend(lgd, data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getChart(id) {
|
function getChart(id) {
|
||||||
var ctx = $(id).get(0).getContext("2d");
|
var ctx = $(id).get(0).getContext("2d");
|
||||||
return new Chart(ctx);
|
return new Chart(ctx);
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
<!-- TODO: Add minification build step -->
|
<!-- TODO: Add minification build step -->
|
||||||
<script src="app/components/masthead/mastheadController.js"></script>
|
<script src="app/components/masthead/mastheadController.js"></script>
|
||||||
<script src="app/components/footer/footerController.js"></script>
|
<script src="app/components/footer/footerController.js"></script>
|
||||||
|
<script src="app/components/dashboard/dashboardController.js"></script>
|
||||||
<script src="app/viewmodel.js"></script>
|
<script src="app/viewmodel.js"></script>
|
||||||
|
|
||||||
<!-- Fav and touch icons -->
|
<!-- Fav and touch icons -->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue