diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 759173ad..474aa6f5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,6 @@ exclude: | (?x) # NOT INSTALLABLE ADDONS - ^cmis_web_proxy_alf/| ^cmis_web_report_write_alf/| # END NOT INSTALLABLE ADDONS # Files and folders generated by bots, to avoid loops diff --git a/cmis_web_proxy_alf/README.rst b/cmis_web_proxy_alf/README.rst index 8f3c3817..b6ab2a20 100644 --- a/cmis_web_proxy_alf/README.rst +++ b/cmis_web_proxy_alf/README.rst @@ -27,4 +27,4 @@ Maintainer :alt: ACSONE SA/NV :target: http://www.acsone.eu -This module is maintained by ACSONE SA/NV. \ No newline at end of file +This module is maintained by ACSONE SA/NV. diff --git a/cmis_web_proxy_alf/__manifest__.py b/cmis_web_proxy_alf/__manifest__.py index 2c3bdea4..a02a62fa 100644 --- a/cmis_web_proxy_alf/__manifest__.py +++ b/cmis_web_proxy_alf/__manifest__.py @@ -4,14 +4,20 @@ { "name": "Alfodoo CMIS Web Proxy for Alfresco", "category": "Document Management", - "version": "14.0.1.0.1", + "version": "16.0.1.0.1", "license": "AGPL-3", "author": "ACSONE SA/NV", "website": "https://alfodoo.org", "depends": ["cmis_web_proxy"], - "data": ["views/cmis_backend.xml", "views/cmis_web_proxy_alf.xml"], + "data": ["views/cmis_backend.xml"], "demo": [], "pre_init_hook": "pre_init_hook", "images": ["static/description/main_icon.png"], - "installable": False, + "assets": { + "web.assets_backend": [ + "/cmis_web_proxy_alf/static/src/cmis_folder/cmis_folder.js", + "/cmis_web_proxy_alf/static/src/cmis_object_wrapper_service.js", + ], + }, + "installable": True, } diff --git a/cmis_web_proxy_alf/controllers/alfresco.py b/cmis_web_proxy_alf/controllers/alfresco.py index 183f76c0..963a48b9 100644 --- a/cmis_web_proxy_alf/controllers/alfresco.py +++ b/cmis_web_proxy_alf/controllers/alfresco.py @@ -6,7 +6,6 @@ from odoo.http import request from odoo.addons.cmis_web_proxy.controllers import cmis -from odoo.addons.web.controllers import main ALFRESCO_API_PROXY_PATH = "/alfresco/s/api" @@ -36,7 +35,6 @@ def _check_alfresco_access(self, proxy_info, params): csrf=False, methods=["GET"], ) - @main.serialize_exception def get_thumnails(self, backend_id, cmis_name, **kwargs): """Call at the root of the CMIS repository. These calls are for requesting the global services provided by the CMIS Container diff --git a/cmis_web_proxy_alf/static/src/cmis_folder/cmis_folder.js b/cmis_web_proxy_alf/static/src/cmis_folder/cmis_folder.js new file mode 100644 index 00000000..66ba185b --- /dev/null +++ b/cmis_web_proxy_alf/static/src/cmis_folder/cmis_folder.js @@ -0,0 +1,21 @@ +/** @odoo-module **/ + +/* --------------------------------------------------------- ++ * Odoo cmis_web ++ * Authors Laurent Mignon 2016, Maxime Franco 2023 Acsone SA/NV ++ * License in __openerp__.py at root level of the module ++ *--------------------------------------------------------- ++*/ + +import {CmisFolderField} from "@cmis_web/cmis_folder/cmis_folder"; +import {patch} from "@web/core/utils/patch"; + +patch(CmisFolderField.prototype, "open_with_proxy_alf", { + getCmisObjectWrapperParams() { + const params = this._super(...arguments); + params.alfrescoApiLocation = this.backend.alfresco_api_location; + return params; + }, +}); + +CmisFolderField.props.backend[0].shape.alfresco_api_location = String; diff --git a/cmis_web_proxy_alf/static/src/cmis_object_wrapper_service.js b/cmis_web_proxy_alf/static/src/cmis_object_wrapper_service.js new file mode 100644 index 00000000..72a2262e --- /dev/null +++ b/cmis_web_proxy_alf/static/src/cmis_object_wrapper_service.js @@ -0,0 +1,38 @@ +/** @odoo-module **/ + +/* --------------------------------------------------------- ++ * Odoo cmis_web ++ * Authors Laurent Mignon 2016, Maxime Franco 2023 Acsone SA/NV ++ * License in __openerp__.py at root level of the module ++ *--------------------------------------------------------- ++*/ + +import {CmisObjectWrapper} from "@cmis_web/cmis_object_wrapper_service"; +import {patch} from "@web/core/utils/patch"; + +patch(CmisObjectWrapper.prototype, "alfresco_proxy_alf_url", { + setup(cmisObject, cmisSession, params) { + this._super(...arguments); + this.alfrescoApiLocation = params.alfrescoApiLocation; + }, + getPreviewUrl() { + var _url = this._super(...arguments); + if (_url) { + return _url; + } + var params = { + c: "force", + lastModified: "pdf%" + new Date().getUTCMilliseconds(), + token: this.token, + objectId: this.objectId, + versionSeriesId: this.versionSeriesId, + }; + return ( + this.alfrescoApiLocation + + "/content/thumbnails/pdf/" + + this.name + + "?" + + $.param(params) + ); + }, +}); diff --git a/cmis_web_proxy_alf/static/src/js/form_widgets.js b/cmis_web_proxy_alf/static/src/js/form_widgets.js deleted file mode 100644 index 80f2d8cf..00000000 --- a/cmis_web_proxy_alf/static/src/js/form_widgets.js +++ /dev/null @@ -1,58 +0,0 @@ -/* --------------------------------------------------------- - + * Odoo web_cmis_viewer - + * Author Laurent Mignon 2016 Acsone SA/NV - + * License in __openerp__.py at root level of the module - + *--------------------------------------------------------- - +*/ - -odoo.define("cmis_web_proxy_alf.form_widgets", function (require) { - "use strict"; - - var form_widgets = require("cmis_web.form_widgets"); - - form_widgets.CmisObjectWrapper.include({ - init: function () { - this._super.apply(this, arguments); - this.alfresco_api_location = null; - this.token = null; - }, - - get_preview_url: function () { - var _url = this._super.apply(this, arguments); - if (_url) { - return _url; - } - // By default, review are generated in alfresco the first time it's requested by share - // Before this first access, the renditions on the cmis object is empty. - // Use the alfresco API to trigger a first rendition of the document. - var params = { - c: "force", - lastModified: "pdf%" + new Date().getUTCMilliseconds(), - token: this.token, - objectId: this.objectId, - versionSeriesId: this.versionSeriesId, - }; - return ( - this.alfresco_api_location + - "/content/thumbnails/pdf/" + - this.name + - "?" + - $.param(params) - ); - }, - }); - - form_widgets.FieldCmisFolder.include({ - wrap_cmis_object: function (cmisObject) { - var obj = this._super.apply(this, arguments); - obj.alfresco_api_location = this.alfresco_api_location; - obj.token = this.gen_cmis_session_token(); - return obj; - }, - - bind_cmis_config: function (backend) { - this._super.apply(this, arguments); - this.alfresco_api_location = backend.alfresco_api_location; - }, - }); -}); diff --git a/cmis_web_proxy_alf/views/cmis_web_proxy_alf.xml b/cmis_web_proxy_alf/views/cmis_web_proxy_alf.xml deleted file mode 100644 index d70f760d..00000000 --- a/cmis_web_proxy_alf/views/cmis_web_proxy_alf.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - -