Skip to content

Commit

Permalink
Fix PUT error (#900)
Browse files Browse the repository at this point in the history
  • Loading branch information
garyluu authored Jan 23, 2020
1 parent b4c0c74 commit 893a772
Showing 1 changed file with 47 additions and 17 deletions.
64 changes: 47 additions & 17 deletions src/app/container/info-tab/info-tab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

import { AlertService } from '../../shared/alert/state/alert.service';
import { Base } from '../../shared/base';
import { ContainerService } from '../../shared/container.service';
Expand Down Expand Up @@ -90,23 +89,54 @@ export class InfoTabService extends Base {
this.wdlTestPathEditing$.next(editing);
}

updateAndRefresh(tool: DockstoreTool) {
updateAndRefresh(tool: ExtendedDockstoreTool) {
const message = 'Tool Info';
tool.workflowVersions = [];
this.containersService.updateContainer(this.tool.id, tool).subscribe(response => {
this.alertService.start('Updating ' + message);
this.containersService.refresh(this.tool.id).subscribe(
refreshResponse => {
this.containerService.replaceTool(this.tools, refreshResponse);
this.containerService.setTool(refreshResponse);
this.alertService.detailedSuccess();
},
error => {
this.alertService.detailedError(error);
this.restoreTool();
}
);
});
const partialTool = this.getPartialToolForUpdate(tool);
this.alertService.start('Updating ' + message);
this.containersService.updateContainer(this.tool.id, partialTool).subscribe(
response => {
this.alertService.start('Refreshing ' + message);
this.containersService.refresh(this.tool.id).subscribe(
refreshResponse => {
this.containerService.replaceTool(this.tools, refreshResponse);
this.containerService.setTool(refreshResponse);
this.alertService.detailedSuccess();
},
error => {
this.alertService.detailedError(error);
this.restoreTool();
}
);
},
error => {
this.alertService.detailedError(error);
this.restoreTool();
}
);
}

/**
* PUT /containers/{containerId} only allows the updating of selected properties.
* Sending back only the ones relevant.
* Additionally, the webservice does not appear to understand starredUsers which causes an error.
*/
private getPartialToolForUpdate(tool: ExtendedDockstoreTool): DockstoreTool {
const partialTool: DockstoreTool = {
gitUrl: tool.gitUrl,
mode: tool.mode,
name: tool.name,
private_access: tool.private_access,
namespace: tool.namespace,
registry_string: tool.registry_string,
tool_maintainer_email: tool.tool_maintainer_email,
defaultVersion: tool.defaultVersion,
default_cwl_path: tool.default_cwl_path,
default_wdl_path: tool.default_wdl_path,
defaultCWLTestParameterFile: tool.defaultCWLTestParameterFile,
defaultWDLTestParameterFile: tool.defaultWDLTestParameterFile,
default_dockerfile_path: tool.default_dockerfile_path
};
return partialTool;
}

get tool(): ExtendedDockstoreTool {
Expand Down

0 comments on commit 893a772

Please sign in to comment.