From 48b892a1f72b97adbe7922ba03f2d27ffd629575 Mon Sep 17 00:00:00 2001 From: Conalb97 Date: Thu, 26 Sep 2024 15:06:04 +0100 Subject: [PATCH 1/7] IMAEGEDAM-1982: Prevent images received from Capture being able to send back to Capture. --- kahuna/public/js/search/results.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/kahuna/public/js/search/results.js b/kahuna/public/js/search/results.js index 45d9dda0da..4269017e32 100644 --- a/kahuna/public/js/search/results.js +++ b/kahuna/public/js/search/results.js @@ -403,17 +403,21 @@ results.controller('SearchResultsCtrl', [ let validImages = []; let invalidImages = []; images.forEach( (image) => { - if (image.data.usages.data.length === 0) { - validImages.push(image); + if (image.data.uploadedBy === "Capture_AutoIngest") { + invalidImages.push(image); } else { - let syndicationExists = false; - for (const usage of image.data.usages.data) { - if (usage.data.platform === "syndication") { - syndicationExists = true; - break; + if (image.data.usages.data.length === 0) { + validImages.push(image); + } else { + let syndicationExists = false; + for (const usage of image.data.usages.data) { + if (usage.data.platform === "syndication") { + syndicationExists = true; + break; + } } + (syndicationExists === true ? invalidImages : validImages).push(image); } - (syndicationExists === true ? invalidImages : validImages).push(image); } }); return [validImages, invalidImages]; From 075fd4694c4b1e9d5149a453851106c96be36441 Mon Sep 17 00:00:00 2001 From: Conalb97 Date: Fri, 27 Sep 2024 13:01:06 +0100 Subject: [PATCH 2/7] IMAEGEDAM-1982: Display icon for capture uploads, restrict icon for standard users --- kahuna/public/js/preview/image.html | 2 +- kahuna/public/js/preview/image.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/kahuna/public/js/preview/image.html b/kahuna/public/js/preview/image.html index 84529115ef..c0cbf69913 100644 --- a/kahuna/public/js/preview/image.html +++ b/kahuna/public/js/preview/image.html @@ -192,7 +192,7 @@ + ng-if="(ctrl.hasSyndicationUsages || ctrl.uploadedByCapture) && ctrl.showSendToPhotoSales() && ctrl.showPaid"> diff --git a/kahuna/public/js/preview/image.js b/kahuna/public/js/preview/image.js index 3dcc92d193..6281bf6e3b 100644 --- a/kahuna/public/js/preview/image.js +++ b/kahuna/public/js/preview/image.js @@ -38,6 +38,7 @@ image.controller('uiPreviewImageCtrl', [ 'inject$', '$rootScope', '$window', + 'mediaApi', 'imageService', 'imageUsagesService', 'labelService', @@ -50,6 +51,7 @@ image.controller('uiPreviewImageCtrl', [ inject$, $rootScope, $window, + mediaApi, imageService, imageUsagesService, labelService, @@ -65,6 +67,11 @@ image.controller('uiPreviewImageCtrl', [ }); ctrl.showSendToPhotoSales = () => $window._clientConfig.showSendToPhotoSales; + ctrl.uploadedByCapture = (ctrl) => ctrl?.image?.data?.uploadedBy === "Capture_AutoIngest"; + ctrl.showPaid = undefined; + mediaApi.getSession().then(session => { + ctrl.showPaid = session.user.permissions.showPaid ? session.user.permissions.showPaid : undefined; + }); ctrl.addLabelToImages = labelService.batchAdd; ctrl.removeLabelFromImages = labelService.batchRemove; From 0ea2a7fa887b9a0c530ba909c9049431091828b7 Mon Sep 17 00:00:00 2001 From: Conalb97 Date: Fri, 27 Sep 2024 17:02:24 +0100 Subject: [PATCH 3/7] IMAEGEDAM-1982: Refactor validate image selection code WIP --- kahuna/public/js/search/results.js | 58 ++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/kahuna/public/js/search/results.js b/kahuna/public/js/search/results.js index 4269017e32..7654f976a2 100644 --- a/kahuna/public/js/search/results.js +++ b/kahuna/public/js/search/results.js @@ -400,26 +400,54 @@ results.controller('SearchResultsCtrl', [ }; const validatePhotoSalesSelection = (images) => { - let validImages = []; - let invalidImages = []; - images.forEach( (image) => { - if (image.data.uploadedBy === "Capture_AutoIngest") { - invalidImages.push(image); - } else { + const validImages = []; + const invalidImages = []; + + const filteredImages = images + .filter(image => { + if (image.data.uploadedBy === "Capture_AutoIngest") { + invalidImages.push(image); + return false; + } + return true; + }) + .filter(image => { if (image.data.usages.data.length === 0) { validImages.push(image); - } else { - let syndicationExists = false; - for (const usage of image.data.usages.data) { - if (usage.data.platform === "syndication") { - syndicationExists = true; - break; - } - } - (syndicationExists === true ? invalidImages : validImages).push(image); + return false; + } + return true; + }); + filteredImages.forEach((image) => { + let syndicationExists = false; + for (const usage of image.data.usages.data) { + if (usage.data.platform === "syndication") { + syndicationExists = true; + break; } } + (syndicationExists === true ? invalidImages : validImages).push(image); }); + // + // + // images.forEach( (image) => { + // if (image.data.uploadedBy === "Capture_AutoIngest") { + // invalidImages.push(image); + // } else { + // if (image.data.usages.data.length === 0) { + // validImages.push(image); + // } else { + // let syndicationExists = false; + // for (const usage of image.data.usages.data) { + // if (usage.data.platform === "syndication") { + // syndicationExists = true; + // break; + // } + // } + // (syndicationExists === true ? invalidImages : validImages).push(image); + // } + // } + // }); return [validImages, invalidImages]; }; From 1a29a6fa8f4d1c50de1463b62aea06a7c430d7a4 Mon Sep 17 00:00:00 2001 From: Conalb97 Date: Fri, 27 Sep 2024 18:10:17 +0100 Subject: [PATCH 4/7] IMAEGEDAM-1982: Remove old validate and change to uploadedByCapture --- kahuna/public/js/preview/image.js | 2 +- kahuna/public/js/search/results.js | 20 -------------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/kahuna/public/js/preview/image.js b/kahuna/public/js/preview/image.js index 6281bf6e3b..53ed6ec686 100644 --- a/kahuna/public/js/preview/image.js +++ b/kahuna/public/js/preview/image.js @@ -67,7 +67,7 @@ image.controller('uiPreviewImageCtrl', [ }); ctrl.showSendToPhotoSales = () => $window._clientConfig.showSendToPhotoSales; - ctrl.uploadedByCapture = (ctrl) => ctrl?.image?.data?.uploadedBy === "Capture_AutoIngest"; + ctrl.uploadedByCapture = (ctrl) => ctrl.image.data.uploadedBy === "Capture_AutoIngest"; ctrl.showPaid = undefined; mediaApi.getSession().then(session => { ctrl.showPaid = session.user.permissions.showPaid ? session.user.permissions.showPaid : undefined; diff --git a/kahuna/public/js/search/results.js b/kahuna/public/js/search/results.js index 7654f976a2..f4bba82f36 100644 --- a/kahuna/public/js/search/results.js +++ b/kahuna/public/js/search/results.js @@ -428,26 +428,6 @@ results.controller('SearchResultsCtrl', [ } (syndicationExists === true ? invalidImages : validImages).push(image); }); - // - // - // images.forEach( (image) => { - // if (image.data.uploadedBy === "Capture_AutoIngest") { - // invalidImages.push(image); - // } else { - // if (image.data.usages.data.length === 0) { - // validImages.push(image); - // } else { - // let syndicationExists = false; - // for (const usage of image.data.usages.data) { - // if (usage.data.platform === "syndication") { - // syndicationExists = true; - // break; - // } - // } - // (syndicationExists === true ? invalidImages : validImages).push(image); - // } - // } - // }); return [validImages, invalidImages]; }; From baceeea73d13e90125ecda4837e2da5c7fd55668 Mon Sep 17 00:00:00 2001 From: Conalb97 Date: Mon, 30 Sep 2024 11:20:48 +0100 Subject: [PATCH 5/7] IMAEGEDAM-1982: Fix uploadedByCapture variable --- kahuna/public/js/preview/image.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kahuna/public/js/preview/image.js b/kahuna/public/js/preview/image.js index 53ed6ec686..c01b9b7a39 100644 --- a/kahuna/public/js/preview/image.js +++ b/kahuna/public/js/preview/image.js @@ -67,8 +67,7 @@ image.controller('uiPreviewImageCtrl', [ }); ctrl.showSendToPhotoSales = () => $window._clientConfig.showSendToPhotoSales; - ctrl.uploadedByCapture = (ctrl) => ctrl.image.data.uploadedBy === "Capture_AutoIngest"; - ctrl.showPaid = undefined; + ctrl.uploadedByCapture = ctrl.image.data.uploadedBy === "Capture_AutoIngest" mediaApi.getSession().then(session => { ctrl.showPaid = session.user.permissions.showPaid ? session.user.permissions.showPaid : undefined; }); From 46a4c0b77960a9a6c946a7dbbc8b02ce4b621577 Mon Sep 17 00:00:00 2001 From: Conalb97 Date: Mon, 30 Sep 2024 11:24:31 +0100 Subject: [PATCH 6/7] IMAEGEDAM-1982: CI/CD check fix --- kahuna/public/js/preview/image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kahuna/public/js/preview/image.js b/kahuna/public/js/preview/image.js index c01b9b7a39..2ec27254b4 100644 --- a/kahuna/public/js/preview/image.js +++ b/kahuna/public/js/preview/image.js @@ -67,7 +67,7 @@ image.controller('uiPreviewImageCtrl', [ }); ctrl.showSendToPhotoSales = () => $window._clientConfig.showSendToPhotoSales; - ctrl.uploadedByCapture = ctrl.image.data.uploadedBy === "Capture_AutoIngest" + ctrl.uploadedByCapture = ctrl.image.data.uploadedBy === "Capture_AutoIngest"; mediaApi.getSession().then(session => { ctrl.showPaid = session.user.permissions.showPaid ? session.user.permissions.showPaid : undefined; }); From 4205430276c330c0355f8931edca21e245f8a933 Mon Sep 17 00:00:00 2001 From: Conalb97 Date: Tue, 15 Oct 2024 16:23:57 +0100 Subject: [PATCH 7/7] IMAEGEDAM-1982: Code review changes --- kahuna/public/js/search/results.js | 36 +++++++++++------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/kahuna/public/js/search/results.js b/kahuna/public/js/search/results.js index f4bba82f36..6ef2323853 100644 --- a/kahuna/public/js/search/results.js +++ b/kahuna/public/js/search/results.js @@ -399,38 +399,28 @@ results.controller('SearchResultsCtrl', [ globalErrors.trigger('clipboard', sharedUrl); }; + const imageHasSyndicationUsage = (image) => { + return image.data.usages.data.some(usage => + usage.data.platform === 'syndication' + ); + }; + const validatePhotoSalesSelection = (images) => { const validImages = []; const invalidImages = []; - const filteredImages = images - .filter(image => { - if (image.data.uploadedBy === "Capture_AutoIngest") { - invalidImages.push(image); - return false; - } - return true; - }) - .filter(image => { - if (image.data.usages.data.length === 0) { - validImages.push(image); - return false; - } - return true; - }); - filteredImages.forEach((image) => { - let syndicationExists = false; - for (const usage of image.data.usages.data) { - if (usage.data.platform === "syndication") { - syndicationExists = true; - break; - } + images.forEach(image => { + if (image.data.uploadedBy === 'Capture_AutoIngest' || imageHasSyndicationUsage(image)) { + invalidImages.push(image); + } else { + validImages.push(image); } - (syndicationExists === true ? invalidImages : validImages).push(image); }); + return [validImages, invalidImages]; }; + ctrl.showPaid = undefined; mediaApi.getSession().then(session => { ctrl.showPaid = session.user.permissions.showPaid ? session.user.permissions.showPaid : undefined;