2021-07-05 10:09:44 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>SeaweedFS Filer</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<link rel="stylesheet" href="/seaweedfsstatic/bootstrap/3.3.1/css/bootstrap.min.css">
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
padding-bottom: 128px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#drop-area {
|
|
|
|
border: 1px transparent;
|
2022-04-07 09:53:22 +00:00
|
|
|
margin-top: 5px;
|
2021-07-05 10:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#drop-area.highlight {
|
|
|
|
border-color: purple;
|
|
|
|
border: 2px dashed #ccc;
|
|
|
|
}
|
|
|
|
|
|
|
|
.button {
|
|
|
|
display: inline-block;
|
|
|
|
padding: 2px;
|
|
|
|
background: #ccc;
|
|
|
|
cursor: pointer;
|
|
|
|
border-radius: 2px;
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
float: right;
|
2022-04-07 08:25:55 +00:00
|
|
|
margin-left: 2px;
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
label {
|
|
|
|
font-weight: normal;
|
2021-07-05 10:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.button:hover {
|
|
|
|
background: #ddd;
|
|
|
|
}
|
|
|
|
|
|
|
|
#fileElem {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2022-04-07 08:25:55 +00:00
|
|
|
td, th {
|
|
|
|
vertical-align: bottom;
|
|
|
|
}
|
|
|
|
|
2022-04-08 05:10:12 +00:00
|
|
|
.table-hover > tbody > tr:hover > * > div.operations {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.table > tbody > tr {
|
2022-04-08 07:07:56 +00:00
|
|
|
height: 39px;
|
2022-04-08 05:10:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
div.operations {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2022-04-07 06:23:06 +00:00
|
|
|
.footer {
|
|
|
|
position: absolute;
|
2022-04-07 09:53:22 +00:00
|
|
|
bottom: 0px;
|
|
|
|
right: 5%;
|
|
|
|
min-width: 25%;
|
|
|
|
border-left: 1px solid #ccc;
|
|
|
|
border-right: 1px solid #ccc;
|
2022-04-07 06:23:06 +00:00
|
|
|
}
|
2022-04-07 07:11:05 +00:00
|
|
|
|
|
|
|
.add-files {
|
|
|
|
font-size: 46px;
|
|
|
|
text-align: center;
|
|
|
|
border: 1px dashed #999;
|
|
|
|
padding-bottom: 9px;
|
|
|
|
margin: 0 2px;
|
|
|
|
}
|
2021-07-05 10:09:44 +00:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="container">
|
|
|
|
<div class="page-header">
|
|
|
|
<h1>
|
2022-07-29 07:17:28 +00:00
|
|
|
<a href="https://github.com/seaweedfs/seaweedfs"><img src="/seaweedfsstatic/seaweed50x50.png"></img></a>
|
2021-07-05 10:09:44 +00:00
|
|
|
SeaweedFS Filer
|
|
|
|
</h1>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div>
|
2022-04-07 09:53:22 +00:00
|
|
|
<div class="btn-group btn-group-sm pull-right" role="group" style="margin-top:3px;">
|
2022-04-08 07:07:56 +00:00
|
|
|
<label class="btn btn-default" onclick="handleCreateDir()">
|
|
|
|
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> New Folder
|
|
|
|
</label>
|
|
|
|
<label class="btn btn-default" for="fileElem">
|
|
|
|
<span class="glyphicon glyphicon-cloud-upload" aria-hidden="true"></span> Upload
|
|
|
|
</label>
|
2022-04-07 09:53:22 +00:00
|
|
|
</div>
|
|
|
|
<ol class="breadcrumb">
|
2021-07-05 10:09:44 +00:00
|
|
|
{{ range $entry := .Breadcrumbs }}
|
2022-04-07 09:53:22 +00:00
|
|
|
<li><a href="{{ printpath $entry.Link }}">
|
2021-07-05 10:09:44 +00:00
|
|
|
{{ $entry.Name }}
|
2022-04-07 09:53:22 +00:00
|
|
|
</li></a>
|
2021-07-05 10:09:44 +00:00
|
|
|
{{ end }}
|
2022-04-07 09:53:22 +00:00
|
|
|
</ol>
|
2021-07-05 10:09:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="row" id="drop-area">
|
|
|
|
<form class="upload-form">
|
|
|
|
<input type="file" id="fileElem" multiple onchange="handleFiles(this.files)">
|
|
|
|
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ if .EmptyFolder }}
|
2022-04-07 09:53:22 +00:00
|
|
|
<div class="row add-files">
|
|
|
|
+
|
|
|
|
</div>
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ else }}
|
2022-04-07 09:53:22 +00:00
|
|
|
<table width="100%" class="table table-hover">
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ $path := .Path }}
|
|
|
|
{{ $showDirDel := .ShowDirectoryDelete }}
|
2021-07-05 10:09:44 +00:00
|
|
|
{{ range $entry_index, $entry := .Entries }}
|
|
|
|
<tr>
|
|
|
|
<td>
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ if $entry.IsDirectory }}
|
2022-04-08 07:07:56 +00:00
|
|
|
<span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span>
|
2021-07-05 10:09:44 +00:00
|
|
|
<a href="{{ printpath $path "/" $entry.Name "/"}}" >
|
|
|
|
{{ $entry.Name }}
|
|
|
|
</a>
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ else }}
|
2021-07-05 10:09:44 +00:00
|
|
|
<a href="{{ printpath $path "/" $entry.Name }}" >
|
|
|
|
{{ $entry.Name }}
|
|
|
|
</a>
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ end }}
|
2021-07-05 10:09:44 +00:00
|
|
|
</td>
|
|
|
|
<td align="right" nowrap>
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ if not $entry.IsDirectory }}
|
2021-07-05 10:09:44 +00:00
|
|
|
{{ $entry.Mime }}
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ end }}
|
2021-07-05 10:09:44 +00:00
|
|
|
</td>
|
|
|
|
<td align="right" nowrap>
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ if not $entry.IsDirectory }}
|
2021-07-05 10:09:44 +00:00
|
|
|
{{ $entry.Size | humanizeBytes }}
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ end }}
|
2021-07-05 10:09:44 +00:00
|
|
|
</td>
|
2022-04-06 14:39:12 +00:00
|
|
|
<td align="right" nowrap>
|
2021-07-05 10:09:44 +00:00
|
|
|
{{ $entry.Timestamp.Format "2006-01-02 15:04" }}
|
|
|
|
</td>
|
2022-04-08 05:34:32 +00:00
|
|
|
<td style="width:75px">
|
2022-04-08 05:10:12 +00:00
|
|
|
<div class="btn-group btn-group-xs pull-right operations" role="group">
|
2022-04-08 07:07:56 +00:00
|
|
|
<label class="btn" onclick="handleRename('{{ $entry.Name }}', '{{ printpath $path "/" }}')">
|
|
|
|
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
|
|
|
|
</label>
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ if and $entry.IsDirectory $showDirDel }}
|
|
|
|
<label class="btn" onclick="handleDelete('{{ printpath $path "/" $entry.Name "/" }}')">
|
2022-04-08 07:07:56 +00:00
|
|
|
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
|
|
|
|
</label>
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ end }}
|
|
|
|
{{ if not $entry.IsDirectory }}
|
2022-04-08 07:07:56 +00:00
|
|
|
<label class="btn" onclick="handleDelete('{{ printpath $path "/" $entry.Name }}')">
|
|
|
|
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
|
|
|
|
</label>
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ end }}
|
2022-04-07 09:53:22 +00:00
|
|
|
</div>
|
2022-04-06 14:39:12 +00:00
|
|
|
</td>
|
2021-07-05 10:09:44 +00:00
|
|
|
</tr>
|
|
|
|
{{ end }}
|
|
|
|
</table>
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ end }}
|
2021-07-05 10:09:44 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ if .ShouldDisplayLoadMore }}
|
2021-07-05 10:09:44 +00:00
|
|
|
<div class="row">
|
2022-06-14 16:30:49 +00:00
|
|
|
<a href={{ print .Path "?limit=" .Limit "&lastFileName=" .LastFileName }} >
|
2021-07-05 10:09:44 +00:00
|
|
|
Load more
|
|
|
|
</a>
|
|
|
|
</div>
|
2022-06-14 16:30:49 +00:00
|
|
|
{{ end }}
|
2021-07-05 10:09:44 +00:00
|
|
|
|
|
|
|
<br/>
|
|
|
|
<br/>
|
2022-04-07 06:23:06 +00:00
|
|
|
<div id="progress-area" class="footer" style="display: none;">
|
|
|
|
</div>
|
2021-07-05 10:09:44 +00:00
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
<script type="text/javascript">
|
|
|
|
// ************************ Drag and drop ***************** //
|
2022-04-06 14:39:12 +00:00
|
|
|
let dropArea = document.getElementById("drop-area");
|
2022-04-07 06:23:06 +00:00
|
|
|
let progressArea = document.getElementById("progress-area");
|
2021-07-05 10:09:44 +00:00
|
|
|
|
|
|
|
// Prevent default drag behaviors
|
|
|
|
;['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
2022-04-06 14:39:12 +00:00
|
|
|
dropArea.addEventListener(eventName, preventDefaults, false);
|
|
|
|
document.body.addEventListener(eventName, preventDefaults, false);
|
|
|
|
});
|
2021-07-05 10:09:44 +00:00
|
|
|
|
|
|
|
// Highlight drop area when item is dragged over it
|
|
|
|
;['dragenter', 'dragover'].forEach(eventName => {
|
2022-04-06 14:39:12 +00:00
|
|
|
dropArea.addEventListener(eventName, highlight, false);
|
|
|
|
});
|
2021-07-05 10:09:44 +00:00
|
|
|
|
|
|
|
;['dragleave', 'drop'].forEach(eventName => {
|
2022-04-06 14:39:12 +00:00
|
|
|
dropArea.addEventListener(eventName, unhighlight, false);
|
|
|
|
});
|
2021-07-05 10:09:44 +00:00
|
|
|
|
|
|
|
// Handle dropped files
|
2022-04-06 14:39:12 +00:00
|
|
|
dropArea.addEventListener('drop', handleDrop, false);
|
2021-07-05 10:09:44 +00:00
|
|
|
|
|
|
|
function preventDefaults(e) {
|
2022-04-06 14:39:12 +00:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2021-07-05 10:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function highlight(e) {
|
2022-04-06 14:39:12 +00:00
|
|
|
dropArea.classList.add('highlight');
|
2021-07-05 10:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function unhighlight(e) {
|
2022-04-06 14:39:12 +00:00
|
|
|
dropArea.classList.remove('highlight');
|
2021-07-05 10:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function handleDrop(e) {
|
2022-04-06 14:39:12 +00:00
|
|
|
var dt = e.dataTransfer;
|
|
|
|
var files = dt.files;
|
2021-07-05 10:09:44 +00:00
|
|
|
|
2022-04-06 14:39:12 +00:00
|
|
|
handleFiles(files);
|
2021-07-05 10:09:44 +00:00
|
|
|
}
|
|
|
|
|
2022-06-10 14:39:21 +00:00
|
|
|
function reloadPage() {
|
|
|
|
window.location.reload(true);
|
|
|
|
}
|
|
|
|
|
2022-04-07 06:23:06 +00:00
|
|
|
var uploadList = {};
|
|
|
|
|
2021-07-05 10:09:44 +00:00
|
|
|
function handleFiles(files) {
|
2022-04-06 14:39:12 +00:00
|
|
|
files = [...files];
|
2022-04-07 06:23:06 +00:00
|
|
|
files.forEach(startUpload);
|
|
|
|
renderProgress();
|
2022-04-06 14:39:12 +00:00
|
|
|
files.forEach(uploadFile);
|
2022-04-07 06:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function startUpload(file, i) {
|
|
|
|
uploadList[file.name] = {'name': file.name, 'percent': 0, 'finish': false};
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderProgress() {
|
|
|
|
var values = Object.values(uploadList);
|
2022-04-07 09:53:22 +00:00
|
|
|
var html = '<table class="table">\n<tr><th>Uploading</th><\/tr>\n';
|
2022-04-07 06:23:06 +00:00
|
|
|
for (let i of values) {
|
2022-04-07 09:53:22 +00:00
|
|
|
var progressBarClass = 'progress-bar-striped active';
|
|
|
|
if (i.percent >= 100) {
|
|
|
|
progressBarClass = 'progress-bar-success';
|
|
|
|
}
|
|
|
|
html += '<tr>\n<td>\n';
|
|
|
|
html += '<div class="progress" style="margin-bottom: 2px;">\n';
|
|
|
|
html += '<div class="progress-bar ' + progressBarClass + '" role="progressbar" aria-valuenow="' + '100" aria-valuemin="0" aria-valuemax="100" style="width:' + i.percent + '%;">';
|
|
|
|
html += '<span style="margin-right: 10px;">' + i.name + '</span>' + i.percent + '%<\/div>';
|
|
|
|
html += '<\/div>\n<\/td>\n<\/tr>\n';
|
2022-04-07 06:23:06 +00:00
|
|
|
}
|
2022-04-07 07:11:05 +00:00
|
|
|
html += '<\/table>\n';
|
2022-04-07 06:23:06 +00:00
|
|
|
progressArea.innerHTML = html;
|
|
|
|
if (values.length > 0) {
|
|
|
|
progressArea.attributes.style.value = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function reportProgress(file, percent) {
|
|
|
|
var item = uploadList[file]
|
|
|
|
item.percent = percent;
|
|
|
|
renderProgress();
|
|
|
|
}
|
|
|
|
|
|
|
|
function finishUpload(file) {
|
|
|
|
uploadList[file]['finish'] = true;
|
|
|
|
renderProgress();
|
|
|
|
var allFinish = true;
|
|
|
|
for (let i of Object.values(uploadList)) {
|
|
|
|
if (!i.finish) {
|
|
|
|
allFinish = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (allFinish) {
|
|
|
|
console.log('All Finish');
|
2022-06-10 14:39:21 +00:00
|
|
|
reloadPage();
|
2022-04-07 06:23:06 +00:00
|
|
|
}
|
2021-07-05 10:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function uploadFile(file, i) {
|
2022-04-06 14:39:12 +00:00
|
|
|
var url = window.location.href;
|
|
|
|
var xhr = new XMLHttpRequest();
|
2022-08-28 14:51:47 +00:00
|
|
|
var fileName = file.name;
|
2022-08-11 05:43:09 +00:00
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
if (xhr.readyState == XMLHttpRequest.DONE) {
|
2022-08-28 14:51:47 +00:00
|
|
|
finishUpload(fileName)
|
2022-08-11 05:43:09 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-07 06:23:06 +00:00
|
|
|
xhr.upload.addEventListener('progress', function(e) {
|
|
|
|
if (e.lengthComputable) {
|
|
|
|
var percent = Math.ceil((e.loaded / e.total) * 100);
|
|
|
|
reportProgress(fileName, percent)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
xhr.upload.addEventListener('loadend', function(e) {
|
|
|
|
finishUpload(fileName);
|
|
|
|
});
|
2022-04-06 14:39:12 +00:00
|
|
|
var formData = new FormData();
|
2022-04-07 06:23:06 +00:00
|
|
|
xhr.open('POST', url, true);
|
2022-04-06 14:39:12 +00:00
|
|
|
formData.append('file', file);
|
|
|
|
xhr.send(formData);
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleCreateDir() {
|
2022-04-07 09:53:22 +00:00
|
|
|
var dirName = prompt('Folder Name:', '');
|
2022-04-06 14:39:12 +00:00
|
|
|
dirName = dirName.trim();
|
2022-04-07 07:11:05 +00:00
|
|
|
if (dirName == null || dirName == '') {
|
2022-04-06 14:39:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var baseUrl = window.location.href;
|
|
|
|
if (!baseUrl.endsWith('/')) {
|
|
|
|
baseUrl += '/';
|
|
|
|
}
|
|
|
|
var url = baseUrl + dirName;
|
|
|
|
if (!url.endsWith('/')) {
|
|
|
|
url += '/';
|
|
|
|
}
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.open('POST', url, false);
|
|
|
|
xhr.setRequestHeader('Content-Type', '');
|
|
|
|
xhr.send();
|
2022-06-10 14:39:21 +00:00
|
|
|
reloadPage();
|
2022-04-06 14:39:12 +00:00
|
|
|
}
|
|
|
|
|
2022-04-07 07:11:05 +00:00
|
|
|
function handleRename(originName, basePath) {
|
|
|
|
var newName = prompt('New Name:', originName);
|
|
|
|
if (newName == null || newName == '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var url = basePath + newName;
|
|
|
|
var originPath = basePath + originName;
|
|
|
|
url += '?mv.from=' + originPath;
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.open('POST', url, false);
|
|
|
|
xhr.setRequestHeader('Content-Type', '');
|
|
|
|
xhr.send();
|
2022-06-10 14:39:21 +00:00
|
|
|
reloadPage();
|
2022-04-07 07:11:05 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 14:39:12 +00:00
|
|
|
function handleDelete(path) {
|
|
|
|
if (!confirm('Are you sure to delete ' + path + '?')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var url = path;
|
|
|
|
if (url.endsWith('/')) {
|
|
|
|
url += '?recursive=true';
|
|
|
|
}
|
2021-07-05 10:09:44 +00:00
|
|
|
|
2022-04-06 14:39:12 +00:00
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.open('DELETE', url, false);
|
|
|
|
xhr.send();
|
2022-06-10 14:39:21 +00:00
|
|
|
reloadPage();
|
2021-07-05 10:09:44 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</html>
|