Skip to content

Commit

Permalink
#23088
Browse files Browse the repository at this point in the history
  • Loading branch information
nczirjak-acdh committed Oct 29, 2024
1 parent 0a9cf47 commit 72dd905
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 49 deletions.
30 changes: 9 additions & 21 deletions js/arche_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jQuery(function ($) {
* @returns {undefined}
*/
function checkUserPermission() {
console.log("https://invalid:credentials@" + baseApiUrl + "/user/logout?redirect=" + apiUrl);
if ($('div').hasClass('download-login-div')) {
let resourceId = $("#resId").val();
let aclRead = $("#resource-acl-read").val();
Expand Down Expand Up @@ -78,30 +77,19 @@ jQuery(function ($) {
if (data.length === 0 || data.access == 'login') {
$('#download-not-logged').removeClass('d-none');
} else {
if (data.access == 'authorized' || (acdhType.toLowerCase() === 'collection' || acdhType.toLowerCase() === 'topcollection')) {
$('#download-resource-section').removeClass('d-none');
$('#download-logged').removeClass('d-none');
$('#download-not-logged').addClass('d-none');
$('#user-logged-text').html(data.username + ' : ' + data.roles);
$('#download-logout').removeClass('d-none');
if (data.access == 'authorized' || (acdhType.toLowerCase() === 'collection' || acdhType.toLowerCase() === 'topcollection')) {
$('#download-restricted').addClass('d-none');
if (data.loginMethod == 'shibboleth') {
$('.gui-shibboleth-logout').removeClass('d-none');
} else {
$('.gui-https-logout').removeClass('d-none');
}
$('#download-not-logged').addClass('d-none');
$('#download-logged').removeClass('d-none');
$('#download-not-authorized').addClass('d-none');
$('#download-resource-section').removeClass('d-none');
$('#user-logged-text').html(data.username + ' : ' + data.roles);
} else if (data.access == 'not authorized') {
$('#download-restricted').addClass('d-none');
$('#download-logged').removeClass('d-none');
$('#download-not-logged').addClass('d-none');
$('#download-logged').addClass('d-none');
$('#download-not-authorized').removeClass('d-none');
$('#user-logged-not-auth-text').html(data.username + ' : ' + data.roles);
$('#user-not-authorized-text').html(Drupal.t("You don't have enough rights!"));
$('#download-logout').removeClass('d-none');
if (data.loginMethod == 'shibboleth') {
$('.gui-shibboleth-logout').removeClass('d-none');
} else {
$('.gui-https-logout').removeClass('d-none');
}
$('#user-logged-not-auth-text').html(data.username + ' : ' + data.roles);
} else if (data.access == 'login') {
$('#download-not-logged').removeClass('d-none');
}
Expand Down
56 changes: 28 additions & 28 deletions templates/blocks/download-card-block.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -48,46 +48,46 @@
</div>
</div>
</div>
</div>

<div class="row d-none" id="download-not-authorized">
<div class="col-lg-12">
<div class="alert alert-warning">
<div>
{{ "You are not authorized to download this data!"|trans }}<br><br>
</div>
<div>
{{ "You are logged in as"|trans }}: <span id="user-logged-not-auth-text"></span>
</div>
<div class="pt-2">
<div class="col-lg-12 d-none gui-https-logout"><a href="#" class="btn btn-arche-blue" id="httpd-logout">{{ "Logout"|trans }}</a></div>
<div class="col-lg-12 d-none gui-shibboleth-logout"><!-- <a href="https://weblogin.oeaw.ac.at/idp/profile/Logout" class="btn btn-arche-blue gui-shibboleth-logout-btn">{{ "Logout"|trans }}</a>--></div>
</div>
<div class="row d-none" id="download-not-authorized">
<div class="col-lg-12">
<div class="alert alert-warning">
<div>
{{ "You are not authorized to download this data!"|trans }}<br><br>
</div>
<div>
{{ "You are logged in as"|trans }}: <span id="user-logged-not-auth-text"></span>
</div>
<div class="pt-2">
<div class="col-lg-12 d-none gui-https-logout"><a href="#" class="btn btn-arche-blue" id="httpd-logout">{{ "Logout"|trans }}</a></div>
<div class="col-lg-12 d-none gui-shibboleth-logout"><!-- <a href="https://weblogin.oeaw.ac.at/idp/profile/Logout" class="btn btn-arche-blue gui-shibboleth-logout-btn">{{ "Logout"|trans }}</a>--></div>
</div>
</div>
</div>
</div>
</div>

{% set resourceApiUrl = data.getRepoUrl() %}
{% set resourceApiUrl = data.getRepoUrl() %}


<div class="row d-none" id="download-resource-section">
<div class="row d-none" id="download-resource-section">

{% if data.isBinary %}
<div class="col-lg-12 pt-2 pb-2"><a href="{{ resourceApiUrl }}" class="btn-arche-blue-sidebar" target="_blank">{{ "Download File"|trans }} <img src="{{ arche_dl_ico }}"/></a></div>
{% if data.isBinary %}
<div class="col-lg-12 pt-2 pb-2"><a href="{{ resourceApiUrl }}" class="btn-arche-blue-sidebar" target="_blank">{{ "Download File"|trans }} <img src="{{ arche_dl_ico }}"/></a></div>

{% endif %}
{% if data.acdhType|lower == "collection" or data.acdhType|lower == "topcollection" %}
<!-- <a href="{{ data.getRepoBaseUrl }}dl_collection/{{ data.getRepoId }}" class="btn-arche-blue-sidebar" target="_blank">{{ "Download Collection"|trans }} <img src="{{ arche_dl_ico }}"/></a>-->
<div class="col-lg-12 pt-2 pb-2"><a href="{{ data.getRepoBaseUrl }}/dissemination/collection_download_script/{{ data.getRepoId }}" class="btn-arche-blue-sidebar" target="_blank">{{ "Download Collection Script"|trans }} <img src="{{ arche_dl_ico }}"/></a></div>
{% elseif data.acdhType|lower == "resource" %}
{% endif %}
{% endif %}
{% if data.acdhType|lower == "collection" or data.acdhType|lower == "topcollection" %}
<!-- <a href="{{ data.getRepoBaseUrl }}dl_collection/{{ data.getRepoId }}" class="btn-arche-blue-sidebar" target="_blank">{{ "Download Collection"|trans }} <img src="{{ arche_dl_ico }}"/></a>-->
<div class="col-lg-12 pt-2 pb-2"><a href="{{ data.getRepoBaseUrl }}/dissemination/collection_download_script/{{ data.getRepoId }}" class="btn-arche-blue-sidebar" target="_blank">{{ "Download Collection Script"|trans }} <img src="{{ arche_dl_ico }}"/></a></div>
{% elseif data.acdhType|lower == "resource" %}
{% endif %}

</div>
<div class="row" id="download-metadata-section">
<div class="col-lg-12 pt-2 pb-2"><a href="{{ resourceApiUrl }}/metadata?format=text/turtle&readMode=relatives&parentProperty=https%3A%2F%2Fvocabs.acdh.oeaw.ac.at%2Fschema%23isPartOf" class="btn-arche-blue-sidebar" target="_blank">{{ "Download Metadata"|trans }} <img src="{{ arche_dl_ico }}"/></a>
</div>
</div>
<div class="row" id="download-metadata-section">
<div class="col-lg-12 pt-2 pb-2"><a href="{{ resourceApiUrl }}/metadata?format=text/turtle&readMode=relatives&parentProperty=https%3A%2F%2Fvocabs.acdh.oeaw.ac.at%2Fschema%23isPartOf" class="btn-arche-blue-sidebar" target="_blank">{{ "Download Metadata"|trans }} <img src="{{ arche_dl_ico }}"/></a>
</div>
</div>
</div>
</div>
</div>
</div>

0 comments on commit 72dd905

Please sign in to comment.