mirror of
https://github.com/portainer/portainer.git
synced 2025-08-07 23:05:26 +02:00
refactor(portainer): remove offline mode [EE-4348] (#7761)
Co-authored-by: deviantony <anthony.lapenna@portainer.io>
This commit is contained in:
parent
61e8e68c31
commit
75f40fe485
39 changed files with 28 additions and 311 deletions
|
@ -21,7 +21,7 @@
|
|||
data-cy="stack-searchInput"
|
||||
/>
|
||||
</div>
|
||||
<div class="actionBar !gap-3" ng-if="!$ctrl.offlineMode" authorization="PortainerStackCreate, PortainerStackDelete">
|
||||
<div class="actionBar !gap-3" authorization="PortainerStackCreate, PortainerStackDelete">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-dangerlight h-fit vertical-center !ml-0"
|
||||
|
@ -92,7 +92,7 @@
|
|||
<tr>
|
||||
<th uib-dropdown dropdown-append-to-body auto-close="disabled" is-open="$ctrl.filters.state.open">
|
||||
<div class="flex flex-row flex-no-wrap gap-1">
|
||||
<span class="md-checkbox" ng-if="!$ctrl.offlineMode" authorization="PortainerStackCreate, PortainerStackDelete">
|
||||
<span class="md-checkbox" authorization="PortainerStackCreate, PortainerStackDelete">
|
||||
<input id="select_all" type="checkbox" ng-model="$ctrl.state.selectAll" ng-change="$ctrl.selectAll()" />
|
||||
<label for="select_all"></label>
|
||||
</span>
|
||||
|
@ -175,16 +175,15 @@
|
|||
ng-class="{ active: item.Checked }"
|
||||
>
|
||||
<td>
|
||||
<span class="md-checkbox" ng-if="!$ctrl.offlineMode" authorization="PortainerStackCreate, PortainerStackDelete">
|
||||
<span class="md-checkbox" authorization="PortainerStackCreate, PortainerStackDelete">
|
||||
<input id="select_{{ $index }}" type="checkbox" ng-model="item.Checked" ng-click="$ctrl.selectItem(item, $event)" ng-disabled="!$ctrl.allowSelection(item)" />
|
||||
<label for="select_{{ $index }}"></label>
|
||||
</span>
|
||||
<a
|
||||
ng-if="!$ctrl.offlineMode && $ctrl.createEnabled"
|
||||
ng-if="$ctrl.createEnabled"
|
||||
ui-sref="docker.stacks.stack({ name: item.Name, id: item.Id, type: item.Type, regular: item.Regular, external: item.External, orphaned: item.Orphaned, orphanedRunning: item.OrphanedRunning })"
|
||||
>{{ item.Name }}</a
|
||||
>
|
||||
<span ng-if="$ctrl.offlineMode">{{ item.Name }}</span>
|
||||
<span ng-if="item.Regular && item.Status == 2" class="label label-warning image-tag ml-2">Inactive</span>
|
||||
</td>
|
||||
<td>{{ item.Type === 1 ? 'Swarm' : 'Compose' }}</td>
|
||||
|
|
|
@ -9,7 +9,6 @@ angular.module('portainer.app').component('stacksDatatable', {
|
|||
orderBy: '@',
|
||||
reverseOrder: '<',
|
||||
removeAction: '<',
|
||||
offlineMode: '<',
|
||||
refreshCallback: '<',
|
||||
createEnabled: '<',
|
||||
},
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<information-panel title-text="Offline mode" cant-dismiss="true">
|
||||
<span class="small">
|
||||
<p class="text-muted">
|
||||
<i class="fa fa-exclamation-circle orange-icon" aria-hidden="true" style="margin-right: 2px"></i>
|
||||
This environment 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>
|
|
@ -1,4 +0,0 @@
|
|||
angular.module('portainer.app').component('informationPanelOffline', {
|
||||
templateUrl: './informationPanelOffline.html',
|
||||
controller: 'InformationPanelOfflineController',
|
||||
});
|
|
@ -1,38 +0,0 @@
|
|||
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 occurred during environment snapshot');
|
||||
});
|
||||
}
|
||||
|
||||
function onInit() {
|
||||
var endpointId = EndpointProvider.endpointID();
|
||||
ctrl.showRefreshButton = Authentication.isAdmin();
|
||||
|
||||
EndpointService.endpoint(endpointId)
|
||||
.then(function onSuccess(data) {
|
||||
ctrl.snapshotTime = data.Snapshots[0].Time;
|
||||
})
|
||||
.catch(function onError(err) {
|
||||
Notifications.error('Failure', err, 'Unable to retrieve environment information');
|
||||
});
|
||||
}
|
||||
},
|
||||
]);
|
|
@ -39,7 +39,3 @@ export default class EndpointHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function isOfflineEndpoint(endpoint) {
|
||||
return endpoint.Status !== 1;
|
||||
}
|
||||
|
|
|
@ -194,11 +194,9 @@ function StateManagerFactory(
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
const reload = endpoint.Status === 1 || !endpoint.Snaphosts || !endpoint.Snaphosts.length || !endpoint.Snapshots[0].SnapshotRaw;
|
||||
|
||||
$q.all({
|
||||
version: reload ? SystemService.version() : $q.when(endpoint.Snapshots[0].SnapshotRaw.Version),
|
||||
info: reload ? SystemService.info() : $q.when(endpoint.Snapshots[0].SnapshotRaw.Info),
|
||||
version: SystemService.version(),
|
||||
info: SystemService.info(),
|
||||
})
|
||||
.then(function success(data) {
|
||||
var endpointMode = InfoHelper.determineEndpointMode(data.info, endpoint.Type);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<page-header title="'Stacks list'" breadcrumbs="['Stacks']" reload="true"> </page-header>
|
||||
|
||||
<information-panel-offline ng-if="offlineMode"></information-panel-offline>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<stacks-datatable
|
||||
|
@ -10,7 +9,6 @@
|
|||
table-key="stacks"
|
||||
order-by="Name"
|
||||
remove-action="removeAction"
|
||||
offline-mode="offlineMode"
|
||||
refresh-callback="getStacks"
|
||||
create-enabled="createEnabled"
|
||||
></stacks-datatable>
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { isOfflineEndpoint } from '@/portainer/helpers/endpointHelper';
|
||||
|
||||
angular.module('portainer.app').controller('StacksController', StacksController);
|
||||
|
||||
/* @ngInject */
|
||||
|
@ -35,7 +33,6 @@ function StacksController($scope, $state, Notifications, StackService, ModalServ
|
|||
});
|
||||
}
|
||||
|
||||
$scope.offlineMode = false;
|
||||
$scope.createEnabled = false;
|
||||
|
||||
$scope.getStacks = getStacks;
|
||||
|
@ -48,7 +45,6 @@ function StacksController($scope, $state, Notifications, StackService, ModalServ
|
|||
StackService.stacks(true, endpointMode.provider === 'DOCKER_SWARM_MODE' && endpointMode.role === 'MANAGER', endpointId, includeOrphanedStacks)
|
||||
.then(function success(stacks) {
|
||||
$scope.stacks = stacks;
|
||||
$scope.offlineMode = isOfflineEndpoint(endpoint);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
$scope.stacks = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue