revised all tooltips and added support for i18n

This commit is contained in:
dcore94 2024-06-07 17:39:35 +02:00
parent 593429ca51
commit 43154c2e2b
7 changed files with 356 additions and 198 deletions

View File

@ -7,6 +7,8 @@
<script src="js/inputwidgeteditorcontroller.js"></script>
<script src="js/outputwidgeteditorcontroller.js"></script>
<script src="js/executionformcontroller.js"></script>
<script src="js/executionhistorycontroller.js"></script>
<script src="js/logterminalcontroller.js"></script>
<script src="js/inputwidgetcontroller.js"></script>
<script src="js/outputwidgetcontroller.js"></script>
<link href="css/common.css" rel="stylesheet">
@ -20,7 +22,7 @@
<d4s-boot-2 clientid="https://next.dev.d4science.org" context="%2Fgcube%2Fdevsec%2FCCP" gateway="next.dev.d4science.org" redirect-url="http://localhost:8080/ccp/index.html" url="https://accounts.dev.d4science.org/auth"> <script src="https://cdn.dev.d4science.org/boot/d4s-boot.js"></script> </d4s-boot-2>
<div class="row">
<div class="col">
<d4s-ccp-methodlist serviceurl="https://ccp.cloud-dev.d4science.org" allow-edit="true"></d4s-ccp-methodlist>
<d4s-ccp-methodlist serviceurl="https://ccp.cloud-dev.d4science.org" allow-edit="true" allow-execute="true" archive="true"></d4s-ccp-methodlist>
</div>
<div class="col">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
@ -29,6 +31,9 @@
<div class="col">
<d4s-ccp-executionform serviceurl="https://ccp.cloud-dev.d4science.org"></d4s-ccp-executionform>
</div>
<div class="col">
<d4s-ccp-executionhistory archive="true" serviceurl="https://ccp.cloud-dev.d4science.org"></d4s-ccp-executionhistory>
</div>
</div>
</body>

View File

