Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996462
long-running-process.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
long-running-process.ts
View Options
import
{
curryImportPath
}
from
"../utils/import-path"
;
export
async
function
LongRunningProcessTemplate
(
action_name
:
string
,
newfilefullpath
:
string
)
:
Promise
<
string
>
{
const
rel
=
curryImportPath
(
newfilefullpath
);
return
`import { Context } from "koa";
import { TempstreamJSX } from "tempstream";
import { Page } from "@sealcode/sealgen";
import html from "
${
rel
(
"src/back/html.js"
)
}
";
import { LongRunningProcess } from "sealious";
export const actionName = "
${
action_name
}
";
export default new (class PatroniteAutoImportStatusPage extends Page {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async canAccess(_: Context) {
return { canAccess: true, message: "" };
}
public interval = 2000;
async render(ctx: Context) {
const lpr_id = ctx.params.id;
const lpr_data = LongRunningProcess.getByID(ctx.$context, lpr_id);
const render_script = lpr_data.state !== "error" && lpr_data.state !== "finished";
const script = /* HTML */ \`<script>
setTimeout(() => {
document.location = document.location;
}, \${this.interval});
</script>\`;
return html(
ctx,
"PatroniteAutoImportStatus",
<div>
{lpr_data.then((lpr_data) => {
return (
<div>
<div>status: {lpr_data.state}</div>
<div style="height: 20px; width: 100%">
<div
style="height: 100%; background-color: green; width: {Math.round(
lpr_data.progress * 100
)}%"
></div>
</div>
<div>
{lpr_data.events.map((e) => (
<div>{e.message}</div>
))}
</div>
{render_script ? { script } : ""}
</div>
);
})}
</div>
);
}
})();
`
;
}
File Metadata
Details
Attached
Mime Type
text/html
Expires
Tue, Dec 24, 14:04 (12 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557271
Default Alt Text
long-running-process.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment