mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 21:35:23 +02:00
feat(host): replace engine view with host view (#2255)
* feat(engine-details): remove old panels * feat(engine-details): add basic engine-details-panel component * feat(engine-details): pass details to the different components * feat(engine-details): replace host-view with host-overview * feat(engine-details): add commaseperated filter * feat(engine-details): add host-view container component * feat(engine-details): add host-details component * feat(engine-details): build host details object * feat(engine-details): format engine version * feat(engine-details): get details for one node * feat(engine-details): pass is-agent from view * feat(engine-details): replace old node view with a new component * feat(engine-details): add swarm-node-details component * feat(engine-details): remove isSwarm binding * feat(engine-details): remove node-details and include in parent * feat(engine-details): add labels-table component * feat(engine-details): add update node service * feat(engine-details): add update label functionality * style(engine-details): remove whitespaces * feat(engine-details): remove old node page * feat(engine-details): pass is agent to host details * feat(host-details): hide missing info * feat(host-details): update node availability * style(host-details): remove obsolete event object * feat(host-details): fix labels not sending * feat(host-details): remove flags for hiding data * feat(host-details): create mock call to server for agent host info * style(host-details): fix spelling mistake in filter's name * feat(host-details): get info from agent * feat(host-details): hide engine labels when empty * feat(node-details): move labels table and save button * feat(host-info): add different urls for refresh * feat(host-details): show disk/devices info for agent * feat(host-view): add loading indicator to devices-panel * feat(host-details): add loading indicator to disks panel * feat(host-details): show devices/disks on standalone agent * refactor(host-details): remove default value * refactor(host-details): remove redundant commaSeperated filter * refactor(host-details): remove unused functions * style(host-details): remove whitespace
This commit is contained in:
parent
275fcf5587
commit
ca08b2fa2a
34 changed files with 737 additions and 528 deletions
|
@ -0,0 +1,96 @@
|
|||
angular
|
||||
.module('portainer.docker')
|
||||
.controller('SwarmNodeDetailsPanelController', [
|
||||
'NodeService', 'LabelHelper', 'Notifications', '$state',
|
||||
function SwarmNodeDetailsPanelController(NodeService, LabelHelper, Notifications, $state) {
|
||||
var ctrl = this;
|
||||
ctrl.state = {
|
||||
managerAddress: '',
|
||||
hasChanges: false
|
||||
};
|
||||
ctrl.$onChanges = $onChanges;
|
||||
ctrl.addLabel = addLabel;
|
||||
ctrl.updateNodeLabels = updateNodeLabels;
|
||||
ctrl.updateNodeAvailability = updateNodeAvailability;
|
||||
ctrl.saveChanges = saveChanges;
|
||||
ctrl.cancelChanges = cancelChanges;
|
||||
|
||||
var managerRole = 'manager';
|
||||
|
||||
function $onChanges() {
|
||||
if (!ctrl.details) {
|
||||
return;
|
||||
}
|
||||
if (ctrl.details.role === managerRole) {
|
||||
ctrl.state.managerAddress = '(' + ctrl.details.managerAddress + ')';
|
||||
}
|
||||
}
|
||||
|
||||
function addLabel() {
|
||||
ctrl.details.nodeLabels.push({
|
||||
key: '',
|
||||
value: '',
|
||||
originalValue: '',
|
||||
originalKey: ''
|
||||
});
|
||||
}
|
||||
|
||||
function updateNodeLabels(labels) {
|
||||
ctrl.details.nodeLabels = labels;
|
||||
ctrl.state.hasChanges = true;
|
||||
}
|
||||
|
||||
function updateNodeAvailability(availability) {
|
||||
ctrl.details.availability = availability;
|
||||
ctrl.state.hasChanges = true;
|
||||
}
|
||||
|
||||
function saveChanges() {
|
||||
var originalNode = ctrl.originalNode;
|
||||
var config = {
|
||||
Name: originalNode.Name,
|
||||
Availability: ctrl.details.availability,
|
||||
Role: originalNode.Role,
|
||||
Labels: LabelHelper.fromKeyValueToLabelHash(ctrl.details.nodeLabels),
|
||||
Id: originalNode.Id,
|
||||
Version: originalNode.Version
|
||||
};
|
||||
|
||||
NodeService.updateNode(config)
|
||||
.then(onUpdateSuccess)
|
||||
.catch(notifyOnError);
|
||||
|
||||
function onUpdateSuccess() {
|
||||
Notifications.success('Node successfully updated', 'Node updated');
|
||||
$state.go(
|
||||
'docker.nodes.node',
|
||||
{ id: originalNode.Id },
|
||||
{ reload: true }
|
||||
);
|
||||
}
|
||||
|
||||
function notifyOnError(error) {
|
||||
Notifications.error('Failure', error, 'Failed to update node');
|
||||
}
|
||||
}
|
||||
|
||||
function cancelChanges() {
|
||||
cancelLabelChanges();
|
||||
ctrl.details.availability = ctrl.originalNode.Availability;
|
||||
ctrl.state.hasChanges = false;
|
||||
}
|
||||
|
||||
function cancelLabelChanges() {
|
||||
ctrl.details.nodeLabels = ctrl.details.nodeLabels
|
||||
.filter(function(label) {
|
||||
return label.originalValue || label.originalKey;
|
||||
})
|
||||
.map(function(label) {
|
||||
return Object.assign(label, {
|
||||
value: label.originalValue,
|
||||
key: label.originalKey
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
]);
|
|
@ -0,0 +1,75 @@
|
|||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<rd-widget>
|
||||
<rd-widget-header icon="fa-code" title-text="Node Details"></rd-widget-header>
|
||||
<rd-widget-body classes="no-padding">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr ng-if="$ctrl.details.name">
|
||||
<td>Node name</td>
|
||||
<td>{{ $ctrl.details.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Role</td>
|
||||
<td>{{ $ctrl.details.role }} {{ $ctrl.state.managerAddress }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Availability</td>
|
||||
<td>
|
||||
<node-availability-select on-save="$ctrl.updateNodeAvailability(availability)"
|
||||
availability="$ctrl.details.availability" original-value="$ctrl.details.availability">
|
||||
</node-availability-select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Status</td>
|
||||
<td><span class="label label-{{ $ctrl.details.status | nodestatusbadge }}">{{
|
||||
$ctrl.details.status }}</span></td>
|
||||
</tr>
|
||||
<tr ng-if=" $ctrl.details.engineLabels.length">
|
||||
<td>Engine Labels</td>
|
||||
<td>{{ $ctrl.details.engineLabels | arraytostr:', ' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="nopadding">
|
||||
<a class="btn btn-default btn-sm pull-right" ng-click="$ctrl.addLabel(node)">
|
||||
<i class="fa fa-plus-circle" aria-hidden="true"></i> label
|
||||
</a>
|
||||
</div>
|
||||
Node Labels
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<node-labels-table labels="$ctrl.details.nodeLabels"
|
||||
on-changed-labels="$ctrl.updateNodeLabels(labels)"></node-labels-table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="btn-toolbar" role="toolbar">
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-primary btn-sm"
|
||||
ng-disabled="!$ctrl.state.hasChanges" ng-click="$ctrl.saveChanges()">
|
||||
Apply changes
|
||||
</button>
|
||||
<button type="button" class="btn btn-default btn-sm dropdown-toggle"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a ng-click="$ctrl.cancelChanges()">Reset changes</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,9 @@
|
|||
angular.module('portainer.docker').component('swarmNodeDetailsPanel', {
|
||||
templateUrl:
|
||||
'app/docker/components/host-view-panels/swarm-node-details-panel/swarm-node-details-panel.html',
|
||||
controller: 'SwarmNodeDetailsPanelController',
|
||||
bindings: {
|
||||
details: '<',
|
||||
originalNode: '<'
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue