Skip to content
Snippets Groups Projects
Commit ceda32be authored by Sebastien's avatar Sebastien
Browse files

Inject home controller url to edit.html.twig and project_view.html.twig

parent 022340af
Branches
Tags
1 merge request!89Tuleap 203 not able to open capsule preview from capsule edition
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
<script language="javascript" type='text/javascript' src='../shared/js/iannix.js'></script> <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 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> <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" /> <link rel="stylesheet" type="text/css" href="../shared/js/libs/video-js/video-js.min.css" />
...@@ -84,7 +83,7 @@ ...@@ -84,7 +83,7 @@
<input class="popupFormButton" id="popupFormButtonUpload" type="submit" value="Upload" name="submit"> <input class="popupFormButton" id="popupFormButtonUpload" type="submit" value="Upload" name="submit">
</div> </div>
</div> --> </div> -->
<a class="displayMode" id="watermarkBox" href="javascript:window.app.rekall.Rekall('openUrl', window.app.urls.memberHome)" title="Open in MemoRekall" target="_parent"><img id="watermark" src="../shared/css/images/watermark.png" /></a> <a class="displayMode" id="watermarkBox" href="javascript:window.app.rekall.Rekall('openUrl', 'home')" title="Open in MemoRekall" target="_parent"><img id="watermark" src="../shared/css/images/watermark.png" /></a>
<!--<a class="displayMode" id="openFullScreenBox" href="http://www.memorekall.fr" alt="Open in MemoRekall" target="_blank"><img id="openFullScreen" src="../shared/css/images/expand.png" /></a>--> <!--<a class="displayMode" id="openFullScreenBox" href="http://www.memorekall.fr" alt="Open in MemoRekall" target="_blank"><img id="openFullScreen" src="../shared/css/images/expand.png" /></a>-->
<div class="displayMode" id="projectInfoBtn" title="Project informations">i</div> <div class="displayMode" id="projectInfoBtn" title="Project informations">i</div>
<div id="popupAlertSpace"> <div id="popupAlertSpace">
...@@ -205,7 +204,7 @@ ...@@ -205,7 +204,7 @@
<div id='left_menu' class='flex-col editmode'> <div id='left_menu' class='flex-col editmode'>
<div class='top'> <div class='top'>
<a class="left_menu_item dropable" href="javascript:window.app.rekall.Rekall('openUrl', window.app.urls.memberHome)"> <a class="left_menu_item dropable" href="javascript:window.app.rekall.Rekall('openUrl', 'home')">
<i class="fas fa-home fa-3x left_menu_item_icn"></i> <i class="fas fa-home fa-3x left_menu_item_icn"></i>
<p>Go back to my capsules</p> <p>Go back to my capsules</p>
</a> </a>
......
...@@ -6,12 +6,24 @@ ...@@ -6,12 +6,24 @@
'init', 'init',
'setPlaybackRate', 'setPlaybackRate',
'videoPlayer', 'videoPlayer',
'rekall' 'rekall',
'getUrl'
]; ];
let localOptions = {}; let localOptions = {};
const OPTIONS = { const OPTIONS = {
getUrl: function (){
if (arguments && localOptions.links && localOptions.links[arguments[0]]) {
return localOptions.links[arguments[0]];
}
return '';
},
init: function (opts) {
if (opts) {
$.extend(localOptions, opts);
}
},
openUrl: function () { openUrl: function () {
if (!arguments) if (!arguments)
return; return;
...@@ -24,10 +36,8 @@ ...@@ -24,10 +36,8 @@
pubSub: function () { pubSub: function () {
return localOptions.PubSub; return localOptions.PubSub;
}, },
init: function (opts) { rekall: function () {
if (opts) { return localOptions.Rekall;
$.extend(localOptions, opts);
}
}, },
setPlaybackRate: function () { setPlaybackRate: function () {
if (arguments.length > 0 && 'number' === typeof arguments[0] && 0 < arguments[0] && arguments[0] < 10) { if (arguments.length > 0 && 'number' === typeof arguments[0] && 0 < arguments[0] && arguments[0] < 10) {
...@@ -40,9 +50,6 @@ ...@@ -40,9 +50,6 @@
} }
return localOptions._videoPlayer; return localOptions._videoPlayer;
},
rekall: function () {
return localOptions.Rekall;
} }
}; };
...@@ -60,5 +67,5 @@ ...@@ -60,5 +67,5 @@
} }
} }
} }
app.rekall = new RekallApplication() app.rekall = new RekallApplication();
})(window.app = window.app || {}) })(window.app = window.app || {})
\ No newline at end of file
...@@ -19,7 +19,6 @@ $(document).ready(function() { ...@@ -19,7 +19,6 @@ $(document).ready(function() {
}); });
window.app.rekall.Rekall().allowProjectDeletion(window.app.Settings.Project.ProjectDeletionEnabled); window.app.rekall.Rekall().allowProjectDeletion(window.app.Settings.Project.ProjectDeletionEnabled);
rekall.allowProjectDeletion(window.app.Settings.Project.ProjectDeletionEnabled)
Utils.actionPrefix = "php/"; Utils.actionPrefix = "php/";
Utils.actionSuffix = ".php?r="; Utils.actionSuffix = ".php?r=";
...@@ -41,8 +40,6 @@ $(document).ready(function() { ...@@ -41,8 +40,6 @@ $(document).ready(function() {
rekall_common = infos; rekall_common = infos;
if(getParameterByName("w") != "") if(getParameterByName("w") != "")
rekall_common.owner.canEdit = false; rekall_common.owner.canEdit = false;
//
//rekall_common.owner.canEdit = true;
if(rekall_common.owner.canEdit) { if(rekall_common.owner.canEdit) {
//Mode preview or not //Mode preview or not
...@@ -310,8 +307,7 @@ function setEditionControls() { ...@@ -310,8 +307,7 @@ function setEditionControls() {
$("#left_menu_item_preview").click(function(event){ $("#left_menu_item_preview").click(function(event){
event.stopPropagation(); event.stopPropagation();
window.open(window.app.urls.memberHome + 'capsule/preview/' + window.location.pathname.replace('/legacy/', '').slice(0, -1), '_blank'); window.open(window.app.rekall.Rekall('getUrl', 'projectPreview'), '_blank');
/*window.open("?w=1", "Preview Rekall", "menubar=no, status=no, scrollbars=no, menubar=no, width=1150, height=560"); */
}); });
$("#popupSettingsBtnDownloadXml").click(function(event){ $("#popupSettingsBtnDownloadXml").click(function(event){
...@@ -1086,7 +1082,7 @@ function removeProject() { ...@@ -1086,7 +1082,7 @@ function removeProject() {
data: {"remove": 1}, data: {"remove": 1},
success: function(retour) { success: function(retour) {
rouletteEnd(); rouletteEnd();
window.app.rekall.Rekall('openUrl', window.app.urls.memberHome); window.app.rekall.Rekall('openUrl', 'home');
}, },
error: function() { error: function() {
openAlert("Server error. Try again."); openAlert("Server error. Try again.");
......
...@@ -20,6 +20,7 @@ use Symfony\Component\Form\FormInterface; ...@@ -20,6 +20,7 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
...@@ -132,7 +133,7 @@ class CapsuleController extends AbstractController ...@@ -132,7 +133,7 @@ class CapsuleController extends AbstractController
} }
#[Route('/{_locale<%app.supported_locales%>}/capsule/preview/{path}', name:'preview_capsule')] #[Route('/{_locale<%app.supported_locales%>}/capsule/preview/{path}', name:'preview_capsule')]
public function preview(string $path): Response public function preview(string $path, UrlGeneratorInterface $urlGenerator): Response
{ {
$file_path = '../legacy/' . $path; $file_path = '../legacy/' . $path;
if (!file_exists($file_path)) { if (!file_exists($file_path)) {
...@@ -143,12 +144,15 @@ class CapsuleController extends AbstractController ...@@ -143,12 +144,15 @@ class CapsuleController extends AbstractController
return $this->render( return $this->render(
'project/project_view.html.twig', 'project/project_view.html.twig',
[ 'url' => $url ] [
'url' => $url,
'linkHome' => $urlGenerator->generate('home', [], UrlGeneratorInterface::ABSOLUTE_URL)
]
); );
} }
#[Route('/{_locale<%app.supported_locales%>}/capsule/edit/{path}', name:'edit_capsule')] #[Route('/{_locale<%app.supported_locales%>}/capsule/edit/{path}', name:'edit_capsule')]
public function edit(string $path): Response public function edit(string $path, UrlGeneratorInterface $urlGenerator): Response
{ {
$current_user = $this->getUser(); $current_user = $this->getUser();
...@@ -175,8 +179,21 @@ class CapsuleController extends AbstractController ...@@ -175,8 +179,21 @@ class CapsuleController extends AbstractController
$url = $this->getParameter('app.legacy_external_prefix') . '/' . $capsule->getEditionLink(); $url = $this->getParameter('app.legacy_external_prefix') . '/' . $capsule->getEditionLink();
return $this->render( return $this->render(
'project/project_view.html.twig', 'project/edit.html.twig',
[ 'url' => $url ] [
'url' => $url,
'linkHome' => $urlGenerator->generate(
'home',
[],
UrlGeneratorInterface::ABSOLUTE_URL
)
,
'linkPreview' => $urlGenerator->generate(
'preview_capsule',
[ 'path' => $capsule->getLinkPath() ],
UrlGeneratorInterface::ABSOLUTE_URL
)
]
); );
} }
......
...@@ -11,3 +11,18 @@ ...@@ -11,3 +11,18 @@
</iframe> </iframe>
{% endblock %} {% endblock %}
{% block script %}
<script>
window.onload = function (){
const iframe = document.getElementById('legacyContent').contentWindow;
iframe.app.rekall.Rekall('init', {
links: {
home: '{{ linkHome }}',
projectPreview: '{{ linkPreview }}'
}
}
);
}
</script>
{% endblock %}
\ No newline at end of file
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
</div> </div>
<iframe src="{{ url }}" <iframe src="{{ url }}"
id="legacyContent"
style="width:100%;height:100%;top:0;left:0;position:absolute" style="width:100%;height:100%;top:0;left:0;position:absolute"
frameborder="0" frameborder="0"
...@@ -36,5 +37,20 @@ ...@@ -36,5 +37,20 @@
allowfullscreen> allowfullscreen>
</iframe> </iframe>
{% block script %}
<script>
window.onload = function (){
const iframe = document.getElementById('legacyContent').contentWindow;
iframe.app.rekall.Rekall('init', {
links: {
home: '{{ linkHome }}'
}
}
);
}
</script>
{% endblock %}
</body> </body>
</html> </html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment