class CCPExecutionForm extends HTMLElement {
#boot;
#rootdoc;
#data;
#method;
#serviceurl;
#messages = {
"en": {
"confirm_form_overwrite": "Please confirm the overwrite of the previous execution form.",
"Inputs": "Inputs",
"Options": "Options",
"Outputs": "Outputs",
"Execute": "Execute",
"execute_help": "Submit an execution request",
"generate_code": "Generate code for",
"generate_code_help": "Generate example code for a selectable programming language or runtime",
"direct_link": "Direct link",
"direct_link_help": "Navigate to the link for directly reopening this method in the execution form",
"automatic_archive_option": "Select what you like to archive automatically when the execution is completed",
"automatic_archive_provenance": "Automatically archive whole execution provenance",
"automatic_archive_provenance_help": "Automatically archive the whole execution provenance to the workspace",
"automatic_archive_outputs": "Automatically archive uncompressed outputs only",
"automatic_archive_outputs_help": "Automatically archive only the outputs to the workspace",
"automatic_archive_none": "Do not archive anything automatically",
"automatic_archive_none_help": "Do not archive anything automatically",
"execution_accepted": "Execution request accepted with id: ",
"drop_method_invitation": "Drop a method here to request an execution",
"err_execution_not_accepted": "Error. Execution has not been accepted by server",
"err_code_generation": "Error while generating code",
"err_load_method": "Error while loading method",
"err_no_runtimes": "This method has no compatible runtimes available",
"err_execute": "Error while sending execution request",
"container_based_warning_confirm" : "The compatible architectures appear to be container based but no ccpimage input has been specified. This could cause errors that can be unpredictable on some infrastructures. Do you want to proceed anyway?"
}
}
constructor() {
super()
this.#boot = document.querySelector("d4s-boot-2")
this.#rootdoc = this.attachShadow({ "mode": "open" })
}
connectedCallback() {
this.#serviceurl = this.getAttribute("serviceurl")
this.connectNewExecutionRequest()
this.render()
const params = new URLSearchParams(window.location.search)
if (params.get('execution')) {
const execution = { id: params.get('execution') }
this.prepareFromExecution(execution)
} else if (params.get('method')) {
this.#method = params.get('method')
this.loadMethod()
} else {
this.showMethod()
}
}
static get observedAttributes() {
return ["method"];
}
getLabel(key, localehint) {
const locale = localehint ? localehint : navigator.language
const actlocale = this.#messages[locale] ? locale : "en"
const msg = this.#messages[actlocale][key]
return msg == null || msg == undefined ? key : this.#messages[actlocale][key]
}
attributeChangedCallback(name, oldValue, newValue) {
//if((oldValue != newValue) && (name === "method")){
if (name === "method") {
this.#method = newValue
this.loadMethod()
}
}
connectNewExecutionRequest() {
document.addEventListener("newexecutionrequest", ev => {
if (this.#data) {
if (window.confirm(this.getLabel("confirm_form_overwrite"))) {
this.setAttribute("method", ev.detail)
this.parentElement.scrollIntoViewIfNeeded()
}
} else {
this.setAttribute("method", ev.detail)
this.parentElement.scrollIntoViewIfNeeded()
}
})
}
render() {
this.#rootdoc.innerHTML = `