Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F6241272
file.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
file.ts
View Options
import
{
Context
}
from
"koa"
;
import
{
FilePointer
}
from
"@sealcode/file-manager"
;
import
{
FlatTemplatable
,
tempstream
}
from
"tempstream"
;
import
{
FileContainer
}
from
"../fields/file.js"
;
import
{
FormDataValue
}
from
"../form-types.js"
;
import
{
FormControlContext
}
from
"./form-control.js"
;
import
{
SimpleInput
}
from
"./simple-input.js"
;
import
{
htmlEscape
}
from
"escape-goat"
;
export
class
File
extends
SimpleInput
<
FileContainer
>
{
getType
()
{
return
"file"
;
}
async
renderFilePreview
(
_ctx
:
Context
,
file
:
FilePointer
|
null
)
:
Promise
<
FlatTemplatable
>
{
const
class_name
=
"file_preview"
;
const
empty_container
=
`<div class="
${
class_name
}
"></div>`
;
if
(
!
file
)
{
return
empty_container
;
}
return
tempstream
/* HTML */
`<div class="
${
class_name
}
">
${
file
.
getOriginalFilename
()
}
</div>`
;
}
async
preInput
(
fctx
:
FormControlContext
,
data
:
Record
<
string
,
FormDataValue
>
)
{
const
{
parsed
}
=
await
this
.
field
.
getValue
(
fctx
.
ctx
,
data
);
return
tempstream
/* HTML */
`
${
this
.
renderFilePreview
(
fctx
.
ctx
,
parsed
.
old
)
}
<input
type="hidden"
name="
${
this
.
field
.
name
}
[old]"
value="
${
htmlEscape
(
parsed
.
old
?
.
token
||
(
await
parsed
.
old
?
.
save
(
false
))
||
""
)
}
"
form="
${
fctx
.
form_id
}
"
/> `
;
}
async
getInputAttributes
(
fctx
:
FormControlContext
)
:
Promise
<
Record
<
string
,
string
|
boolean
>>
{
const
original
=
await
super
.
getInputAttributes
(
fctx
);
const
{
parsed
}
=
await
this
.
field
.
getValue
(
fctx
.
ctx
,
fctx
.
data
);
return
{
...
original
,
name
:
this
.
field
.
name
+
"[new]"
,
required
:
original
.
required
&&
!
parsed
.
new
,
value
:
false
,
};
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, Jun 17, 03:28 (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
635970
Default Alt Text
file.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment