refactor(docker/stack): stack creation page [EE-3486] (#7316)

* reactor(docker/stack): stack creation page [EE-3486]

* feat(stack): some missing component on stack create page and edit page [EE-3486]
pull/7319/head^2
Zhang Hao 2022-08-01 23:07:41 +08:00 committed by GitHub
parent c54bb255ba
commit d0a9c046b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 42 deletions

View File

@ -15,7 +15,7 @@
<div ng-if="$ctrl.mode == 'advanced'" class="environment-variables-panel--advanced"> <div ng-if="$ctrl.mode == 'advanced'" class="environment-variables-panel--advanced">
<div class="col-sm-12"> <div class="col-sm-12">
<a class="small interactive" ng-click="$ctrl.switchEnvMode()"> <i class="fa fa-list-ol space-right" aria-hidden="true"></i> Simple mode </a> <a class="small interactive" ng-click="$ctrl.switchEnvMode()"> <pr-icon icon="'list'" feather="true"></pr-icon> Simple mode </a>
</div> </div>
<div class="col-sm-12 small text-muted"> <div class="col-sm-12 small text-muted">
<pr-icon icon="'alert-circle'" mode="'primary'" feather="true"></pr-icon> <pr-icon icon="'alert-circle'" mode="'primary'" feather="true"></pr-icon>

View File

@ -84,6 +84,12 @@ angular
$scope.onChangeFormValues = onChangeFormValues; $scope.onChangeFormValues = onChangeFormValues;
$scope.onEnableWebhookChange = function (enable) {
$scope.$evalAsync(() => {
$scope.formValues.EnableWebhook = enable;
});
};
$scope.addAdditionalFiles = function () { $scope.addAdditionalFiles = function () {
$scope.formValues.AdditionalFiles.push(''); $scope.formValues.AdditionalFiles.push('');
}; };

View File

@ -107,7 +107,10 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-12"> <div class="col-sm-12">
<button type="button" class="btn btn-sm btn-primary" ngf-select="uploadFile($file)">Select file</button> <button type="button" class="btn btn-sm btn-light" ngf-select="uploadFile($file)">
<pr-icon icon="'upload'" feather="true"></pr-icon>
Select file</button
>
<span style="margin-left: 5px"> <span style="margin-left: 5px">
{{ formValues.StackFile.name }} {{ formValues.StackFile.name }}
<i class="fa fa-times red-icon" ng-if="!formValues.StackFile" aria-hidden="true"></i> <i class="fa fa-times red-icon" ng-if="!formValues.StackFile" aria-hidden="true"></i>
@ -164,21 +167,17 @@
</web-editor-form> </web-editor-form>
<div ng-if="state.Method !== 'repository' && isAdmin && applicationState.endpoint.type !== 4"> <div ng-if="state.Method !== 'repository' && isAdmin && applicationState.endpoint.type !== 4">
<div class="col-sm-12 form-section-title"> Webhooks </div> <div class="col-sm-12 form-section-title">
<div class="form-group"> Webhooks
<div class="col-sm-12"> <por-switch-field
<label class="control-label text-left"> name="EnableWebhook"
Create a Stack webhook checked="formValues.EnableWebhook"
<portainer-tooltip label-class="'col-sm-2'"
position="'top'" tooltip="'Create a webhook (or callback URI) to automate the update of this stack. Sending a POST request to this callback URI (without requiring any authentication) will pull the most up-to-date version of the associated image and re-deploy this stack.'"
message="'Create a webhook (or callback URI) to automate the update of this stack. Sending a POST request to this callback URI (without requiring any authentication) will pull the most up-to-date version of the associated image and re-deploy this stack.'" label="'Create a Stack webhook'"
></portainer-tooltip> on-change="(onEnableWebhookChange)"
</label> feature-id="'stack-webhook'"
<label class="switch box-selector-item limited business" style="margin-left: 20px"> ></por-switch-field>
<input type="checkbox" ng-model="formValues.EnableWebhook" disabled="disabled" ng-checked="false" /><i></i>
</label>
<be-feature-indicator feature="stackWebhookFeature"></be-feature-indicator>
</div>
</div> </div>
</div> </div>

View File

@ -44,15 +44,15 @@
ng-if="regular && stack.Status === 1" ng-if="regular && stack.Status === 1"
authorization="PortainerStackUpdate" authorization="PortainerStackUpdate"
ng-disabled="state.actionInProgress" ng-disabled="state.actionInProgress"
class="btn btn-xs btn-danger" class="btn btn-xs btn-light"
ng-click="stopStack()" ng-click="stopStack()"
> >
<i class="fa fa-stop space-right" aria-hidden="true"></i> <pr-icon icon="'stop-circle'" feather="true"></pr-icon>
Stop this stack Stop this stack
</button> </button>
<button authorization="PortainerStackDelete" class="btn btn-xs btn-danger" ng-click="removeStack()" ng-if="!external || stack.Type == 1"> <button authorization="PortainerStackDelete" class="btn btn-xs btn-light" ng-click="removeStack()" ng-if="!external || stack.Type == 1">
<i class="fa fa-trash-alt space-right" aria-hidden="true"></i> <pr-icon icon="'trash-2'" feather="true"></pr-icon>
Delete this stack Delete this stack
</button> </button>
@ -61,7 +61,7 @@
class="btn btn-primary btn-xs" class="btn btn-primary btn-xs"
ui-sref="docker.templates.custom.new({fileContent: stackFileContent, type: stack.Type})" ui-sref="docker.templates.custom.new({fileContent: stackFileContent, type: stack.Type})"
> >
<i class="fa fa-plus space-right" aria-hidden="true"></i> <pr-icon icon="'plus'" feather="true"></pr-icon>
Create template from stack Create template from stack
</button> </button>
<button <button
@ -156,21 +156,16 @@
</div> </div>
<div ng-if="isAdmin && applicationState.endpoint.type !== 4"> <div ng-if="isAdmin && applicationState.endpoint.type !== 4">
<div class="col-sm-12 form-section-title"> Webhooks </div> <div class="col-sm-12 form-section-title">
<div class="form-group"> Webhooks
<div class="col-sm-12"> <por-switch-field
<label class="control-label text-left"> name="EnableWebhook"
Create a Stack webhook checked="formValues.EnableWebhook"
<portainer-tooltip label-class="'col-sm-2'"
position="'top'" tooltip="'Create a webhook (or callback URI) to automate the update of this stack. Sending a POST request to this callback URI (without requiring any authentication) will pull the most up-to-date version of the associated image and re-deploy this stack.'"
message="'Create a webhook (or callback URI) to automate the update of this stack. Sending a POST request to this callback URI (without requiring any authentication) will pull the most up-to-date version of the associated image and re-deploy this stack.'" label="'Create a Stack webhook'"
></portainer-tooltip> feature-id="'stack-webhook'"
</label> ></por-switch-field>
<label class="switch box-selector-item limited business" style="margin-left: 20px">
<input type="checkbox" ng-model="formValues.EnableWebhook" disabled="disabled" ng-checked="false" /><i></i>
</label>
<be-feature-indicator feature="stackWebhookFeature"></be-feature-indicator>
</div>
</div> </div>
</div> </div>
@ -189,11 +184,14 @@
<div class="col-sm-12 form-section-title"> Options </div> <div class="col-sm-12 form-section-title"> Options </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-12"> <div class="col-sm-12">
<label for="prune" class="control-label text-left"> <por-switch-field
Prune services name="prune"
<portainer-tooltip position="'top'" message="'Prune services that are no longer referenced.'"></portainer-tooltip> checked="formValues.Prune"
</label> tooltip="'Prune services that are no longer referenced.'"
<label class="switch" style="margin-left: 20px"> <input name="prune" type="checkbox" ng-model="formValues.Prune" /><i></i> </label> label-class="'col-sm-2'"
label="'Prune services'"
on-change="(onPruneChange)"
></por-switch-field>
</div> </div>
</div> </div>
</div> </div>

View File

@ -94,6 +94,18 @@ angular.module('portainer.app').controller('StackController', [
$scope.formValues.Env = value; $scope.formValues.Env = value;
} }
$scope.onEnableWebhookChange = function (enable) {
$scope.$evalAsync(() => {
$scope.formValues.EnableWebhook = enable;
});
};
$scope.onPruneChange = function (enable) {
$scope.$evalAsync(() => {
$scope.formValues.Prune = enable;
});
};
$scope.duplicateStack = function duplicateStack(name, targetEndpointId) { $scope.duplicateStack = function duplicateStack(name, targetEndpointId) {
var stack = $scope.stack; var stack = $scope.stack;
var env = FormHelper.removeInvalidEnvVars($scope.formValues.Env); var env = FormHelper.removeInvalidEnvVars($scope.formValues.Env);