1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-04 21:35:23 +02:00

feat(edge): EE-4570 allow pre-pull images with edge stack deployment (#8210)

Co-authored-by: Matt Hook <hookenz@gmail.com>
This commit is contained in:
cmeng 2022-12-21 13:18:51 +13:00 committed by GitHub
parent 7fe0712b61
commit 919a854d93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 234 additions and 53 deletions

View file

@ -20,12 +20,6 @@ export class EdgeStackEndpointsDatatableController {
this.onPageChange = this.onPageChange.bind(this);
this.paginationChanged = this.paginationChanged.bind(this);
this.paginationChangedAsync = this.paginationChangedAsync.bind(this);
this.statusMap = {
1: 'OK',
2: 'Error',
3: 'Acknowledged',
};
}
extendGenericController($controller, $scope) {
@ -45,8 +39,9 @@ export class EdgeStackEndpointsDatatableController {
endpointStatusLabel(endpointId) {
const status = this.getEndpointStatus(endpointId);
const details = (status && status.Details) || {};
return status ? this.statusMap[status.Type] : 'Pending';
return (details.Error && 'Error') || (details.Ok && 'Ok') || (details.ImagesPulled && 'Images pre-pulled') || (details.Acknowledged && 'Acknowledged') || 'Pending';
}
endpointStatusError(endpointId) {

View file

@ -0,0 +1,28 @@
.edge-stack-status {
padding: 2px 10px;
border-radius: 10px;
}
.edge-stack-status.status-acknowledged {
color: #337ab7;
background-color: rgba(51, 122, 183, 0.1);
}
.edge-stack-status.status-images-pulled {
color: #e1a800;
background-color: rgba(238, 192, 32, 0.1);
}
.edge-stack-status.status-ok {
color: #23ae89;
background-color: rgba(35, 174, 137, 0.1);
}
.edge-stack-status.status-error {
color: #ae2323;
background-color: rgba(174, 35, 35, 0.1);
}
.edge-stack-status.status-total {
background-color: rgba(168, 167, 167, 0.1);
}

View file

@ -87,7 +87,10 @@
></table-column-header>
</div>
</th>
<th> Status </th>
<th class="text-center"> Acknowledged </th>
<th class="text-center"> Deployed </th>
<th class="text-center"> Failed </th>
<th class="text-center"> Total deployments </th>
<th>
<table-column-header
col-title="'Creation Date'"
@ -113,14 +116,36 @@
{{ item.Name }}
</a>
</td>
<td><edge-stack-status stack-status="item.Status"></edge-stack-status></td>
<td class="text-center">
<span class="edge-stack-status status-acknowledged">
&bull;
{{ item.aggregateStatus.acknowledged }}
</span>
</td>
<td class="text-center">
<span class="edge-stack-status status-ok">
&bull;
{{ item.aggregateStatus.ok }}
</span>
</td>
<td class="text-center">
<span class="edge-stack-status status-error">
&bull;
{{ item.aggregateStatus.error }}
</span>
</td>
<td class="text-center">
<span class="edge-stack-status status-total">
{{ item.NumDeployments }}
</span>
</td>
<td>{{ item.CreationDate | getisodatefromtimestamp }}</td>
</tr>
<tr ng-if="!$ctrl.dataset" data-cy="edgeStack-loadingRow">
<td colspan="4" class="text-center text-muted">Loading...</td>
<td colspan="6" class="text-center text-muted">Loading...</td>
</tr>
<tr ng-if="$ctrl.state.filteredDataSet.length === 0" data-cy="edgeStack-noStackRow">
<td colspan="4" class="text-center text-muted"> No stack available. </td>
<td colspan="6" class="text-center text-muted"> No stack available. </td>
</tr>
</tbody>
</table>

View file

@ -1,4 +1,5 @@
import angular from 'angular';
import './edgeStackDatatable.css';
angular.module('portainer.edge').component('edgeStacksDatatable', {
templateUrl: './edgeStacksDatatable.html',

View file

@ -32,7 +32,7 @@
</div>
<web-editor-form
ng-if="$ctrl.model.DeploymentType === 0"
ng-if="$ctrl.model.DeploymentType === $ctrl.EditorType.Compose"
value="$ctrl.model.StackFileContent"
yml="true"
identifier="compose-editor"
@ -48,7 +48,7 @@
</editor-description>
</web-editor-form>
<div ng-if="$ctrl.model.DeploymentType === 1">
<div ng-if="$ctrl.model.DeploymentType === $ctrl.EditorType.Kubernetes">
<div class="form-group">
<div class="col-sm-12">
<por-switch-field

View file

@ -1,4 +1,5 @@
import { PortainerEndpointTypes } from '@/portainer/models/endpoint/models';
import { EditorType } from '@/react/edge/edge-stacks/types';
export class EditEdgeStackFormController {
/* @ngInject */
@ -13,6 +14,8 @@ export class EditEdgeStackFormController {
1: '',
};
this.EditorType = EditorType;
this.onChangeGroups = this.onChangeGroups.bind(this);
this.onChangeFileContent = this.onChangeFileContent.bind(this);
this.onChangeComposeConfig = this.onChangeComposeConfig.bind(this);

View file

@ -1,3 +1,5 @@
import { EditorType } from '@/react/edge/edge-stacks/types';
export default class CreateEdgeStackViewController {
/* @ngInject */
constructor($state, $window, ModalService, EdgeStackService, EdgeGroupService, EdgeTemplateService, Notifications, FormHelper, $async, $scope) {
@ -19,6 +21,8 @@ export default class CreateEdgeStackViewController {
UseManifestNamespaces: false,
};
this.EditorType = EditorType;
this.state = {
Method: 'editor',
formValidationError: '',

View file

@ -57,9 +57,17 @@
</div>
</div>
<edge-stacks-docker-compose-form ng-if="$ctrl.formValues.DeploymentType == 0" form-values="$ctrl.formValues" state="$ctrl.state"></edge-stacks-docker-compose-form>
<edge-stacks-docker-compose-form
ng-if="$ctrl.formValues.DeploymentType == $ctrl.EditorType.Compose"
form-values="$ctrl.formValues"
state="$ctrl.state"
></edge-stacks-docker-compose-form>
<edge-stacks-kube-manifest-form ng-if="$ctrl.formValues.DeploymentType == 1" form-values="$ctrl.formValues" state="$ctrl.state"></edge-stacks-kube-manifest-form>
<edge-stacks-kube-manifest-form
ng-if="$ctrl.formValues.DeploymentType == $ctrl.EditorType.Kubernetes"
form-values="$ctrl.formValues"
state="$ctrl.state"
></edge-stacks-kube-manifest-form>
<!-- actions -->
<div class="col-sm-12 form-section-title"> Actions </div>

View file

@ -38,9 +38,25 @@ export class EdgeStacksViewController {
this.$state.reload();
}
aggregateStatus() {
if (this.stacks) {
this.stacks.forEach((stack) => {
const aggregateStatus = { ok: 0, error: 0, acknowledged: 0 };
for (let endpointId in stack.Status) {
const { Details } = stack.Status[endpointId];
aggregateStatus.ok += Number(Details.Ok);
aggregateStatus.error += Number(Details.Error);
aggregateStatus.acknowledged += Number(Details.Acknowledged);
}
stack.aggregateStatus = aggregateStatus;
});
}
}
async getStacks() {
try {
this.stacks = await this.EdgeStackService.stacks();
this.aggregateStatus();
} catch (err) {
this.stacks = [];
this.Notifications.error('Failure', err, 'Unable to retrieve stacks');

View file

@ -0,0 +1,5 @@
export enum EditorType {
Compose,
Kubernetes,
Nomad,
}