Merge pull request 'ccp-features' (#9) from ccp-features into master

Reviewed-on: gCubeSystem/cdn-experiments#9
This commit is contained in:
Marco Lettere 2023-07-10 15:47:20 +02:00
commit 82d5b25ff4
1 changed files with 17 additions and 3 deletions

View File

@ -83,7 +83,7 @@ class CCPMethodList extends HTMLElement{
</button>`
: ``
}
<button data-index="0" name="publish" title="Publish to VRE" class="btn btn-warning ccp-toolbar-button ccp-toolbar-button-small">
<button data-index="0" name="publish" title="Share with vlab" 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>
@ -332,6 +332,10 @@ class CCPMethodList extends HTMLElement{
}).catch(err=>{ alert(err)})
}
isShared(process){
return 0 < process.metadata.filter(md=>{ return md.role === "context" && md.title === this.#boot.context}).length
}
isAuthor(m){
const href = `${this.#boot.url}/admin/realms/${this.#boot.realm}/users/${this.#boot.subject}`
const found = m.metadata.filter(md=>{return md.role === "author" && md.href === href})
@ -414,7 +418,7 @@ class CCPMethodList extends HTMLElement{
this.toArchive(id)
}
}else if(ev.target.getAttribute("name") === "publish"){
if(confirm("Please confirm publication of method to VRE?")){
if(confirm("Please confirm publication of method to Vlab?")){
this.publish(id)
}
}
@ -447,7 +451,17 @@ class CCPMethodList extends HTMLElement{
},
{
target: "button[name=publish]",
apply : (e,d)=>{ e.style.display = this.isAuthor(d) ? "revert" : "none" }
apply : (e,d)=>{
if(this.isShared(d)){
const span = document.createElement("span")
span.classList.add("badge")
span.classList.add("badge-warning")
span.textContent = "shared"
e.replaceWith(span)
}else if(!this.isAuthor(d)){
e.parentElement.removeChild(e)
}
}
},
{
target : "span[name=author]",