From ddbcc8cecde45bb14f911a71a567528b6a9908a9 Mon Sep 17 00:00:00 2001 From: Sebastien Curt <sebastien.curt@tetras-libre.fr> Date: Fri, 28 Jan 2022 14:31:00 +0100 Subject: [PATCH] disallow project deletion --- .env_default | 3 +- capsule-prototype/index.html | 8 ++-- capsule-prototype/js/online-rekall/Rekall.js | 50 +++++++++++++++++++- capsule-prototype/js/online-script.js | 12 ++--- capsule-prototype/php/rekallApp.js.php | 11 +++-- docker-compose.yml | 1 + 6 files changed, 70 insertions(+), 15 deletions(-) diff --git a/.env_default b/.env_default index e851c24..10c973b 100644 --- a/.env_default +++ b/.env_default @@ -69,4 +69,5 @@ LEGACY_URL_EXTERNAL=http://localhost:8081/legacy/ LEGACY_EXTERNAL_PREFIX=/legacy MEMBER_URL_EXTERNAL=http://localhost:8081/ -FRONT_URL_EXTERNAL=http://localhost:8081/ \ No newline at end of file +FRONT_URL_EXTERNAL=http://localhost:8081/ +LEGACY_PROJECT_DELETION_ENABLED=false \ No newline at end of file diff --git a/capsule-prototype/index.html b/capsule-prototype/index.html index 6a4892c..7ee8857 100644 --- a/capsule-prototype/index.html +++ b/capsule-prototype/index.html @@ -26,6 +26,8 @@ <script language="javascript" type='text/javascript' src='../shared/js/libs/fastdom.js'></script> <script language="javascript" type='text/javascript' src='../shared/js/libs/moment-with-langs.min.js'></script> + <script type="module" src="../shared/php/rekallApp.js.php"></script> + <script language="javascript" type='text/javascript' src='../shared/js/rekall/Utils.js'></script> <script language="javascript" type='text/javascript' src='../shared/js/online-rekall/Rekall.js'></script> <script language="javascript" type='text/javascript' src='../shared/js/rekall/Source.js'></script> @@ -38,7 +40,6 @@ <script language="javascript" type='text/javascript' src='../shared/js/iannix.js'></script> <script language="javascript" type='text/javascript' src='../shared/js/online-script.js'></script> - <script type="module" src="../shared/php/rekallApp.js.php"></script> <script language="javascript" type='text/javascript' src="../shared/js/libs/video-js/video.min.js"></script> <link rel="stylesheet" type="text/css" href="../shared/js/libs/video-js/video-js.min.css" /> @@ -244,13 +245,14 @@ </div> </tr></td> </table> - <video id="video" class="video-js vjs-default-skin vjs-big-play-centered"> + <div style="width: 100%; height: 30px; background: black"></div> + <video id="video" class="video-js vjs-default-skin vjs-big-play-centered"> <p class="vjs-no-js">Your browser is not compatible with HTML5. Please upgrade!</p> <!-- <track kind="captions" src="demo.captions.vtt" srclang="en" label="English"></track> <track kind="subtitles" src="demo.captions.vtt" srclang="en" label="English"></track> --> - </video> + </video> <div id='flattentimeline'> <div id="flattentimeline_highlight"> </div> diff --git a/capsule-prototype/js/online-rekall/Rekall.js b/capsule-prototype/js/online-rekall/Rekall.js index 676df7e..5048899 100644 --- a/capsule-prototype/js/online-rekall/Rekall.js +++ b/capsule-prototype/js/online-rekall/Rekall.js @@ -22,12 +22,55 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -function Rekall() { +function Rekall(options) { this.sortings = new Object(); this.sortings["horizontal"] = new Sorting("Time"); this.sortings["colors"] = new Sorting("Rekall->Type", false, ""); this.timeline = new Timeline(); this.videoPlayer = undefined; + + function getDefaultBaseUrl() { + var oldURL = window.document.location + ""; + var url = oldURL; + var index = 0; + url = url.replace("pro-index.html", ""); + url = url.replace("online-index.html", ""); + url = url.replace("index.html", ""); + index = oldURL.indexOf('?'); + if(index == -1) + index = oldURL.indexOf('#'); + if(index != -1) + url = oldURL.substring(0, index); + if(!url.endsWith("/")) + url = url + "/"; + + if(window.location.host == "dev3.memorekall.com") { + url = url.replace("dev3.memorekall.com", "dev2.memorekall.com"); + } + if(window.location.host == "legacy.memorekall.com") { + url = url.replace("legacy.memorekall.com", "project.memorekall.com"); + } + if(window.location.host == "legacy.memorekall.fr") { + url = url.replace("legacy.memorekall.fr", "project.memorekall.com"); + } + + return url; + } + + var defaultSettings = { + _allowProjectDeletion: false, + baseUrl: getDefaultBaseUrl() + } + + this.Settings = $.extend({}, defaultSettings, options); +} + +Rekall.prototype.enableProjectDeletion = function() { + this.Settings.allowProjectDeletion = true; +} + +Rekall.prototype.disableProjectDeletion = function() { + this.Settings.allowProjectDeletion = false; } Rekall.prototype.loadXMLFile = function() { @@ -44,6 +87,11 @@ Rekall.prototype.loadXMLFile = function() { url = oldURL.substring(0, index); if(!url.endsWith("/")) url = url + "/"; + + if(!this.Settings._allowProjectDeletion){ + $('#popupSettingsBtnDelete').hide(); + }; + if(window.location.host == "dev3.memorekall.com") { url = url.replace("dev3.memorekall.com", "dev2.memorekall.com"); $("#popupSettingsBtnDelete").hide(); diff --git a/capsule-prototype/js/online-script.js b/capsule-prototype/js/online-script.js index dd64c9b..17e974f 100644 --- a/capsule-prototype/js/online-script.js +++ b/capsule-prototype/js/online-script.js @@ -1,6 +1,8 @@ var rekall = new Rekall(); var rekall_common = new Object(); $(document).ready(function() { + rekall.Settings.ProjectDeletionEnabled = window.app.ProjectDeletionEnabled; + Utils.actionPrefix = "php/"; Utils.actionSuffix = ".php?r="; @@ -130,10 +132,8 @@ $(document).ready(function() { event.stopPropagation(); var tmp = shareLink(); openAlert("input",tmp); - }); - - -}); + }); +}); function setEditionControls() { //Drag&drop files @@ -534,9 +534,7 @@ function setEditionControls() { $("#popupEditSupprimer").click(function(){ openAlert("Do you really want to delete this file from the project ?", "yesnodelete"); - }); - - + }); } /*var rubanTimeout = 0; diff --git a/capsule-prototype/php/rekallApp.js.php b/capsule-prototype/php/rekallApp.js.php index 992a34b..f0d9638 100644 --- a/capsule-prototype/php/rekallApp.js.php +++ b/capsule-prototype/php/rekallApp.js.php @@ -3,8 +3,8 @@ Header("content-type: application/x-javascript"); $front_url = $_ENV["FRONT_URL_EXTERNAL"]; $member_url = $_ENV["MEMBER_URL_EXTERNAL"]; +$project_allow_deletion = isset($_ENV["LEGACY_PROJECT_DELETION_ENABLED"]) && $_ENV["LEGACY_PROJECT_DELETION_ENABLED"] == 'true'; ?> - function RekallApp (opts = {}){ const METHODS = [ 'openUrl', @@ -18,10 +18,10 @@ function RekallApp (opts = {}){ return; window.top.location.assign(arguments[0]); }, - pubSub: new function(PubSub){ + pubSub: function(PubSub){ return window.PubSub; }, - init: new function(PubSub){ + init: function(PubSub){ window.PubSub = PubSub; } }; @@ -54,5 +54,10 @@ function RekallApp (opts = {}){ frontHome : '<?= $front_url ?>', memberHome : '<?= $member_url ?>', }; + app.Settings = { + Project: { + ProjectDeletionEnabled: <?= $project_allow_deletion ?>, + } + }; return app; })(window.app = window.app || {}); diff --git a/docker-compose.yml b/docker-compose.yml index d0fdb7d..07f02b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,6 +35,7 @@ services: environment: - MEMBER_URL_EXTERNAL - FRONT_URL_EXTERNAL + - LEGACY_PROJECT_DELETION_ENABLED volumes: - $PWD/legacy:/sites/memorekall/www/web_legacy:rw - $PWD/log:/sites/memorekall/www/log:rw -- GitLab