Sunday, July 1, 2018

AEM 61 Classic UI Disable Drag and Drop from Desktop to DAM Admin Console

AEM 61 Classic UI Disable Drag and Drop from Desktop to DAM Admin Console


Goal


Disable upload of assets using Drag and Drop from Desktop to DAM Admin Console - http://localhost:4502/damadmin

For TouchUI check this post

Demo | Package Install




Solution


1) Login to CRXDE Lite (http://localhost:4502/crx/de) and create folder /apps/classicui-assets-disable-desktop-drop

2) Create node /apps/classicui-assets-disable-desktop-drop/clientlib of type cq:ClientLibraryFolder and add a String property categories with value cq.widgets

3) Create file (nt:file) /apps/classicui-assets-disable-desktop-drop/clientlib/js.txt and add

                       disable-drop.js

4) Create file (nt:file) /apps/classicui-assets-disable-desktop-drop/clientlib/disable-drop.js and add the following code.

(function () {
if (window.location.pathname !== "/damadmin") {
return;
}

//id set in /libs/wcm/core/content/damadmin
var DAM_ADMIN_ID = "cq-damadmin";

function handleDrops() {
var damAdmin = CQ.Ext.getCmp(DAM_ADMIN_ID);

damAdmin.html5UploadFiles = function (files) {
CQ.Ext.Msg.alert("Drop Error", "Drop from desktop disabled");
}
}

var INTERVAL = setInterval(function () {
var grid = CQ.Ext.getCmp(DAM_ADMIN_ID + "-grid");

if (!grid) {
return;
}

clearInterval(INTERVAL);

try {
handleDrops();
} catch (err) {
console.log("error executing drag drop disable extension");
}
}, 250);
})();



visit link download