mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 21:35:23 +02:00
refactor(app): redesign dashboard-item component [EE-3634] (#7175)
This commit is contained in:
parent
a66fd78dc1
commit
8bf1c91bc9
15 changed files with 236 additions and 248 deletions
|
@ -235,49 +235,6 @@ angular
|
|||
return runningTasks;
|
||||
};
|
||||
})
|
||||
.filter('runningcontainers', function () {
|
||||
'use strict';
|
||||
return function runningContainersFilter(containers) {
|
||||
return containers.filter(function (container) {
|
||||
return container.State === 'running';
|
||||
}).length;
|
||||
};
|
||||
})
|
||||
.filter('stoppedcontainers', function () {
|
||||
'use strict';
|
||||
return function stoppedContainersFilter(containers) {
|
||||
return containers.filter(function (container) {
|
||||
return container.State === 'exited';
|
||||
}).length;
|
||||
};
|
||||
})
|
||||
.filter('healthycontainers', function () {
|
||||
'use strict';
|
||||
return function healthyContainersFilter(containers) {
|
||||
return containers.filter(function (container) {
|
||||
return container.Status === 'healthy';
|
||||
}).length;
|
||||
};
|
||||
})
|
||||
.filter('unhealthycontainers', function () {
|
||||
'use strict';
|
||||
return function unhealthyContainersFilter(containers) {
|
||||
return containers.filter(function (container) {
|
||||
return container.Status === 'unhealthy';
|
||||
}).length;
|
||||
};
|
||||
})
|
||||
.filter('imagestotalsize', function () {
|
||||
'use strict';
|
||||
return function (images) {
|
||||
var totalImageSize = 0;
|
||||
for (var i = 0; i < images.length; i++) {
|
||||
var item = images[i];
|
||||
totalImageSize += item.VirtualSize;
|
||||
}
|
||||
return totalImageSize;
|
||||
};
|
||||
})
|
||||
.filter('tasknodename', function () {
|
||||
'use strict';
|
||||
return function (nodeId, nodes) {
|
||||
|
|
|
@ -28,136 +28,74 @@
|
|||
</span>
|
||||
</information-panel>
|
||||
|
||||
<div class="row" ng-if="(!applicationState.endpoint.mode.agentProxy || applicationState.endpoint.mode.provider !== 'DOCKER_SWARM_MODE') && info && endpoint">
|
||||
<div class="col-sm-12">
|
||||
<rd-widget>
|
||||
<rd-widget-header icon="fa-tachometer-alt" title-text="Environment info"></rd-widget-header>
|
||||
<rd-widget-body classes="no-padding">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Environment</td>
|
||||
<td>
|
||||
{{ endpoint.Name }}
|
||||
<span class="small text-muted space-left">
|
||||
<i class="fa fa-microchip"></i> {{ endpoint.Snapshots[0].TotalCPU }} <i class="fa fa-memory space-left"></i> {{ endpoint.Snapshots[0].TotalMemory | humansize }}
|
||||
</span>
|
||||
<span class="small text-muted">
|
||||
- {{ info.Swarm && info.Swarm.NodeID !== '' ? 'Swarm' : 'Standalone' }} {{ info.ServerVersion }}
|
||||
<span ng-if="endpoint.Type === 2">+ <i class="fa fa-bolt" aria-hidden="true"></i> Agent</span></span
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-if="showEnvUrl">
|
||||
<td>URL</td>
|
||||
<td>{{ endpoint.URL | stripprotocol }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tags</td>
|
||||
<td>{{ endpointTags }}</td>
|
||||
</tr>
|
||||
<tr ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE' && applicationState.endpoint.mode.role === 'MANAGER'">
|
||||
<td colspan="2">
|
||||
<div class="btn-group" role="group" aria-label="...">
|
||||
<a ui-sref="docker.swarm.visualizer"><i class="fa fa-object-group space-right" aria-hidden="true"></i>Go to cluster visualizer</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
<div ng-if="info">
|
||||
<div class="row" ng-if="(!applicationState.endpoint.mode.agentProxy || applicationState.endpoint.mode.provider !== 'DOCKER_SWARM_MODE') && info && endpoint">
|
||||
<div class="col-sm-12">
|
||||
<rd-widget>
|
||||
<rd-widget-header icon="fa-tachometer-alt" title-text="Environment info"></rd-widget-header>
|
||||
<rd-widget-body classes="no-padding">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Environment</td>
|
||||
<td>
|
||||
{{ endpoint.Name }}
|
||||
<span class="small text-muted space-left">
|
||||
<i class="fa fa-microchip"></i> {{ endpoint.Snapshots[0].TotalCPU }} <i class="fa fa-memory space-left"></i> {{ endpoint.Snapshots[0].TotalMemory | humansize }}
|
||||
</span>
|
||||
<span class="small text-muted">
|
||||
- {{ info.Swarm && info.Swarm.NodeID !== '' ? 'Swarm' : 'Standalone' }} {{ info.ServerVersion }}
|
||||
<span ng-if="endpoint.Type === 2">+ <i class="fa fa-bolt" aria-hidden="true"></i> Agent</span></span
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-if="showEnvUrl">
|
||||
<td>URL</td>
|
||||
<td>{{ endpoint.URL | stripprotocol }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tags</td>
|
||||
<td>{{ endpointTags }}</td>
|
||||
</tr>
|
||||
<tr ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE' && applicationState.endpoint.mode.role === 'MANAGER'">
|
||||
<td colspan="2">
|
||||
<div class="btn-group" role="group" aria-label="...">
|
||||
<a ui-sref="docker.swarm.visualizer"><i class="fa fa-object-group space-right" aria-hidden="true"></i>Go to cluster visualizer</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6" ng-if="showStacks">
|
||||
<a ui-sref="docker.stacks">
|
||||
<rd-widget>
|
||||
<rd-widget-body>
|
||||
<div class="widget-icon blue pull-left">
|
||||
<i class="fa fa-th-list"></i>
|
||||
</div>
|
||||
<div class="title">{{ stackCount }}</div>
|
||||
<div class="comment">{{ stackCount === 1 ? 'Stack' : 'Stacks' }}</div>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
<div class="dashboard-grid mx-4">
|
||||
<a ui-sref="docker.stacks" ng-if="showStacks">
|
||||
<dashboard-item icon="'layers'" feather-icon="true" type="'Stack'" value="stackCount"></dashboard-item>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6" ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE' && applicationState.endpoint.mode.role === 'MANAGER'">
|
||||
<a ui-sref="docker.services">
|
||||
<rd-widget>
|
||||
<rd-widget-body>
|
||||
<div class="widget-icon blue pull-left">
|
||||
<i class="fa fa-list-alt"></i>
|
||||
</div>
|
||||
<div class="title">{{ serviceCount }}</div>
|
||||
<div class="comment">{{ serviceCount === 1 ? 'Service' : 'Services' }}</div>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
|
||||
<div ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE' && applicationState.endpoint.mode.role === 'MANAGER'">
|
||||
<a ui-sref="docker.services">
|
||||
<dashboard-item icon="'fa-list-alt'" type="'Service'" value="serviceCount"></dashboard-item>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<a ng-if="containers" ui-sref="docker.containers">
|
||||
<dashboard-item icon="'fa-cubes'" type="'Container'" value="containers.length" children="containerStatusComponent"></dashboard-item>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6" ng-if="containers">
|
||||
<a ui-sref="docker.containers">
|
||||
<rd-widget>
|
||||
<rd-widget-body>
|
||||
<div class="widget-icon blue pull-left">
|
||||
<i class="fa fa-cubes"></i>
|
||||
</div>
|
||||
<div class="pull-right" style="padding-left: 5px">
|
||||
<div><i class="fa fa-power-off space-right green-icon"></i>{{ containers | runningcontainers }} running</div>
|
||||
<div><i class="fa fa-power-off space-right red-icon"></i>{{ containers | stoppedcontainers }} stopped</div>
|
||||
</div>
|
||||
<div class="pull-right" style="padding-right: 5px">
|
||||
<div><i class="fa fa-heartbeat space-right green-icon"></i>{{ containers | healthycontainers }} healthy</div>
|
||||
<div><i class="fa fa-heartbeat space-right orange-icon"></i>{{ containers | unhealthycontainers }} unhealthy</div>
|
||||
</div>
|
||||
<div class="title">{{ containers.length }}</div>
|
||||
<div class="comment">{{ containers.length === 1 ? 'Container' : 'Containers' }}</div>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
|
||||
<a ng-if="images" ui-sref="docker.images">
|
||||
<dashboard-item icon="'fa-clone'" type="'Image'" value="images.length" children="imagesTotalSizeComponent"></dashboard-item>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6" ng-if="images">
|
||||
<a ui-sref="docker.images">
|
||||
<rd-widget>
|
||||
<rd-widget-body>
|
||||
<div class="widget-icon blue pull-left">
|
||||
<i class="fa fa-clone"></i>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<div><i class="fa fa-chart-pie space-right"></i>{{ images | imagestotalsize | humansize }}</div>
|
||||
</div>
|
||||
<div class="title">{{ images.length }}</div>
|
||||
<div class="comment">{{ images.length === 1 ? 'Image' : 'Images' }}</div>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6">
|
||||
|
||||
<a ui-sref="docker.volumes">
|
||||
<rd-widget>
|
||||
<rd-widget-body>
|
||||
<div class="widget-icon blue pull-left">
|
||||
<i class="fa fa-hdd"></i>
|
||||
</div>
|
||||
<div class="title">{{ volumeCount }}</div>
|
||||
<div class="comment">{{ volumeCount === 1 ? 'Volume' : 'Volumes' }}</div>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
<dashboard-item icon="'fa-hdd'" type="'Volume'" value="volumeCount"></dashboard-item>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6">
|
||||
|
||||
<a ui-sref="docker.networks">
|
||||
<rd-widget>
|
||||
<rd-widget-body>
|
||||
<div class="widget-icon blue pull-left">
|
||||
<i class="fa fa-sitemap"></i>
|
||||
</div>
|
||||
<div class="title">{{ networkCount }}</div>
|
||||
<div class="comment">{{ networkCount === 1 ? 'Network' : 'Networks' }}</div>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
<dashboard-item icon="'fa-sitemap'" type="'Network'" value="networkCount"></dashboard-item>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -3,6 +3,8 @@ import _ from 'lodash';
|
|||
|
||||
import { isOfflineEndpoint } from '@/portainer/helpers/endpointHelper';
|
||||
import { PortainerEndpointTypes } from 'Portainer/models/endpoint/models';
|
||||
import { useContainerStatusComponent } from '@/react/docker/DashboardView/ContainerStatus';
|
||||
import { useImagesTotalSizeComponent } from '@/react/docker/DashboardView/ImagesTotalSize';
|
||||
|
||||
angular.module('portainer.docker').controller('DashboardController', [
|
||||
'$scope',
|
||||
|
@ -60,7 +62,11 @@ angular.module('portainer.docker').controller('DashboardController', [
|
|||
})
|
||||
.then(function success(data) {
|
||||
$scope.containers = data.containers;
|
||||
$scope.containerStatusComponent = useContainerStatusComponent(data.containers);
|
||||
|
||||
$scope.images = data.images;
|
||||
$scope.imagesTotalSizeComponent = useImagesTotalSizeComponent(imagesTotalSize(data.images));
|
||||
|
||||
$scope.volumeCount = data.volumes.length;
|
||||
$scope.networkCount = data.networks.length;
|
||||
$scope.serviceCount = data.services.length;
|
||||
|
@ -94,3 +100,7 @@ angular.module('portainer.docker').controller('DashboardController', [
|
|||
initView();
|
||||
},
|
||||
]);
|
||||
|
||||
function imagesTotalSize(images) {
|
||||
return images.reduce((acc, image) => acc + image.VirtualSize, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue