mirror of
https://github.com/portainer/portainer.git
synced 2025-08-07 23:05:26 +02:00
feat(endpoints): improve offline banner UX (#2462)
* feat(endpoints): add the last snapshot timestamp in offline banner * feat(endpoints): add the ability to refresh a snapshot in the offline banner
This commit is contained in:
parent
cf370f6a4c
commit
0825d05546
9 changed files with 133 additions and 33 deletions
|
@ -4,5 +4,12 @@
|
|||
<i class="fa fa-exclamation-circle orange-icon" aria-hidden="true" style="margin-right: 2px;"></i>
|
||||
This endpoint is currently offline (read-only). Data shown is based on the latest available snapshot.
|
||||
</p>
|
||||
<p class="text-muted">
|
||||
<i class="fa fa-clock" aria-hidden="true" style="margin-right: 2px;"></i>
|
||||
Last snapshot: {{ $ctrl.snapshotTime | getisodatefromtimestamp }}
|
||||
</p>
|
||||
<button type="button" class="btn btn-xs btn-primary" ng-click="$ctrl.triggerSnapshot()" ng-if="$ctrl.showRefreshButton">
|
||||
<i class="fa fa-sync space-right" aria-hidden="true"></i>Refresh
|
||||
</button>
|
||||
</span>
|
||||
</information-panel>
|
||||
</information-panel>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
angular.module('portainer.app').component('informationPanelOffline', {
|
||||
templateUrl: 'app/portainer/components/information-panel-offline/informationPanelOffline.html',
|
||||
transclude: true
|
||||
controller: 'InformationPanelOfflineController'
|
||||
});
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
angular.module('portainer.app').controller('InformationPanelOfflineController', ['$state', 'EndpointProvider', 'EndpointService', 'Authentication', 'Notifications',
|
||||
function StackDuplicationFormController($state, EndpointProvider, EndpointService, Authentication, Notifications) {
|
||||
var ctrl = this;
|
||||
|
||||
this.$onInit = onInit;
|
||||
this.triggerSnapshot = triggerSnapshot;
|
||||
|
||||
function triggerSnapshot() {
|
||||
var endpointId = EndpointProvider.endpointID();
|
||||
|
||||
EndpointService.snapshotEndpoint(endpointId)
|
||||
.then(function onSuccess() {
|
||||
$state.reload();
|
||||
})
|
||||
.catch(function onError(err) {
|
||||
Notifications.error('Failure', err, 'An error occured during endpoint snapshot');
|
||||
});
|
||||
}
|
||||
|
||||
function onInit() {
|
||||
var endpointId = EndpointProvider.endpointID();
|
||||
ctrl.showRefreshButton = Authentication.getUserDetails().role === 1;
|
||||
|
||||
|
||||
EndpointService.endpoint(endpointId)
|
||||
.then(function onSuccess(data) {
|
||||
ctrl.snapshotTime = data.Snapshots[0].Time;
|
||||
})
|
||||
.catch(function onError(err) {
|
||||
Notifications.error('Failure', err, 'Unable to retrieve endpoint information');
|
||||
});
|
||||
}
|
||||
|
||||
}]);
|
|
@ -7,7 +7,8 @@ angular.module('portainer.app')
|
|||
update: { method: 'PUT', params: { id: '@id' } },
|
||||
updateAccess: { method: 'PUT', params: { id: '@id', action: 'access' } },
|
||||
remove: { method: 'DELETE', params: { id: '@id'} },
|
||||
snapshot: { method: 'POST', params: { id: 'snapshot' }},
|
||||
snapshots: { method: 'POST', params: { action: 'snapshot' }},
|
||||
snapshot: { method: 'POST', params: { id: '@id', action: 'snapshot' }},
|
||||
executeJob: { method: 'POST', ignoreLoadingBar: true, params: { id: '@id', action: 'job' } }
|
||||
});
|
||||
}]);
|
||||
|
|
|
@ -12,8 +12,12 @@ function EndpointServiceFactory($q, Endpoints, FileUploadService) {
|
|||
return Endpoints.query({}).$promise;
|
||||
};
|
||||
|
||||
service.snapshot = function() {
|
||||
return Endpoints.snapshot({}, {}).$promise;
|
||||
service.snapshotEndpoints = function() {
|
||||
return Endpoints.snapshots({}, {}).$promise;
|
||||
};
|
||||
|
||||
service.snapshotEndpoint = function(endpointID) {
|
||||
return Endpoints.snapshot({ id: endpointID }, {}).$promise;
|
||||
};
|
||||
|
||||
service.endpointsByGroup = function(groupId) {
|
||||
|
|
|
@ -101,7 +101,7 @@ function ($q, $scope, $state, Authentication, EndpointService, EndpointHelper, G
|
|||
}
|
||||
|
||||
function triggerSnapshot() {
|
||||
EndpointService.snapshot()
|
||||
EndpointService.snapshotEndpoints()
|
||||
.then(function success() {
|
||||
Notifications.success('Success', 'Endpoints updated');
|
||||
$state.reload();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue