fix(edge-jobs): HTTP 404 on file upload (#6671)

* fix(edge-jobs): HTTP 404 on file upload

* fix(edge-jobs): state 'edge job' in message on edge job removal instead of 'stack'

* fix(api/edge-jobs): save changes on edge-jobs update
pull/6771/head
LP B 2022-04-14 18:44:04 +02:00 committed by GitHub
parent 355674cf22
commit 030b3d7c4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 3 deletions

View File

@ -119,7 +119,7 @@ func (payload *edgeJobCreateFromFilePayload) Validate(r *http.Request) error {
payload.CronExpression = cronExpression
var endpoints []portainer.EndpointID
err = request.RetrieveMultiPartFormJSONValue(r, "Environments", &endpoints, false)
err = request.RetrieveMultiPartFormJSONValue(r, "Endpoints", &endpoints, false)
if err != nil {
return errors.New("Invalid environments")
}

View File

@ -114,6 +114,7 @@ func (handler *Handler) updateEdgeSchedule(edgeJob *portainer.EdgeJob, payload *
}
if payload.FileContent != nil && *payload.FileContent != string(fileContent) {
fileContent = []byte(*payload.FileContent)
_, err := handler.FileService.StoreEdgeJobFileFromBytes(strconv.Itoa(int(edgeJob.ID)), fileContent)
if err != nil {
return err

View File

@ -31,7 +31,7 @@ export class EdgeJobsViewController {
for (let edgeJob of edgeJobs) {
try {
await this.EdgeJobService.remove(edgeJob.Id);
this.Notifications.success('Stack successfully removed', edgeJob.Name);
this.Notifications.success('Edge job successfully removed', edgeJob.Name);
_.remove(this.edgeJobs, edgeJob);
} catch (err) {
this.Notifications.error('Failure', err, 'Unable to remove Edge job ' + edgeJob.Name);

View File

@ -48,7 +48,7 @@ angular.module('portainer.app').factory('FileUploadService', [
service.createSchedule = function (payload) {
return Upload.upload({
url: 'api/schedules?method=file',
url: 'api/edge_jobs?method=file',
data: {
file: payload.File,
Name: payload.Name,