Skip to content

Commit

Permalink
task/DES-2610: Fix undefined DOI being logged with copy and other ope…
Browse files Browse the repository at this point in the history
…rations (#1124)

* Fix undefined doi being logged with copy and other operations

* only pass DOI if it exists

---------

Co-authored-by: Jake Rosenberg <[email protected]>
  • Loading branch information
jarosenb and Jake Rosenberg authored Nov 13, 2023
1 parent de7303b commit 0fc872b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class FilesListingCtrl {
browse($event, file) {
$event.preventDefault();
$event.stopPropagation();
if (this.doi) file.doi = this.doi;
this.onBrowse({ file });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class DataDepotToolbarCtrl {
copy() {
const { api, scheme, system, path } = this.FileListingService.listings.main.params;
const files = this.getAllSelected();
this.FileOperationService.openCopyModal({api, scheme, system, path, files});
const doi = this.FileListingService.currentDOI || this.$stateParams.doi;
this.FileOperationService.openCopyModal({api, scheme, system, path, files, doi});
}
move() {
const { api, scheme, system, path } = this.FileListingService.listings.main.params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ class PublishedViewCtrl {
}

onBrowse(file, doi) {
if (!doi) {doi = file.doi}
if (!doi) {doi = this.$stateParams.doi}
if (file.type === 'dir') {
this.$state.go(this.$state.current.name, { filePath: file.path, query_string: null, doi: doi });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class DataBrowserCopyCtrl {
destSystem: dest.system,
destPath: dest.path,
successCallback: this.successCallback,
doi: this.resolve.doi
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class DataBrowserServicePreviewCtrl {
copy() {
const { api, scheme, system, path } = this.FileListingService.listings.main.params;
const files = [this.resolve.file];
this.FileOperationService.openCopyModal({ api, scheme, system, path, files });
this.FileOperationService.openCopyModal({ api, scheme, system, path, files, doi: this.resolve.doi });
}

move() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
published="true"
on-scroll="$ctrl.scrollToBottom()"
listing="$ctrl.FileListingService.listings[collection.uuid]"
on-browse="$ctrl.onBrowse(file)">&nbsp;
on-browse="$ctrl.onBrowse(file)"
doi="mission.doi">&nbsp;
</files-listing>
</div>
</div>
Expand Down Expand Up @@ -206,7 +207,8 @@
published="true"
on-scroll="$ctrl.scrollToBottom()"
listing="$ctrl.FileListingService.listings[collection.uuid]"
on-browse="$ctrl.onBrowse(file)">&nbsp;
on-browse="$ctrl.onBrowse(file)"
doi="mission.doi">&nbsp;
</files-listing>
</div>
</div>
Expand Down Expand Up @@ -299,7 +301,8 @@
published="true"
on-scroll="$ctrl.scrollToBottom()"
listing="$ctrl.FileListingService.listings[collection.uuid]"
on-browse="$ctrl.onBrowse(file)">&nbsp;
on-browse="$ctrl.onBrowse(file)"
doi="mission.doi">&nbsp;
</files-listing>
</div>
</div>
Expand Down Expand Up @@ -347,7 +350,8 @@
published="true"
on-scroll="$ctrl.scrollToBottom()"
listing="$ctrl.FileListingService.listings[collection.uuid]"
on-browse="$ctrl.onBrowse(file)">&nbsp;
on-browse="$ctrl.onBrowse(file)"
doi="mission.doi">&nbsp;
</files-listing>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { map, tap, catchError } from 'rxjs/operators';
import { takeLatestSubscriber } from './_rxjs-utils';

export class FileOperationService {
constructor($http, $state, $rootScope, $uibModal, $q, ProjectService, Django, toastr) {
constructor($http, $state, $stateParams, $rootScope, $uibModal, $q, ProjectService, Django, toastr) {
'ngInject';
this.$state = $state;
this.$uibModal = $uibModal;
Expand All @@ -12,6 +12,7 @@ export class FileOperationService {
this.toastr = toastr;
this.$rootScope = $rootScope;
this.$http = $http;
this.$stateParams = $stateParams;
this.ProjectService = ProjectService;
this.from = from; // bind rxjs method for mocking

Expand Down Expand Up @@ -125,7 +126,7 @@ export class FileOperationService {
* @param {string} params.system System to copy files from.
* @param {Object[]} params.files Array of file objects {name, system, path} to copy.
*/
openCopyModal({ api, scheme, system, files }) {
openCopyModal({ api, scheme, system, files, doi }) {
this.operations.copy.status = {};
var modal = this.$uibModal.open({
component: 'copyModal',
Expand All @@ -134,6 +135,7 @@ export class FileOperationService {
scheme: () => scheme,
system: () => system,
files: () => files,
doi: () => doi,
},
size: 'lg',
});
Expand All @@ -154,14 +156,15 @@ export class FileOperationService {
* @param {string} params.destPath Path of directory to copy files into.
* @param {function} params.successCallback Callback on successful copy of all files.
*/
handleCopy({ srcApi, srcFiles, destApi, destSystem, destPath, successCallback }) {
handleCopy({ srcApi, srcFiles, destApi, destSystem, destPath, successCallback, doi}) {
const copyParams = {
srcApi,
srcFiles,
destApi,
destSystem,
destPath,
successCallback,
doi,
};

const copyMapping = () => this.mapParamsToCopy(copyParams);
Expand All @@ -180,7 +183,7 @@ export class FileOperationService {
* @param {Object[]} params.files Array of file objects {name, system, path} to copy.
* @param {function} params.successCallback Callback on successful copy of all files.
*/
mapParamsToCopy({ srcApi, destApi, destSystem, destPath, srcFiles, successCallback }) {
mapParamsToCopy({ srcApi, destApi, destSystem, destPath, srcFiles, successCallback, doi }) {
// Treat Shared Data as Agave for the purpose of copying files.
if (srcApi === 'shared') {
srcApi = 'agave';
Expand All @@ -193,7 +196,7 @@ export class FileOperationService {
// Copying files between APIs requires the transfer endpoint.
if (srcApi === destApi) {
const copyUrl = this.removeDuplicateSlashes(
`/api/datafiles/${srcApi}/private/copy/${f.system}/${f.path}/`
`/api/datafiles/${srcApi}/private/copy/${f.system}/${f.path}/?doi=${doi}`
);
copyRequest = this.$http.put(copyUrl, {
dest_system: destSystem,
Expand Down

0 comments on commit 0fc872b

Please sign in to comment.