moved to method service instead of ogc, added author in editor and clone adn editable are now service calls

This commit is contained in:
dcore94 2022-07-21 15:42:55 +02:00
parent 6ee7bda28e
commit 8132792fa0
2 changed files with 43 additions and 10 deletions

View File

@ -18,6 +18,7 @@ class CCPMethodEditorController extends HTMLElement{
description : "New empty method",
version : "1.0.0",
jobControlOptions : "async-execute",
metadata : [],
inputs : {},
outputs : {},
additionalParameters : {
@ -143,6 +144,28 @@ class CCPMethodEditorController extends HTMLElement{
background-color: rgba(0,0,0,.3);
z-index: 10;
}
ul.author_list{
list-style: none;
display: flex;
flex-direction: row;
gap:2px;
padding-left: 0;
font-size: small;
font-weight: 300;
}
li.author_list_item{
display: inline-block;
padding: 0.25em 0.4em;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: 0.25rem;
background-color: #eeffff;
color: #9900CC;
border: solid 1px #9900CC;
}
</style>
`
#erase_icon = `
@ -219,7 +242,7 @@ class CCPMethodEditorController extends HTMLElement{
(resp)=>{
if(resp.status === 201 || resp.status === 204){
return resp.text()
}else throw "Error saving process"
}else throw "Error saving process: " + resp.status
}).then(data=>{
if(!this.#isupdate) this.#isupdate = true;
this.unlockRender()
@ -272,18 +295,15 @@ class CCPMethodEditorController extends HTMLElement{
cloneMethod(method){
if(this.#locked) return;
this.lockRender()
this.#boot.secureFetch(this.#serviceurl + "/processes/" + method).then(
this.#boot.secureFetch(this.#serviceurl + "/methods/" + method + "/clone").then(
(resp)=>{
if(resp.status === 200){
return resp.json()
}else throw "Error retrieving process"
}else throw "Error retrieving process: " + resp.status
}
).then(data=>{
this.#current = data
this.#current.id = Math.abs((Math.random() * 10e11)|0)
this.#isupdate = false
this.#current.title = "Clone of " + this.#current.title
this.#current.description = "[Clone of] " + this.#current.description
this.#tmp_inputs = Object.keys(this.#current.inputs).map(k=>this.#current.inputs[k])
this.#tmp_outputs = Object.keys(this.#current.outputs).map(k=>this.#current.outputs[k])
this.unlockRender()
@ -295,11 +315,11 @@ class CCPMethodEditorController extends HTMLElement{
editMethod(method){
if(this.#locked) return;
this.lockRender()
this.#boot.secureFetch(this.#serviceurl + "/processes/" + method).then(
this.#boot.secureFetch(this.#serviceurl + "/methods/" + method + "/updatable").then(
(resp)=>{
if(resp.status === 200){
return resp.json()
}else throw "Error retrieving process"
}else throw "Error retrieving process: " + resp.status
}
).then(data=>{
this.#current = data
@ -370,6 +390,9 @@ class CCPMethodEditorController extends HTMLElement{
</div>
</div>
<div class="card-body">
<div class="mb-3 row">
${this.renderAuthors()}
</div>
<div class="mb-3 row">
<div class="col">
<label class="form-label">Title</label>
@ -698,6 +721,16 @@ class CCPMethodEditorController extends HTMLElement{
`
}
renderAuthors(){
return `
<ul class="author_list">
${ this.#current.metadata.
filter(md=>md.role === "author").
map(a=>`<li class="author_list_item">${a.title}</li>`) }
</ul>
`
}
renderSaveButton(){
return `
<button title="Save" name="save" class="btn btn-primary ccp-toolbar-button">

View File

@ -138,7 +138,7 @@ class CCPMethodList extends HTMLElement{
fetchProcesses(){
console.log("Calling fetch processes")
this.#boot.secureFetch(this.#serviceurl + "/processes?limit=1000").
this.#boot.secureFetch(this.#serviceurl + "/methods").
then(resp=>{
console.log("Received resp for processes ", resp.status)
return resp.json()
@ -161,7 +161,7 @@ class CCPMethodList extends HTMLElement{
this.#filtered = []
}else{
const f = filter.toLowerCase()
this.#filtered = this.#data["processes"].filter(d=>{
this.#filtered = this.#data.filter(d=>{
return false ||
(d.title.toLowerCase().indexOf(f) !== -1)||
(d.description.indexOf(f) !== -1) ||