Small fixes
This commit is contained in:
parent
df361947cd
commit
ffa3fc9a25
@ -39,7 +39,7 @@ fn handle_request(mut req: Request, db: db::DBPool) {
|
||||
if !(path.contains('\\') || path.contains("..") || path.contains(':')) {
|
||||
let path_str = "./static".to_owned() + &path;
|
||||
let path = std::path::Path::new(&path_str);
|
||||
if path.exists() {
|
||||
if path.is_file() {
|
||||
let resp = Response::from_file(File::open(path).unwrap());
|
||||
match path.extension().map(|s| s.to_str()).unwrap_or(None) {
|
||||
Some("html") => resp.with_header(header("content-type", "text/html; charset=utf-8")),
|
||||
@ -175,10 +175,12 @@ fn handle_api_request(span: &mut Span, req: &mut Request, pool: db::DBPool) -> R
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("Loading config...");
|
||||
let _ = config::CONFIG;
|
||||
|
||||
let db_pool: db::DBPool = db::build_pool();
|
||||
|
||||
println!("Running migrations...");
|
||||
db::run_migrations(&mut db_pool.get().unwrap());
|
||||
|
||||
if !std::path::Path::new("files").exists() {
|
||||
@ -188,11 +190,13 @@ fn main() {
|
||||
if !std::path::Path::new("temp").is_dir() {
|
||||
std::fs::create_dir("temp").expect("Failed to create temp dir");
|
||||
}
|
||||
println!("Cleaning up temp...");
|
||||
std::fs::read_dir("temp").expect("Failed to iter temp dir").for_each(|dir| {
|
||||
std::fs::remove_file(dir.expect("Failed to retrieve temp dir entry").path())
|
||||
.expect("Failed to delete file in temp dir");
|
||||
});
|
||||
|
||||
println!("Loading metrics...");
|
||||
metrics::init(DBConnection::from(db_pool.get().unwrap()));
|
||||
|
||||
let shutdown = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false));
|
||||
@ -213,6 +217,7 @@ fn main() {
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
println!("Listening on 0.0.0.0:2345");
|
||||
'server: loop {
|
||||
match server.recv() {
|
||||
Ok(req) => {
|
||||
@ -226,5 +231,5 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
println!("Quitting");
|
||||
println!("Goodbye");
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ function createNewFolderDialog() {
|
||||
</n-gi>
|
||||
<n-gi span="2">
|
||||
<DirViewerTable
|
||||
:current-node="node"
|
||||
:nodes="nodes"
|
||||
:show-preview="showPreview"
|
||||
@reloadNode="emit('reloadNode')"
|
||||
|
@ -10,7 +10,7 @@ import type {
|
||||
import type { SummaryCell } from 'naive-ui/es/data-table/src/interface';
|
||||
import { inject, ref, nextTick, Suspense } from 'vue';
|
||||
import filesize from 'filesize';
|
||||
import { check_token, FS } from '@/api';
|
||||
import { check_token, FS, isErrorResponse } from '@/api';
|
||||
import { loadingMsgWrapper } from '@/utils';
|
||||
import {
|
||||
useMessage,
|
||||
@ -31,7 +31,8 @@ import {
|
||||
FolderParent,
|
||||
DocumentBlank,
|
||||
Delete,
|
||||
Download
|
||||
Download,
|
||||
Cut
|
||||
} from '@vicons/carbon';
|
||||
import semaphore from 'semaphore';
|
||||
import NLink from '@/components/NLink.vue';
|
||||
@ -56,6 +57,7 @@ type DropdownOptionsType = Array<
|
||||
>;
|
||||
|
||||
const props = defineProps<{
|
||||
currentNode: Responses.GetNode;
|
||||
nodes: Responses.GetNodeEntry[];
|
||||
showPreview: boolean;
|
||||
}>();
|
||||
@ -65,6 +67,7 @@ const checkedRows = ref<number[]>([]);
|
||||
const deleteNodes = ref<number[]>([]);
|
||||
const deleteDialog = ref();
|
||||
const deleteDialogShow = ref(false);
|
||||
const cutNodes = ref<number[]>([]);
|
||||
|
||||
const dropdownX = ref(0);
|
||||
const dropdownY = ref(0);
|
||||
@ -82,6 +85,15 @@ const dropdownOptionsFolder: DropdownOptionsType = [
|
||||
</NIcon>
|
||||
)
|
||||
},
|
||||
{
|
||||
label: () => <NText>Cut</NText>,
|
||||
key: 'cut',
|
||||
icon: () => (
|
||||
<NIcon>
|
||||
<Cut />
|
||||
</NIcon>
|
||||
)
|
||||
},
|
||||
{
|
||||
label: () => <NText type="error">Delete</NText>,
|
||||
key: 'delete',
|
||||
@ -102,6 +114,15 @@ const dropdownOptionsFile: DropdownOptionsType = [
|
||||
</NIcon>
|
||||
)
|
||||
},
|
||||
{
|
||||
label: () => <NText>Cut</NText>,
|
||||
key: 'cut',
|
||||
icon: () => (
|
||||
<NIcon>
|
||||
<Cut />
|
||||
</NIcon>
|
||||
)
|
||||
},
|
||||
{
|
||||
label: () => <NText type="error">Delete</NText>,
|
||||
key: 'delete',
|
||||
@ -124,6 +145,9 @@ const dropdownSelect = loadingMsgWrapper(message, async (key: string) => {
|
||||
await FS.download_file(token, dropdownCurrentNode.id);
|
||||
else createZipDialog([dropdownCurrentNode.id], dialog, jwt);
|
||||
break;
|
||||
case 'cut':
|
||||
cutNodes.value = [dropdownCurrentNode.id];
|
||||
break;
|
||||
case 'delete':
|
||||
dialog.warning({
|
||||
title: 'Really delete?',
|
||||
@ -269,19 +293,45 @@ const massDelete = loadingMsgWrapper(message, async () => {
|
||||
});
|
||||
});
|
||||
|
||||
function massCut() {
|
||||
cutNodes.value = checkedRows.value;
|
||||
checkedRows.value = [];
|
||||
}
|
||||
|
||||
const pasteNodes = loadingMsgWrapper(message, async () => {
|
||||
const token = await check_token(jwt);
|
||||
if (!token) return;
|
||||
const res = await FS.move(token, cutNodes.value, props.currentNode.id);
|
||||
cutNodes.value = [];
|
||||
if (isErrorResponse(res)) {
|
||||
message.error(`Failed to move nodes: ${res.message}`);
|
||||
return;
|
||||
}
|
||||
emit('reloadNode');
|
||||
});
|
||||
|
||||
const selectionCell = (): SummaryCell => {
|
||||
return {
|
||||
value:
|
||||
checkedRows.value.length != 0 ? (
|
||||
<NButtonGroup>
|
||||
<NButton onClick={massDownload}>Download</NButton>
|
||||
<NButton onClick={massDelete} type="error">
|
||||
Delete
|
||||
</NButton>
|
||||
</NButtonGroup>
|
||||
) : (
|
||||
''
|
||||
),
|
||||
value: (
|
||||
<NButtonGroup>
|
||||
{cutNodes.value.length != 0 ? (
|
||||
<NButton onClick={pasteNodes}>Paste</NButton>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{checkedRows.value.length != 0 ? (
|
||||
<>
|
||||
<NButton onClick={massDownload}>Download</NButton>
|
||||
<NButton onClick={massCut}>Cut</NButton>
|
||||
<NButton onClick={massDelete} type="error">
|
||||
Delete
|
||||
</NButton>
|
||||
</>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</NButtonGroup>
|
||||
),
|
||||
colSpan: props.showPreview ? 2 : 1
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user