2022-07-17 18:16:00 +00:00
|
|
|
<!--
|
2023-11-04 09:54:52 +00:00
|
|
|
Copyright (C) 2023 Nicola Murino
|
2022-07-17 18:16:00 +00:00
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
This WebUI uses the KeenThemes Mega Bundle, a proprietary theme:
|
2022-07-17 18:16:00 +00:00
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
https://keenthemes.com/products/templates-mega-bundle
|
2022-07-17 18:16:00 +00:00
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
KeenThemes HTML/CSS/JS components are allowed for use only within the
|
|
|
|
SFTPGo product and restricted to be used in a resealable HTML template
|
|
|
|
that can compete with KeenThemes products anyhow.
|
|
|
|
|
|
|
|
This WebUI is allowed for use only within the SFTPGo product and
|
|
|
|
therefore cannot be used in derivative works/products without an
|
|
|
|
explicit grant from the SFTPGo Team (support@sftpgo.com).
|
2022-07-17 18:16:00 +00:00
|
|
|
-->
|
2024-01-01 19:09:15 +00:00
|
|
|
{{- template "base" .}}
|
2021-11-06 13:13:20 +00:00
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
{{- define "extra_css"}}
|
|
|
|
<link href="{{.StaticURL}}/assets/plugins/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css"/>
|
|
|
|
{{- end}}
|
|
|
|
|
2024-01-01 19:09:15 +00:00
|
|
|
{{- define "page_body"}}
|
2024-02-04 13:33:51 +00:00
|
|
|
{{- template "errmsg" ""}}
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="card shadow-sm">
|
|
|
|
<div class="card-header bg-light">
|
2023-12-26 07:59:52 +00:00
|
|
|
<h3 data-i18n="share.view_manage" class="card-title section-title">View and manage shares</h3>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
2023-11-04 09:54:52 +00:00
|
|
|
<div id="card_body" class="card-body">
|
|
|
|
<div id="loader" class="align-items-center text-center my-10">
|
|
|
|
<span class="spinner-border w-15px h-15px text-muted align-middle me-2"></span>
|
2024-01-01 19:09:15 +00:00
|
|
|
<span data-i18n="general.loading" class="text-gray-700">Loading...</span>
|
2023-11-04 09:54:52 +00:00
|
|
|
</div>
|
|
|
|
<div id="card_content" class="d-none">
|
2024-01-01 19:09:15 +00:00
|
|
|
<div class="d-flex flex-stack flex-wrap mb-5">
|
2024-01-09 18:54:08 +00:00
|
|
|
<div class="d-flex align-items-center position-relative my-2">
|
2024-01-11 18:26:13 +00:00
|
|
|
<i class="ki-solid ki-magnifier fs-1 position-absolute ms-6"></i>
|
2024-01-01 19:09:15 +00:00
|
|
|
<input name="search" data-i18n="[placeholder]general.search" type="text" data-table-filter="search"
|
2023-12-26 07:59:52 +00:00
|
|
|
class="form-control rounded-1 w-250px ps-15 me-5" placeholder="Search" />
|
2023-11-04 09:54:52 +00:00
|
|
|
</div>
|
2024-01-09 18:54:08 +00:00
|
|
|
<div class="d-flex justify-content-end my-2" data-table-toolbar="base">
|
2024-01-01 19:09:15 +00:00
|
|
|
<a href="{{.ShareURL}}" class="btn btn-primary">
|
2023-11-04 09:54:52 +00:00
|
|
|
<i class="ki-duotone ki-plus fs-2"></i>
|
2024-01-01 19:09:15 +00:00
|
|
|
<span data-i18n="general.add">Add</span>
|
2023-11-04 09:54:52 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<table id="dataTable" class="table align-middle table-row-dashed fs-6 gy-5">
|
2021-11-06 13:13:20 +00:00
|
|
|
<thead>
|
2023-11-04 09:54:52 +00:00
|
|
|
<tr class="text-start text-muted fw-bold fs-6 gs-0">
|
2023-12-10 15:40:13 +00:00
|
|
|
<th data-i18n="general.name">Name</th>
|
|
|
|
<th data-i18n="share.scope">Scope</th>
|
|
|
|
<th data-i18n="general.info">Info</th>
|
2023-11-04 09:54:52 +00:00
|
|
|
<th class="min-w-100px"></th>
|
2021-11-06 13:13:20 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
2023-12-10 15:40:13 +00:00
|
|
|
<tbody id="table_body" class="text-gray-800 fw-semibold"></tbody>
|
2021-11-06 13:13:20 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-11-04 09:54:52 +00:00
|
|
|
{{- end}}
|
2021-11-06 13:13:20 +00:00
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
{{- define "modals"}}
|
|
|
|
<div class="modal fade" id="link_modal" tabindex="-1">
|
2021-11-06 13:13:20 +00:00
|
|
|
<div class="modal-dialog" role="document">
|
|
|
|
<div class="modal-content">
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="modal-header border-0">
|
2023-12-26 07:59:52 +00:00
|
|
|
<h3 data-i18n="share.access_links_title" class="modal-title">
|
2022-06-03 12:36:38 +00:00
|
|
|
Share access links
|
2023-11-04 09:54:52 +00:00
|
|
|
</h3>
|
2023-12-26 07:59:52 +00:00
|
|
|
<div data-i18n="[aria-label]general.close" class="btn btn-icon btn-sm btn-active-light-primary" data-bs-dismiss="modal" aria-label="Close">
|
|
|
|
<i class="ki-solid ki-cross fs-2x text-gray-700"></i>
|
2023-11-04 09:54:52 +00:00
|
|
|
</div>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="modal-body fs-5">
|
2024-02-04 13:33:51 +00:00
|
|
|
<div id="readShare" class="mb-5">
|
2024-01-11 18:26:13 +00:00
|
|
|
<div class="mb-3">
|
2023-12-26 07:59:52 +00:00
|
|
|
<h4 data-i18n="share.link_single_title">Single zip file</h4>
|
|
|
|
<p data-i18n="share.link_single_desc">You can download shared content as a single zip file</p>
|
|
|
|
<div class="d-flex">
|
|
|
|
<button id="readLinkCopy" type="button" class="btn btn-flex btn-light-primary btn-clipboard-copy me-3">
|
|
|
|
<i class="ki-duotone ki-fasten fs-2">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
</i>
|
|
|
|
<span data-i18n="general.copy_link">Copy link</span>
|
|
|
|
</button>
|
|
|
|
<a id="readLink" href="#" target="_blank" type="button" class="btn btn-flex btn-primary">
|
|
|
|
<i class="ki-duotone ki-folder-down fs-2">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
</i>
|
|
|
|
<span data-i18n="fs.download">Download</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<hr>
|
2024-01-11 18:26:13 +00:00
|
|
|
<div class="mb-3 mt-10">
|
2023-12-26 07:59:52 +00:00
|
|
|
<h4 data-i18n="share.link_dir_title">Single directory</h4>
|
|
|
|
<p data-i18n="share.link_dir_desc">If the share consists of a single directory you can browse and download files</p>
|
|
|
|
<button id="readBrowseLinkCopy" data-clipboard-target="#readBrowseLink" type="button" class="btn btn-flex btn-light-primary btn-clipboard-copy me-3">
|
|
|
|
<i class="ki-duotone ki-fasten fs-2">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
</i>
|
|
|
|
<span data-i18n="general.copy_link">Copy link</span>
|
|
|
|
</button>
|
|
|
|
<a id="readBrowseLink" href="#" target="_blank" type="button" class="btn btn-flex btn-primary">
|
|
|
|
<i class="ki-duotone ki-arrow-up-right fs-2">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
</i>
|
|
|
|
<span data-i18n="share.go">Go to share</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<hr>
|
2024-01-11 18:26:13 +00:00
|
|
|
<div class="mt-10">
|
2023-12-26 07:59:52 +00:00
|
|
|
<h4 data-i18n="share.link_uncompressed_title">Uncompressed file</h4>
|
|
|
|
<p data-i18n="share.link_uncompressed_desc">If the share consists of a single file you can download it uncompressed</p>
|
|
|
|
<button id="readUncompressedLinkCopy" data-clipboard-target="#readUncompressedLink" type="button" class="btn btn-flex btn-light-primary btn-clipboard-copy me-3">
|
|
|
|
<i class="ki-duotone ki-fasten fs-2">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
</i>
|
|
|
|
<span data-i18n="general.copy_link">Copy link</span>
|
|
|
|
</button>
|
|
|
|
<a id="readUncompressedLink" href="#" target="_blank" type="button" class="btn btn-flex btn-primary">
|
|
|
|
<i class="ki-duotone ki-folder-down fs-2">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
</i>
|
|
|
|
<span data-i18n="fs.download">Download</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
2024-02-04 13:33:51 +00:00
|
|
|
<div id="writeShare" class="mb-5">
|
2023-12-26 07:59:52 +00:00
|
|
|
<p data-i18n="share.upload_desc">You can upload one or more files to the shared directory</p>
|
|
|
|
<button id="writePageLinkCopy" data-clipboard-target="#writePageLink" type="button" class="btn btn-flex btn-light-primary btn-clipboard-copy me-3">
|
|
|
|
<i class="ki-duotone ki-fasten fs-2">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
</i>
|
|
|
|
<span data-i18n="general.copy_link">Copy link</span>
|
|
|
|
</button>
|
|
|
|
<a id="writePageLink" href="#" target="_blank" type="button" class="btn btn-flex btn-primary">
|
|
|
|
<i class="ki-duotone ki-folder-up fs-2">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
</i>
|
|
|
|
<span data-i18n="fs.upload.text">Upload</span>
|
|
|
|
</a>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
2024-02-04 13:33:51 +00:00
|
|
|
<div data-i18n="share.expired_desc" id="expiredShare" class="fw-semibold fs-4 mb-5">
|
2021-11-25 19:09:11 +00:00
|
|
|
This share is no longer accessible because it has expired
|
|
|
|
</div>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
|
2024-01-09 18:54:08 +00:00
|
|
|
{{- define "extra_js"}}
|
2023-11-21 15:24:43 +00:00
|
|
|
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/assets/plugins/custom/datatables/datatables.bundle.js"></script>
|
2023-11-15 17:48:16 +00:00
|
|
|
<script type="text/javascript" {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}}>
|
2021-11-06 13:13:20 +00:00
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
function deleteAction(shareID) {
|
|
|
|
ModalAlert.fire({
|
2023-12-10 15:40:13 +00:00
|
|
|
text: $.t('general.delete_confirm_generic'),
|
2023-11-04 09:54:52 +00:00
|
|
|
icon: "warning",
|
2023-12-26 07:59:52 +00:00
|
|
|
confirmButtonText: $.t('general.delete_confirm_btn'),
|
2023-12-10 15:40:13 +00:00
|
|
|
cancelButtonText: $.t('general.cancel'),
|
2023-11-04 09:54:52 +00:00
|
|
|
customClass: {
|
|
|
|
confirmButton: "btn btn-danger",
|
|
|
|
cancelButton: 'btn btn-secondary'
|
|
|
|
}
|
|
|
|
}).then((result) => {
|
|
|
|
if (result.isConfirmed){
|
|
|
|
$('#loading_message').text("");
|
|
|
|
KTApp.showPageLoading();
|
2023-11-22 14:57:33 +00:00
|
|
|
let path = '{{.ShareURL}}' + "/" + encodeURIComponent(shareID);
|
2023-11-04 09:54:52 +00:00
|
|
|
|
|
|
|
axios.delete(path, {
|
|
|
|
timeout: 15000,
|
|
|
|
headers: {
|
|
|
|
'X-CSRF-TOKEN': '{{.CSRFToken}}'
|
|
|
|
},
|
|
|
|
validateStatus: function (status) {
|
|
|
|
return status == 200;
|
|
|
|
}
|
|
|
|
}).then(function(response){
|
|
|
|
location.reload();
|
|
|
|
}).catch(function(error){
|
|
|
|
KTApp.hidePageLoading();
|
2023-12-10 15:40:13 +00:00
|
|
|
let errorMessage;
|
2023-11-04 09:54:52 +00:00
|
|
|
if (error && error.response) {
|
2023-12-10 15:40:13 +00:00
|
|
|
switch (error.response.status) {
|
|
|
|
case 403:
|
|
|
|
errorMessage = "general.delete_error_403";
|
|
|
|
break;
|
|
|
|
case 404:
|
|
|
|
errorMessage = "general.delete_error_404";
|
|
|
|
break;
|
2021-11-06 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
2023-12-10 15:40:13 +00:00
|
|
|
if (!errorMessage){
|
|
|
|
errorMessage = "general.delete_error_generic";
|
|
|
|
}
|
2024-01-14 15:59:27 +00:00
|
|
|
ModalAlert.fire({
|
|
|
|
text: $.t(errorMessage),
|
|
|
|
icon: "warning",
|
|
|
|
confirmButtonText: $.t('general.ok'),
|
|
|
|
customClass: {
|
|
|
|
confirmButton: "btn btn-primary"
|
|
|
|
}
|
|
|
|
});
|
2023-11-04 09:54:52 +00:00
|
|
|
});
|
2021-11-06 13:13:20 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
function editAction(shareID) {
|
2023-11-22 14:57:33 +00:00
|
|
|
window.location.replace('{{.ShareURL}}' + "/" + encodeURIComponent(shareID));
|
2023-11-04 09:54:52 +00:00
|
|
|
}
|
2021-11-06 13:13:20 +00:00
|
|
|
|
2024-02-04 13:33:51 +00:00
|
|
|
function showShareLink(shareID, shareScope, expiresAt) {
|
|
|
|
if (expiresAt < Date.now()) {
|
2023-11-16 17:55:14 +00:00
|
|
|
$('#expiredShare').show();
|
|
|
|
$('#writeShare').hide();
|
|
|
|
$('#readShare').hide();
|
|
|
|
} else {
|
2023-11-22 14:57:33 +00:00
|
|
|
let shareURL = '{{.BasePublicSharesURL}}' + "/" + encodeURIComponent(shareID);
|
2023-12-10 15:40:13 +00:00
|
|
|
if (shareScope == '1') {
|
2023-11-16 17:55:14 +00:00
|
|
|
$('#expiredShare').hide();
|
2023-11-04 09:54:52 +00:00
|
|
|
$('#writeShare').hide();
|
2023-11-16 17:55:14 +00:00
|
|
|
$('#readShare').show();
|
2023-11-17 18:10:03 +00:00
|
|
|
$('#readLink').attr("href", shareURL + "/download");
|
|
|
|
$('#readLink').attr("title", shareURL + "/download");
|
2023-12-26 07:59:52 +00:00
|
|
|
$('#readLinkCopy').attr("data-clipboard-text",getCurrentURI()+shareURL + "/download");
|
2023-11-17 18:10:03 +00:00
|
|
|
$('#readUncompressedLink').attr("href", shareURL + "/download?compress=false");
|
|
|
|
$('#readUncompressedLink').attr("title", shareURL + "/download?compress=false");
|
2023-12-26 07:59:52 +00:00
|
|
|
$('#readUncompressedLinkCopy').attr("data-clipboard-text",getCurrentURI()+shareURL + "/download?compress=false");
|
2023-11-16 17:55:14 +00:00
|
|
|
$('#readBrowseLink').attr("href", shareURL + "/browse");
|
|
|
|
$('#readBrowseLink').attr("title", shareURL + "/browse");
|
2023-12-26 07:59:52 +00:00
|
|
|
$('#readBrowseLinkCopy').attr("data-clipboard-text",getCurrentURI()+shareURL + "/browse");
|
2023-11-04 09:54:52 +00:00
|
|
|
} else {
|
2023-11-16 17:55:14 +00:00
|
|
|
$('#expiredShare').hide();
|
|
|
|
$('#writeShare').show();
|
|
|
|
$('#readShare').hide();
|
|
|
|
$('#writePageLink').attr("href", shareURL + "/upload");
|
|
|
|
$('#writePageLink').attr("title", shareURL + "/upload");
|
2023-12-26 07:59:52 +00:00
|
|
|
$('#writePageLinkCopy').attr("data-clipboard-text",getCurrentURI()+shareURL + "/upload");
|
2023-11-04 09:54:52 +00:00
|
|
|
}
|
|
|
|
}
|
2023-11-16 17:55:14 +00:00
|
|
|
$('#link_modal').modal('show');
|
|
|
|
}
|
2021-11-06 13:13:20 +00:00
|
|
|
|
2023-11-16 17:55:14 +00:00
|
|
|
var sharesDatatable = function(){
|
|
|
|
var dt;
|
|
|
|
|
|
|
|
var initDatatable = function () {
|
|
|
|
dt = $('#dataTable').DataTable({
|
2024-02-04 13:33:51 +00:00
|
|
|
ajax: {
|
|
|
|
url: "{{.SharesURL}}/json",
|
|
|
|
dataSrc: "",
|
|
|
|
error: function ($xhr, textStatus, errorThrown) {
|
2024-05-23 17:47:45 +00:00
|
|
|
$(".dt-processing").hide();
|
2024-03-31 18:42:28 +00:00
|
|
|
$('#loader').addClass("d-none");
|
2024-02-04 13:33:51 +00:00
|
|
|
let txt = "";
|
|
|
|
if ($xhr) {
|
|
|
|
let json = $xhr.responseJSON;
|
|
|
|
if (json) {
|
|
|
|
if (json.message){
|
|
|
|
txt = json.message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!txt){
|
|
|
|
txt = "general.error500";
|
|
|
|
}
|
|
|
|
setI18NData($('#errorTxt'), txt);
|
|
|
|
$('#errorMsg').removeClass("d-none");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
columns: [
|
2023-12-10 15:40:13 +00:00
|
|
|
{
|
2024-02-04 13:33:51 +00:00
|
|
|
data: "name",
|
2023-12-10 15:40:13 +00:00
|
|
|
render: function(data, type, row) {
|
|
|
|
if (type === 'display') {
|
|
|
|
return escapeHTML(data);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2024-02-04 13:33:51 +00:00
|
|
|
data: "scope",
|
2023-12-10 15:40:13 +00:00
|
|
|
render: function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
|
|
|
switch (data){
|
2024-02-04 13:33:51 +00:00
|
|
|
case 2:
|
2023-12-10 15:40:13 +00:00
|
|
|
return $.t('share.scope_write');
|
2024-02-04 13:33:51 +00:00
|
|
|
case 3:
|
2023-12-10 15:40:13 +00:00
|
|
|
return $.t('share.scope_read_write');
|
|
|
|
default:
|
|
|
|
return $.t('share.scope_read');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2024-02-04 13:33:51 +00:00
|
|
|
data: "expires_at",
|
|
|
|
defaultContent: 0,
|
2023-12-10 15:40:13 +00:00
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
|
|
|
render: function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
|
|
|
let info = "";
|
2024-02-04 13:33:51 +00:00
|
|
|
if (row.expires_at && row.expires_at > 0){
|
2023-12-10 15:40:13 +00:00
|
|
|
info+= $.t('share.expiration_date', {
|
2024-02-04 13:33:51 +00:00
|
|
|
val: row.expires_at,
|
2023-12-10 15:40:13 +00:00
|
|
|
formatParams: {
|
|
|
|
val: { year: 'numeric', month: 'numeric', day: 'numeric' },
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2024-02-04 13:33:51 +00:00
|
|
|
if (row.last_use_at && row.last_use_at > 0){
|
2023-12-10 15:40:13 +00:00
|
|
|
info+= $.t('share.last_use', {
|
2024-02-04 13:33:51 +00:00
|
|
|
val: row.last_use_at,
|
2023-12-10 15:40:13 +00:00
|
|
|
formatParams: {
|
|
|
|
val: { year: 'numeric', month: 'numeric', day: 'numeric' },
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2024-02-04 13:33:51 +00:00
|
|
|
let used_tokens = 0;
|
|
|
|
if (row.used_tokens && row.used_tokens > 0){
|
|
|
|
used_tokens = row.used_tokens;
|
|
|
|
}
|
|
|
|
if (row.max_tokens && row.max_tokens > 0){
|
|
|
|
info+= $.t('share.usage', {used: used_tokens, total: row.max_tokens});
|
2023-12-10 15:40:13 +00:00
|
|
|
} else {
|
2024-02-04 13:33:51 +00:00
|
|
|
info+= $.t('share.used_tokens', {used: used_tokens});
|
2023-12-10 15:40:13 +00:00
|
|
|
}
|
2024-02-04 13:33:51 +00:00
|
|
|
if (row.password){
|
2023-12-10 15:40:13 +00:00
|
|
|
info+= $.t('share.password_protected')
|
|
|
|
}
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
},
|
2023-11-16 17:55:14 +00:00
|
|
|
{
|
2024-02-04 13:33:51 +00:00
|
|
|
data: "id",
|
2023-11-16 17:55:14 +00:00
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
|
|
|
className: 'text-end',
|
|
|
|
render: function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
|
|
|
return `<div class="d-flex justify-content-end">
|
|
|
|
<div class="ms-2">
|
2024-01-21 15:49:04 +00:00
|
|
|
<a href="#" class="btn btn-sm btn-icon btn-light btn-active-light-primary" data-table-action="show_link">
|
2023-11-16 17:55:14 +00:00
|
|
|
<i class="ki-duotone ki-fasten fs-5 m-0">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
</i>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div class="ms-2">
|
|
|
|
<button type="button" class="btn btn-sm btn-icon btn-light btn-active-light-primary"
|
|
|
|
data-kt-menu-trigger="click" data-kt-menu-placement="bottom-end">
|
|
|
|
<i class="ki-duotone ki-dots-square fs-5 m-0">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
<span class="path3"></span>
|
|
|
|
<span class="path4"></span>
|
|
|
|
</i>
|
|
|
|
</button>
|
2024-01-09 18:54:08 +00:00
|
|
|
<div class="menu menu-sub menu-sub-dropdown menu-column menu-rounded menu-gray-700 menu-state-bg-light-primary fw-semibold fs-6 w-150px py-4" data-kt-menu="true">
|
2023-11-16 17:55:14 +00:00
|
|
|
<div class="menu-item px-3">
|
2024-01-21 15:49:04 +00:00
|
|
|
<a data-i18n="general.edit" href="#" class="menu-link px-3" data-table-action="edit_row">Edit</a>
|
2023-11-16 17:55:14 +00:00
|
|
|
</div>
|
|
|
|
<div class="menu-item px-3">
|
2024-01-21 15:49:04 +00:00
|
|
|
<a data-i18n="general.delete" href="#" class="menu-link text-danger px-3" data-table-action="delete_row">Delete</a>
|
2023-11-16 17:55:14 +00:00
|
|
|
</div>
|
2023-11-04 09:54:52 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-11-16 17:55:14 +00:00
|
|
|
</div>`;
|
|
|
|
}
|
|
|
|
return "";
|
2023-11-04 09:54:52 +00:00
|
|
|
}
|
|
|
|
}
|
2023-11-16 17:55:14 +00:00
|
|
|
],
|
|
|
|
deferRender: true,
|
|
|
|
stateSave: true,
|
|
|
|
stateDuration: 0,
|
|
|
|
stateLoadParams: function (settings, data) {
|
|
|
|
if (data.search.search){
|
2024-01-01 19:09:15 +00:00
|
|
|
const filterSearch = document.querySelector('[data-table-filter="search"]');
|
2023-11-16 17:55:14 +00:00
|
|
|
filterSearch.value = data.search.search;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
language: {
|
2023-12-10 15:40:13 +00:00
|
|
|
info: $.t('datatable.info'),
|
|
|
|
infoEmpty: $.t('datatable.info_empty'),
|
|
|
|
infoFiltered: $.t('datatable.info_filtered'),
|
|
|
|
loadingRecords: "",
|
|
|
|
processing: $.t('datatable.processing'),
|
|
|
|
zeroRecords: "",
|
|
|
|
emptyTable: $.t('share.no_share')
|
2023-11-04 09:54:52 +00:00
|
|
|
},
|
2023-11-16 17:55:14 +00:00
|
|
|
order: [[1, 'asc']],
|
|
|
|
initComplete: function(settings, json) {
|
|
|
|
$('#loader').addClass("d-none");
|
|
|
|
$('#card_content').removeClass("d-none");
|
|
|
|
let api = $.fn.dataTable.Api(settings);
|
2023-11-19 12:27:49 +00:00
|
|
|
api.columns.adjust().draw("page");
|
2024-01-09 18:54:08 +00:00
|
|
|
drawAction();
|
2023-11-16 17:55:14 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-01-09 18:54:08 +00:00
|
|
|
dt.on('draw', drawAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawAction() {
|
|
|
|
KTMenu.createInstances();
|
|
|
|
handleRowActions();
|
|
|
|
$('#table_body').localize();
|
2023-11-16 17:55:14 +00:00
|
|
|
}
|
2021-11-06 13:13:20 +00:00
|
|
|
|
2023-11-16 17:55:14 +00:00
|
|
|
var handleSearchDatatable = function () {
|
2024-01-09 18:54:08 +00:00
|
|
|
const filterSearch = $(document.querySelector('[data-table-filter="search"]'));
|
|
|
|
filterSearch.off("keyup");
|
|
|
|
filterSearch.on('keyup', function (e) {
|
2023-11-16 17:55:14 +00:00
|
|
|
dt.rows().deselect();
|
2024-05-04 10:22:10 +00:00
|
|
|
dt.search(e.target.value).draw();
|
2023-11-16 17:55:14 +00:00
|
|
|
});
|
|
|
|
}
|
2021-11-06 13:13:20 +00:00
|
|
|
|
2023-11-16 17:55:14 +00:00
|
|
|
function handleRowActions() {
|
2024-01-21 15:49:04 +00:00
|
|
|
const editButtons = document.querySelectorAll('[data-table-action="edit_row"]');
|
2023-11-16 17:55:14 +00:00
|
|
|
|
|
|
|
editButtons.forEach(d => {
|
2024-01-09 18:54:08 +00:00
|
|
|
let el = $(d);
|
|
|
|
el.off("click");
|
|
|
|
el.on("click", function(e){
|
2023-11-16 17:55:14 +00:00
|
|
|
e.preventDefault();
|
|
|
|
const parent = e.target.closest('tr');
|
2024-02-04 13:33:51 +00:00
|
|
|
editAction(dt.row(parent).data()["id"]);
|
2023-11-16 17:55:14 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-01-21 15:49:04 +00:00
|
|
|
const deleteButtons = document.querySelectorAll('[data-table-action="delete_row"]');
|
2023-11-16 17:55:14 +00:00
|
|
|
|
|
|
|
deleteButtons.forEach(d => {
|
2024-01-09 18:54:08 +00:00
|
|
|
let el = $(d);
|
|
|
|
el.off("click");
|
|
|
|
el.on("click", function(e){
|
2023-11-16 17:55:14 +00:00
|
|
|
e.preventDefault();
|
|
|
|
const parent = e.target.closest('tr');
|
2024-02-04 13:33:51 +00:00
|
|
|
deleteAction(dt.row(parent).data()["id"]);
|
2023-11-16 17:55:14 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-01-21 15:49:04 +00:00
|
|
|
const showLinkButtons = document.querySelectorAll('[data-table-action="show_link"]');
|
2023-11-16 17:55:14 +00:00
|
|
|
|
|
|
|
showLinkButtons.forEach(d => {
|
2024-01-09 18:54:08 +00:00
|
|
|
let el = $(d);
|
|
|
|
el.off("click");
|
|
|
|
el.on("click", function(e){
|
2023-11-16 17:55:14 +00:00
|
|
|
e.preventDefault();
|
|
|
|
let rowData = dt.row(e.target.closest('tr')).data();
|
2024-02-04 13:33:51 +00:00
|
|
|
showShareLink(rowData["id"], rowData["scope"], rowData["expires_at"]);
|
2023-11-16 17:55:14 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2023-11-04 09:54:52 +00:00
|
|
|
|
2023-11-16 17:55:14 +00:00
|
|
|
return {
|
|
|
|
init: function () {
|
|
|
|
initDatatable();
|
|
|
|
handleSearchDatatable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
|
2023-12-10 15:40:13 +00:00
|
|
|
$(document).on("i18nshow", function(){
|
2023-11-16 17:55:14 +00:00
|
|
|
sharesDatatable.init();
|
2023-12-26 07:59:52 +00:00
|
|
|
|
|
|
|
var clipboard = new ClipboardJS('.btn-clipboard-copy',{
|
|
|
|
container: document.getElementById('link_modal')
|
|
|
|
});
|
|
|
|
|
|
|
|
clipboard.on('success', function (e) {
|
|
|
|
e.trigger.querySelectorAll('span').forEach(spanEl => {
|
|
|
|
if (spanEl.getAttribute('data-i18n')){
|
2023-12-26 08:23:43 +00:00
|
|
|
e.trigger.classList.remove("btn-light-primary");
|
|
|
|
e.trigger.classList.add("btn-success");
|
2023-12-26 07:59:52 +00:00
|
|
|
setI18NData($(spanEl),"general.copied");
|
|
|
|
setTimeout(function(){
|
2023-12-26 08:23:43 +00:00
|
|
|
e.trigger.classList.remove("btn-success");
|
|
|
|
e.trigger.classList.add("btn-light-primary");
|
2023-12-26 07:59:52 +00:00
|
|
|
setI18NData($(spanEl),"general.copy_link");
|
|
|
|
}, 3000)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
e.clearSelection();
|
|
|
|
});
|
|
|
|
|
2021-11-06 13:13:20 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{{end}}
|