added triggers for saving and retrieving executions to/from workspace
This commit is contained in:
parent
7a6215499c
commit
77f6f49d6f
|
@ -4,11 +4,14 @@ class CCPExecutionHistory extends HTMLElement {
|
|||
#rootdoc = null;
|
||||
#serviceurl = null;
|
||||
#broadcasturl = null;
|
||||
#archive = null;
|
||||
#data = [];
|
||||
#filtered = [];
|
||||
#socket = null;
|
||||
#interval = null;
|
||||
#searchfield = null;
|
||||
#fileupload = null;
|
||||
#archiveupload = null;
|
||||
|
||||
constructor(){
|
||||
super()
|
||||
|
@ -20,6 +23,7 @@ class CCPExecutionHistory extends HTMLElement {
|
|||
this.#broadcasturl = this.#serviceurl.replace(/^http/, "ws")
|
||||
}
|
||||
this.#broadcasturl = this.#broadcasturl + "/ws/notification"
|
||||
this.#archive = this.getAttribute("archive")
|
||||
this.connectNewExecution()
|
||||
this.connectBroadcast()
|
||||
}
|
||||
|
@ -73,15 +77,18 @@ 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>
|
||||
${ this.#archive ? `
|
||||
<button data-index="0" name="archive" title="Archive to workspace" 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="provo" title="Export to Prov-o document" class="btn btn-primary ccp-toolbar-button ccp-toolbar-button-small">
|
||||
<svg viewBox="0 0 24 24"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/></svg>
|
||||
</button>
|
||||
<button data-index="0" name="reexecute1" title="Level 1 re-execution" class="btn btn-info ccp-toolbar-button ccp-toolbar-button-small">
|
||||
<svg enable-background="new 0 0 24 24" viewBox="0 0 24 24"><g><rect fill="none" height="24" width="24"/><rect fill="none" height="24" width="24"/><rect fill="none" height="24" width="24"/></g><g><g/><path d="M12,5V1L7,6l5,5V7c3.31,0,6,2.69,6,6s-2.69,6-6,6s-6-2.69-6-6H4c0,4.42,3.58,8,8,8s8-3.58,8-8S16.42,5,12,5z"/></g></svg>
|
||||
</button>
|
||||
<!-- button data-index="0" name="reexecute2" title="Level 2 re-execution" class="btn btn-info ccp-toolbar-button ccp-toolbar-button-small">
|
||||
<svg enable-background="new 0 0 24 24" viewBox="0 0 24 24"><g><rect fill="none" height="24" width="24"/></g><g><path d="M12,2C6.48,2,2,6.48,2,12s4.48,10,10,10s10-4.48,10-10S17.52,2,12,2z M12,18.5c-3.31,0-6-2.69-6-6h2c0,2.21,1.79,4,4,4 s4-1.79,4-4c0-2.24-1.85-4.09-4.16-3.99l1.57,1.57L12,11.5l-4-4l4-4l1.41,1.41l-1.6,1.6C15.28,6.4,18,9.18,18,12.5 C18,15.81,15.31,18.5,12,18.5z"/></g></svg>
|
||||
</button-->
|
||||
<button data-index="0" name="delete" title="Delete" 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>
|
||||
|
@ -124,22 +131,33 @@ class CCPExecutionHistory extends HTMLElement {
|
|||
</ul>
|
||||
</template>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
<div class="card">
|
||||
<div class="card" style="min-width:600px">
|
||||
<div class="card-header">
|
||||
<div class="ccp-toolbar-header">
|
||||
<div>
|
||||
<span name="header" class="mr-2">Execution Monitor</span>
|
||||
</div>
|
||||
<div class="ccp-toolbar-right">
|
||||
<div class="ccp-toolbar-right d-flex" style="gap:2px">
|
||||
<button name="refresh" class="btn btn-primary ccp-toolbar-button" title="Refresh">
|
||||
<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>
|
||||
</button>
|
||||
<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>
|
||||
<div class="d-flex ml-2" style="gap:2px">
|
||||
<input type="text" class="form-control" placeholder="Paste link here"/>
|
||||
<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 class="card-body">
|
||||
<div class="mb-3">
|
||||
<input type="text" name="search" class="form-control" placeholder="Search"/>
|
||||
<input accept="application/zip" type="text" name="search" class="form-control" placeholder="Search"/>
|
||||
</div>
|
||||
<div>
|
||||
<ul name="ccp_execution_list"></ul>
|
||||
|
@ -155,6 +173,23 @@ class CCPExecutionHistory extends HTMLElement {
|
|||
this.#searchfield.addEventListener("input", ev=>{
|
||||
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.importExecutions(files)
|
||||
}
|
||||
})
|
||||
|
||||
this.#archiveupload = this.#rootdoc.querySelector("button[name=archive]")
|
||||
this.#archiveupload.addEventListener("click", ev=>{
|
||||
const link = ev.target.parentElement.querySelector("input").value
|
||||
if(link){
|
||||
this.fromArchive(link)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
updateList(){
|
||||
|
@ -332,6 +367,29 @@ class CCPExecutionHistory extends HTMLElement {
|
|||
}).catch(err=>{ alert(err)})
|
||||
}
|
||||
|
||||
toArchive(id){
|
||||
this.#boot.secureFetch(`${this.#serviceurl}/executions/${id}/archive`, { method: "POST" })
|
||||
.then(reply =>{
|
||||
if (reply.status !== 200) {
|
||||
throw "Unable to archive"
|
||||
}
|
||||
}).catch(err=>{ alert(err)})
|
||||
}
|
||||
|
||||
fromArchive(url){
|
||||
if(url){
|
||||
this.#boot.secureFetch(`${this.#serviceurl}/executions/archive?url=${url}`)
|
||||
.then(reply =>{
|
||||
if (reply.status !== 200) {
|
||||
throw "Unable to fetch from archive"
|
||||
}
|
||||
return reply.text()
|
||||
}).then(data=>{
|
||||
this.refreshExecutions()
|
||||
}).catch(err=>{ alert(err)})
|
||||
}
|
||||
}
|
||||
|
||||
#execution_list_bss = {
|
||||
template : "#EXECUTIOM_LIST_TEMPLATE",
|
||||
target : "ul[name=ccp_execution_list]",
|
||||
|
@ -427,9 +485,9 @@ class CCPExecutionHistory extends HTMLElement {
|
|||
const id = ev.currentTarget.getAttribute("data-index")
|
||||
this.reexecute(id, 1)
|
||||
}
|
||||
if(ev.target.getAttribute("name") === "reexecute2"){
|
||||
if(ev.target.getAttribute("name") === "archive"){
|
||||
const id = ev.currentTarget.getAttribute("data-index")
|
||||
this.reexecute(id, 2)
|
||||
this.toArchive(id)
|
||||
}
|
||||
},
|
||||
recurse : [
|
||||
|
|
Loading…
Reference in New Issue