@ -4,10 +4,36 @@ class CCPExecutionForm extends HTMLElement{
#rootdoc;
#data;
#method;
#executionmonitor;
#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",
}
}
constructor(){
super()
this.#boot = document.querySelector("d4s-boot-2")
@ -35,6 +61,13 @@ class CCPExecutionForm extends HTMLElement{
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"){
@ -45,9 +78,14 @@ class CCPExecutionForm extends HTMLElement{
connectNewExecutionRequest(){
document.addEventListener("newexecutionrequest", ev=>{
if(window.confirm("Please confirm overwrite of execution form?")){
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()
this.parentElement.scrollIntoViewIfNeeded()
}
})
}
@ -72,7 +110,7 @@ class CCPExecutionForm extends HTMLElement{
<form name="execution_form" class="d-flex flex-column gap-3" style="gap:5px">
<div class="card">
<div class="card-header">
<h5>Inputs</h5>
<h5>${this.getLabel("Inputs")}</h5>
</div>
<div class="card-body ccp-inputs">
<div>
@ -82,30 +120,22 @@ class CCPExecutionForm extends HTMLElement{
</div>
<div class="card">
<div class="card-header">
<h5>Options</h5>
<h5>${this.getLabel("Options")}</h5>
</div>
<div class="card-body">
<div class="p-1">
<label class="small text-muted p-0">Select what you like to archive automatically when the execution is completed.</label>
<label class="small text-muted p-0">${this.getLabel("automatic_archive_option")}.</label>
<select name="archive-selector" class="form-select p-2" style="padding:2px">
<option value="execution" title="Automatically archive the whole execution provenance to the workspace">Automatically archive whole execution provenance</option>
<option value="outputs" title="Automatically archive only the outputs to the workspace">Automatically archive uncompressed outputs only</option>
<option value="none" title="Do not archive anything">Do not archive anything automatically</option>
<option value="execution" title="${this.getLabel("automatic_archive_provenance_help")}">${this.getLabel("automatic_archive_provenance")}</option>
<option value="outputs" title="${this.getLabel("automatic_archive_outputs_help")}">${this.getLabel("automatic_archive_outputs")}</option>
<option value="none" title="${this.getLabel("automatic_archive_none_help")}">${this.getLabel("automatic_archive_none")}</option>
</select>
</div>
<!--div class="col form-check">
<input class="form-check-input" type="checkbox" name="auto-archive" alt="Automatically archive the whole execution with metadata to workspace folder" title="Automatically archive the whole execution with metadata to workspace folder">
<label class="form-check-label">Automatically archive the entire execution provenance to workspace</label>
</div>
<div class="col form-check">
<input class="form-check-input" type="checkbox" name="auto-archive-outputs" alt="Automatically archive only the outputs to workspace" title="Automatically archive only the outputs to workspace" checked="checked">
<label class="form-check-label">Automatically archive outputs to workspace</label>
</div-->
</div>
</div>
<div class="card">
<div class="card-header">
<h5>Outputs</h5>
<h5>${this.getLabel("Outputs")}</h5>
</div>
<div class="card-body">
<div class="row ccp-outputs">
@ -115,11 +145,11 @@ class CCPExecutionForm extends HTMLElement{
</div>
<div class="row">
<div class="col-6">
<button id="execute_method_button" class="btn btn-info">Execute</button>
<button title="${this.getLabel("execute_help")}" id="execute_method_button" class="btn btn-info">${this.getLabel("Execute")}</button>
</div>
<div class="col-6">
<div class="mb-3">
<label>Generate code for:</label>
<label>${this.getLabel("generate_code")}</label>
<div class="d-flex">
<select name="language-selector" class="form-control" style="padding:2px">
<option value="text/python" data-ext="py" title="Generate plain Python3">Python 3</option>
@ -131,7 +161,7 @@ class CCPExecutionForm extends HTMLElement{
<option value="application/json+galaxy" data-ext="json" title="Generate JSON request for Galaxy">Galaxy CCP request (preview)</option>
<option value="application/xml+galaxy" data-ext="xml" title="Generate installable Galaxy tool">Galaxy tool (preview)</option>
</select>
<button name="codegen" title="Generate code" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<button name="codegen" title="${this.getLabel("generate_code_help")}" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<svg viewBox="0 96 960 960">
<path d="M320 814 80 574l242-242 43 43-199 199 197 197-43 43Zm318 2-43-43 199-199-197-197 43-43 240 240-242 242Z"></path>
</svg>
@ -140,7 +170,7 @@ class CCPExecutionForm extends HTMLElement{
</div>
<div>
<div class="d-flex">
<a name="direct_link_method" class="text-truncate" href="${window.location.href}">Direct link</a>
<a title="${this.getLabel("direct_link_help")}" name="direct_link_method" class="text-truncate" href="${window.location.href}">${this.getLabel("direct_link")}</a>
</div>
</div>
</div>
@ -150,7 +180,7 @@ class CCPExecutionForm extends HTMLElement{
</template>
<template id="EXECUTION_FORM_EMPTY_TEMPLATE">
<div name="execution_form">
<i style="padding:3rem">Drop a method here!</i>
<i style="padding:3rem">${this.getLabel("drop_method_invitation")}!</i>
</div>
</template>
<div name="execution_form"></div>
@ -184,7 +214,7 @@ class CCPExecutionForm extends HTMLElement{
(resp)=>{
if(resp.status === 200){
return resp.json()
}else throw "Error retrieving process"
}else throw this.getLabel("err_load_method")
}
).then(data=>{
this.#data = data
@ -218,18 +248,18 @@ class CCPExecutionForm extends HTMLElement{
url, { method : "POST", body : JSON.stringify(req), headers : { "Content-Type" : "application/json"}}
).then(reply=>{
if(reply.status !== 200 && reply.status !== 201){
throw "Error while requesting resource"
throw this.getLabel("err_execute")
}
return reply.json()
}).then(data=>{
if(data.status !== "accepted"){
throw "Execution has not been accepted by server"
throw this.getLabel("err_execution_not_accepted")
}
const event = new CustomEvent('newexecution', { detail: data.jobID });
document.dispatchEvent(event)
this.writeToPlexi("Execution request accepted with id: " + data.jobID)
this.writeToPlexi(this.getLabel("execution_accepted") + " " + data.jobID)
window.setTimeout(()=>this.unlockRender(), 3000)
}).catch(err => {alert("Unable to call execute: " + err); this.unlockRender()})
}).catch(err => {alert(this.getLabel("err_execute") + ": " + err); this.unlockRender()})
}
generateCode(mime, filename){
@ -238,7 +268,7 @@ class CCPExecutionForm extends HTMLElement{
this.#boot.secureFetch(
url, { method : "POST", body : JSON.stringify(req), headers : { "Content-Type" : "application/json", "Accept" : mime}}
).then(reply=>{
if(reply.status !== 200) throw "Error while requesting code:";
if(reply.status !== 200) throw this.getLabel("err_code_generation");
return reply.blob()
}).then(blob => {
const objectURL = URL.createObjectURL(blob)
@ -266,13 +296,6 @@ class CCPExecutionForm extends HTMLElement{
if(o.enabled) request.outputs[o.name] = { transmissionMode : "value" };
})
/*const autoarchiveoption = this.#rootdoc.querySelector("input[name='auto-archive']")
const autoarchiveoutputsoption = this.#rootdoc.querySelector("input[name='auto-archive-outputs']")
if (autoarchiveoption.checked || autoarchiveoutputsoption.checked){
request.subscribers = []
if(autoarchiveoption.checked) request.subscribers.push({ successUri : "http://registry:8080/executions/archive-to-folder" })
if(autoarchiveoutputsoption.checked) request.subscribers.push({ successUri : "http://registry:8080/executions/outputs/archive-to-folder" })
}*/
const archiveoption = this.#rootdoc.querySelector("select[name='archive-selector']").value
switch(archiveoption){
case 'execution':
@ -304,10 +327,6 @@ class CCPExecutionForm extends HTMLElement{
})
}
//initOptionValues(request){
// const autoarchiveoption = this.#rootdoc.querySelector("select[name='auto-archive-outputs']")
// autoarchiveoption.checked = request.subscribers && request.subscribers.filter(s=>s.successUri === "http://registry:8080/executions/archive-to-folder").length === 1
//}
initOptionValues(request){
const archiveselector = this.#rootdoc.querySelector("select[name='archive-selector']")
if(request.subscribers){
@ -329,7 +348,7 @@ class CCPExecutionForm extends HTMLElement{
.then(resp=>{
if(resp.status === 200){
return resp.json()
}else throw "Error retrieving process"
}else throw this.getLabel("err_load_method")
}
).then(data=>data)
@ -338,7 +357,7 @@ class CCPExecutionForm extends HTMLElement{
.then(resp=>{
if(resp.status === 200){
return resp.json()
}else throw "Error retrieving process"
}else throw this.getLabel("err_load_method")
}
).then(data=>data)
@ -455,7 +474,7 @@ class CCPExecutionForm extends HTMLElement{
ev.preventDefault()
ev.stopPropagation()
if(this.#data.executable) this.sendExecutionRequest();
else alert("This method has no compatible runtimes available")
else alert(this.getLabel("err_no_runtimes"))
return false;
}
},

View File

@ -13,11 +13,39 @@ class CCPExecutionHistory extends HTMLElement {
#searchfield = null;
#fileupload = null;
#archiveupload = null;
#messages = {
"en" : {
"search" : "Search",
"failed_count_help" : "Count of failed executions",
"successful_count_help" : "Count of successful executions",
"running_count_help" : "Count of running executions",
"accepted_count_help" : "Count of accepted executions",
"download_help" : "Click to download outputs to your local disk",
"archive_execution_help" : "Archive whole execution to workspace folder",
"archive_outputs_help" : "Archive only outputs to workspace folder",
"re-submit_help" : "Re submit this exact execution",
"delete_help" : "Delete this execution",
"generate_code" : "Generate code for",
"generate_code_help" : "Generate code that replicates this exact execution on a chosen programming language or runtime",
"direct_link" : "Direct link",
"direct_link_help" : "Navigate to the direct link for opening this exact execution in the exeuction form"
}
}
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]
}
constructor(){
super()
this.#boot = document.querySelector("d4s-boot-2")
this.#rootdoc = this.attachShadow({ "mode" : "open"})
}
connectedCallback(){
this.#serviceurl = this.getAttribute("serviceurl")
this.#broadcasturl = this.getAttribute("broadcasturl")
if(!this.#broadcasturl){
@ -26,9 +54,6 @@ class CCPExecutionHistory extends HTMLElement {
this.#broadcasturl = this.#broadcasturl + "/ws/notification"
this.#archive = this.getAttribute("archive")
this.connectNewExecution()
}
connectedCallback(){
this.connectBroadcastWithSubject()
this.render()
this.refreshExecutions()
@ -64,10 +89,10 @@ class CCPExecutionHistory extends HTMLElement {
<summary class="ccp-method-item-header noselect d-flex flex-wrap justify-content-between">
<h5 class="text-primary d-inline"></h5>
<div>
<span name="failed" title="Failed executions" class="badge badge-danger float-right">Z</span>
<span name="successful" title="Successful executions"class="badge badge-success float-right mr-1">Y</span>
<span name="running" title="Running executions"class="badge badge-primary float-right mr-1">Y</span>
<span name="accepted" title="Accepted executions" class="badge badge-secondary float-right mr-1">X</span>
<span name="failed" title="${this.getLabel("failed_count_help")}" class="badge badge-danger float-right">Z</span>
<span name="successful" title="${this.getLabel("successful_count_help")}"class="badge badge-success float-right mr-1">Y</span>
<span name="running" title="${this.getLabel("running_count_help")}"class="badge badge-primary float-right mr-1">Y</span>
<span name="accepted" title="${this.getLabel("accepted_count_help")}" class="badge badge-secondary float-right mr-1">X</span>
</div>
</summary>
<ul class="ccp-execution-list list-group" style="list-style:none">
@ -78,7 +103,7 @@ class CCPExecutionHistory extends HTMLElement {
<span name="status" class="ml-1 badge"></span>
<div class="d-flex float-right" style="gap: 3px 5px; max-width: 40%; min-width:60px; flex-wrap:wrap;">
${ this.#archive ? `
<button data-index="0" name="archive" title="Archive whole execution to workspace folder" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<button data-index="0" name="archive" title="${this.getLabel("archive_execution_help_help")}" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<svg viewBox="0 96 960 960"><path d="M140 796h680V516H140v280Zm540.118-90Q701 706 715.5 691.382q14.5-14.617 14.5-35.5Q730 635 715.382 620.5q-14.617-14.5-35.5-14.5Q659 606 644.5 620.618q-14.5 14.617-14.5 35.5Q630 677 644.618 691.5q14.617 14.5 35.5 14.5ZM880 456h-85L695 356H265L165 456H80l142-142q8-8 19.278-13 11.278-5 23.722-5h430q12.444 0 23.722 5T738 314l142 142ZM140 856q-24.75 0-42.375-17.625T80 796V456h800v340q0 24.75-17.625 42.375T820 856H140Z"/></svg>
</button>`
: ``
@ -89,13 +114,13 @@ class CCPExecutionHistory extends HTMLElement {
<!-- button data-index="0" name="zip" title="Download as zip archive" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<svg viewBox="0 0 48 48"><path d="M7 40q-1.15 0-2.075-.925Q4 38.15 4 37V11q0-1.15.925-2.075Q5.85 8 7 8h14l3 3h17q1.15 0 2.075.925Q44 12.85 44 14v23q0 1.15-.925 2.075Q42.15 40 41 40Zm25-3h9V14h-9v4.6h4.6v4.6H32v4.6h4.6v4.6H32ZM7 37h20.4v-4.6H32v-4.6h-4.6v-4.6H32v-4.6h-4.6V14h-4.65l-3-3H7v26Zm0-23v-3 26-23Z"/></svg>
</button-->
<button data-index="0" name="archiveoutputs" title="Archive only outputs to workspace folder" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<button data-index="0" name="archiveoutputs" title="${this.getLabel("archive_outputs_help_help")}" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<svg viewBox="0 0 48 48"><path d="M7 40q-1.15 0-2.075-.925Q4 38.15 4 37V11q0-1.15.925-2.075Q5.85 8 7 8h14l3 3h17q1.15 0 2.075.925Q44 12.85 44 14v23q0 1.15-.925 2.075Q42.15 40 41 40Zm25-3h9V14h-9v4.6h4.6v4.6H32v4.6h4.6v4.6H32ZM7 37h20.4v-4.6H32v-4.6h-4.6v-4.6H32v-4.6h-4.6V14h-4.65l-3-3H7v26Zm0-23v-3 26-23Z"/></svg>
</button>
<button data-index="0" name="reexecute1" title="Re-submit this execution" class="btn btn-info ccp-toolbar-button ccp-toolbar-button-small">
<button data-index="0" name="reexecute1" title="${this.getLabel("re-submit_help")}" class="btn btn-info ccp-toolbar-button ccp-toolbar-button-small">
Re-submit
</button>
<button data-index="0" name="delete" title="Delete" class="btn btn-danger ccp-toolbar-button ccp-toolbar-button-small">
<button data-index="0" name="delete" title="${this.getLabel("delete_help")}" class="btn btn-danger ccp-toolbar-button ccp-toolbar-button-small">
<svg viewBox="0 0 24 24">
<path d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z"></path>
</svg>
@ -120,8 +145,8 @@ class CCPExecutionHistory extends HTMLElement {
<li></li>
</ul>
<div class="d-flex flex-column align-items-end" style="gap: 3px;">
<div class="d-flex align-items-center" style="gap:5px">
<label style="text-wrap:nowrap">Generate code for:</label>
<div class="d-flex align-items-center" style="gap:5px" title="${this.getLabel("generate_code_help")}">
<label style="text-wrap:nowrap">${this.getLabel("generate_code")}</label>
<select name="language-selector" class="form-control">
<option value="text/python" data-ext="py" title="Generate plain Python3">Python 3</option>
<option value="text/plain+r" data-ext="r" title="Generate plain R">R</option>
@ -138,7 +163,7 @@ class CCPExecutionHistory extends HTMLElement {
</div>
<div class="d-flex align-items-middle" style="gap:5px">
<div class="d-flex">
<a class="text-truncate" name="direct_link_execution" href="${window.location.href}">Direct link</a>
<a title="${this.getLabel("direct_link_help")}" class="text-truncate" name="direct_link_execution" href="${window.location.href}">${this.getLabel("direct_link")}</a>
</div>
</div>
</div>

View File

@ -3,6 +3,37 @@ class CCPInputWidgetEditorController extends HTMLElement{
#input = null
#index = null
#type = null
#messages = {
"en" : {
"input_id_help" : "The Id of the input. This has to be unique accross all the inputs the method. This is used as variable expansion in scripts.",
"input_delete_help" : "Delete this input",
"title" : "Title",
"title_help" : "Title of the input. This is how the input will appear in forms.",
"description" : "Description",
"description_help" : "A description for this input",
"min_occurs" : "Min. count",
"max_occurs" : "Max. count",
"min_occurs_help" : "Minimum cardinality of this input",
"max_occurs_help" : "Maximum cardinality of this input",
"type" : "Type",
"type_help" : "Set the type of the input. Either String or Enumeration",
"mime" : "Mime",
"mime_help" : "Set MIME type of expected input",
"format" : "Format",
"format_help" : "Set specific format to tune the widget that will be used in forms",
"readonly" : "Read only",
"readonly_help" : "If enabled this input will not be editable in forms",
"string" : "String",
"enum" : "Enumerated",
"options" : "Options",
"options_help" : "A comma separated list of options for this enumerated input",
"options_ext_help" : "Comma separated list of options",
"choice" : "Single choice",
"multichoice" : "Multiple choices",
"default" : "Default value",
"default_help" : "The default value applied for this input when nothing is set explicitly"
}
}
#delete_icon = `
<svg style="width:24px;height:24px;pointer-events: none;" viewBox="0 0 24 24">
@ -19,42 +50,27 @@ class CCPInputWidgetEditorController extends HTMLElement{
}
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]
}
get index(){
return this.#index
}
/*computeDefaultInputType(){
if(this.#input.schema.format === "secret"){
return "password"
}else if(this.#input.schema.format === "date"){
return "date"
}else if(this.#input.schema.format === "time"){
return "time"
}else if(this.#input.schema.format === "dateTime"){
return "datetime-local"
}
return "text"
}*/
isSelectedFormat(fmt){
return this.#input.schema.format === fmt
}
renderDefaultByType(){
return `<d4s-ccp-input name="default" input="${btoa(JSON.stringify(this.#input))}"></d4s-ccp-input>`
/*if(this.#input.schema.format === "code"){
return `
<textarea rows="5" name="default" class="form-control" placeholder="default">${this.#input.schema.default}</textarea>
`
} else {
return `
<input type="${this.computeDefaultInputType()}" value="${this.#input.schema.default}" name="default" class="form-control" placeholder="default"/>
`
}*/
}
renderDeleteButton(){
return `<button data-index="${this.#index}" name="delete-input" title="Delete" class="btn btn-danger ccp-toolbar-button">
return `<button data-index="${this.#index}" name="delete-input" title="${this.getLabel("input_delete_help")}" class="btn btn-danger ccp-toolbar-button">
${this.#delete_icon}
</button>`
}
@ -68,46 +84,46 @@ class CCPInputWidgetEditorController extends HTMLElement{
this.innerHTML = `
<details ${ reopen ? 'open' : ''}>
<summary class="mb-3">
<input class="form-control" style="width:auto;display:inline" required="required" name="id" value="${input.id}" title="Id of input" ${ input.id === 'ccpimage' ? 'readonly' : ''}/>
<input class="form-control" style="width:auto;display:inline" required="required" name="id" value="${input.id}" title="${this.getLabel("input_id_help")}" ${ input.id === 'ccpimage' ? 'readonly' : ''}/>
${ input.id !== 'ccpimage' ? this.renderDeleteButton() : ''}
</summary>
<div style="padding-left: 1rem;border-left: 1px solid gray;">
<div class="row mb-3">
<div class="col">
<div class="form-field" title="Title">
<input name="title" class="form-control" placeholder="title" value="${input.title}" required="required" ${ input.id === 'ccpimage' ? 'readonly' : ''}/>
<div class="form-field" title="${this.getLabel("title_help")}">
<input name="title" class="form-control" placeholder="${this.getLabel("title")}" value="${input.title}" required="required" ${ input.id === 'ccpimage' ? 'readonly' : ''}/>
</div>
</div>
</div>
<div class="mb-3">
<div class="form-field" title="description">
<textarea rows="1" name="description" class="form-control" placeholder="description" required="required" ${ input.id === 'ccpimage' ? 'readonly' : ''}>${input.description}</textarea>
<div class="form-field" title="${this.getLabel("description_help")}">
<textarea rows="1" name="description" class="form-control" placeholder="${this.getLabel("description")}" required="required" ${ input.id === 'ccpimage' ? 'readonly' : ''}>${input.description}</textarea>
</div>
</div>
<div class="row mb-3">
<div class="col-3">
<div class="form-field" title="Type">
<label>Type</label>
<select name="type" class="form-control" placeholder="type" value="${this.#type}">
<option value="string" ${this.#type === "string" ? "selected" : ""}>String</option>
${ input.id === 'ccpimage' ? '' : `<option value="enum" ${this.#type === "enum" ? "selected" : ""}>Enum</option>` }
<div class="form-field" title="${this.getLabel("type_help")}">
<label>${this.getLabel("type")}</label>
<select name="type" class="form-control" placeholder="${this.getLabel("type")}" value="${this.#type}">
<option value="string" ${this.#type === "string" ? "selected" : ""}>${this.getLabel("string")}</option>
${ input.id === 'ccpimage' ? '' : `<option value="enum" ${this.#type === "enum" ? "selected" : ""}>${this.getLabel("enum")}</option>` }
</select>
</div>
</div>
<div class="col">
<div class="form-field" title="Minimum occurrences">
<label>Min occurs</label>
<input value="${minOccurs}" type="number" min="0" step="1" name="minOccurs" value="${minOccurs}" required="required" class="form-control" placeholder="minOccurs" ${ input.id === 'ccpimage' ? 'readonly' : ''}/>
<div class="form-field" title="${this.getLabel("min_occurs_help")}">
<label>${this.getLabel("min_occurs")}</label>
<input value="${minOccurs}" type="number" min="0" step="1" name="minOccurs" value="${minOccurs}" required="required" class="form-control" placeholder="${this.getLabel("min_occurs")}" ${ input.id === 'ccpimage' ? 'readonly' : ''}/>
</div>
</div>
<div class="col">
<div class="form-field" title="Maximum occurrences">
<label>Max occurs</label>
<input value="${maxOccurs}" type="number" min="0" step="1" name="maxOccurs" value="${maxOccurs}" required="required" class="form-control" placeholder="maxOccurs" ${ input.id === 'ccpimage' ? 'readonly' : ''}/>
<div class="form-field" title="${this.getLabel("max_occurs_help")}">
<label>${this.getLabel("max_occurs")}</label>
<input value="${maxOccurs}" type="number" min="0" step="1" name="maxOccurs" value="${maxOccurs}" required="required" class="form-control" placeholder="${this.getLabel("max_occurs")}" ${ input.id === 'ccpimage' ? 'readonly' : ''}/>
</div>
</div>
<div class="col" title="Read only">
<label>Read only</label>
<div class="col" title="${this.getLabel("readonly_help")}">
<label>${this.getLabel("readonly")}</label>
<div class="form-field">
<input type="checkbox" ${input.schema.readOnly ? 'checked' : ''} name="readonly" class="form-check-input">
</div>
@ -115,8 +131,8 @@ class CCPInputWidgetEditorController extends HTMLElement{
</div>
<div name="string-input" class="${this.#type === 'enum' ? 'd-none' : ''} row mb-3">
<div class="col-3">
<div class="form-field" title="Format">
<label>Format</label>
<div class="form-field" title="${this.getLabel("format_help")}">
<label>${this.getLabel("format")}</label>
<select value="${input.schema.format}" name="format" class="form-control" ${ input.id === 'ccpimage' ? 'readonly' : ''}>
<option value="none" ${this.isSelectedFormat('none') ? "selected" : ""}>None</option>
<option value="date" ${this.isSelectedFormat('date') ? "selected" : ""}>Date</option>
@ -133,29 +149,29 @@ class CCPInputWidgetEditorController extends HTMLElement{
</select>
</div>
</div>
<div class="col" title="Mime type">
<label>Mime</label>
<div class="col" title="${this.getLabel("mime_help")}">
<label>${this.getLabel("mime")}</label>
<div class="form-field">
<input value="${input.schema.contentMediaType}" name="contentMediaType" class="form-control" placeholder="mime" ${ input.id === 'ccpimage' ? 'readonly' : ''}/>
</div>
</div>
</div>
<div name="enum-input" class="${this.#type !== 'enum' ? 'd-none' : ''} mb-3">
<div class="form-field" title="options">
<input name="options" class="form-control" type="text" placeholder="option" value="${input.schema.enum ? input.schema.enum.join(',') : ''}"/>
<small class="form-text text-muted">Comma separated list of options</small>
<div class="form-field" title="${this.getLabel("options_help")}">
<input name="options" class="form-control" type="text" placeholder="${this.getLabel("options")}" value="${input.schema.enum ? input.schema.enum.join(',') : ''}"/>
<small class="form-text text-muted">${this.getLabel("options_ext_help")}</small>
</div>
<div class="form-field" title="Format">
<label>Format</label>
<div class="form-field" title="${this.getLabel("format_help")}">
<label>${this.getLabel("format")}</label>
<select value="${input.schema.format}" name="format" class="form-control">
<option value="select" ${this.isSelectedFormat('select') ? "selected" : ""}>Choice</option>
<option value="checklist" ${this.isSelectedFormat('checklist') ? "selected" : ""}>Multi Choice</option>
<option value="select" ${this.isSelectedFormat('select') ? "selected" : ""}>${this.getLabel("choice")}</option>
<option value="checklist" ${this.isSelectedFormat('checklist') ? "selected" : ""}>${this.getLabel("multi_choice")}e</option>
</select>
</div>
</div>
<div name="input-default" class="mb-3">
<label>Default value</label>
<div class="form-field border border-info px-2 py-1" style="background-color:#0dcaf022" title="Default value">
<label>${this.getLabel("default")}</label>
<div class="form-field border border-info px-2 py-1" style="background-color:#0dcaf022" title="${this.getLabel("default_help")}">
<div name="default-container">${this.renderDefaultByType()}</div>
<span style="user-select:none;position:relative;top:-1.6rem;float:right;cursor:pointer" name="password_toggle" class="${this.isSelectedFormat('secret') ? 'inline' : 'd-none'}">&#128065;</span>
</div>

View File

@ -42,6 +42,50 @@ class CCPMethodEditorController extends HTMLElement {
links: []
}
#messages = {
"en" : {
"clone" : "Clone",
"clone_help" : "All setting will be cloned but no relation to cloned method will be kept",
"derive" : "Derive",
"derive_help" : "All settings will be cloned and a relation to the originating method will be kept",
"edit" : "Edit",
"edit_help" : "Edit this method",
"edit_clone_derive_help" : "Choose whether you want to clone this method or edit it",
"save_help" : "Save this method definition",
"reset_help" : "Reset all fields",
"delete_help" : "Permanently delete this method",
"title" : "Title",
"title_help" : "The title for the method",
"version" : "Version",
"version_help" : "The version of the method",
"description" : "Description",
"description_help" : "The description of this method",
"keywords" : "Keywords",
"keywords_help" : "Keywords that can be used to search for the method. Write and add by hitting enter.",
"categories" : "Categories",
"categories_help" : "Categories to classify the method. Select one from the list or type a new one. Add by pressing enter.",
"compatible_infrastructures" : "Compatible infrastructures",
"compatible_infrastructures_help" : "Select the infrastructures that are able to execute your method",
"inputs" : "Inputs",
"outputs" : "Outputs",
"scripts" : "Scripts",
"scripts_help" : "Deploy and execute scripts configure the deployment and execution life cycle of the method on the selected infrastructures. Use {{input_id}} notation to expand the inputs with their default values.",
"add-input_help" : "Add an input to this method",
"add-output_help" : "Add an output to this method",
"add_ccpnote_help" : "Add ccpnote annotation for this method. This helps in identifying executions.",
"add_stdout_help" : "Add standard outout",
"add_stderr_help" : "Add standard error",
"preview" : "Preview",
"err_fetch_infrastructures" : "Unable to fetch insfrastructures",
"err_save_method" : "Unable to save method",
"err_load_method" : "Unable to load method",
"err_delete_method" : "Unable to delete method",
"confirm_reset" : "All unsaved data will be lost. Proceed?",
"confirm_save" : "Confirm updating of method",
"confirm_delete" : "Confirm deletion of method"
}
}
#style = `
<link rel="stylesheet" href="https://cdn.dev.d4science.org/ccp/css/common.css"></link>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
@ -145,6 +189,13 @@ class CCPMethodEditorController extends HTMLElement {
</svg>
`
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]
}
constructor() {
super();
this.#boot = document.querySelector("d4s-boot-2")
@ -171,7 +222,7 @@ class CCPMethodEditorController extends HTMLElement {
fetchInfrastructures() {
this.#boot.secureFetch(this.#serviceurl + "/infrastructures").
then(resp => {
if (resp.status !== 200) throw "Unable to fetch infrastructures";
if (resp.status !== 200) throw this.getLabel("err_fetch_infrastructures");
return resp.json()
}).then(data => {
this.#infrastructures = data
@ -185,7 +236,7 @@ class CCPMethodEditorController extends HTMLElement {
if (this.#locked) return;
if (this.#current != null) {
this.adoptTemporaries()
const text = `Please confirm ${this.#isupdate ? "updating" : "creation"} of ${this.#current.title} version ${this.#current.version}`
const text = this.getLabel("confirm_save") + ` ${this.#current.title} v. ${this.#current.version}`
if (window.confirm(text)) {
this.lockRender()
const url = this.#serviceurl + "/methods"
@ -198,7 +249,7 @@ class CCPMethodEditorController extends HTMLElement {
(resp) => {
if (resp.ok) {
return resp.text()
} else throw "Error saving process: " + resp.status
} else throw this.getLabel("err_save_method") + resp.status
}).then(data => {
if (!this.#isupdate) {
this.#current = JSON.parse(data)
@ -218,7 +269,7 @@ class CCPMethodEditorController extends HTMLElement {
deleteMethod() {
if (this.#locked) return;
if (this.#current != null) {
const text = `Please confirm deletion of ${this.#current.title} version ${this.#current.version}`
const text = this.getLabel("confirm_delete") + ` ${this.#current.title} v. ${this.#current.version}`
if (window.confirm(text)) {
this.lockRender()
const url = this.#serviceurl + "/methods/" + this.#current.id
@ -229,7 +280,7 @@ class CCPMethodEditorController extends HTMLElement {
(resp) => {
if (resp.status === 404 || resp.status === 204) {
return null
} else throw "Error deleting method: " + resp.status
} else throw this.getLabel("err_delete_method") + ": " + resp.status
}).then(data => {
this.#isupdate = false
this.initMethod()
@ -289,7 +340,7 @@ class CCPMethodEditorController extends HTMLElement {
(resp) => {
if (resp.status === 200) {
return resp.json()
} else throw "Error retrieving process: " + resp.status
} else throw this.getLabel("err_load_method") + ": " + resp.status
}
).then(data => {
this.#current = data
@ -309,7 +360,7 @@ class CCPMethodEditorController extends HTMLElement {
(resp) => {
if (resp.status === 200) {
return resp.json()
} else throw "Error retrieving process: " + resp.status
} else throw this.getLabel("err_load_method") + ": " + resp.status
}
).then(data => {
this.#current = data
@ -364,12 +415,12 @@ class CCPMethodEditorController extends HTMLElement {
<div class="modal-dialog" role="document">
<div class="modal-content shadow-lg border-primary">
<div class="modal-body">
Choose whether you want to clone this method or edit it.
${this.getLabel("edit_clone_derive_help")}
</div>
<div class="modal-footer">
<button name="clone" type="button" class="btn btn-info">Clone</button>
<button name="edit" type="button" class="btn btn-primary">Edit</button>
<button name="derive" type="button" class="btn btn-secondary">Derive</button>
<button name="clone" title="${this.getLabel("clone_help")}" type="button" class="btn btn-info">${this.getLabel("clone")}</button>
<button name="edit" title="${this.getLabel("edit_help")}" type="button" class="btn btn-primary">${this.getLabel("edit")}</button>
<button name="derive" title="${this.getLabel("derive_help")}" type="button" class="btn btn-secondary">${this.getLabel("derive")}</button>
</div>
</div>
</div>
@ -403,29 +454,29 @@ class CCPMethodEditorController extends HTMLElement {
${this.renderContexts()}
</div-->
<div class="mb-3 row">
<div class="col">
<label class="form-label">Title</label>
<div class="col" title="${this.getLabel("title_help")}">
<label class="form-label">${this.getLabel("title")}</label>
<input name="title" class="form-control" type="text" required="required" value="${this.#current.title}"/>
</div>
<div class="col">
<label class="form-label">Version</label>
<div class="col" title="${this.getLabel("version_help")}">
<label class="form-label">${this.getLabel("version")}</label>
<input name="version" class="form-control" type="text" required="required" value="${this.#current.version}"/>
</div>
</div>
<div class="mb-3">
<label class="form-label">Description</label>
<div class="mb-3" title="${this.getLabel("description_help")}">
<label class="form-label">${this.getLabel("description")}</label>
<input name="description" class="form-control" type="text" required="required" value="${this.#current.description}"/>
</div>
<div class="row">
<div class="col mb-3">
<label class="form-label">Keywords</label>
<div class="col mb-3" title="${this.getLabel("keywords_help")}">
<label class="form-label">${this.getLabel("keywords")}</label>
<input name="keyword-input" class="form-control" type="text"/>
<div name="keyword-list" class="form-text">
${this.renderKeywords()}
</div>
</div>
<div class="col mb-3">
<label class="form-label">Categories</label>
<div class="col mb-3" title="${this.getLabel("categories_help")}">
<label class="form-label">${this.getLabel("categories")}</label>
<input list="categoryhints" name="category-input" class="form-control" type="text"/>
${this.renderCategoryHints()}
<div name="category-list" class="form-text">
@ -433,8 +484,8 @@ class CCPMethodEditorController extends HTMLElement {
</div>
</div>
</div>
<div name="infrastructures" class="mb-3">
<label class="form-label">Compatible Infrastrucures</label>
<div name="infrastructures" class="mb-3" title="${this.getLabel("compatible_infrastructures_help")}">
<label class="form-label">${this.getLabel("compatible_infrastructures")}</label>
<select name="infrastructure-input" class="form-control">
${this.renderInfrastructureOptions()}
</select>
@ -448,7 +499,7 @@ class CCPMethodEditorController extends HTMLElement {
<summary class="card-header">
<div class="ccp-toolbar-header">
<div>
<span class="mr-2">Inputs</span>
<span class="mr-2">${this.getLabel("inputs")}</span>
</div>
<div class="ccp-toolbar-right">
${this.renderStandardInputButtons()}
@ -463,7 +514,7 @@ class CCPMethodEditorController extends HTMLElement {
<summary class="card-header" name="output-buttons">
<div class="ccp-toolbar-header">
<div>
<span class="mr-2">Outputs</span>
<span class="mr-2">${this.getLabel("outputs")}</span>
</div>
<div class="ccp-toolbar-right">
${this.renderStandardOutputButtons()}
@ -475,14 +526,14 @@ class CCPMethodEditorController extends HTMLElement {
<d4s-ccp-output-editor></d4s-ccp-output-editor>
</div>
</div>
<details class="card" name="script-list">
<details class="card" name="script-list" title="${this.getLabel("scripts_help")}">
<summary class="card-header">
<div class="ccp-toolbar-header">
<div>
<span>Scripts</span>
<span>${this.getLabel("scripts")}</span>
<select name="script-selector" style="border:none; padding:.3rem">
<option value="deploy-script">Deploy</option>
<option value="execute-script">Execute</option>
<option value="deploy-script">${this.getLabel("deploy")}</option>
<option value="execute-script">${this.getLabel("execute")}</option>
<!--option value="undeploy-script">Undeploy</option-->
</select>
</div>
@ -549,7 +600,7 @@ class CCPMethodEditorController extends HTMLElement {
})
this.#rootdoc.querySelector("button[name=reset]").addEventListener("click", ev => {
if (window.confirm("All unsaved data will be lost. Proceed?")) {
if (window.confirm(this.getLabel("confirm_reset"))) {
this.resetMethod()
}
ev.preventDefault()
@ -862,7 +913,7 @@ class CCPMethodEditorController extends HTMLElement {
renderSaveButton() {
return `
<button title="Save" name="save" class="btn btn-primary ccp-toolbar-button">
<button title="${this.getLabel("save_help")}" name="save" class="btn btn-primary ccp-toolbar-button">
${this.#disc_icon}
</button>
`
@ -870,7 +921,7 @@ class CCPMethodEditorController extends HTMLElement {
renderDeleteButton() {
return `
<button title="Delete" name="delete" class="btn btn-danger ccp-toolbar-button">
<button title="${this.getLabel("delete_help")}" name="delete" class="btn btn-danger ccp-toolbar-button">
${this.#delete_icon}
</button>
`
@ -878,7 +929,7 @@ class CCPMethodEditorController extends HTMLElement {
renderResetButton() {
return `
<button name="reset" title="Reset" class="btn btn-primary ccp-toolbar-button">
<button name="reset" title="${this.getLabel("reset_help")}" class="btn btn-primary ccp-toolbar-button">
<svg viewBox="0 0 24 24">
${this.#erase_icon}
</svg>
@ -888,7 +939,7 @@ class CCPMethodEditorController extends HTMLElement {
renderPlusButton(name) {
return `
<button name="${name}" title="Add" name="reset" class="btn btn-primary ccp-toolbar-button">
<button name="${name}" title="${this.getLabel(name + "_help")}" class="btn btn-primary ccp-toolbar-button">
${this.#plus_icon}
</button>
`
@ -896,7 +947,7 @@ class CCPMethodEditorController extends HTMLElement {
renderStandardInputButtons() {
return `
<button name="add-ccpannotation" title="Add annotation input" name="reset" class="btn btn-info ccp-toolbar-button">
<button name="add-ccpannotation" title="${this.getLabel("add_ccpnote_help")}" class="btn btn-info ccp-toolbar-button">
${this.#annotation_input_icon}
</button>
`
@ -904,10 +955,10 @@ class CCPMethodEditorController extends HTMLElement {
renderStandardOutputButtons() {
return `
<button name="add-stdout" title="Add stdout" class="btn btn-success ccp-toolbar-button">
<button name="add-stdout" title="${this.getLabel("add_stdout_help")}" class="btn btn-success ccp-toolbar-button">
${this.#output_icon}
</button>
<button name="add-stderr" title="Add stderr" class="btn btn-danger ccp-toolbar-button">
<button name="add-stderr" title="${this.getLabel("add_stderr_help")}" class="btn btn-danger ccp-toolbar-button">
${this.#output_icon}
</button>
`

View File

@ -4,15 +4,29 @@ class CCPMethodList extends HTMLElement{
#rootdoc;
#data = null;
#filtered;
#dragged = null;
#searchfield = null;
#allowedit = false;
#allowexecute = false;
#archive = false;
#fileupload = null;
#archiveupload = null;
//#fileupload = null;
//#archiveupload = null;
#serviceurl;
#messages = {
"en" : {
"Methods" : "Methods",
"refresh_help" : "Refresh the list of available methods",
"Search" : "Search",
"count_executable_help" : "Number of executable methods",
"count_not_executable_help" : "Number of non executable methods",
"export_category_help" : "Export all the methods in this category as JSON files",
"export_method_help" : "Export this method as JSON file",
"archive_method_help" : "Export this method as JSON file to your workspace",
"shared_help" : "This method is shared in this community",
"share_help" : "You can share this method in this community",
"execute_help" : "Open method's form to set inputs and execute",
"edit_help" : "Open method's form for cloning, deriving or editing"
}
}
constructor(){
super()
@ -21,6 +35,13 @@ class CCPMethodList extends HTMLElement{
this.#archive = this.getAttribute("archive")
}
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]
}
render(){
this.#rootdoc.innerHTML = `
<link rel="stylesheet" href="https://cdn.dev.d4science.org/ccp/css/common.css"></link>
@ -47,9 +68,9 @@ class CCPMethodList extends HTMLElement{
<summary>
<h5 class="d-inline mr-2 text-primary"></h5>
<div class="float-right d-flex" style="gap:2px">
<span name="count_notexecutables" title="Number of non executable methods" class="badge border border-danger text-danger"></span>
<span name="count_executables" title="Number of executable methods" class="badge border border-success text-success"></span>
<button name="export_category" title="Export whole category" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<span name="count_notexecutables" title="${this.getLabel('count_not_executable_help')}" class="badge border border-danger text-danger"></span>
<span name="count_executables" title="${this.getLabel('count_executable_help')}" class="badge border border-success text-success"></span>
<button name="export_category" title="${this.getLabel('export_category_help')}" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<svg viewBox="0 0 24 24"><g><rect fill="none" height="24" width="24"/></g><g><path d="M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M17,11l-1.41-1.41L13,12.17V4h-2v8.17L8.41,9.59L7,11l5,5 L17,11z"/></g></svg>
</button>
</div>
@ -61,26 +82,26 @@ class CCPMethodList extends HTMLElement{
<span name="version" class="badge badge-primary"></span>
<span name="author" class="badge badge-warning"></span>
<div class="float-right d-flex" style="gap:3px">
<button name="executable" title="Execute" class="btn btn-success ccp-toolbar-button ccp-toolbar-button-small">
<button name="executable" title="${this.getLabel("execute_help")}" class="btn btn-success ccp-toolbar-button ccp-toolbar-button-small">
<svg viewBox="0 0 48 48" style="fill:white; stroke:white">
<path d="M10,10 v28 L38,24 Z"/>
</svg>
</button>
<button name="export_method" title="Export this version" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<button name="export_method" title="${this.getLabel("export_method_help")}" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<svg viewBox="0 0 24 24"><g><rect fill="none"/></g><g><path d="M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M17,11l-1.41-1.41L13,12.17V4h-2v8.17L8.41,9.59L7,11l5,5 L17,11z"/></g></svg>
</button>
<button name="edit" title="Edit" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<button name="edit" title="${this.getLabel("edit_help")}" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<svg viewBox="0 0 48 48">
<path d="M9 39h2.2l22.15-22.15-2.2-2.2L9 36.8Zm30.7-24.3-6.4-6.4 2.1-2.1q.85-.85 2.1-.85t2.1.85l2.2 2.2q.85.85.85 2.1t-.85 2.1Zm-2.1 2.1L12.4 42H6v-6.4l25.2-25.2Zm-5.35-1.05-1.1-1.1 2.2 2.2Z"/>
</svg>
</button>
${ this.#archive ? `
<button data-index="0" name="archive" title="Archive to workspace" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<button data-index="0" name="archive" title="${this.getLabel("archive_help")}" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
<svg viewBox="0 96 960 960"><path d="M140 796h680V516H140v280Zm540.118-90Q701 706 715.5 691.382q14.5-14.617 14.5-35.5Q730 635 715.382 620.5q-14.617-14.5-35.5-14.5Q659 606 644.5 620.618q-14.5 14.617-14.5 35.5Q630 677 644.618 691.5q14.617 14.5 35.5 14.5ZM880 456h-85L695 356H265L165 456H80l142-142q8-8 19.278-13 11.278-5 23.722-5h430q12.444 0 23.722 5T738 314l142 142ZM140 856q-24.75 0-42.375-17.625T80 796V456h800v340q0 24.75-17.625 42.375T820 856H140Z"/></svg>
</button>`
: ``
}
<button data-index="0" name="publish" title="Share with vlab" class="btn btn-warning ccp-toolbar-button ccp-toolbar-button-small">
<button data-index="0" name="publish" title="${this.getLabel("share_help")}" class="btn btn-warning ccp-toolbar-button ccp-toolbar-button-small">
<svg style="fill:black" viewBox="0 -960 960 960"><path d="M727-80q-47.5 0-80.75-33.346Q613-146.693 613-194.331q0-6.669 1.5-16.312T619-228L316-404q-15 17-37 27.5T234-366q-47.5 0-80.75-33.25T120-480q0-47.5 33.25-80.75T234-594q23 0 44 9t38 26l303-174q-3-7.071-4.5-15.911Q613-757.75 613-766q0-47.5 33.25-80.75T727-880q47.5 0 80.75 33.25T841-766q0 47.5-33.25 80.75T727-652q-23.354 0-44.677-7.5T646-684L343-516q2 8 3.5 18.5t1.5 17.741q0 7.242-1.5 15Q345-457 343-449l303 172q15-14 35-22.5t46-8.5q47.5 0 80.75 33.25T841-194q0 47.5-33.25 80.75T727-80Zm.035-632Q750-712 765.5-727.535q15.5-15.535 15.5-38.5T765.465-804.5q-15.535-15.5-38.5-15.5T688.5-804.465q-15.5 15.535-15.5 38.5t15.535 38.465q15.535 15.5 38.5 15.5Zm-493 286Q257-426 272.5-441.535q15.5-15.535 15.5-38.5T272.465-518.5q-15.535-15.5-38.5-15.5T195.5-518.465q-15.5 15.535-15.5 38.5t15.535 38.465q15.535 15.5 38.5 15.5Zm493 286Q750-140 765.5-155.535q15.5-15.535 15.5-38.5T765.465-232.5q-15.535-15.5-38.5-15.5T688.5-232.465q-15.5 15.535-15.5 38.5t15.535 38.465q15.535 15.5 38.5 15.5ZM727-766ZM234-480Zm493 286Z"/></svg>
</button>
</div>
@ -102,13 +123,13 @@ class CCPMethodList extends HTMLElement{
<div class="card-header">
<div class="ccp-toolbar-header d-flex flex-wrap justify-content-between">
<div>
<span name="header">Methods</span>
<span name="header">${this.getLabel("Methods")}</span>
</div>
<div class="d-flex flex-wrap" style="gap:2px">
<button name="refresh" class="btn btn-primary ccp-toolbar-button" title="Refresh">
<button name="refresh" class="btn btn-primary ccp-toolbar-button" title="${this.getLabel('refresh_help')}">
<svg viewBox="0 0 48 48"><path d="M24 40q-6.65 0-11.325-4.675Q8 30.65 8 24q0-6.65 4.675-11.325Q17.35 8 24 8q4.25 0 7.45 1.725T37 14.45V8h3v12.7H27.3v-3h8.4q-1.9-3-4.85-4.85Q27.9 11 24 11q-5.45 0-9.225 3.775Q11 18.55 11 24q0 5.45 3.775 9.225Q18.55 37 24 37q4.15 0 7.6-2.375 3.45-2.375 4.8-6.275h3.1q-1.45 5.25-5.75 8.45Q29.45 40 24 40Z"/></svg>
</button>
<label name="fileupload" class="btn btn-primary ccp-toolbar-button m-0" title="Upload from file">
<!--label name="fileupload" class="btn btn-primary ccp-toolbar-button m-0" title="Upload from file">
<svg viewBox="0 96 960 960"><path d="M452 854h60V653l82 82 42-42-156-152-154 154 42 42 84-84v201ZM220 976q-24 0-42-18t-18-42V236q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554V236H220v680h520V422H551ZM220 236v186-186 680-680Z"/></svg>
<input type="file" class="d-none" multiple="multiple"/>
</label>
@ -117,13 +138,13 @@ class CCPMethodList extends HTMLElement{
<button name="archive" class="btn btn-primary ccp-toolbar-button m-0" title="Upload from link">
<svg viewBox="0 96 960 960"><path d="M450 776H280q-83 0-141.5-58.5T80 576q0-83 58.5-141.5T280 376h170v60H280q-58.333 0-99.167 40.765-40.833 40.764-40.833 99Q140 634 180.833 675q40.834 41 99.167 41h170v60ZM324 606v-60h310v60H324Zm556-30h-60q0-58-40.833-99-40.834-41-99.167-41H510v-60h170q83 0 141.5 58.5T880 576ZM699 896V776H579v-60h120V596h60v120h120v60H759v120h-60Z"/></svg>
</button>
</div>
</div-->
</div>
</div>
</div>
<div class="card-body">
<div class="mb-3">
<input type="text" name="search" class="form-control" placeholder="Search"/>
<input type="text" name="search" class="form-control" placeholder="${this.getLabel("Search")}"/>
</div>
<div>
<ul name="process_category_list"></ul>
@ -141,24 +162,24 @@ class CCPMethodList extends HTMLElement{
this.updateList()
})
this.#fileupload = this.#rootdoc.querySelector("label[name=fileupload] > input[type=file]")
this.#fileupload.addEventListener("change", ev=>{
const filelist = ev.target.files;
if (filelist.length > 0) {
const files = Array.prototype.slice.call(filelist)
this.importMethods(files)
}
})
// this.#fileupload = this.#rootdoc.querySelector("label[name=fileupload] > input[type=file]")
// this.#fileupload.addEventListener("change", ev=>{
// const filelist = ev.target.files;
// if (filelist.length > 0) {
// const files = Array.prototype.slice.call(filelist)
// this.importMethods(files)
// }
// })
this.#archiveupload = this.#rootdoc.querySelector("button[name=archive]")
this.#archiveupload.addEventListener("click", ev=>{
const link = ev.target.parentElement.querySelector("input").value
if(link){
if(confirm("Please confirm importing of method from link?")){
this.fromArchive(link)
}
}
})
// this.#archiveupload = this.#rootdoc.querySelector("button[name=archive]")
// this.#archiveupload.addEventListener("click", ev=>{
// const link = ev.target.parentElement.querySelector("input").value
// if(link){
// if(confirm("Please confirm importing of method from link?")){
// this.fromArchive(link)
// }
// }
// })
}
connectedCallback(){
@ -457,6 +478,7 @@ class CCPMethodList extends HTMLElement{
span.classList.add("badge")
span.classList.add("badge-warning")
span.textContent = "shared"
span.alt = span.title = this.getLabel("shared_help")
e.replaceWith(span)
}else if(!this.isAuthor(d)){
e.parentElement.removeChild(e)

View File

@ -3,13 +3,32 @@ class CCPOutputWidgetEditorController extends HTMLElement {
#output = null
#index = null
#type = null
#messages = {
"en" : {
"output_id_help" : "The Id of the output. This has to be unique accross all the outputs the method",
"output_delete_help" : "Delete this output",
"output_title_help" : "Title of the output. This is how the output will appear in forms.",
"output_description_help" : "A description for this output",
"min_occurs_help" : "Minimum cardinality",
"max_occurs_help" : "Msximum cardinality",
"mimetype_help" : "Set MIME type of expected output",
"file_path" : "Path to file",
"file_path_help" : "Define the path to the file holding the output. This documents the location of the output in the zip archive returned by the execution. Paths in the execution runtime instead are infrastructure dependant."
}
}
#delete_icon = `
<svg style="width:24px;height:24px;pointer-events: none;" viewBox="0 0 24 24">
<path d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z" />
</svg>
`
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]
}
constructor(){
super()
}
@ -29,38 +48,38 @@ class CCPOutputWidgetEditorController extends HTMLElement {
this.innerHTML = `
<details>
<summary class="mb-3">
<input class="form-control" style="width:auto;display:inline" required="required" name="id" value="${this.#output.id}" title="Id of output"/>
<button data-index="${this.#index}" name="delete-output" title="Delete" class="btn btn-danger ccp-toolbar-button">
<input class="form-control" style="width:auto;display:inline" required="required" name="id" value="${this.#output.id}" title="${this.getLabel('output_id_help')}"/>
<button data-index="${this.#index}" name="delete-output" title="${this.getLabel('output_delete_help')}" class="btn btn-danger ccp-toolbar-button">
${this.#delete_icon}
</button>
</summary>
<div style="padding-left: 1rem;border-left: 1px solid gray;">
<div class="row mb-3">
<div class="col">
<div class="form-field" title="Title">
<div class="form-field" title="${this.getLabel('output_title_help')}">
<input name="title" class="form-control" placeholder="title" value="${this.#output.title}" required="required"/>
</div>
</div>
</div>
<div class="mb-3">
<div class="form-field" title="Description">
<div class="form-field" title="${this.getLabel('output_description_help')}">
<textarea rows="1" name="description" class="form-control" placeholder="description" required="required">${this.#output.description}</textarea>
</div>
</div>
<div class="row mb-3">
<div class="row mb-3 d-none">
<div class="col">
<div class="form-field" title="Mininum cardinality">
<div class="form-field" title="${this.getLabel("min_occurs_help")}">
<input value="${this.#output.minOccurs}" type="number" min="0" step="1" name="minOccurs" class="form-control" placeholder="minOccurs"/>
</div>
</div>
<div class="col">
<div class="form-field" title="Maximum cardinality">
<div class="form-field" title="${this.getLabel("max_occurs_help")}">
<input value="${this.#output.maxOccurs}" type="number" min="0" step="1" name="maxOccurs" class="form-control" placeholder="maxOccurs"/>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-3">
<div class="col d-none">
<div class="form-field" title="Type">
<select name="type" class="form-control" placeholder="type">
<option value="string">String</option>
@ -68,7 +87,7 @@ class CCPOutputWidgetEditorController extends HTMLElement {
</div>
</div>
<div class="col-3">
<div class="form-field" title="Mime type">
<div class="form-field" title="${this.getLabel("mimetype_help")}">
<input value="${this.#output.schema.contentMediaType}" name="contentMediaType" class="form-control" placeholder="mime"/>
</div>
</div>
@ -110,8 +129,9 @@ class CCPOutputWidgetEditorController extends HTMLElement {
if(this.#output.metadata && this.#output.metadata.length > 0){
return `
<div class="col">
<div class="form-field" title="File path">
<input value="${this.#output.metadata[0].href}" name="href" class="form-control" placeholder="file path"/>
<div class="form-field" title="${this.getLabel("file_path_help")}">
<input value="${this.#output.metadata[0].href}" name="href" class="form-control" placeholder="${this.getLabel("file_path")}"/>
</div>
</div>
`