Change date types to strings because the json parser does not detect dates types
This commit is contained in:
@@ -18,14 +18,14 @@ export type FSNode = {
|
|||||||
type: string,
|
type: string,
|
||||||
path: string,
|
path: string,
|
||||||
name: string,
|
name: string,
|
||||||
created: Date,
|
created: string,
|
||||||
modified: Date,
|
modified: string,
|
||||||
mode_string: string,
|
mode_string: string,
|
||||||
mode_octal: string,
|
mode_octal: string,
|
||||||
created_by: string,
|
created_by: string,
|
||||||
|
|
||||||
abuse_type: string | undefined,
|
abuse_type: string | undefined,
|
||||||
abuse_report_time: Date | undefined,
|
abuse_report_time: string | undefined,
|
||||||
|
|
||||||
file_size: number,
|
file_size: number,
|
||||||
file_type: string,
|
file_type: string,
|
||||||
@@ -54,8 +54,8 @@ export type FSContext = {
|
|||||||
|
|
||||||
export type NodeOptions = {
|
export type NodeOptions = {
|
||||||
mode: number | undefined,
|
mode: number | undefined,
|
||||||
created: Date | undefined,
|
created: string | undefined,
|
||||||
modified: Date | undefined,
|
modified: string | undefined,
|
||||||
shared: boolean | undefined,
|
shared: boolean | undefined,
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
@@ -127,7 +127,7 @@ export const fs_update = async (path: string, opts: NodeOptions) => {
|
|||||||
if (opts[key] === undefined) {
|
if (opts[key] === undefined) {
|
||||||
continue
|
continue
|
||||||
} else if ((key === "created" || key === "modified")) {
|
} else if ((key === "created" || key === "modified")) {
|
||||||
form.append(key, opts[key].toISOString())
|
form.append(key, new Date(opts[key]).toISOString())
|
||||||
} else if (typeof opts[key] === "object") {
|
} else if (typeof opts[key] === "object") {
|
||||||
form.append(key, JSON.stringify(opts[key]))
|
form.append(key, JSON.stringify(opts[key]))
|
||||||
} else {
|
} else {
|
||||||
@@ -222,7 +222,7 @@ export const fs_path_url = (path: string) => {
|
|||||||
if (window["api_endpoint"] !== undefined) {
|
if (window["api_endpoint"] !== undefined) {
|
||||||
return window["api_endpoint"] + "/filesystem" + fs_encode_path(path)
|
return window["api_endpoint"] + "/filesystem" + fs_encode_path(path)
|
||||||
} else {
|
} else {
|
||||||
throw Error("api_endpoint is undefined")
|
throw Error("fs_path_url: api_endpoint is undefined")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,10 +240,6 @@ export const fs_split_path = (path: string) => {
|
|||||||
return { base: patharr.pop(), parent: patharr.join("/") }
|
return { base: patharr.pop(), parent: patharr.join("/") }
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fs_thumbnail_url = (path: string, width = 64, height = 64) => {
|
|
||||||
return fs_path_url(path) + "?thumbnail&width=" + width + "&height=" + height
|
|
||||||
}
|
|
||||||
|
|
||||||
export const fs_node_type = (node: FSNode) => {
|
export const fs_node_type = (node: FSNode) => {
|
||||||
if (node.type === "dir") {
|
if (node.type === "dir") {
|
||||||
return "dir"
|
return "dir"
|
||||||
@@ -299,5 +295,9 @@ export const fs_node_icon = (node: FSNode, width = 64, height = 64) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fs_thumbnail_url(node.path, width, height)
|
return fs_thumbnail_url(node.path, width, height) + "&mod=" + new Date(node.modified).getTime()
|
||||||
|
}
|
||||||
|
|
||||||
|
export const fs_thumbnail_url = (path: string, width = 64, height = 64) => {
|
||||||
|
return fs_path_url(path) + "?thumbnail&width=" + width + "&height=" + height
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user