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
-->
2021-05-06 19:35:43 +00:00
{{template "base" .}}
2023-11-04 09:54:52 +00:00
{{- define "page_body"}}
{{- template "errmsg" .Error}}
2024-02-20 17:19:09 +00:00
{{- $move_copy_msg := ""}}
{{- if and .CanRename .CanCopy}}
{{- $move_copy_msg = "fs.move_copy"}}
{{- else}}
{{- if .CanRename}}
{{- $move_copy_msg = "fs.move.msg"}}
{{- else}}
{{- if .CanCopy}}
{{- $move_copy_msg = "fs.copy.msg"}}
{{- end}}
{{- end}}
{{- end}}
2023-11-04 09:54:52 +00:00
< div class = "card card-flush shadow-sm" >
< div class = "card-header pt-8" >
< div class = "card-title" >
< div class = "d-flex align-items-center position-relative my-1" >
2024-01-11 18:26:13 +00:00
< i class = "ki-solid ki-magnifier fs-1 position-absolute ms-6" > < / i >
2023-12-13 17:03:42 +00:00
< input name = "search" data-i18n = "[placeholder]general.search" type = "text" data-kt-filemanager-table-filter = "search" class = "form-control rounded-1 w-250px ps-15" placeholder = "Search Files & Folders" / >
2023-06-16 19:06:21 +00:00
< / div >
2021-05-06 19:35:43 +00:00
< / div >
2023-11-04 09:54:52 +00:00
< div class = "card-toolbar" >
< div class = "d-flex justify-content-end" data-kt-filemanager-table-toolbar = "base" >
{{- if .CanCreateDirs}}
2023-12-14 09:36:25 +00:00
< button id = "id_create_dir_button" type = "button" class = "btn btn-flex btn-light-primary me-3" >
2023-11-04 09:54:52 +00:00
< i class = "ki-duotone ki-add-folder fs-2" >
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< / i >
2023-12-14 09:36:25 +00:00
< span data-i18n = "fs.new_folder" > New Folder< / span >
2021-07-26 18:55:49 +00:00
< / button >
2023-11-04 09:54:52 +00:00
{{- end}}
{{- if .CanAddFiles}}
2023-12-14 09:36:25 +00:00
< button type = "button" class = "btn btn-flex btn-primary" data-bs-toggle = "modal" data-bs-target = "#modal_upload" >
2023-11-04 09:54:52 +00:00
< i class = "ki-duotone ki-folder-up fs-2" >
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< / i >
2023-12-14 09:36:25 +00:00
< span data-i18n = "fs.upload.text" > Upload Files< / span >
2021-07-26 18:55:49 +00:00
< / button >
2023-11-04 09:54:52 +00:00
{{- end}}
2021-07-26 18:55:49 +00:00
< / div >
2023-12-26 07:59:52 +00:00
< / div >
< / div >
< div class = "card-body" >
< div class = "d-flex flex-stack" >
< div class = "badge badge-lg badge-light-primary" data-kt-filemanager-table-nav-bar = "base" >
< div class = "d-flex align-items-center flex-wrap" >
< i class = "ki-duotone ki-home fs-1 text-primary me-3" > < / i >
< a data-i18n = "fs.home" href = "{{.FilesURL}}?path=%2F" > Home< / a >
{{- range .Paths}}
< i class = "ki-duotone ki-right fs-2x text-primary mx-1" > < / i >
{{- if eq .Href ""}}
< span > {{.DirName}}< / span >
{{- else}}
< a href = "{{.Href}}" > {{.DirName}}< / a >
{{- end}}
{{- end}}
< / div >
< / div >
< div class = "d-flex align-items-center d-none" data-kt-filemanager-table-toolbar = "selected" >
2023-11-04 09:54:52 +00:00
< div class = "fw-bold me-5" >
< span class = "me-2" data-kt-filemanager-table-select = "selected_count" > < / span >
2021-07-26 18:55:49 +00:00
< / div >
2023-11-04 09:54:52 +00:00
< div class = "form-check form-switch form-check-custom form-check-solid me-5" data-kt-filemanager-table-select = "select_all_pages_container" >
< input class = "form-check-input" type = "checkbox" id = "id_select_all_pages" data-kt-filemanager-table-select = "select_all_pages" / >
2023-12-10 15:40:13 +00:00
< label data-i18n = "fs.select_across_pages" class = "form-check-label fw-semibold text-gray-900" for = "id_select_all_pages" >
2023-11-04 09:54:52 +00:00
Select across pages
< / label >
2021-07-26 18:55:49 +00:00
< / div >
2023-11-04 09:54:52 +00:00
{{- if or .CanDownload .CanDelete}}
< div >
2023-12-14 09:36:25 +00:00
< button type = "button" class = "btn btn-light-primary rotate" data-kt-menu-trigger = "click" data-kt-menu-placement = "bottom" >
2024-01-09 18:54:08 +00:00
< span data-i18n = "general.actions" > Actions< / span >
2023-11-04 09:54:52 +00:00
< i class = "ki-duotone ki-down fs-3 rotate-180 ms-3 me-0" > < / i >
< / button >
< div class = "menu menu-sub menu-sub-dropdown menu-column menu-rounded menu-gray-800 menu-state-bg-light-primary fw-semibold w-auto min-w-200 mw-300px py-4" data-kt-menu = "true" >
{{- if .CanDownload}}
< div class = "menu-item px-3" >
2023-12-10 15:40:13 +00:00
< a data-i18n = "fs.download" href = "#" class = "menu-link px-3 fs-6" data-kt-filemanager-table-select = "download_selected" >
2023-11-04 09:54:52 +00:00
Download
< / a >
< / div >
{{- end}}
2023-11-06 18:10:35 +00:00
{{- if not .ShareUploadBaseURL}}
{{- if or .CanRename .CanAddFiles}}
< div class = "menu-item px-3" >
2024-02-20 17:19:09 +00:00
< a data-i18n = "{{$move_copy_msg}}" href = "#" class = "menu-link px-3 fs-6" data-kt-filemanager-table-select = "move_or_copy_selected" >
2023-11-06 18:10:35 +00:00
Move or copy
< / a >
< / div >
{{- end}}
2023-11-06 17:46:12 +00:00
{{- if .CanShare}}
< div class = "menu-item px-3" >
2023-12-10 15:40:13 +00:00
< a data-i18n = "fs.share" href = "#" class = "menu-link px-3 fs-6" data-kt-filemanager-table-select = "share_selected" >
2023-11-06 17:46:12 +00:00
Share
< / a >
< / div >
{{- end}}
2023-11-06 18:10:35 +00:00
{{- end}}
2023-11-04 09:54:52 +00:00
{{- if .CanDelete}}
< div class = "menu-item px-3" >
2023-12-10 15:40:13 +00:00
< a data-i18n = "general.delete" href = "#" class = "menu-link px-3 text-danger fs-6" data-kt-filemanager-table-select = "delete_selected" >
2023-11-04 09:54:52 +00:00
Delete
< / a >
< / div >
{{- end}}
2022-12-30 18:30:16 +00:00
< / div >
< / div >
2023-11-04 09:54:52 +00:00
{{- end}}
2021-07-26 18:55:49 +00:00
< / div >
< / div >
2023-12-26 07:59:52 +00:00
< div class = "new_folder_divider py-2 d-none" >
< hr >
2021-07-26 18:55:49 +00:00
< / div >
2023-12-26 07:59:52 +00:00
< div id = "file_manager_new_folder" class = "d-flex align-items-center d-none" >
2023-11-04 09:54:52 +00:00
< span >
< i class = "ki-duotone ki-folder fs-2x text-primary me-4" >
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< / i >
< / span >
2023-12-10 15:40:13 +00:00
< input data-i18n = "[placeholder]fs.create_folder_msg" id = "file_manager_new_folder_input" type = "text" name = "new_folder_name" placeholder = "Enter the new folder name" class = "form-control mw-250px me-3" / >
2023-11-13 21:09:55 +00:00
< button class = "btn btn-icon btn-light-primary me-3" id = "file_manager_add_folder" >
2023-11-04 09:54:52 +00:00
< span class = "indicator-label" >
< i class = "ki-duotone ki-check fs-1" > < / i >
< / span >
< span class = "indicator-progress" >
< span class = "spinner-border spinner-border-sm align-middle" > < / span >
< / span >
< / button >
2023-11-13 21:09:55 +00:00
< button class = "btn btn-icon btn-light-danger" id = "file_manager_cancel_folder" >
2023-12-26 07:59:52 +00:00
< i class = "ki-solid ki-cross fs-1" > < / i >
2023-11-04 09:54:52 +00:00
< / button >
2022-07-21 16:42:22 +00:00
< / div >
2023-12-26 07:59:52 +00:00
< div class = "new_folder_divider py-2 d-none" >
< hr >
< / div >
2023-12-26 18:07:50 +00:00
< div id = "upload_files_empty_container" class = "d-none mt-10" >
< form id = "upload_files_empty_form" action = "{{.FilesURL}}?path={{.CurrentDir}}" method = "POST" enctype = "multipart/form-data" >
< div class = "fv-row" >
2024-03-31 18:42:28 +00:00
< div class = "dropzone mh-350px overflow-auto visibility-auto" id = "upload_files_empty" >
2023-12-26 18:07:50 +00:00
< div class = "dz-message needsclick align-items-center" >
< i class = "ki-duotone ki-file-up fs-3x text-primary" >
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< / i >
< div class = "ms-4" >
< h3 data-i18n = "fs.upload.message_empty" class = "fs-5 fw-bold text-gray-900 mb-1" > < / h3 >
<!-- <span class="fs - 7 fw - semibold text - gray - 500">Upload up to 30 files</span> -->
< / div >
2023-11-04 09:54:52 +00:00
< / div >
2023-12-26 18:07:50 +00:00
< / div >
< / div >
< / form >
< div class = "d-flex justify-content-end mt-5" >
< button data-i18n = "general.submit" type = "button" id = "upload_files_empty_button" class = "btn btn-primary" > Submit< / button >
< / div >
< / div >
2024-02-18 10:51:15 +00:00
< 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 >
< span data-i18n = "general.loading" class = "text-gray-700" > Loading...< / span >
< / div >
< div id = "file_manager_list_container" class = "d-none" >
2023-12-26 18:07:50 +00:00
< table id = "file_manager_list" class = "table align-middle table-row-dashed fs-6 gy-5" >
< thead >
< tr class = "text-start text-muted fw-bold fs-6 gs-0 text-gray-500" >
< th class = "w-10px pe-2" >
< div class = "form-check form-check-sm form-check-custom form-check-solid me-3" >
< input id = "select_checkbox" class = "form-check-input" type = "checkbox" / >
< / div >
< / th >
< th > < / th >
< th data-i18n = "general.name" class = "min-w-250px" > Name< / th >
< th data-i18n = "general.size" class = "min-w-10px" > Size< / th >
< th data-i18n = "general.last_modified" class = "min-w-125px" > Last Modified< / th >
< th class = "w-125px" > < / th >
< / tr >
< / thead >
< tbody id = "file_manager_list_body" class = "text-gray-700 fw-semibold" >
< / tbody >
< / table >
< / div >
2022-07-21 16:42:22 +00:00
< / div >
< / div >
2023-11-04 09:54:52 +00:00
{{- end}}
{{- define "extra_css"}}
< link href = "{{.StaticURL}}/assets/plugins/custom/datatables/datatables.bundle.css" rel = "stylesheet" type = "text/css" / >
< link href = "{{.StaticURL}}/vendor/glightbox/glightbox.min.css" rel = "stylesheet" type = "text/css" / >
2023-11-15 17:48:16 +00:00
< style { { - if . CSPNonce } } nonce = "{{.CSPNonce}}" { { - end } } >
2023-11-04 09:54:52 +00:00
.gslide-description-bg {
background: var(--bs-app-bg-color) !important;
opacity: 0.9;
}
< / style >
{{- end}}
{{- 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 >
< script { { - if . CSPNonce } } nonce = "{{.CSPNonce}}" { { - end } } src = "{{.StaticURL}}/vendor/glightbox/glightbox.min.js" > < / script >
< script { { - if . CSPNonce } } nonce = "{{.CSPNonce}}" { { - end } } src = "{{.StaticURL}}/vendor/pdfobject/pdfobject.min.js" > < / script >
2023-11-15 17:48:16 +00:00
< script type = "text/javascript" { { - if . CSPNonce } } nonce = "{{.CSPNonce}}" { { - end } } >
2024-02-20 17:19:09 +00:00
//{{- $move_copy_msg := ""}}
//{{- if and .CanRename .CanCopy}}
//{{- $move_copy_msg = "fs.move_copy"}}
//{{- else}}
//{{- if .CanRename}}
//{{- $move_copy_msg = "fs.move.msg"}}
//{{- else}}
//{{- if .CanCopy}}
//{{- $move_copy_msg = "fs.copy.msg"}}
//{{- end}}
//{{- end}}
//{{- end}}
2024-03-31 18:42:28 +00:00
const dzPreviewTemplate = `< div class = "d-flex align-items-center mb-2" >
< span class = "bullet bullet-dot bg-primary me-2" > < / span >
< div class = "text-break text-wrap text-left" > < span class = "fs-5 fw-semibold" data-dz-name > < / span > (< span class = "fs-5 fw-semibold" data-custom-size > < / span > )< / div >
< / div >
< div class = "dz-error-message d-none" data-dz-errormessage > < / div >
< div class = "dz-progress d-none" > < span class = "dz-upload" data-dz-uploadprogress > < / span > < / div >
`;
2023-11-16 17:55:14 +00:00
//{{- if not .ShareUploadBaseURL}}
2023-11-04 09:54:52 +00:00
const supportedEditExtensions = ["csv", "bat", "dyalog", "apl", "asc", "pgp", "sig", "asn", "asn1", "b", "bf",
"c", "h", "ino", "cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx", "cob", "cpy", "cbl", "cs", "clj",
"cljc", "cljx", "cljs", "gss", "cmake", "cmake.in", "coffee", "cl", "lisp", "el", "cyp", "cypher",
"pyx", "pxd", "pxi", "cr", "css", "cql", "d", "dart", "diff", "patch", "dtd", "dylan", "dyl", "intr",
"ecl", "edn", "e", "elm", "ejs", "erb", "erl", "sql", "factor", "forth", "fth", "4th", "f", "for", "f77",
"f90", "f95", "fsharp", "s", "go", "groovy", "gradle", "haml", "hs", "lhs", "hx", "hxml", "aspx",
"html", "htm", "handlebars", "hbs", "pro", "jade", "pug", "java", "jsp", "js", "json", "map", "jsonld",
"jsx", "j2", "jinja", "jinja2", "jl", "kt", "less", "ls", "lua", "markdown", "md", "mkd", "m", "nb", "wl",
"wls", "mo", "mps", "mbox", "nsh", "nsi", "nt", "nq", "m", "mm", "ml", "mli", "mll", "mly", "oz", "p",
"pas", "pl", "pm", "php", "php3", "php4", "php5", "php7", "phtml", "pig", "txt", "text", "conf", "def",
"list", "log", "pls", "ps1", "psd1", "psm1", "properties", "ini", "in", "proto", "BUILD", "bzl", "py",
"pyw", "pp", "q", "r", "rst", "spec", "rb", "rs", "sas", "sass", "scala", "scm", "ss", "scss", "sh",
"ksh", "bash", "siv", "sieve", "slim", "st", "tpl", "sml", "sig", "fun", "smackspec", "soy", "rq", "sparql",
"nut", "styl", "swift", "text", "ltx", "tex", "v", "sv", "svh", "tcl", "textile", "toml", "1", "2", "3", "4",
"5", "6", "7", "8", "9", "ttcn", "ttcn3", "ttcnpp", "cfg", "ttl", "ts", "tsx", "webidl", "vb", "vbs",
"vtl", "vhd", "vhdl", "vue", "xml", "xsl", "xsd", "svg", "xy", "xquery", "ys", "yaml", "yml", "z80",
2024-10-04 17:18:00 +00:00
"mscgen", "mscin", "msc", "xu", "msgenny", "wat", "wast", "env"];
2023-11-04 09:54:52 +00:00
const supportedEditFilenames = ["readme", "dockerfile", "pkgbuild"]
2023-11-16 17:55:14 +00:00
//{{- end}}
2023-11-04 09:54:52 +00:00
function keepAlive() {
//{{- if not .ShareUploadBaseURL}}
2023-11-06 18:58:39 +00:00
axios.get('{{.PingURL}}',{
timeout: 15000,
responseType: 'text'
2023-11-04 09:54:52 +00:00
}).catch(function (error){});
//{{- end}}
2021-12-03 17:33:08 +00:00
}
2024-03-11 17:19:57 +00:00
var taskStatusWaiter = function () {
var promiseResolve;
function getTaskStatus(taskID, numErrors) {
axios.get('{{.TasksURL}}'+"/"+encodeURIComponent(taskID),{
timeout: 15000,
headers: {
'X-CSRF-TOKEN': '{{.CSRFToken}}'
},
validateStatus: function (status) {
return status == 200;
}
}).then(function(response){
let status = response.data.status;
if (status == 0){
setTimeout(function() {
getTaskStatus(taskID, numErrors);
}, 2500);
} else {
promiseResolve({
status: status
});
}
}).catch(function(error){
numErrors++;
if (numErrors >= 3){
promiseResolve({
status: 0
});
return;
}
if (error & & error.response & & error.response.status == 404){
promiseResolve({
status: 404
});
return;
}
setTimeout(function() {
getTaskStatus(taskID, numErrors);
}, 2500);
});
}
return {
wait: function(params){
setTimeout(function() {
getTaskStatus(params.taskID, 0);
}, params.delay);
return new Promise(function(resolve, reject) {
promiseResolve = resolve;
});
}
}
}();
2023-11-04 09:54:52 +00:00
//{{- if not .ShareUploadBaseURL}}
var KTDatatablesFoldersExplorer = function () {
var dt;
var curDir;
var initDatatable = function (dirsURL) {
$('#errorModalMsg').addClass("d-none");
dt = $("#dirsbrowser_list").DataTable({
ajax: {
url: dirsURL,
dataSrc: "",
error: function ($xhr, textStatus, errorThrown) {
2024-05-23 17:47:45 +00:00
$(".dt-processing").hide();
2023-12-10 15:40:13 +00:00
let txt = "";
2023-11-04 09:54:52 +00:00
if ($xhr) {
let json = $xhr.responseJSON;
if (json) {
if (json.message) {
2023-12-10 15:40:13 +00:00
txt = json.message;
2023-11-04 09:54:52 +00:00
}
}
}
2023-12-10 15:40:13 +00:00
if (!txt){
txt = "fs.dir_list.err_generic";
}
setI18NData($('#errorModalTxt'), txt);
2023-11-04 09:54:52 +00:00
$('#errorModalMsg').removeClass("d-none");
}
},
deferRender: true,
processing: true,
stateSave: false,
columns: [
{
data: "meta"
},
{
data: "name",
render: function (data, type, row) {
if (type === 'display') {
data = escapeHTML(data);
return `< div class = "d-flex align-items-center" >
< i class = "ki-duotone ki-folder fs-1 text-primary me-4" >
< i class = "path1" > < / i >
< i class = "path2" > < / i >
< / i >
2023-11-16 17:55:14 +00:00
< a href = "#" class = "text-gray-700 text-hover-primary" data-dirbrowser-table-row = "open" > ${data}< / a >
2023-11-04 09:54:52 +00:00
< / div > `
}
return data;
}
}
],
lengthChange: true,
columnDefs: [
{
targets: 0,
visible: false,
searchable: false
},
{
targets: 1,
visible: true,
searchable: true
}
],
language: {
2023-12-10 15:40:13 +00:00
info: $.t('datatable.info'),
infoEmpty: $.t('datatable.info_empty'),
infoFiltered: $.t('datatable.info_filtered'),
2023-11-04 09:54:52 +00:00
loadingRecords: "",
2023-12-10 15:40:13 +00:00
processing: $.t('datatable.processing'),
zeroRecords: "",
emptyTable: $.t('fs.no_more_subfolders')
2023-11-04 09:54:52 +00:00
},
order: [1, 'asc']
});
2021-12-08 18:25:22 +00:00
2023-11-04 09:54:52 +00:00
dt.on('draw', function () {
2023-11-16 17:55:14 +00:00
let dirBrowserNav = document.getElementById("dirs_browser_nav");
2023-11-18 19:06:31 +00:00
clearChilds(dirBrowserNav);
2023-11-16 17:55:14 +00:00
let mainNavIcon = document.createElement("i");
mainNavIcon.classList.add("ki-duotone", "ki-home", "fs-1", "text-primary", "me-3");
let mainNavLink = document.createElement("a");
2023-12-10 15:40:13 +00:00
mainNavLink.textContent = $.t('fs.home');
2023-11-16 17:55:14 +00:00
mainNavLink.href = "#";
mainNavLink.addEventListener("click", function(e){
e.preventDefault();
onDirBrowserClick("%2F");
});
dirBrowserNav.appendChild(mainNavIcon);
dirBrowserNav.appendChild(mainNavLink);
2023-11-04 09:54:52 +00:00
let p = "/";
if (curDir & & curDir != "%2F") {
p = decodeURIComponent(curDir.replace(/\+/g, '%20'));
const dirPaths = p.split("/");
let fullPath = "%2F";
for (idx in dirPaths) {
let dir = dirPaths[idx];
if (dir) {
if (fullPath.endsWith("%2F")){
fullPath += encodeURIComponent(dir);
} else {
fullPath += encodeURIComponent("/" + dir);
}
dir = escapeHTML(dir);
2023-11-16 17:55:14 +00:00
let navIcon = document.createElement("i");
navIcon.classList.add("ki-duotone", "ki-right", "fs-2x", "text-primary", "mx-1");
let navLink = document.createElement("a");
navLink.textContent = dir;
navLink.href = "#";
let pathCopy = fullPath
navLink.addEventListener("click", function(e){
e.preventDefault();
onDirBrowserClick(pathCopy);
});
dirBrowserNav.appendChild(navIcon);
dirBrowserNav.appendChild(navLink);
2023-11-04 09:54:52 +00:00
}
}
}
2023-11-16 17:55:14 +00:00
2023-11-04 09:54:52 +00:00
$('#move_copy_folder').val(p);
2023-11-16 17:55:14 +00:00
handleRowActions();
2023-11-04 09:54:52 +00:00
});
2021-12-03 17:33:08 +00:00
}
2023-11-04 09:54:52 +00:00
var handleCreateNewFolder = function() {
$('#dirsbrowser_add_folder').click(function(){
let errDivEl = $('#errorModalMsg');
let errTxtEl = $('#errorModalTxt');
2023-11-22 14:57:33 +00:00
let dirName = $("#dirsbrowser_new_folder_input").val();
2023-11-04 09:54:52 +00:00
let submitButton = document.querySelector('#dirsbrowser_add_folder');
2023-11-06 18:10:35 +00:00
let cancelButton = document.querySelector('#dirsbrowser_cancel_folder');
2023-11-04 09:54:52 +00:00
errDivEl.addClass("d-none");
if (!dirName){
2023-12-10 15:40:13 +00:00
setI18NData(errTxtEl, "fs.folder_name_required");
2023-11-04 09:54:52 +00:00
errDivEl.removeClass("d-none");
return;
}
2023-11-22 14:57:33 +00:00
if (dirName.includes("/")){
2023-12-10 15:40:13 +00:00
setI18NData(errTxtEl, "fs.invalid_name");
2023-11-22 14:57:33 +00:00
errDivEl.removeClass("d-none");
return;
}
2023-11-04 09:54:52 +00:00
let path = '{{.DirsURL}}?path='+ curDir + encodeURIComponent("/"+dirName);
submitButton.setAttribute('data-kt-indicator', 'on');
submitButton.disabled = true;
2023-11-06 18:10:35 +00:00
cancelButton.disabled = true;
2023-11-04 09:54:52 +00:00
axios.post(path, null, {
timeout: 15000,
headers: {
'X-CSRF-TOKEN': '{{.CSRFToken}}'
},
validateStatus: function (status) {
return status == 201;
}
}).then(function (response) {
dt.ajax.reload();
errDivEl.addClass("d-none");
submitButton.removeAttribute('data-kt-indicator');
submitButton.disabled = false;
2023-11-06 18:10:35 +00:00
cancelButton.disabled = false;
2023-12-26 07:59:52 +00:00
$('.dir_browser_folder_divider').addClass("d-none");
2023-11-04 09:54:52 +00:00
$('#dirsbrowser_new_folder').addClass("d-none");
}).catch(function (error) {
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 = "fs.create_dir.err_403";
break;
case 429:
errorMessage = "fs.create_dir.err_429";
break;
2023-11-04 09:54:52 +00:00
}
}
2023-12-10 15:40:13 +00:00
if (!errorMessage){
errorMessage = "fs.create_dir.err_generic";
}
setI18NData(errTxtEl, errorMessage);
2023-11-04 09:54:52 +00:00
errDivEl.removeClass("d-none");
submitButton.removeAttribute('data-kt-indicator');
submitButton.disabled = false;
2023-11-06 18:10:35 +00:00
cancelButton.disabled = false;
2023-11-04 09:54:52 +00:00
});
});
2021-12-03 17:33:08 +00:00
}
2023-11-04 09:54:52 +00:00
2023-11-16 17:55:14 +00:00
function handleRowActions(){
const openLinks = document.querySelectorAll('[data-dirbrowser-table-row="open"]');
openLinks.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');
onDirBrowserClick(dt.row(parent).data()['dir_path']);
});
});
}
2023-11-04 09:54:52 +00:00
return {
init: function (url, dirPath) {
curDir = dirPath;
if (dt) {
dt.ajax.url(url).load();
return;
}
initDatatable(url);
handleCreateNewFolder();
}
2021-12-03 17:33:08 +00:00
}
2023-11-04 09:54:52 +00:00
}();
//{{- end}}
< / script >
2023-11-15 17:48:16 +00:00
< script type = "text/javascript" { { - if . CSPNonce } } nonce = "{{.CSPNonce}}" { { - end } } >
2023-11-04 09:54:52 +00:00
var KTDatatablesServerSide = function () {
// Shared variables
var dt;
var lightbox;
// Private functions
var initDatatable = function () {
dt = $("#file_manager_list").DataTable({
ajax: {
url: "{{.DirsURL}}?path={{.CurrentDir}}",
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");
2023-12-10 15:40:13 +00:00
let txt = "";
2023-11-04 09:54:52 +00:00
if ($xhr) {
let json = $xhr.responseJSON;
if (json) {
if (json.message){
2023-12-10 15:40:13 +00:00
txt = json.message;
2023-11-04 09:54:52 +00:00
}
}
}
2023-12-10 15:40:13 +00:00
if (!txt){
txt = "fs.dir_list.err_generic";
}
setI18NData($('#errorTxt'), txt);
2023-11-04 09:54:52 +00:00
$('#errorMsg').removeClass("d-none");
}
},
deferRender: true,
processing: true,
lengthMenu: [ 10, 25, 50, 100, 250, 500 ],
select: {
style: 'multi',
selector: 'td:first-child input[type="checkbox"]',
className: 'row-selected'
},
stateSave: true,
stateDuration: 0,
stateSaveParams: function (settings, data) {
data.sftpgo_dir = '{{.CurrentDir}}';
},
stateLoadParams: function (settings, data) {
if (!data.sftpgo_dir || data.sftpgo_dir != '{{.CurrentDir}}'){
data.start = 0;
data.search.search = "";
}
if (data.search.search){
const filterSearch = document.querySelector('[data-kt-filemanager-table-filter="search"]');
filterSearch.value = data.search.search;
2021-12-08 18:25:22 +00:00
}
2023-11-04 09:54:52 +00:00
},
columns: [
{
data: "meta",
render: function (data, type) {
if (type == 'display'){
return `
< div class = "form-check form-check-sm form-check-custom form-check-solid" >
< input class = "form-check-input" type = "checkbox" / >
< / div > `;
}
return data;
2021-12-08 18:25:22 +00:00
}
2023-11-04 09:54:52 +00:00
},
{ data: "type" },
{
data: "name",
render: function (data, type, row) {
if (type === 'display') {
data = escapeHTML(data);
let icon_name = "ki-file";
if (row["type"] == "1") {
icon_name = "ki-folder";
} else if (row["size"] === "") {
icon_name = "ki-file-right"
}
return `< div class = "d-flex align-items-center" >
< i class = "ki-duotone ${icon_name} fs-2x text-primary me-4" >
< i class = "path1" > < / i >
< i class = "path2" > < / i >
< / i >
< a href = "${row['url']}" class = "text-gray-800 text-hover-primary" > ${data}< / a >
< / div > `
}
return data;
2021-12-08 18:25:22 +00:00
}
2023-11-04 09:54:52 +00:00
},
{
data: "size",
render: function (data, type) {
if (type === 'display') {
if (data || data === 0){
return fileSizeIEC(data);
}
return "";
}
return data;
2021-12-08 18:25:22 +00:00
}
2023-11-04 09:54:52 +00:00
},
2023-12-10 15:40:13 +00:00
{
data: "last_modified",
render: function (data, type, row) {
if (type === 'display') {
if (data){
return $.t('general.datetime', {
val: new Date(data),
formatParams: {
val: { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric' },
}
});
}
return ""
}
return data;
}
},
2023-11-04 09:54:52 +00:00
{
data: "edit_url",
className: 'text-end',
render: function (data, type, row) {
if (type === 'display') {
let previewDiv = "";
if (row["type"] == "2") {
let filename = escapeHTML(row["name"]);
let extension = filename.slice((filename.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
switch (extension) {
case "jpeg":
case "jpg":
case "png":
case "gif":
case "webp":
case "bmp":
case "svg":
let desc = escapeHTML(filename).replace(/"/g, '" ');
previewDiv = `< div class = "ms-2" data-kt-filemanger-table = "view_item" >
< a href = "${row['url']}" data-gallery = "gallery" data-glightbox = "description: <span class="fs-5 fw-bold">${desc}</span>" class = "btn btn-sm btn-icon btn-light btn-active-light-primary glightbox" >
2024-01-09 18:54:08 +00:00
< i class = "ki-duotone ki-eye fs-6 m-0" >
2023-11-04 09:54:52 +00:00
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< span class = "path3" > < / span >
< / i >
< / a >
< / div > `;
break;
case "mp4":
case "mov":
case "webm":
case "ogv":
case "ogg":
case "mp3":
case "wav":
previewDiv = `< div class = "ms-2" data-kt-filemanger-table = "view_item" >
2023-11-16 17:55:14 +00:00
< a href = "#" class = "btn btn-sm btn-icon btn-light btn-active-light-primary" data-kt-filemanager-table-action = "view_media" >
2024-01-09 18:54:08 +00:00
< i class = "ki-duotone ki-eye fs-6 m-0" >
2023-11-04 09:54:52 +00:00
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< span class = "path3" > < / span >
< / i >
< / a >
< / div > `;
break;
case "pdf":
if (PDFObject.supportsPDFs){
let view_url = row['url'];
view_url = view_url.replace('{{.FilesURL}}','{{.ViewPDFURL}}');
previewDiv = `< div class = "ms-2" data-kt-filemanger-table = "view_item" >
2024-08-20 09:24:42 +00:00
< a href = "${view_url}" target = "_blank" rel = "noopener noreferrer" class = "btn btn-sm btn-icon btn-light btn-active-light-primary" >
2024-01-09 18:54:08 +00:00
< i class = "ki-duotone ki-eye fs-6 m-0" >
2023-11-04 09:54:52 +00:00
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< span class = "path3" > < / span >
< / i >
< / a >
< / div > `;
}
break;
default:
//{{- if not .ShareUploadBaseURL}}
if (data & & (supportedEditExtensions.includes(extension) || supportedEditFilenames.includes(filename.toLowerCase()))){
previewDiv = `< div class = "ms-2" data-kt-filemanger-table = "view_item" >
2024-08-20 09:24:42 +00:00
< a href = "${data}" target = "_blank" rel = "noopener noreferrer" class = "btn btn-sm btn-icon btn-light btn-active-light-primary" >
2024-01-09 18:54:08 +00:00
< i class = "ki-duotone ki-eye fs-6 m-0" >
2023-11-04 09:54:52 +00:00
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< span class = "path3" > < / span >
< / i >
< / a >
< / div > `;
}
//{{- end}}
}
}
let more = `{{- if not .ShareUploadBaseURL}}
{{- if or .CanRename .CanAddFiles .CanShare .CanDelete }}
< 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-04 09:54:52 +00:00
{{- if .CanRename}}
< div class = "menu-item px-3" >
2023-12-10 15:40:13 +00:00
< a data-i18n = "general.rename" href = "#" class = "menu-link px-3" data-kt-filemanager-table-action = "rename" > Rename< / a >
2023-11-04 09:54:52 +00:00
< / div >
{{- end}}
2024-02-20 17:19:09 +00:00
{{- if or .CanRename .CanCopy}}
2023-11-04 09:54:52 +00:00
< div class = "menu-item px-3" >
2024-02-20 17:19:09 +00:00
< a data-i18n = "{{$move_copy_msg}}" href = "#" class = "menu-link px-3" data-kt-filemanager-table-action = "move_or_copy" > Move or copy< / a >
2023-11-04 09:54:52 +00:00
< / div >
{{- end}}
{{- if .CanShare}}
< div class = "menu-item px-3" >
2023-12-10 15:40:13 +00:00
< a data-i18n = "fs.share" href = "#" class = "menu-link px-3" data-kt-filemanager-table-action = "share" > Share< / a >
2023-11-04 09:54:52 +00:00
< / div >
{{- end}}
{{- if .CanDelete}}
< div class = "menu-item px-3" >
2023-12-10 15:40:13 +00:00
< a data-i18n = "general.delete" href = "#" class = "menu-link text-danger px-3" data-kt-filemanager-table-action = "delete" > Delete< / a >
2023-11-04 09:54:52 +00:00
< / div >
{{- end}}
< / div >
< / div >
{{- end}}
{{- end}}`;
return `< div class = "d-flex justify-content-end" >
${previewDiv}
${more}
< / div >
`;
}
return "";
2021-12-08 18:25:22 +00:00
}
}
2023-11-04 09:54:52 +00:00
],
lengthChange: true,
columnDefs: [
{
targets: 0,
orderable: false,
searchable: false,
},
{
targets: 1,
visible: false,
searchable: false
},
{
targets: 2,
visible: true,
searchable: true
},
{
targets: [3,4],
searchable: false
},
{
targets: 5,
orderable: false,
searchable: false
2021-12-08 18:25:22 +00:00
}
2023-11-04 09:54:52 +00:00
],
language: {
2023-12-10 15:40:13 +00:00
info: $.t('datatable.info'),
infoEmpty: $.t('datatable.info_empty'),
infoFiltered: $.t('datatable.info_filtered'),
2023-11-04 09:54:52 +00:00
loadingRecords: "",
2023-12-10 15:40:13 +00:00
processing: $.t('datatable.processing'),
zeroRecords: "",
emptyTable: $.t('fs.no_files_folders')
2023-11-04 09:54:52 +00:00
},
orderFixed: [1, 'asc'],
2024-02-18 10:51:15 +00:00
order: [2, 'asc'],
initComplete: function(settings, json) {
$('#loader').addClass("d-none");
$('#file_manager_list_container').removeClass("d-none");
let api = $.fn.dataTable.Api(settings);
api.columns.adjust().draw("page");
drawAction();
}
2023-11-04 09:54:52 +00:00
});
2024-02-18 10:51:15 +00:00
dt.on('draw', drawAction);
function drawAction() {
2023-12-26 18:07:50 +00:00
//{{- if .CanAddFiles}}
if (dt.rows().count() === 0) {
$('#file_manager_list_container').addClass("d-none");
$('#upload_files_empty_container').removeClass("d-none");
return;
}
$('#upload_files_empty_container').addClass("d-none");
$('#file_manager_list_container').removeClass("d-none");
//{{- end}}
2023-11-04 09:54:52 +00:00
lightbox.reload();
KTMenu.createInstances();
let targets = document.querySelectorAll('#file_manager_list_body tr');
if (targets) {
KTUtil.each(targets, function (target) {
if (!target){
return;
2021-12-03 17:33:08 +00:00
}
2023-11-04 09:54:52 +00:00
let checkbox = target.querySelector('.form-check-input');
if (!checkbox) {
return;
2021-12-08 18:25:22 +00:00
}
2023-11-04 09:54:52 +00:00
if (target.classList.contains('row-selected')) {
checkbox.checked = true;
} else {
checkbox.checked = false;
2021-12-08 18:25:22 +00:00
}
2023-11-04 09:54:52 +00:00
});
2021-12-08 18:25:22 +00:00
}
2023-11-04 09:54:52 +00:00
toggleToolbars();
2023-11-16 17:55:14 +00:00
handleRowActions();
2023-12-10 15:40:13 +00:00
$('#file_manager_list_body').localize();
2024-02-18 10:51:15 +00:00
}
2021-12-08 18:25:22 +00:00
2023-11-04 09:54:52 +00:00
dt.on('user-select', function(e, dt, type, cell, originalEvent){
let pageSelected = dt.rows({ selected: true, page: 'current' }).count();
let totalSelected = dt.rows({ selected: true, search: 'applied' }).count();
if (totalSelected > pageSelected){
let currentIndexes = [];
dt.rows({ page: 'current' }).every(function (rowIdx, tableLoop, rowLoop){
currentIndexes.push(rowIdx);
});
dt.rows().deselect();
currentIndexes.forEach((idx) => {
dt.row(idx).select();
});
totalSelected = dt.rows({ selected: true, search: 'applied' }).count();
}
if ($(originalEvent.target).is(':checked')){
pageSelected++;
totalSelected++;
} else {
pageSelected--;
totalSelected--;
}
2021-12-03 17:33:08 +00:00
2023-11-04 09:54:52 +00:00
handleToogleToolbar(pageSelected, totalSelected);
});
2021-12-03 17:33:08 +00:00
}
2023-11-04 09:54:52 +00:00
function handleToogleToolbar(pageSelected, totalSelected) {
2023-12-26 07:59:52 +00:00
const navBar = document.querySelector('[data-kt-filemanager-table-nav-bar="base"]');
2023-11-04 09:54:52 +00:00
const toolbarSelected = document.querySelector('[data-kt-filemanager-table-toolbar="selected"]');
const selectedCount = document.querySelector('[data-kt-filemanager-table-select="selected_count"]');
const selectAllContainer = document.querySelector('[data-kt-filemanager-table-select="select_all_pages_container"]');
const selectAllCheck = document.querySelector('[data-kt-filemanager-table-select="select_all_pages"]');
if (pageSelected > 0) {
let pageTotal = dt.rows({ page: 'current' }).count();
if (pageSelected === pageTotal){
selectAllContainer.classList.remove("d-none");
$('#select_checkbox').prop("checked", true);
} else {
$('#select_checkbox').prop("checked", false);
selectAllCheck.checked = false;
selectAllContainer.classList.add('d-none');
}
if (selectedCount){
2023-12-10 15:40:13 +00:00
selectedCount.innerHTML = $.t('general.selected_items', { count: totalSelected});
2023-11-04 09:54:52 +00:00
}
2023-12-26 07:59:52 +00:00
if (navBar){
navBar.classList.add('d-none');
2023-11-04 09:54:52 +00:00
}
if (toolbarSelected){
toolbarSelected.classList.remove('d-none');
}
} else {
$('#select_checkbox').prop("checked", false);
selectAllCheck.checked = false;
2023-12-26 07:59:52 +00:00
if (navBar) {
navBar.classList.remove('d-none');
2023-11-04 09:54:52 +00:00
}
2023-12-26 07:59:52 +00:00
if (toolbarSelected) {
2023-11-04 09:54:52 +00:00
toolbarSelected.classList.add('d-none');
}
}
2021-12-03 17:33:08 +00:00
}
2021-05-27 07:40:46 +00:00
2023-11-16 17:55:14 +00:00
function handleRowActions() {
const renameButtons = document.querySelectorAll('[data-kt-filemanager-table-action="rename"]');
renameButtons.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');
renameItem(dt.row(parent).data()["meta"]);
});
});
const moveCopyButtons = document.querySelectorAll('[data-kt-filemanager-table-action="move_or_copy"]');
moveCopyButtons.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');
moveOrCopyItem(dt.row(parent).data()["meta"]);
});
});
const shareButtons = document.querySelectorAll('[data-kt-filemanager-table-action="share"]');
shareButtons.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');
shareItem(dt.row(parent).data()["meta"]);
});
});
const deleteButtons = document.querySelectorAll('[data-kt-filemanager-table-action="delete"]');
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');
deleteItem(dt.row(parent).data()["meta"]);
});
});
const viewMediaLinks = document.querySelectorAll('[data-kt-filemanager-table-action="view_media"]');
viewMediaLinks.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');
let rowData = dt.row(parent).data();
2023-11-17 20:42:22 +00:00
openMediaPlayer(rowData["name"], rowData["url"]);
2023-11-16 17:55:14 +00:00
});
});
}
2023-11-04 09:54:52 +00:00
var initLightbox = function() {
lightbox = GLightbox({
slideHTML: `< div class = "gslide" >
< div class = "gslide-inner-content" >
< div class = "ginner-container" >
< div class = "gslide-media" >
< / div >
< div class = "gslide-description gslide-description-bg" >
< div class = "gdesc-inner" >
< h4 class = "gslide-title" > < / h4 >
< div class = "gslide-desc" > < / div >
< / div >
< / div >
< / div >
< / div >
< / div > `,
preload: false,
closeOnOutsideClick: false
});
}
2021-12-10 17:43:26 +00:00
2023-11-04 09:54:52 +00:00
var handleSearchDatatable = function () {
2024-01-09 18:54:08 +00:00
const filterSearch = $(document.querySelector('[data-kt-filemanager-table-filter="search"]'));
filterSearch.off("keyup");
filterSearch.on('keyup', function (e) {
2023-11-04 09:54:52 +00:00
dt.rows().deselect();
2024-05-04 10:22:10 +00:00
dt.search(e.target.value).draw();
2023-11-04 09:54:52 +00:00
});
}
2021-12-10 17:43:26 +00:00
2023-11-04 09:54:52 +00:00
var initToggleToolbar = function () {
const selectAllCheck = document.querySelector('[data-kt-filemanager-table-select="select_all_pages"]');
if (selectAllCheck){
2024-01-09 18:54:08 +00:00
let el = $(selectAllCheck);
el.off("change");
el.on('change', function(e){
2023-11-04 09:54:52 +00:00
if (this.checked){
dt.rows({ search: 'applied' }).select();
} else {
let selectedIndexes = [];
dt.rows({ selected: true, page: 'current' }).every(function (rowIdx, tableLoop, rowLoop){
selectedIndexes.push(rowIdx);
});
dt.rows().deselect();
selectedIndexes.forEach((idx) => {
dt.row(idx).select();
});
}
toggleToolbars();
})
}
const downloadButton = document.querySelector('[data-kt-filemanager-table-select="download_selected"]');
if (downloadButton){
2024-01-09 18:54:08 +00:00
let el = $(downloadButton);
el.off("click");
el.on('click', function(e){
2023-11-04 09:54:52 +00:00
let filesArray = [];
dt.rows({ selected: true, search: 'applied' }).every(function (rowIdx, tableLoop, rowLoop){
let row = dt.row(rowIdx);
filesArray.push(getNameFromMeta(row.data()['meta']));
});
let token = "{{.CSRFToken}}";
let downloadURL = '{{.DownloadURL}}';
let currentDir = '{{.CurrentDir}}';
let ts = new Date().getTime().toString();
let files = JSON.stringify(filesArray);
2024-08-20 09:24:42 +00:00
$(`< form method = "post" action = "${downloadURL}?path=${currentDir}&_=${ts}" target = "_blank" rel = "noopener noreferrer" >
2023-11-04 09:54:52 +00:00
< input type = "hidden" name = "_form_token" value = "${token}" >
< textarea name = "files" hidden > ${files}< / textarea >
< / form > `).appendTo('body').submit().remove();
});
}
2021-12-10 17:43:26 +00:00
2023-11-06 18:10:35 +00:00
const moveOrCopyButton = document.querySelector('[data-kt-filemanager-table-select="move_or_copy_selected"]');
if (moveOrCopyButton){
2024-01-09 18:54:08 +00:00
let el = $(moveOrCopyButton);
el.off("click");
el.on('click', function(e){
2023-11-06 18:10:35 +00:00
$('#errorMsg').addClass("d-none");
$('#move_copy_name_container').addClass("d-none");
$('#move_copy_source').val("");
$('#modal_move_or_copy').modal('show');
KTDatatablesFoldersExplorer.init('{{.DirsURL}}?dirtree=1& path={{.CurrentDir}}', '{{.CurrentDir}}');
});
}
2023-11-06 17:46:12 +00:00
const shareButton = document.querySelector('[data-kt-filemanager-table-select="share_selected"]');
if (shareButton){
2024-01-09 18:54:08 +00:00
let el = $(shareButton);
el.off("click");
el.on('click', function(e){
2023-11-06 17:46:12 +00:00
let filesArray = [];
dt.rows({ selected: true, search: 'applied' }).every(function (rowIdx, tableLoop, rowLoop){
let row = dt.row(rowIdx);
filesArray.push(getNameFromMeta(row.data()['meta']));
});
let files = encodeURIComponent(JSON.stringify(filesArray));
let shareURL = '{{.ShareURL}}';
let currentDir = '{{.CurrentDir}}';
let ts = new Date().getTime().toString();
window.open(`${shareURL}?path=${currentDir}&files=${files}&_=${ts}`,'_blank');
});
}
2023-11-04 09:54:52 +00:00
const deleteButton = document.querySelector('[data-kt-filemanager-table-select="delete_selected"]');
if (deleteButton) {
2024-03-11 17:19:57 +00:00
function getMultiDeleteErrorMessage(status, deleted) {
let errorMessage;
switch (status) {
case 403:
if (deleted > 0){
errorMessage = "fs.delete_multi.err_403_partial";
} else {
errorMessage = "fs.delete_multi.err_403";
}
break;
case 429:
if (deleted > 0){
errorMessage = "fs.delete_multi.err_429_partial";
} else {
errorMessage = "fs.delete_multi.err_429";
}
break;
}
if (!errorMessage){
if (deleted > 0){
errorMessage = "fs.delete_multi.err_generic_partial";
} else {
errorMessage = "fs.delete_multi.err_generic";
}
}
return errorMessage;
}
2024-01-09 18:54:08 +00:00
let el = $(deleteButton);
el.off("click");
el.on('click', function(e){
2023-11-04 09:54:52 +00:00
ModalAlert.fire({
2023-12-10 15:40:13 +00:00
text: $.t('general.delete_multi_confirm'),
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){
let hasError = false;
let deleted = 0;
let index = 0;
let errDivEl = $('#errorMsg');
let errTxtEl = $('#errorTxt');
errDivEl.addClass("d-none");
let selectedRowsIdx = [];
dt.rows({ selected: true, search: 'applied' }).every(function (rowIdx, tableLoop, rowLoop){
selectedRowsIdx.push(rowIdx);
});
if (selectedRowsIdx.length == 0){
return;
}
2024-10-03 16:53:57 +00:00
clearLoading();
2023-11-04 09:54:52 +00:00
KTApp.showPageLoading();
function deleteSelected() {
if (index >= selectedRowsIdx.length || hasError){
KTApp.hidePageLoading();
if (!hasError){
location.reload();
}
return;
}
let meta = dt.row(selectedRowsIdx[index]).data()['meta'];
2024-03-11 17:19:57 +00:00
let itemName = getNameFromMeta(meta);
let isDir = (getTypeFromMeta(meta) == "1");
let path;
if (isDir){
path = '{{.DirsURL}}';
} else {
path = '{{.FilesURL}}';
}
path+='?path={{.CurrentDir}}'+encodeURIComponent("/"+itemName);
2023-11-06 18:10:35 +00:00
if (selectedRowsIdx.length > 1){
2024-10-03 16:53:57 +00:00
let info = $.t('fs.deleting', {
2023-12-10 15:40:13 +00:00
idx : index + 1,
2024-10-03 16:53:57 +00:00
total: selectedRowsIdx.length
2023-12-10 15:40:13 +00:00
});
2024-10-03 16:53:57 +00:00
setLoadingText(info,itemName);
2023-11-06 18:10:35 +00:00
}
2024-10-03 16:53:57 +00:00
2024-03-11 17:19:57 +00:00
axios.delete(path,{
timeout: 15000,
2023-11-04 09:54:52 +00:00
headers: {
'X-CSRF-TOKEN': '{{.CSRFToken}}'
},
validateStatus: function (status) {
2024-03-11 17:19:57 +00:00
if (isDir){
return status == 202;
}
2023-11-04 09:54:52 +00:00
return status == 200;
}
}).then(function(response){
2024-03-11 17:19:57 +00:00
if (isDir){
taskStatusWaiter.wait({
taskID: response.data.message,
delay: 500
}).then((result) => {
index++;
if (result.status == 200){
deleted++;
} else {
hasError = true;
let errorMessage = getMultiDeleteErrorMessage(result.status, deleted);
setI18NData(errTxtEl, errorMessage);
errDivEl.removeClass("d-none");
}
deleteSelected();
});
} else {
index++;
deleted++;
deleteSelected();
}
2023-11-04 09:54:52 +00:00
}).catch(function(error){
index++;
hasError = true;
2024-03-11 17:19:57 +00:00
let status = 0;
2023-11-04 09:54:52 +00:00
if (error & & error.response) {
2024-03-11 17:19:57 +00:00
status = error.response.status;
2023-11-04 09:54:52 +00:00
}
2024-03-11 17:19:57 +00:00
let errorMessage = getMultiDeleteErrorMessage(status, deleted);
2023-12-10 15:40:13 +00:00
setI18NData(errTxtEl, errorMessage);
2023-11-04 09:54:52 +00:00
errDivEl.removeClass("d-none");
deleteSelected();
});
}
deleteSelected();
}
});
});
}
$('#select_checkbox').on("click", function(){
let targets = document.querySelectorAll('#file_manager_list_body .form-check-input');
if (!targets){
return;
}
dt.rows().deselect();
let isChecked = $(this).is(':checked');
if (isChecked){
dt.rows({page: 'current'}).select();
}
KTUtil.each(targets, function (target) {
if (target){
target.checked = isChecked;
}
});
toggleToolbars();
});
2022-07-21 16:42:22 +00:00
2023-11-04 09:54:52 +00:00
toggleToolbars();
2021-05-27 07:40:46 +00:00
}
2023-11-04 09:54:52 +00:00
var toggleToolbars = function () {
let pageSelected = dt.rows({ selected: true, page: 'current' }).count();
let totalSelected = dt.rows({ selected: true , search: 'applied'}).count();
handleToogleToolbar(pageSelected, totalSelected);
}
return {
init: function () {
initLightbox();
initDatatable();
handleSearchDatatable();
initToggleToolbar();
}
}
}();
2021-05-27 07:40:46 +00:00
2021-10-09 12:17:28 +00:00
function getNameFromMeta(meta) {
return meta.split('_').slice(1).join('_');
2021-07-26 18:55:49 +00:00
}
2021-10-09 12:17:28 +00:00
function getTypeFromMeta(meta) {
return meta.split('_')[0];
2021-07-26 18:55:49 +00:00
}
2023-11-04 09:54:52 +00:00
//{{- if not .ShareUploadBaseURL}}
function onDirBrowserClick(dirPath) {
KTDatatablesFoldersExplorer.init('{{.DirsURL}}?dirtree=1& path='+dirPath, dirPath);
}
2021-11-30 17:40:50 +00:00
2023-11-04 09:54:52 +00:00
function moveOrCopyItem(meta) {
$('#errorMsg').addClass("d-none");
2023-11-06 18:10:35 +00:00
$('#move_copy_name_container').removeClass("d-none");
2023-11-04 09:54:52 +00:00
$('#move_copy_source').val(meta);
2023-11-16 17:55:14 +00:00
$('#move_copy_name').val(getNameFromMeta(meta));
2023-11-04 09:54:52 +00:00
$('#modal_move_or_copy').modal('show');
KTDatatablesFoldersExplorer.init('{{.DirsURL}}?dirtree=1& path={{.CurrentDir}}', '{{.CurrentDir}}');
}
2023-11-22 14:57:33 +00:00
function getMoveOrCopyItems() {
2023-11-06 18:10:35 +00:00
let items = [];
2023-11-04 09:54:52 +00:00
let targetDir = $("#move_copy_folder").val();
if (targetDir != "/") {
targetDir = targetDir.endsWith('/') ? targetDir.slice(0, -1) : targetDir;
}
if (targetDir.trim() == ""){
targetDir = "{{.CurrentDir}}";
} else {
targetDir = encodeURIComponent(targetDir);
}
2023-11-06 18:10:35 +00:00
if ($('#move_copy_name_container').hasClass("d-none")){
2023-12-28 17:43:07 +00:00
// bulk action
2023-11-06 18:10:35 +00:00
let dt = $('#file_manager_list').DataTable();
dt.rows({ selected: true, search: 'applied' }).every(function (rowIdx, tableLoop, rowLoop){
let row = dt.row(rowIdx);
let sourceName = getNameFromMeta(row.data()['meta']);
items.push({
targetDir: targetDir,
sourceName: sourceName,
targetName: sourceName
});
});
} else {
2023-11-16 17:55:14 +00:00
let meta = $('#move_copy_source').val();
2023-11-06 18:10:35 +00:00
let sourceName = getNameFromMeta(meta);
items.push({
targetDir: targetDir,
sourceName: sourceName,
targetName: $("#move_copy_name").val()
});
}
return items;
}
2023-11-22 14:57:33 +00:00
function checkMoveCopyItems(items) {
let hasSlash = items.some(item => item.targetName.includes("/"));
if (hasSlash){
return [];
}
return items;
}
2023-11-06 18:10:35 +00:00
function doCopy() {
2023-12-14 09:36:25 +00:00
$('#errorMsg').addClass("d-none");
2023-11-22 14:57:33 +00:00
let items = getMoveOrCopyItems();
2023-11-06 18:10:35 +00:00
if (items.length == 0){
return;
}
2023-11-22 14:57:33 +00:00
items = checkMoveCopyItems(items)
if (items.length == 0){
2024-01-14 15:59:27 +00:00
ModalAlert.fire({
text: $.t('fs.invalid_name'),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-11-22 14:57:33 +00:00
return;
}
2024-03-11 17:19:57 +00:00
function showCopyError(status) {
KTApp.hidePageLoading();
let errorMessage = "";
switch (status) {
case 403:
errorMessage = "fs.copy.err_403";
break;
case 429:
errorMessage = "fs.copy.err_429";
break;
default:
errorMessage = "fs.copy.err_generic";
}
ModalAlert.fire({
text: $.t(errorMessage),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
}
2023-11-06 18:10:35 +00:00
let hasError = false;
let index = 0;
2021-11-30 17:40:50 +00:00
2024-10-03 16:53:57 +00:00
clearLoading();
2023-11-04 09:54:52 +00:00
KTApp.showPageLoading();
2021-11-30 17:40:50 +00:00
2023-11-06 18:10:35 +00:00
function copyItem() {
if (index >= items.length || hasError){
KTApp.hidePageLoading();
if (!hasError){
location.reload();
}
return;
2023-11-04 09:54:52 +00:00
}
2023-11-06 18:10:35 +00:00
let item = items[index];
let sourcePath = decodeURIComponent('{{.CurrentDir}}');
if (!sourcePath.endsWith('/')){
sourcePath+="/";
}
sourcePath+=item.sourceName;
let targetPath = decodeURIComponent(item.targetDir);
if (!targetPath.endsWith('/')){
targetPath+="/";
}
targetPath+=item.targetName;
2023-12-10 15:40:13 +00:00
if (items.length > 1) {
2024-10-03 16:53:57 +00:00
let info = $.t('fs.copying', {
2023-12-10 15:40:13 +00:00
idx: index + 1,
2024-10-03 16:53:57 +00:00
total: items.length
2023-12-10 15:40:13 +00:00
});
2024-10-03 16:53:57 +00:00
setLoadingText(info,`${sourcePath} => ${targetPath}`);
2023-11-06 18:10:35 +00:00
}
let path = '{{.FileActionsURL}}/copy';
path+='?path={{.CurrentDir}}'+encodeURIComponent("/"+item.sourceName)+'&target='+item.targetDir+encodeURIComponent("/"+item.targetName);
axios.post(path, null, {
2024-03-11 17:19:57 +00:00
timeout: 15000,
2023-11-06 18:10:35 +00:00
headers: {
'X-CSRF-TOKEN': '{{.CSRFToken}}'
},
validateStatus: function (status) {
2024-03-11 17:19:57 +00:00
return status == 202;
2023-11-04 09:54:52 +00:00
}
2023-11-06 18:10:35 +00:00
}).then(function (response) {
2024-03-11 17:19:57 +00:00
taskStatusWaiter.wait({
taskID: response.data.message,
delay: 500
}).then((result) => {
index++;
if (result.status != 200){
hasError = true;
showCopyError(result.status);
}
copyItem();
});
2023-11-06 18:10:35 +00:00
}).catch(function (error) {
index++;
hasError = true;
2024-03-11 17:19:57 +00:00
let status = 0;
2023-11-06 18:10:35 +00:00
if (error & & error.response) {
2024-03-11 17:19:57 +00:00
status = error.response.status;
2023-12-10 15:40:13 +00:00
}
2024-03-11 17:19:57 +00:00
showCopyError(status);
2023-11-06 18:10:35 +00:00
copyItem();
});
}
2023-12-28 17:43:07 +00:00
let filesArray = [];
for (let i = 0; i < items.length ; i + + ) {
2024-04-01 10:00:06 +00:00
filesArray.push(items[i].targetName);
2023-12-28 17:43:07 +00:00
}
CheckExist.fire({
operation: "copy",
files: filesArray,
path: items[0].targetDir
}).then((result)=>{
if (result.error) {
hasError = true;
2024-01-14 15:59:27 +00:00
ModalAlert.fire({
text: $.t("fs.copy.err_generic"),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-12-28 17:43:07 +00:00
} else if (result.data.length > 0){
hasError = true;
2024-01-14 15:59:27 +00:00
ModalAlert.fire({
text: $.t("fs.copy.err_exists"),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-12-28 17:43:07 +00:00
}
copyItem();
});
2021-11-22 11:25:36 +00:00
}
2023-11-04 09:54:52 +00:00
function doMove() {
2023-12-14 09:36:25 +00:00
$('#errorMsg').addClass("d-none");
2023-11-22 14:57:33 +00:00
let items = getMoveOrCopyItems();
2023-11-06 18:10:35 +00:00
if (items.length == 0){
return;
2023-11-04 09:54:52 +00:00
}
2023-11-22 14:57:33 +00:00
items = checkMoveCopyItems(items)
if (items.length == 0){
2024-01-14 15:59:27 +00:00
ModalAlert.fire({
text: $.t("fs.invalid_name"),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-11-22 14:57:33 +00:00
return;
}
2024-03-11 17:19:57 +00:00
function showMoveError(status) {
KTApp.hidePageLoading();
let errorMessage = "";
switch (status) {
case 400:
errorMessage = "fs.move.err_unsupported";
break;
case 403:
errorMessage = "fs.move.err_403";
break;
case 429:
errorMessage = "fs.move.err_429";
break;
default:
errorMessage = "fs.move.err_generic";
}
ModalAlert.fire({
text: $.t(errorMessage),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
}
2023-11-06 18:10:35 +00:00
let hasError = false;
let index = 0;
2022-11-19 11:31:03 +00:00
2024-10-03 16:53:57 +00:00
clearLoading();
2023-11-04 09:54:52 +00:00
KTApp.showPageLoading();
2022-07-21 16:42:22 +00:00
2023-11-06 18:10:35 +00:00
function moveItem() {
if (index >= items.length || hasError){
KTApp.hidePageLoading();
if (!hasError){
location.reload();
}
return;
2021-11-30 17:40:50 +00:00
}
2023-11-06 18:10:35 +00:00
let item = items[index];
let sourcePath = decodeURIComponent('{{.CurrentDir}}');
if (!sourcePath.endsWith('/')){
sourcePath+="/";
}
sourcePath+=item.sourceName;
let targetPath = decodeURIComponent(item.targetDir);
if (!targetPath.endsWith('/')){
targetPath+="/";
}
targetPath+=item.targetName;
2023-12-10 15:40:13 +00:00
if (items.length > 1) {
2024-10-03 16:53:57 +00:00
let info = $.t('fs.moving', {
2023-12-10 15:40:13 +00:00
idx: index + 1,
2024-10-03 16:53:57 +00:00
total: items.length
2023-12-10 15:40:13 +00:00
});
2024-10-03 16:53:57 +00:00
setLoadingText(info,`${sourcePath} => ${targetPath}`);
2023-11-06 18:10:35 +00:00
}
let path = '{{.FileActionsURL}}/move';
path+='?path={{.CurrentDir}}'+encodeURIComponent("/"+item.sourceName)+'&target='+item.targetDir+encodeURIComponent("/"+item.targetName);
axios.post(path, null, {
2024-03-11 17:19:57 +00:00
timeout: 15000,
2023-11-06 18:10:35 +00:00
headers: {
'X-CSRF-TOKEN': '{{.CSRFToken}}'
},
validateStatus: function (status) {
2024-03-11 17:19:57 +00:00
return status == 202;
2022-11-19 11:31:03 +00:00
}
2023-11-06 18:10:35 +00:00
}).then(function (response) {
2024-03-11 17:19:57 +00:00
taskStatusWaiter.wait({
taskID: response.data.message,
delay: 500
}).then((result) => {
index++;
if (result.status != 200){
hasError = true;
showMoveError(result.status);
}
moveItem();
});
2023-11-06 18:10:35 +00:00
}).catch(function (error) {
index++;
hasError = true;
2024-03-11 17:19:57 +00:00
let status = 0;
2023-11-06 18:10:35 +00:00
if (error & & error.response) {
2024-03-11 17:19:57 +00:00
status = error.response.status;
2023-12-10 15:40:13 +00:00
}
2024-03-11 17:19:57 +00:00
showMoveError(status);
2023-11-06 18:10:35 +00:00
moveItem();
});
}
2023-12-28 17:43:07 +00:00
let filesArray = [];
for (let i = 0; i < items.length ; i + + ) {
2024-04-01 10:00:06 +00:00
filesArray.push(items[i].targetName);
2023-12-28 17:43:07 +00:00
}
CheckExist.fire({
operation: "move",
files: filesArray,
path: items[0].targetDir
}).then((result)=>{
if (result.error) {
hasError = true;
2024-01-14 15:59:27 +00:00
ModalAlert.fire({
text: $.t("fs.move.err_generic"),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-12-28 17:43:07 +00:00
} else if (result.data.length > 0){
hasError = true;
2024-01-14 15:59:27 +00:00
ModalAlert.fire({
text: $.t("fs.move.err_exists"),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-12-28 17:43:07 +00:00
}
moveItem();
});
2023-11-04 09:54:52 +00:00
}
2022-11-19 11:31:03 +00:00
2024-03-11 17:19:57 +00:00
function showDeleteItemError(status, itemName) {
KTApp.hidePageLoading();
let errorMessage;
switch (status) {
case 403:
errorMessage = "fs.delete.err_403";
break;
case 429:
errorMessage = "fs.delete.err_429";
break;
default:
errorMessage = "fs.delete.err_generic";
2023-11-04 09:54:52 +00:00
}
2024-03-11 17:19:57 +00:00
ModalAlert.fire({
text: $.t(errorMessage, {name: itemName}),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-11-04 09:54:52 +00:00
}
2022-11-19 11:31:03 +00:00
2023-11-04 09:54:52 +00:00
function deleteItem(meta) {
2023-12-14 09:36:25 +00:00
$('#errorMsg').addClass("d-none");
2023-11-04 09:54:52 +00:00
let itemName = getNameFromMeta(meta);
ModalAlert.fire({
2023-12-10 15:40:13 +00:00
text: $.t('general.delete_confirm', {name: itemName}),
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){
2024-10-03 16:53:57 +00:00
clearLoading();
2023-11-04 09:54:52 +00:00
KTApp.showPageLoading();
2024-03-11 17:19:57 +00:00
let isDir = (getTypeFromMeta(meta) == "1");
let path;
if (isDir){
path = '{{.DirsURL}}';
} else {
path = '{{.FilesURL}}';
}
path+='?path={{.CurrentDir}}'+encodeURIComponent("/"+itemName);
2023-11-04 09:54:52 +00:00
2024-03-11 17:19:57 +00:00
axios.delete(path, {
timeout: 15000,
2023-11-04 09:54:52 +00:00
headers: {
'X-CSRF-TOKEN': '{{.CSRFToken}}'
},
validateStatus: function (status) {
2024-03-11 17:19:57 +00:00
if (isDir){
return status == 202;
}
2023-11-04 09:54:52 +00:00
return status == 200;
}
}).then(function(response){
2024-03-11 17:19:57 +00:00
if (isDir){
taskStatusWaiter.wait({
taskID: response.data.message,
delay: 500
}).then((result) => {
if (result.status == 200){
location.reload();
} else {
showDeleteItemError(result.status, itemName);
}
});
} else {
location.reload();
}
2023-11-04 09:54:52 +00:00
}).catch(function(error){
2024-03-11 17:19:57 +00:00
let status = 0;
2023-11-04 09:54:52 +00:00
if (error & & error.response) {
2024-03-11 17:19:57 +00:00
status = error.response.status;
2022-11-19 11:31:03 +00:00
}
2024-03-11 17:19:57 +00:00
showDeleteItemError(status, itemName);
2022-11-19 11:31:03 +00:00
});
}
2023-11-04 09:54:52 +00:00
});
}
function shareItem(meta) {
let filesArray = [];
filesArray.push(getNameFromMeta(meta));
let files = encodeURIComponent(JSON.stringify(filesArray));
let shareURL = '{{.ShareURL}}';
let currentDir = '{{.CurrentDir}}';
let ts = new Date().getTime().toString();
window.open(`${shareURL}?path=${currentDir}&files=${files}&_=${ts}`,'_blank');
}
function renameItem(meta) {
$('#errorMsg').addClass("d-none");
2023-11-16 17:55:14 +00:00
let oldName = getNameFromMeta(meta);
2023-11-04 09:54:52 +00:00
$('#rename_old_name').val(meta);
$('#rename_new_name').val(oldName);
2023-12-26 07:59:52 +00:00
$('#rename_title').text($.t('fs.rename.title', { name: oldName}));
2023-11-04 09:54:52 +00:00
$('#modal_rename').modal('show');
}
2022-11-19 11:31:03 +00:00
2024-03-11 17:19:57 +00:00
function showRenameItemError(status, oldName) {
KTApp.hidePageLoading();
let errorMessage;
switch (status) {
case 400:
errorMessage = "fs.rename.err_unsupported";
break;
case 403:
errorMessage = "fs.rename.err_403";
break;
case 429:
errorMessage = "fs.rename.err_429";
break;
default:
errorMessage = "fs.rename.err_generic";
}
ModalAlert.fire({
text: $.t(errorMessage, {name: oldName}),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
}
2023-11-04 09:54:52 +00:00
function doRename() {
2023-11-16 17:55:14 +00:00
let meta = $('#rename_old_name').val();
let oldName = getNameFromMeta(meta);
2023-11-04 09:54:52 +00:00
let newName = $('#rename_new_name').val();
if (!newName){
2024-01-14 15:59:27 +00:00
ModalAlert.fire({
text: $.t('general.name_required'),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-11-04 09:54:52 +00:00
return;
}
if (newName == oldName){
2024-01-14 15:59:27 +00:00
ModalAlert.fire({
text: $.t('general.name_different'),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-11-04 09:54:52 +00:00
return;
}
2023-11-22 14:57:33 +00:00
if (newName.includes("/")){
2024-01-14 15:59:27 +00:00
ModalAlert.fire({
text: $.t('fs.invalid_name'),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-11-22 14:57:33 +00:00
return;
}
2023-12-28 17:43:07 +00:00
2024-10-03 16:53:57 +00:00
clearLoading();
2023-12-28 17:43:07 +00:00
KTApp.showPageLoading();
function executeRename() {
let path = '{{.FileActionsURL}}/move';
path += '?path={{.CurrentDir}}' + encodeURIComponent("/" + oldName) + '& target={{.CurrentDir}}' + encodeURIComponent("/" + newName);
axios.post(path, null, {
timeout: 15000,
headers: {
'X-CSRF-TOKEN': '{{.CSRFToken}}'
},
validateStatus: function (status) {
2024-03-11 17:19:57 +00:00
return status == 202;
2023-12-28 17:43:07 +00:00
}
}).then(function (response) {
2024-03-11 17:19:57 +00:00
taskStatusWaiter.wait({
taskID: response.data.message,
delay: 500
}).then((result) => {
if (result.status == 200){
location.reload();
} else {
showRenameItemError(result.status, oldName);
}
});
2023-12-28 17:43:07 +00:00
}).catch(function (error) {
2024-03-11 17:19:57 +00:00
let status = 0;
2023-12-28 17:43:07 +00:00
if (error & & error.response) {
2024-03-11 17:19:57 +00:00
status = error.response.status;
2023-11-04 09:54:52 +00:00
}
2024-03-11 17:19:57 +00:00
showRenameItemError(status, oldName);
2023-12-28 17:43:07 +00:00
});
}
CheckExist.fire({
operation: "move",
2024-04-01 10:00:06 +00:00
files: [newName],
2023-12-28 17:43:07 +00:00
path: '{{.CurrentDir}}'
}).then((result)=>{
if (result.error) {
KTApp.hidePageLoading();
2024-01-14 15:59:27 +00:00
ModalAlert.fire({
text: $.t('fs.rename.err_generic', { name: oldName }),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-12-28 17:43:07 +00:00
return;
2023-11-04 09:54:52 +00:00
}
2023-12-28 17:43:07 +00:00
if (result.data.length > 0){
KTApp.hidePageLoading();
2024-01-14 15:59:27 +00:00
ModalAlert.fire({
text: $.t('fs.rename.err_exists', { name: oldName }),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
2023-12-28 17:43:07 +00:00
return;
2023-12-10 15:40:13 +00:00
}
2023-12-28 17:43:07 +00:00
executeRename();
2021-07-26 18:55:49 +00:00
});
2023-11-04 09:54:52 +00:00
}
2021-07-26 18:55:49 +00:00
2023-11-04 09:54:52 +00:00
function showCreateNewFolder(sender) {
if (sender == 0) {
2023-12-26 07:59:52 +00:00
$('.new_folder_divider').removeClass("d-none");
2023-11-04 09:54:52 +00:00
$('#file_manager_new_folder').removeClass("d-none");
$('#errorMsg').addClass("d-none");
let el = $('#file_manager_new_folder_input');
el.val("");
el.focus();
return;
}
2023-12-26 07:59:52 +00:00
$('.dir_browser_folder_divider').removeClass("d-none");
2023-11-04 09:54:52 +00:00
$('#dirsbrowser_new_folder').removeClass("d-none");
$('#errorModalMsg').addClass("d-none");
let el = $('#dirsbrowser_new_folder_input');
el.val("");
el.focus();
}
2021-12-08 18:25:22 +00:00
2023-11-04 09:54:52 +00:00
function hideCreateNewFolder(sender) {
if (sender == 0){
2023-12-26 07:59:52 +00:00
$('.new_folder_divider').addClass("d-none");
2023-11-04 09:54:52 +00:00
$('#file_manager_new_folder').addClass("d-none");
} else {
2023-12-26 07:59:52 +00:00
$('.dir_browser_folder_divider').addClass("d-none");
2023-11-04 09:54:52 +00:00
$('#dirsbrowser_new_folder').addClass("d-none");
}
}
2021-12-08 18:25:22 +00:00
2023-11-04 09:54:52 +00:00
function createNewFolder() {
let errDivEl = $('#errorMsg');
let errTxtEl = $('#errorTxt');
2023-11-22 14:57:33 +00:00
let dirName = $("#file_manager_new_folder_input").val();
2023-11-04 09:54:52 +00:00
let submitButton = document.querySelector('#file_manager_add_folder');
2023-11-06 18:10:35 +00:00
let cancelButton = document.querySelector('#file_manager_cancel_folder');
2023-11-04 09:54:52 +00:00
errDivEl.addClass("d-none");
if (!dirName){
2023-12-10 15:40:13 +00:00
setI18NData(errTxtEl, "fs.folder_name_required");
2023-11-04 09:54:52 +00:00
errDivEl.removeClass("d-none");
return;
}
2023-11-22 14:57:33 +00:00
if (dirName.includes("/")){
2023-12-10 15:40:13 +00:00
setI18NData(errTxtEl, "fs.invalid_name");
2023-11-22 14:57:33 +00:00
errDivEl.removeClass("d-none");
return;
}
2021-11-30 17:40:50 +00:00
2023-11-04 09:54:52 +00:00
let path = '{{.DirsURL}}?path={{.CurrentDir}}' + encodeURIComponent("/"+dirName);
submitButton.setAttribute('data-kt-indicator', 'on');
submitButton.disabled = true;
2023-11-06 18:10:35 +00:00
cancelButton.disabled = true;
2021-07-26 18:55:49 +00:00
2023-11-04 09:54:52 +00:00
axios.post(path, null, {
timeout: 15000,
headers: {
'X-CSRF-TOKEN': '{{.CSRFToken}}'
},
validateStatus: function (status) {
return status == 201;
2021-12-25 16:13:23 +00:00
}
2023-11-04 09:54:52 +00:00
}).then(function (response) {
location.reload();
}).catch(function (error) {
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 = "fs.create_dir.err_403";
break;
case 429:
errorMessage = "fs.create_dir.err_429";
break;
2021-07-26 18:55:49 +00:00
}
}
2023-12-10 15:40:13 +00:00
if (!errorMessage){
errorMessage = "fs.create_dir.err_generic";
}
setI18NData(errTxtEl, errorMessage);
2023-11-04 09:54:52 +00:00
errDivEl.removeClass("d-none");
submitButton.removeAttribute('data-kt-indicator');
submitButton.disabled = false;
2023-11-06 18:10:35 +00:00
cancelButton.disabled = false;
2021-07-26 18:55:49 +00:00
});
2023-11-04 09:54:52 +00:00
}
//{{- end}}
2021-07-26 18:55:49 +00:00
2023-11-04 09:54:52 +00:00
var playerKeepAlive;
function uploadFiles(files) {
keepAlive();
let keepAliveTimer = setInterval(keepAlive, 300000);
let has_errors = false;
let index = 0;
let success = 0;
2024-03-31 18:42:28 +00:00
let checkedDirs = [];
2023-11-04 09:54:52 +00:00
$('#errorMsg').addClass("d-none");
2024-10-03 16:53:57 +00:00
clearLoading();
2023-11-04 09:54:52 +00:00
KTApp.showPageLoading();
function uploadFile() {
if (index >= files.length || has_errors) {
//console.log("upload done, index: "+index+" has errors: "+has_errors+" ok: "+success);
clearInterval(keepAliveTimer);
KTApp.hidePageLoading();
if (!has_errors) {
2022-12-30 18:30:16 +00:00
location.reload();
}
2023-11-04 09:54:52 +00:00
return;
}
2022-12-30 18:30:16 +00:00
2023-11-04 09:54:52 +00:00
let f = files[index];
let uploadPath;
2024-03-31 18:42:28 +00:00
let name = f.name;
let mkdirParents = "false";
if (f.fullPath){
name = f.fullPath;
let dirName = name.substr(0, name.lastIndexOf("/"));
if (!checkedDirs.includes(dirName)){
mkdirParents = "true";
checkedDirs.push(dirName);
}
}
2023-11-04 09:54:52 +00:00
//{{- if .ShareUploadBaseURL}}
2024-03-31 18:42:28 +00:00
uploadPath = '{{.ShareUploadBaseURL}}' + encodeURIComponent("/" + name)+"?mkdir_parents="+mkdirParents;
2023-11-04 09:54:52 +00:00
//{{- else}}
2024-03-31 18:42:28 +00:00
uploadPath = '{{.FileURL}}?path={{.CurrentDir}}' + encodeURIComponent("/" + name)+"&mkdir_parents="+mkdirParents;
2023-11-04 09:54:52 +00:00
//{{- end}}
let lastModified;
try {
lastModified = f.lastModified;
} catch (e) {
2023-12-10 15:40:13 +00:00
console.error("unable to get last modified time from file: " + e.message);
2023-11-04 09:54:52 +00:00
lastModified = "";
2021-05-06 19:35:43 +00:00
}
2021-12-10 17:43:26 +00:00
2024-10-03 16:53:57 +00:00
let info = "";
2023-11-04 09:54:52 +00:00
if (files.length > 1){
2024-10-03 16:53:57 +00:00
info = $.t('fs.uploading', {
2023-12-10 15:40:13 +00:00
idx: index + 1,
2024-10-03 16:53:57 +00:00
total: files.length
2023-12-10 15:40:13 +00:00
});
2023-11-04 09:54:52 +00:00
}
2024-10-03 16:53:57 +00:00
setLoadingText(info,f.name);
2023-11-04 09:54:52 +00:00
axios.post(uploadPath, f, {
headers: {
'X-SFTPGO-MTIME': lastModified,
'X-CSRF-TOKEN': '{{.CSRFToken}}'
2021-05-27 07:40:46 +00:00
},
2023-11-04 09:54:52 +00:00
onUploadProgress: function (progressEvent) {
if (!progressEvent.total){
return;
2023-06-04 19:45:31 +00:00
}
2023-11-04 09:54:52 +00:00
const percentage = Math.round((100 * progressEvent.loaded) / progressEvent.total);
if (percentage > 0 & & percentage < 100 ) {
2024-10-03 16:53:57 +00:00
setLoadingText(info,`${f.name} ${percentage}%`);
2021-10-09 12:17:28 +00:00
}
2021-12-03 17:33:08 +00:00
},
2023-11-04 09:54:52 +00:00
validateStatus: function (status) {
return status == 201;
2021-10-09 12:17:28 +00:00
}
2023-11-04 09:54:52 +00:00
}).then(function (response) {
index++;
success++;
uploadFile();
}).catch(function (error) {
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 = "fs.upload.err_403";
break;
case 429:
errorMessage = "fs.upload.err_429";
break;
2023-11-04 09:54:52 +00:00
}
2021-05-06 19:35:43 +00:00
}
2023-12-10 15:40:13 +00:00
if (!errorMessage){
errorMessage = "fs.upload.err_generic";
}
2023-11-04 09:54:52 +00:00
index++;
has_errors = true;
2023-12-10 15:40:13 +00:00
setI18NData($('#errorTxt'), errorMessage);
2023-11-04 09:54:52 +00:00
$('#errorMsg').removeClass("d-none");
uploadFile();
});
}
2024-03-31 18:42:28 +00:00
let filesArray = [];
let dirsArray = [];
if (files.length > 0){
for (let i = 0; i < files.length ; i + + ) {
if (files[i].fullPath){
let dirName = files[i].fullPath.split('/')[0];
if (!dirsArray.includes(dirName)){
dirsArray.push(dirName);
}
if (!filesArray.includes(dirName)){
filesArray.push(dirName);
}
} else {
filesArray.push(files[i].name);
}
}
}
2023-12-28 17:43:07 +00:00
CheckExist.fire({
operation: "upload",
2024-03-31 18:42:28 +00:00
files: filesArray,
2023-12-28 17:43:07 +00:00
path: "{{.CurrentDir}}"
}).then((result)=> {
if (result.error) {
has_errors = true;
setI18NData($('#errorTxt'), "fs.upload.err_generic");
$('#errorMsg').removeClass("d-none");
uploadFile();
return;
}
2024-04-01 09:42:22 +00:00
let existingEntries = [];
let fileOverwriteDirs = [];
2023-12-28 17:43:07 +00:00
$.each(result.data, function (key, item) {
2024-03-31 18:42:28 +00:00
if (item.type === "1" & & !dirsArray.includes(item.name)) {
2024-04-01 09:42:22 +00:00
fileOverwriteDirs.push(item.name);
2023-12-28 17:43:07 +00:00
} else {
2024-04-01 09:42:22 +00:00
existingEntries.push(item.name);
2023-12-28 17:43:07 +00:00
}
});
2024-04-01 09:42:22 +00:00
if (fileOverwriteDirs.length > 0) {
2023-12-28 17:43:07 +00:00
has_errors = true;
2024-04-01 09:42:22 +00:00
setI18NData($('#errorTxt'), "fs.upload.err_dir_overwrite", {val: fileOverwriteDirs.join(", ")});
2023-12-28 17:43:07 +00:00
$('#errorMsg').removeClass("d-none");
uploadFile();
return;
}
2024-04-01 09:42:22 +00:00
if (existingEntries.length > 0) {
2023-12-28 17:43:07 +00:00
KTApp.hidePageLoading();
ModalAlert.fire({
text: $.t('fs.upload.overwrite_text'),
2024-04-01 09:42:22 +00:00
items: existingEntries,
2023-12-28 17:43:07 +00:00
icon: "warning",
confirmButtonText: $.t('general.confirm'),
cancelButtonText: $.t('general.cancel'),
customClass: {
confirmButton: "btn btn-danger",
cancelButton: 'btn btn-secondary'
}
}).then((result) => {
if (result.isConfirmed){
KTApp.showPageLoading();
} else {
has_errors = true;
}
uploadFile();
});
return;
}
uploadFile();
});
2023-11-04 09:54:52 +00:00
}
2023-12-28 17:43:07 +00:00
var CheckExist = function () {
var promiseResolve;
function doCheck(operation, files, target) {
let path = '{{.CheckExistURL}}?op='+encodeURIComponent(operation)+"&path="+target;
axios.post(path, {
2024-03-31 18:42:28 +00:00
files: files
2023-12-28 17:43:07 +00:00
}, {
headers: {
timeout: 15000,
'X-CSRF-TOKEN': '{{.CSRFToken}}'
},
validateStatus: function (status) {
return status == 200;
}
}).then(function(response){
promiseResolve({
error: false,
data: response.data
});
}).catch(function(error){
promiseResolve({
error: true
});
});
}
return {
fire: function (params) {
return new Promise(function (resolve, reject) {
promiseResolve = resolve;
doCheck(params.operation, params.files, params.path);
});
}
}
}();
2023-11-17 20:42:22 +00:00
function openMediaPlayer(name, url){
2023-11-16 17:55:14 +00:00
$("#video_title").text(name);
2023-11-17 20:42:22 +00:00
$("#video_player").attr("src", url);
$("#video_player").get(0).load();
2023-11-04 09:54:52 +00:00
$('#modal_video_player').modal('show');
keepAlive();
playerKeepAlive = setInterval(keepAlive, 300000);
}
2023-12-10 15:40:13 +00:00
$(document).on("i18nshow", function(){
2023-11-04 09:54:52 +00:00
KTDatatablesServerSide.init();
2024-10-03 17:06:33 +00:00
var lastAddedFile = Date.now();
function canUpload() {
// Ugly hack to detect if we are still loading a large file list when the user try to upload files.
// The Dropzone addedfiles event is fired for directories before the files within them are added to the queue.
// TODO: investigate if there is a better way.
if (Date.now() - lastAddedFile < 500 ) {
ModalAlert.fire({
text: $.t('fs.upload_queue_not_ready'),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
return false;
}
return true;
}
2023-11-04 09:54:52 +00:00
var dropzone = new Dropzone("#upload_files", {
url: "{{.FilesURL}}?path={{.CurrentDir}}",
paramName: "filenames",
2024-03-31 18:42:28 +00:00
createImageThumbnails: false,
maxFiles: null,
2023-11-04 09:54:52 +00:00
maxFilesize: null,
autoQueue: false,
2024-03-31 18:42:28 +00:00
addRemoveLinks: false,
2023-11-04 09:54:52 +00:00
autoProcessQueue: false,
filesizeBase: 1000,
2024-03-31 18:42:28 +00:00
previewTemplate: dzPreviewTemplate,
2023-11-04 09:54:52 +00:00
init: function() {
var dropzone = this;
$("#upload_files_button").click(function(){
2024-10-03 17:06:33 +00:00
if (canUpload()){
uploadFiles(dropzone.getAcceptedFiles());
}
2023-11-04 09:54:52 +00:00
});
}
2021-05-06 19:35:43 +00:00
});
2023-11-04 09:54:52 +00:00
dropzone.on("addedfile", file => {
2024-03-31 18:42:28 +00:00
for (node of file.previewElement.querySelectorAll("[data-custom-size]")) {
node.textContent = fileSizeIEC(file.size);
}
if (file.fullPath){
for (var node of file.previewElement.querySelectorAll("[data-dz-name]")) {
node.textContent = file.fullPath;
}
}
2024-10-03 17:06:33 +00:00
lastAddedFile = Date.now();
2023-11-04 09:54:52 +00:00
});
2023-12-26 18:07:50 +00:00
var dropzoneEmpty = new Dropzone("#upload_files_empty", {
url: "{{.FilesURL}}?path={{.CurrentDir}}",
paramName: "filenames",
2024-03-31 18:42:28 +00:00
createImageThumbnails: false,
maxFiles: null,
2023-12-26 18:07:50 +00:00
maxFilesize: null,
autoQueue: false,
2024-03-31 18:42:28 +00:00
addRemoveLinks: false,
2023-12-26 18:07:50 +00:00
autoProcessQueue: false,
filesizeBase: 1000,
2024-03-31 18:42:28 +00:00
previewTemplate: dzPreviewTemplate,
2023-12-26 18:07:50 +00:00
init: function() {
var dropzoneEmpty = this;
$("#upload_files_empty_button").click(function(){
2024-10-03 17:06:33 +00:00
if (canUpload()){
uploadFiles(dropzoneEmpty.getAcceptedFiles());
}
2023-12-26 18:07:50 +00:00
});
}
});
dropzoneEmpty.on("addedfile", file => {
2024-03-31 18:42:28 +00:00
for (node of file.previewElement.querySelectorAll("[data-custom-size]")) {
node.textContent = fileSizeIEC(file.size);
}
if (file.fullPath){
for (var node of file.previewElement.querySelectorAll("[data-dz-name]")) {
node.textContent = file.fullPath;
}
}
2024-10-03 17:06:33 +00:00
lastAddedFile = Date.now();
2023-12-26 18:07:50 +00:00
});
2023-11-04 09:54:52 +00:00
$('#modal_video_player').on('hide.bs.modal', function () {
2023-11-17 20:42:22 +00:00
$("#video_player").get(0).pause();
2023-11-04 09:54:52 +00:00
if (playerKeepAlive != null) {
clearInterval(playerKeepAlive);
playerKeepAlive = null;
}
});
2021-05-06 19:35:43 +00:00
2023-11-04 09:54:52 +00:00
//{{- if not .ShareUploadBaseURL}}
$('#modal_rename').on('shown.bs.modal', function () {
let newNameEl = $('#rename_new_name');
newNameEl.focus();
newNameEl.select();
});
//{{- end}}
2023-11-13 21:09:55 +00:00
// onclick handlers
var createDirBtn = $('#id_create_dir_button');
if (createDirBtn){
createDirBtn.on("click", function (){
showCreateNewFolder(0);
});
}
var dirBrowserCreateDir = $('#id_dir_browser_create_dir');
if (dirBrowserCreateDir){
dirBrowserCreateDir.on("click", function(){
showCreateNewFolder(1);
});
}
var fileManagerAddFolder = $('#file_manager_add_folder');
if (fileManagerAddFolder){
fileManagerAddFolder.on("click", function() {
createNewFolder();
});
}
var fileManagerCancelCreateFolder = $('#file_manager_cancel_folder');
if (fileManagerCancelCreateFolder){
fileManagerCancelCreateFolder.on("click", function(){
hideCreateNewFolder(0);
})
}
var dirBrowserCancelCreateFolder = $('#dirsbrowser_cancel_folder');
if (dirBrowserCancelCreateFolder){
dirBrowserCancelCreateFolder.on("click", function(){
hideCreateNewFolder(1);
});
}
var doRenameBtn = $('#id_do_rename_button');
if (doRenameBtn){
doRenameBtn.on("click", function() {
doRename();
});
}
var doCopyBtn = $('#id_copy_button');
if (doCopyBtn){
doCopyBtn.on("click", function(){
doCopy();
});
}
var doMoveBtn = $('#id_move_button');
if (doMoveBtn){
doMoveBtn.on("click", function(){
doMove();
});
}
var dismissErrorModalBtn = $('#id_dismiss_error_modal_msg');
if (dismissErrorModalBtn){
dismissErrorModalBtn.on("click",function(){
$('#errorModalMsg').addClass("d-none");
});
}
2021-05-06 19:35:43 +00:00
});
< / script >
2023-11-04 09:54:52 +00:00
{{- end}}
{{- define "additionalnavitems"}}
{{- if .QuotaUsage.HasQuotaInfo}}
< div class = "d-flex align-items-center ms-2 ms-lg-3" >
2024-01-09 18:54:08 +00:00
< div class = "btn btn-icon btn-active-light-primary position-relative w-35px h-35px w-md-40px h-md-40px" data-kt-menu-trigger = "{default:'click', lg: 'hover'}" data-kt-menu-attach = "parent" data-kt-menu-placement = "bottom-end" >
2023-11-04 09:54:52 +00:00
< i class = "ki-duotone {{if .QuotaUsage.IsQuotaLow}}ki-information-5 text-warning{{else}}ki-information-2{{end}} fs-2" >
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< span class = "path3" > < / span >
< / i >
< / div >
2023-12-10 15:40:13 +00:00
< div class = "menu menu-sub menu-sub-dropdown menu-column w-375px" data-kt-menu = "true" >
2023-11-04 09:54:52 +00:00
< div class = "card" >
< div class = "card-header" >
2023-12-10 15:40:13 +00:00
< h3 class = "card-title" > < span data-i18n = "fs.quota_usage.title" class = "text-gray-700 fw-bold fs-6" > Quota usage< / span > < / h3 >
2023-11-04 09:54:52 +00:00
< / div >
< div class = "card-body p-0" >
{{- if .QuotaUsage.HasDiskQuota}}
{{- $size := .QuotaUsage.GetQuotaSize}}
{{- $files := .QuotaUsage.GetQuotaFiles}}
< div class = "d-flex align-items-center bg-hover-lighten py-3 px-9" >
< div class = "symbol symbol-40px symbol-circle me-5" >
< span class = "symbol-label {{ if .QuotaUsage.IsDiskQuotaLow }}bg-light-warning{{end}}" >
< i class = "ki-duotone ki-external-drive {{ if .QuotaUsage.IsDiskQuotaLow }}text-warning{{end}} fs-1" >
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< span class = "path3" > < / span >
< span class = "path4" > < / span >
< span class = "path5" > < / span >
< / i >
< / span >
< / div >
< div class = "mb-1 pe-3 flex-grow-1" >
2023-12-10 15:40:13 +00:00
< span data-i18n = "fs.quota_usage.disk" class = "fs-6 text-gray-900 fw-semibold" > Disk quota< / span >
2023-11-04 09:54:52 +00:00
{{- if $size}}
{{- $percentage := .QuotaUsage.GetQuotaSizePercentage}}
2023-12-10 15:40:13 +00:00
< div class = "{{if .QuotaUsage.IsQuotaSizeLow}}text-warning{{else}}text-gray-700{{end}} fw-semibold fs-6" >
< span { { if gt $ percentage 0 } } data-i18n = "fs.quota_usage.size_percentage" data-i18n-options = '{ "val": "{{$size}}", "percentage": {{$percentage}} }' { { else } } data-i18n = "fs.quota_usage.size" data-i18n-options = '{ "val": "{{$size}}" }' { { end } } > < / span >
< / div >
2023-11-04 09:54:52 +00:00
{{- end}}
{{- if $files}}
{{- $percentage := .QuotaUsage.GetQuotaFilesPercentage}}
2023-12-10 15:40:13 +00:00
< div class = "{{if .QuotaUsage.IsQuotaFilesLow}}text-warning{{else}}text-gray-700{{end}} fw-semibold fs-6" >
2023-12-28 18:59:06 +00:00
< span { { if gt $ percentage 0 } } data-i18n = "fs.quota_usage.files_percentage" data-i18n-options = '{ "val": "{{$files}}", "percentage": {{$percentage}} }' { { else } } data-i18n = "fs.quota_usage.files" data-i18n-options = '{ "val": "{{$files}}" }' { { end } } > < / span >
2023-12-10 15:40:13 +00:00
< / div >
2023-11-04 09:54:52 +00:00
{{- end}}
< / div >
< / div >
{{- end}}
{{- if .QuotaUsage.HasTranferQuota}}
{{- $total := .QuotaUsage.GetTotalTransferQuota}}
{{- $upload := .QuotaUsage.GetUploadTransferQuota}}
{{- $download := .QuotaUsage.GetDownloadTransferQuota}}
< div class = "d-flex align-items-center bg-hover-lighten py-3 px-9" >
< div class = "symbol symbol-40px symbol-circle me-5" >
< span class = "symbol-label {{ if .QuotaUsage.IsTransferQuotaLow }}bg-light-warning{{end}}" >
< i class = "ki-duotone ki-arrow-right-left {{ if .QuotaUsage.IsTransferQuotaLow }}text-warning{{end}} fs-1" >
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< / i >
< / span >
< / div >
< div class = "mb-1 pe-3 flex-grow-1" >
2023-12-10 15:40:13 +00:00
< span data-i18n = "fs.quota_usage.transfer" class = "fs-6 text-gray-900 fw-semibold" > Transfer quota< / span >
2023-11-04 09:54:52 +00:00
{{- if $total}}
{{$percentage := .QuotaUsage.GetTotalTransferQuotaPercentage}}
2023-12-10 15:40:13 +00:00
< div class = "{{if .QuotaUsage.IsTotalTransferQuotaLow}}text-warning{{else}}text-gray-700{{end}} fw-semibold fs-6" >
< span { { if gt $ percentage 0 } } data-i18n = "fs.quota_usage.total_percentage" data-i18n-options = '{ "val": "{{$total}}", "percentage": {{$percentage}} }' { { else } } data-i18n = "fs.quota_usage.total" data-i18n-options = '{ "val": "{{$total}}" }' { { end } } >
< / span >
< / div >
2023-11-04 09:54:52 +00:00
{{- end}}
{{- if $download}}
{{$percentage := .QuotaUsage.GetDownloadTransferQuotaPercentage}}
2023-12-10 15:40:13 +00:00
< div class = "{{if .QuotaUsage.IsDownloadTransferQuotaLow}}text-warning{{else}}text-gray-700{{end}} fw-semibold fs-6" >
< span { { if gt $ percentage 0 } } data-i18n = "fs.quota_usage.downloads_percentage" data-i18n-options = '{ "val": "{{$download}}", "percentage": {{$percentage}} }' { { else } } data-i18n = "fs.quota_usage.downloads" data-i18n-options = '{ "val": "{{$download}}" }' { { end } } >
< / span >
< / div >
2023-11-04 09:54:52 +00:00
{{- end}}
{{- if $upload}}
{{$percentage := .QuotaUsage.GetUploadTransferQuotaPercentage}}
2023-12-10 15:40:13 +00:00
< div class = "{{if .QuotaUsage.IsUploadTransferQuotaLow}}text-warning{{else}}text-gray-700{{end}} fw-semibold fs-6" >
< span { { if gt $ percentage 0 } } data-i18n = "fs.quota_usage.uploads_percentage" data-i18n-options = '{ "val": "{{$upload}}", "percentage": {{$percentage}} }' { { else } } data-i18n = "fs.quota_usage.uploads" data-i18n-options = '{ "val": "{{$upload}}" }' { { end } } >
< / span >
< / div >
2023-11-04 09:54:52 +00:00
{{- end}}
< / div >
< / div >
{{- end}}
< / div >
< / div >
< / div >
< / div >
{{- end}}
{{- end}}
{{- define "modals"}}
< div class = "modal fade" tabindex = "-1" id = "modal_upload" >
< div class = "modal-dialog modal-dialog-centered mw-600px" >
< div class = "modal-content" >
< div class = "modal-header border-0" >
2023-12-10 15:40:13 +00:00
< h3 data-i18n = "fs.upload.text" class = "modal-title" > Upload files< / 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 >
< / div >
< div class = "modal-body" >
< form id = "upload_files_form" action = "{{.FilesURL}}?path={{.CurrentDir}}" method = "POST" enctype = "multipart/form-data" >
< div class = "fv-row" >
2024-03-31 18:42:28 +00:00
< div class = "dropzone mh-350px overflow-auto visibility-auto" id = "upload_files" >
2023-11-04 09:54:52 +00:00
< div class = "dz-message needsclick align-items-center" >
< i class = "ki-duotone ki-file-up fs-3x text-primary" > < span class = "path1" > < / span > < span class = "path2" > < / span > < / i >
< div class = "ms-4" >
2023-12-10 15:40:13 +00:00
< h3 data-i18n = "fs.upload.message" class = "fs-5 fw-bold text-gray-900 mb-1" > Drop files here or click to upload.< / h3 >
2023-11-13 21:09:55 +00:00
<!-- <span class="fs - 7 fw - semibold text - gray - 500">Upload up to 30 files</span> -->
2023-11-04 09:54:52 +00:00
< / div >
< / div >
< / div >
< / div >
< / form >
< / div >
< div class = "modal-footer border-0" >
2023-12-10 15:40:13 +00:00
< button data-i18n = "general.cancel" type = "button" class = "btn btn-light me-5" data-bs-dismiss = "modal" > Cancel< / button >
< button data-i18n = "general.submit" type = "button" id = "upload_files_button" class = "btn btn-primary" data-bs-dismiss = "modal" > Submit< / button >
2023-11-04 09:54:52 +00:00
< / div >
< / div >
< / div >
< / div >
< div class = "modal fade" tabindex = "-1" id = "modal_video_player" data-bs-backdrop = "static" data-bs-keyboard = "false" >
< div class = "modal-dialog modal-dialog-centered modal-lg" >
< div class = "modal-content" >
< div class = "modal-header border-0" >
< h5 class = "modal-title" >
< span id = "video_title" > < / span >
< / h5 >
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 >
< / div >
< div class = "modal-body" >
2023-11-17 20:42:22 +00:00
< video id = "video_player" width = "100%" height = "auto" controls preload = "metadata" >
2023-12-10 15:40:13 +00:00
< span data-i18n = "general.html5_media_not_supported" > < / span >
2023-11-04 09:54:52 +00:00
< / video >
< / div >
< / div >
< / div >
< / div >
{{- if not .ShareUploadBaseURL}}
< div class = "modal fade" tabindex = "-1" id = "modal_rename" >
< div class = "modal-dialog modal-dialog-centered" >
< div class = "modal-content" >
< div class = "modal-header border-0" >
< h5 class = "modal-title" >
< span id = "rename_title" > < / span >
< / h5 >
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 >
< / div >
< div class = "modal-body" >
< input id = "rename_old_name" type = "text" class = "d-none" / >
< div class = "mb-10" >
2023-12-10 15:40:13 +00:00
< label data-i18n = "fs.rename.new_name" for = "rename_new_name" class = "form-label" > < / label >
2023-11-04 09:54:52 +00:00
< input id = "rename_new_name" type = "text" class = "form-control" / >
< / div >
< / div >
< div class = "modal-footer border-0" >
2023-12-10 15:40:13 +00:00
< button data-i18n = "general.cancel" type = "button" class = "btn btn-secondary me-5" data-bs-dismiss = "modal" > Cancel< / button >
2023-12-26 07:59:52 +00:00
< button data-i18n = "general.confirm" id = "id_do_rename_button" type = "button" class = "btn btn-primary" data-bs-dismiss = "modal" > Submit< / button >
2023-11-04 09:54:52 +00:00
< / div >
< / div >
< / div >
< / div >
< div class = "modal fade" tabindex = "-1" id = "modal_move_or_copy" >
< div class = "modal-dialog modal-dialog-centered modal-lg" >
< div class = "modal-content" >
< div class = "modal-header border-0" >
2023-12-10 15:40:13 +00:00
< h3 data-i18n = "general.choose_target_folder" class = "modal-title" >
2023-11-06 18:10:35 +00:00
Choose target folder
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 >
< / div >
< div class = "modal-body" >
2023-12-10 15:40:13 +00:00
< div id = "errorModalMsg" class = "d-none rounded border-warning border border-dashed bg-light-warning d-flex align-items-center p-5 mb-10" >
2023-12-26 07:59:52 +00:00
< i class = "ki-duotone ki-information-5 fs-3x text-warning me-5" > < span class = "path1" > < / span > < span class = "path2" > < / span > < span class = "path3" > < / span > < / i >
2023-11-04 09:54:52 +00:00
< div class = "text-gray-700 fw-bold fs-5 d-flex flex-column pe-0 pe-sm-10" >
< span id = "errorModalTxt" > < / span >
< / div >
2023-11-13 21:09:55 +00:00
< button id = "id_dismiss_error_modal_msg" type = "button" class = "position-absolute position-sm-relative m-2 m-sm-0 top-0 end-0 btn btn-icon btn-sm btn-active-light-primary ms-sm-auto" >
2023-12-26 07:59:52 +00:00
< i class = "ki-solid ki-cross fs-2x text-gray-700" > < / i >
2023-11-04 09:54:52 +00:00
< / button >
< / div >
< div class = "row" >
< div class = "col-md-9 align-items-center d-flex flex-stack" >
< div class = "badge badge-lg badge-light-primary" >
< div id = "dirs_browser_nav" class = "d-flex align-items-center flex-wrap" >
< / div >
< / div >
< / div >
< div class = "col-md-3 align-items-center d-flex justify-content-end" >
2023-11-13 21:09:55 +00:00
< button id = "id_dir_browser_create_dir" type = "button" class = "btn btn-flex btn-primary" >
2023-11-04 09:54:52 +00:00
< i class = "ki-duotone ki-add-folder fs-2" >
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< / i >
2023-12-10 15:40:13 +00:00
< span data-i18n = "general.add" > < / span >
2023-11-04 09:54:52 +00:00
< / button >
< / div >
< / div >
2023-12-26 07:59:52 +00:00
< div class = "dir_browser_folder_divider py-2 d-none" >
< hr >
< / div >
< div id = "dirsbrowser_new_folder" class = "d-flex align-items-center d-none" >
2023-11-04 09:54:52 +00:00
< span >
< i class = "ki-duotone ki-folder fs-2x text-primary me-4" >
< span class = "path1" > < / span >
< span class = "path2" > < / span >
< / i >
< / span >
2023-12-10 15:40:13 +00:00
< input data-i18n = "[placeholder]fs.create_folder_msg" id = "dirsbrowser_new_folder_input" type = "text" name = "new_folder_name" placeholder = "Enter the new folder name" class = "form-control mw-250px me-3" / >
2023-11-04 09:54:52 +00:00
< button class = "btn btn-icon btn-light-primary me-3" id = "dirsbrowser_add_folder" >
< span class = "indicator-label" >
< i class = "ki-duotone ki-check fs-1" > < / i >
< / span >
< span class = "indicator-progress" >
< span class = "spinner-border spinner-border-sm align-middle" > < / span >
< / span >
< / button >
2023-11-13 21:09:55 +00:00
< button class = "btn btn-icon btn-light-danger" id = "dirsbrowser_cancel_folder" >
2023-12-26 07:59:52 +00:00
< i class = "ki-solid ki-cross fs-1" > < / i >
2023-11-04 09:54:52 +00:00
< / button >
< / div >
2023-12-26 07:59:52 +00:00
< div class = "dir_browser_folder_divider py-2 d-none" >
< hr >
< / div >
2023-11-04 09:54:52 +00:00
< table id = "dirsbrowser_list" class = "table align-middle table-row-dashed fs-6 gy-5" >
< thead >
< tr class = "text-start text-muted fw-bold fs-7 text-uppercase gs-0" >
< th > < / th >
2023-12-10 15:40:13 +00:00
< th data-i18n = "general.name" class = "min-w-250px" > Name< / th >
2023-11-04 09:54:52 +00:00
< / tr >
< / thead >
< tbody id = "dirsbrowser_list_body" class = "text-gray-600 fw-semibold" >
< / tbody >
< / table >
< div class = "form-floating d-none" >
< input type = "text" class = "form-control form-control-solid" id = "move_copy_source" / >
2023-12-10 15:40:13 +00:00
< label data-i18n = "general.source_name" for = "move_copy_source" > Source name< / label >
2023-11-04 09:54:52 +00:00
< / div >
2021-05-06 19:35:43 +00:00
2023-11-04 09:54:52 +00:00
< div class = "form-floating mb-5 mt-7" >
< input type = "text" class = "form-control form-control-solid" id = "move_copy_folder" / >
2023-12-10 15:40:13 +00:00
< label data-i18n = "general.target_folder" for = "move_copy_folder" > Target folder< / label >
2023-11-04 09:54:52 +00:00
< / div >
2023-11-06 18:10:35 +00:00
< div class = "form-floating" id = "move_copy_name_container" >
2023-11-04 09:54:52 +00:00
< input type = "text" class = "form-control form-control-solid" id = "move_copy_name" / >
2023-12-10 15:40:13 +00:00
< label data-i18n = "general.dest_name" for = "move_copy_name" > Destination name< / label >
2023-11-04 09:54:52 +00:00
< / div >
< / div >
< div class = "modal-footer border-0" >
2024-02-20 17:19:09 +00:00
{{- if .CanCopy }}
< button id = "id_copy_button" type = "button" class = "btn {{if .CanRename}}btn-light-primary me-5{{else}}btn-primary{{end}}" data-bs-dismiss = "modal" >
2023-12-14 09:36:25 +00:00
< span data-i18n = "fs.copy.msg" > Copy< / span >
< / button >
2023-11-04 09:54:52 +00:00
{{- end}}
{{- if .CanRename }}
2023-12-14 09:36:25 +00:00
< button id = "id_move_button" type = "button" class = "btn btn-primary" data-bs-dismiss = "modal" >
< span data-i18n = "fs.move.msg" > Move< / span >
< / button >
2023-11-04 09:54:52 +00:00
{{- end}}
< / div >
< / div >
< / div >
< / div >
{{- end}}
{{- end}}