From 106b71461f96ee49b45a2da4d917c387daac1937 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Tue, 7 Nov 2023 16:49:45 -0500 Subject: [PATCH] Handle optional plugins and plugin order. --- import_tracker/__init__.py | 5 +++++ import_tracker/web_client/main.js | 29 +++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/import_tracker/__init__.py b/import_tracker/__init__.py index fd5e63e..110848e 100644 --- a/import_tracker/__init__.py +++ b/import_tracker/__init__.py @@ -251,6 +251,11 @@ class GirderPlugin(plugin.GirderPlugin): def load(self, info): plugin.getPlugin('jobs').load(info) + try: + import large_image_source_dicom # noqa + plugin.getPlugin('dicomweb').load(info) + except ImportError: + pass ModelImporter.registerModel( 'assetstoreImport', AssetstoreImport, 'import_tracker' ) diff --git a/import_tracker/web_client/main.js b/import_tracker/web_client/main.js index 2e5c407..e51fea2 100644 --- a/import_tracker/web_client/main.js +++ b/import_tracker/web_client/main.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + import AssetstoreView from '@girder/core/views/body/AssetstoresView'; import FilesystemImportView from '@girder/core/views/body/FilesystemImportView'; import S3ImportView from '@girder/core/views/body/S3ImportView'; @@ -22,16 +24,23 @@ import './JobStatus'; wrap(AssetstoreView, 'render', function (render) { // Call the underlying render function that we are wrapping render.call(this); - - this.$el.find('.g-current-assetstores-container .g-body-title').after( - 'View all past Imports' - ); - - // Inject new button into each assetstore - const assetstores = this.collection.toArray(); - this.$('.g-assetstore-import-button-container').after( - (i) => importDataButton({ importsPageLink: `#assetstore/${assetstores[i].id}/imports` }) - ); + // defer adding buttons so optional plugins can render first. + window.setTimeout(() => { + this.$el.find('.g-current-assetstores-container .g-body-title').after( + 'View all past Imports' + ); + + // Inject new button into each assetstore + const assetstores = this.collection; + this.$('.g-assetstore-import-button-container').after( + function () { + // we can't just use the index of the after call, since not + // all assetstores will have import buttons. + var assetstore = assetstores.get($(this).closest('.g-assetstore-buttons').find('[cid]').attr('cid')); + return importDataButton({ importsPageLink: `#assetstore/${assetstore.id}/imports` }); + } + ); + }, 0); }); // Add duplicate_files option to Import Asset form