Compare commits
14 Commits
87b65cab81
...
b2d0ae9e82
Author | SHA1 | Date |
---|---|---|
Marco Lettere | b2d0ae9e82 | |
dcore94 | b254262f58 | |
dcore94 | f7cd0932b5 | |
dcore94 | e3efc70bad | |
dcore94 | 96030670c2 | |
dcore94 | e8c71ecb55 | |
dcore94 | 4173ee650c | |
dcore94 | cc752abe40 | |
dcore94 | 78a3009573 | |
dcore94 | cc792a3e62 | |
dcore94 | 2f8f9483b8 | |
dcore94 | f4faebc9f1 | |
dcore94 | 687be71314 | |
dcore94 | 1078e7abbb |
|
@ -124,14 +124,14 @@ window.customElements.define('d4s-boot-2', class extends HTMLElement {
|
||||||
}).then(token => {
|
}).then(token => {
|
||||||
console.log("Authorized. Token exp: " + this.expirationDate(this.parseJwt(token).exp))
|
console.log("Authorized. Token exp: " + this.expirationDate(this.parseJwt(token).exp))
|
||||||
//transform all queued requests to fetches
|
//transform all queued requests to fetches
|
||||||
console.log("All pending requests to promises")
|
//console.log("All pending requests to promises")
|
||||||
let promises = this.#queue.map(r => {
|
let promises = this.#queue.map(r => {
|
||||||
r.request.headers["Authorization"] = "Bearer " + token
|
r.request.headers["Authorization"] = "Bearer " + token
|
||||||
return r.resolve( fetch(r.url, r.request) )
|
return r.resolve( fetch(r.url, r.request) )
|
||||||
})
|
})
|
||||||
//clear queue
|
//clear queue
|
||||||
this.#queue = []
|
this.#queue = []
|
||||||
console.log("Resolving all fetches")
|
//console.log("Resolving all fetches")
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
|
|
||||||
}).catch(err => console.error("Unable to make calls: " + err)) // Sometimes throws: Unable to make calls: TypeError: Cannot read properties of undefined (reading 'split')
|
}).catch(err => console.error("Unable to make calls: " + err)) // Sometimes throws: Unable to make calls: TypeError: Cannot read properties of undefined (reading 'split')
|
||||||
|
@ -177,7 +177,7 @@ window.customElements.define('d4s-boot-2', class extends HTMLElement {
|
||||||
} else {
|
} else {
|
||||||
req.headers = { "Authorization" : null}
|
req.headers = { "Authorization" : null}
|
||||||
}
|
}
|
||||||
console.log("Queued request to url ", url)
|
//console.log("Queued request to url ", url)
|
||||||
this.#queue.push({ url : url, request : req, resolve : resolve, reject : reject})
|
this.#queue.push({ url : url, request : req, resolve : resolve, reject : reject})
|
||||||
})
|
})
|
||||||
return p
|
return p
|
||||||
|
@ -202,7 +202,7 @@ window.customElements.define('d4s-boot-2', class extends HTMLElement {
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(json => {
|
.then(json => {
|
||||||
this.#config = json
|
this.#config = json
|
||||||
console.log("Keycloak uma2 configuration loaded")
|
//console.log("Keycloak uma2 configuration loaded")
|
||||||
resolve(true)
|
resolve(true)
|
||||||
})
|
})
|
||||||
.catch(err => reject("Failed to fetch uma2-configuration from server: " + err))
|
.catch(err => reject("Failed to fetch uma2-configuration from server: " + err))
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<script src="js/methodlistcontroller.js"></script>
|
||||||
|
<script src="js/methodeditorcontroller.js"></script>
|
||||||
|
<script src="js/inputwidgeteditorcontroller.js"></script>
|
||||||
|
<script src="js/outputwidgeteditorcontroller.js"></script>
|
||||||
|
<script src="js/executionformcontroller.js"></script>
|
||||||
|
<script src="js/inputwidgetcontroller.js"></script>
|
||||||
|
<script src="js/outputwidgetcontroller.js"></script>
|
||||||
|
<link href="css/common.css" rel="stylesheet">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
||||||
|
<script src="https://cdn.cloud-dev.d4science.org/common/js/bss-min-1.2.6.js"></script>
|
||||||
|
<script src="../storage/d4s-storage.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="m-4">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
<d4s-ccp-methodeditor serviceurl="https://ccp.cloud-dev.d4science.org"></d4s-ccp-methodeditor>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<d4s-ccp-executionform serviceurl="https://ccp.cloud-dev.d4science.org"></d4s-ccp-executionform>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -55,8 +55,9 @@ class CCPExecutionForm extends HTMLElement{
|
||||||
render(){
|
render(){
|
||||||
this.#rootdoc.innerHTML = `
|
this.#rootdoc.innerHTML = `
|
||||||
<div>
|
<div>
|
||||||
|
<link rel="canonical" href="https://getbootstrap.com/docs/5.0/components/modal/">
|
||||||
<link rel="stylesheet" href="https://cdn.dev.d4science.org/ccp/css/common.css"></link>
|
<link rel="stylesheet" href="https://cdn.dev.d4science.org/ccp/css/common.css"></link>
|
||||||
<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">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" crossorigin="anonymous">
|
||||||
<style>
|
<style>
|
||||||
.ccp-execution-form{
|
.ccp-execution-form{
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -94,12 +95,12 @@ class CCPExecutionForm extends HTMLElement{
|
||||||
<h5>Outputs</h5>
|
<h5>Outputs</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="form-row ccp-outputs">
|
<div class="row ccp-outputs">
|
||||||
<div class="col form-group"></div>
|
<div class="col form-group"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<button id="execute_method_button" class="btn btn-info">Execute</button>
|
<button id="execute_method_button" class="btn btn-info">Execute</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -23,7 +23,7 @@ class CCPInputWidgetEditorController extends HTMLElement{
|
||||||
return this.#index
|
return this.#index
|
||||||
}
|
}
|
||||||
|
|
||||||
computeDefaultInputType(){
|
/*computeDefaultInputType(){
|
||||||
if(this.#input.schema.format === "secret"){
|
if(this.#input.schema.format === "secret"){
|
||||||
return "password"
|
return "password"
|
||||||
}else if(this.#input.schema.format === "date"){
|
}else if(this.#input.schema.format === "date"){
|
||||||
|
@ -34,14 +34,15 @@ class CCPInputWidgetEditorController extends HTMLElement{
|
||||||
return "datetime-local"
|
return "datetime-local"
|
||||||
}
|
}
|
||||||
return "text"
|
return "text"
|
||||||
}
|
}*/
|
||||||
|
|
||||||
isSelectedFormat(fmt){
|
isSelectedFormat(fmt){
|
||||||
return this.#input.schema.format === fmt
|
return this.#input.schema.format === fmt
|
||||||
}
|
}
|
||||||
|
|
||||||
renderDefaultByType(){
|
renderDefaultByType(){
|
||||||
if(this.#input.schema.format === "code"){
|
return `<d4s-ccp-input name="default" input="${btoa(JSON.stringify(this.#input))}"></d4s-ccp-input>`
|
||||||
|
/*if(this.#input.schema.format === "code"){
|
||||||
return `
|
return `
|
||||||
<textarea rows="5" name="default" class="form-control" placeholder="default">${this.#input.schema.default}</textarea>
|
<textarea rows="5" name="default" class="form-control" placeholder="default">${this.#input.schema.default}</textarea>
|
||||||
`
|
`
|
||||||
|
@ -49,7 +50,7 @@ class CCPInputWidgetEditorController extends HTMLElement{
|
||||||
return `
|
return `
|
||||||
<input type="${this.computeDefaultInputType()}" value="${this.#input.schema.default}" name="default" class="form-control" placeholder="default"/>
|
<input type="${this.computeDefaultInputType()}" value="${this.#input.schema.default}" name="default" class="form-control" placeholder="default"/>
|
||||||
`
|
`
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
renderDeleteButton(){
|
renderDeleteButton(){
|
||||||
|
@ -62,6 +63,8 @@ class CCPInputWidgetEditorController extends HTMLElement{
|
||||||
this.#index = i
|
this.#index = i
|
||||||
this.#input = input
|
this.#input = input
|
||||||
this.#type = input.schema.enum ? "enum" : "string"
|
this.#type = input.schema.enum ? "enum" : "string"
|
||||||
|
const minOccurs = input.minOccurs = Number(input.minOccurs) ? Number(input.minOccurs) : 0
|
||||||
|
const maxOccurs = input.maxOccurs = Number(input.maxOccurs) ? Number(input.maxOccurs) : 0
|
||||||
this.innerHTML = `
|
this.innerHTML = `
|
||||||
<details ${ reopen ? 'open' : ''}>
|
<details ${ reopen ? 'open' : ''}>
|
||||||
<summary class="mb-3">
|
<summary class="mb-3">
|
||||||
|
@ -85,22 +88,22 @@ class CCPInputWidgetEditorController extends HTMLElement{
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<div class="form-field" title="Type">
|
<div class="form-field" title="Type">
|
||||||
<label>Type</label>
|
<label>Type</label>
|
||||||
<select name="type" class="form-control" placeholder="type" value="${this.#type}" ${ input.id === 'ccpimage' ? 'readonly' : ''}>
|
<select name="type" class="form-control" placeholder="type" value="${this.#type}">
|
||||||
<option value="string" ${this.#type === "string" ? "selected" : ""}>String</option>
|
<option value="string" ${this.#type === "string" ? "selected" : ""}>String</option>
|
||||||
<option value="enum" ${this.#type === "enum" ? "selected" : ""}>Enum</option>
|
${ input.id === 'ccpimage' ? '' : `<option value="enum" ${this.#type === "enum" ? "selected" : ""}>Enum</option>` }
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="form-field" title="Minimum occurrences">
|
<div class="form-field" title="Minimum occurrences">
|
||||||
<label>Min occurs</label>
|
<label>Min occurs</label>
|
||||||
<input value="${input.minOccurs}" type="number" min="0" step="1" name="minOccurs" value="${input.minOccurs}" required="required" class="form-control" placeholder="minOccurs" ${ input.id === 'ccpimage' ? 'readonly' : ''}/>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="form-field" title="Maximum occurrences">
|
<div class="form-field" title="Maximum occurrences">
|
||||||
<label>Max occurs</label>
|
<label>Max occurs</label>
|
||||||
<input value="${input.maxOccurs}" type="number" min="0" step="1" name="maxOccurs" value="${input.maxOccurs}" required="required" class="form-control" placeholder="maxOccurs" ${ input.id === 'ccpimage' ? 'readonly' : ''}/>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col" title="Read only">
|
<div class="col" title="Read only">
|
||||||
|
@ -123,7 +126,7 @@ class CCPInputWidgetEditorController extends HTMLElement{
|
||||||
<option value="boolean" ${this.isSelectedFormat('boolean') ? "selected" : ""}>True/False</option>
|
<option value="boolean" ${this.isSelectedFormat('boolean') ? "selected" : ""}>True/False</option>
|
||||||
<option value="code" ${this.isSelectedFormat('code') ? "selected" : ""}>Code</option>
|
<option value="code" ${this.isSelectedFormat('code') ? "selected" : ""}>Code</option>
|
||||||
<option value="file" ${this.isSelectedFormat('file') ? "selected" : ""}>File</option>
|
<option value="file" ${this.isSelectedFormat('file') ? "selected" : ""}>File</option>
|
||||||
<option value="remotefile" ${this.isSelectedFormat('remotefile') ? "selected" : ""}>Remote file</option>
|
<option value="remotefile" ${this.isSelectedFormat('remotefile') ? "selected" : ""}>Workspace file</option>
|
||||||
<option value="secret" ${this.isSelectedFormat('secret') ? "selected" : ""}>Secret</option>
|
<option value="secret" ${this.isSelectedFormat('secret') ? "selected" : ""}>Secret</option>
|
||||||
<option value="url" ${this.isSelectedFormat('url') ? "selected" : ""}>Url</option>
|
<option value="url" ${this.isSelectedFormat('url') ? "selected" : ""}>Url</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -150,8 +153,9 @@ class CCPInputWidgetEditorController extends HTMLElement{
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div name="input-default" class="mb-3">
|
<div name="input-default" class="mb-3">
|
||||||
<div class="form-field" title="Default value">
|
<label>Default value</label>
|
||||||
${this.renderDefaultByType()}
|
<div class="form-field border border-info px-2 py-1" style="background-color:#0dcaf022" title="Default value">
|
||||||
|
<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'}">👁</span>
|
<span style="user-select:none;position:relative;top:-1.6rem;float:right;cursor:pointer" name="password_toggle" class="${this.isSelectedFormat('secret') ? 'inline' : 'd-none'}">👁</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -166,54 +170,64 @@ class CCPInputWidgetEditorController extends HTMLElement{
|
||||||
ev.preventDefault()
|
ev.preventDefault()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const defaultinp = this.querySelector("div[name='input-default']")
|
||||||
|
defaultinp.addEventListener("input", ev=>{
|
||||||
|
const inp = this.querySelector("d4s-ccp-input")
|
||||||
|
this.#input.schema.default = inp.value
|
||||||
|
})
|
||||||
|
|
||||||
|
defaultinp.addEventListener("change", ev=>{
|
||||||
|
const inp = this.querySelector("d4s-ccp-input")
|
||||||
|
this.#input.schema.default = inp.value
|
||||||
|
})
|
||||||
|
|
||||||
|
defaultinp.addEventListener("click", ev=>{
|
||||||
|
const src = ev.target.getAttribute("name")
|
||||||
|
if (src === "plus" || src === "minus") {
|
||||||
|
const inp = this.querySelector("d4s-ccp-input")
|
||||||
|
this.#input.schema.default = inp.value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
this.addEventListener("input", ev=>{
|
this.addEventListener("input", ev=>{
|
||||||
const val = ev.target.value
|
const val = ev.target.value
|
||||||
const ename = ev.target.getAttribute("name")
|
const ename = ev.target.getAttribute("name")
|
||||||
|
const display = this.querySelector("div[name='default-container']")
|
||||||
if(ename === "id"){
|
if(ename === "id"){
|
||||||
this.#input.id = val
|
this.#input.id = val
|
||||||
}
|
}
|
||||||
else if(ename === "title"){
|
else if(ename === "title"){
|
||||||
this.#input.title = val
|
this.#input.title = val
|
||||||
|
display.innerHTML = this.renderDefaultByType()
|
||||||
}
|
}
|
||||||
else if(ename === "description"){
|
else if(ename === "description"){
|
||||||
this.#input.description = val
|
this.#input.description = val
|
||||||
|
display.innerHTML = this.renderDefaultByType()
|
||||||
}
|
}
|
||||||
else if(ename === "minOccurs"){
|
else if(ename === "minOccurs"){
|
||||||
this.#input.minOccurs = val
|
this.#input.minOccurs = Number(val) ? Number(val) : 0
|
||||||
|
display.innerHTML = this.renderDefaultByType()
|
||||||
}
|
}
|
||||||
else if(ename === "maxOccurs"){
|
else if(ename === "maxOccurs"){
|
||||||
this.#input.maxOccurs = val
|
this.#input.maxOccurs = Number(val) ? Number(val) : 0
|
||||||
|
display.innerHTML = this.renderDefaultByType()
|
||||||
}
|
}
|
||||||
else if(ename === "format"){
|
else if(ename === "format"){
|
||||||
this.#input.schema.format = val
|
this.#input.schema.format = val
|
||||||
//this.render(this.#input, this.#index, true)
|
display.innerHTML = this.renderDefaultByType()
|
||||||
/*this.querySelector("div[name=input-default] span[name=password_toggle]").classList.add("d-none")
|
|
||||||
this.querySelector("div[name=input-default] input[name=default]").type = ""
|
|
||||||
if(this.#input.schema.format === "secret"){
|
|
||||||
this.querySelector("div[name=input-default] input[name=default]").type = "password"
|
|
||||||
this.querySelector("div[name=input-default] span[name=password_toggle]").classList.remove("d-none")
|
|
||||||
}else if(this.#input.schema.format === "date"){
|
|
||||||
this.querySelector("div[name=input-default] input[name=default]").type = "date"
|
|
||||||
}else if(this.#input.schema.format === "time"){
|
|
||||||
this.querySelector("div[name=input-default] input[name=default]").type = "time"
|
|
||||||
}else if(this.#input.schema.format === "dateTime"){
|
|
||||||
this.querySelector("div[name=input-default] input[name=default]").type = "dateTime"
|
|
||||||
}else if(this.#input.schema.format === "file"){
|
|
||||||
this.querySelector("div[name=input-default] input[name=default]").type = "file"
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
else if(ename === "contentMediaType"){
|
else if(ename === "contentMediaType"){
|
||||||
this.#input.schema.contentMediaType = val
|
this.#input.schema.contentMediaType = val
|
||||||
|
display.innerHTML = this.renderDefaultByType()
|
||||||
}
|
}
|
||||||
else if(ename === "options"){
|
else if(ename === "options"){
|
||||||
this.#input.schema.enum = val.split(",")
|
this.#input.schema.enum = val.split(",")
|
||||||
}
|
display.innerHTML = this.renderDefaultByType()
|
||||||
else if(ename === "default"){
|
|
||||||
this.#input.schema.default = val
|
|
||||||
}
|
}
|
||||||
else if(ename === "readonly"){
|
else if(ename === "readonly"){
|
||||||
this.#input.schema.readOnly = ev.target.checked
|
this.#input.schema.readOnly = ev.target.checked
|
||||||
|
display.innerHTML = this.renderDefaultByType()
|
||||||
}
|
}
|
||||||
else if(ename === "type"){
|
else if(ename === "type"){
|
||||||
this.#type = ev.target.value
|
this.#type = ev.target.value
|
||||||
|
@ -225,10 +239,10 @@ class CCPInputWidgetEditorController extends HTMLElement{
|
||||||
this.querySelector("div[name=enum-input]").classList.add("d-none")
|
this.querySelector("div[name=enum-input]").classList.add("d-none")
|
||||||
this.querySelector("div[name=string-input]").classList.remove("d-none")
|
this.querySelector("div[name=string-input]").classList.remove("d-none")
|
||||||
delete this.#input.schema['enum']
|
delete this.#input.schema['enum']
|
||||||
}
|
}
|
||||||
}
|
display.innerHTML = this.renderDefaultByType()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -220,9 +220,9 @@ class CCPMethodList extends HTMLElement{
|
||||||
const f = filter.toLowerCase()
|
const f = filter.toLowerCase()
|
||||||
this.#filtered = this.#data.filter(d=>{
|
this.#filtered = this.#data.filter(d=>{
|
||||||
return false ||
|
return false ||
|
||||||
(d.title.toLowerCase().indexOf(f) !== -1)||
|
(d.title && d.title.toLowerCase().indexOf(f) !== -1)||
|
||||||
(d.description.indexOf(f) !== -1) ||
|
(d.description && d.description.indexOf(f) !== -1) ||
|
||||||
(d.keywords.map(k=>k.toLowerCase()).filter(i=>i.indexOf(f) !== -1)).length
|
(Array.isArray(d.keywords) && d.keywords.map(k=>k.toLowerCase()).filter(i=>i.indexOf(f) !== -1)).length
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.groupBy()
|
this.groupBy()
|
||||||
|
|
|
@ -12,10 +12,13 @@
|
||||||
<h3>CDN sandbox</h3>
|
<h3>CDN sandbox</h3>
|
||||||
<p>Select the section you want to enter</p>
|
<p>Select the section you want to enter</p>
|
||||||
</header>
|
</header>
|
||||||
<div class="d-flex">
|
<div class="d-flex flex-column">
|
||||||
<div class="d-inline-block">
|
<div class="d-inline-block">
|
||||||
<a href="storage/index.html">D4S Workspace</a> (OIDC protected)
|
<a href="storage/index.html">D4S Workspace</a> (OIDC protected)
|
||||||
</div>
|
</div>
|
||||||
|
<div class="d-inline-block">
|
||||||
|
<a href="ccp/index.html">CCP</a> (OIDC protected)
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,7 @@ class D4SStorageHtmlElement extends HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
let linkElem = document.createElement('link');
|
|
||||||
linkElem.setAttribute('rel', 'stylesheet');
|
|
||||||
linkElem.setAttribute('href', 'https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css');
|
|
||||||
this.shadowRoot.appendChild(linkElem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get srcBaseURL() {
|
get srcBaseURL() {
|
||||||
|
@ -98,7 +95,7 @@ class D4SStorageToolbar extends D4SStorageHtmlElement {
|
||||||
|
|
||||||
class D4SStorageTree extends D4SStorageHtmlElement {
|
class D4SStorageTree extends D4SStorageHtmlElement {
|
||||||
|
|
||||||
static tree_event_name = "d4s-toolbar";
|
static tree_event_name = "d4s-tree";
|
||||||
static folder_data_event_name = "d4s-folder-data";
|
static folder_data_event_name = "d4s-folder-data";
|
||||||
|
|
||||||
static dataid_attr = 'data-id';
|
static dataid_attr = 'data-id';
|
||||||
|
@ -226,8 +223,10 @@ class D4SStorageTree extends D4SStorageHtmlElement {
|
||||||
|
|
||||||
const div = document.createElement('div')
|
const div = document.createElement('div')
|
||||||
div.innerHTML = /*css*/`
|
div.innerHTML = /*css*/`
|
||||||
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||||
<style>
|
<style>
|
||||||
.selected > span {
|
.selected > .li-title {
|
||||||
background-color: ${this.#selectedbgcolor};
|
background-color: ${this.#selectedbgcolor};
|
||||||
}
|
}
|
||||||
ul.root {
|
ul.root {
|
||||||
|
@ -238,6 +237,12 @@ class D4SStorageTree extends D4SStorageHtmlElement {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
padding-left: 0.6em;
|
padding-left: 0.6em;
|
||||||
}
|
}
|
||||||
|
li{
|
||||||
|
color: #444444;
|
||||||
|
}
|
||||||
|
li:hover{
|
||||||
|
color: #555555;
|
||||||
|
}
|
||||||
li {
|
li {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +383,7 @@ class D4SStorageTree extends D4SStorageHtmlElement {
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new CustomEvent(
|
new CustomEvent(
|
||||||
D4SStorageTree.tree_event_name,
|
D4SStorageTree.tree_event_name,
|
||||||
{detail: {id: id}}
|
{detail: {id: id, bubbles: true}}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -417,15 +422,43 @@ class D4SStorageTree extends D4SStorageHtmlElement {
|
||||||
data
|
data
|
||||||
.filter(item => this.showFiles || item['@class'].includes('FolderItem'))
|
.filter(item => this.showFiles || item['@class'].includes('FolderItem'))
|
||||||
.forEach(item => {
|
.forEach(item => {
|
||||||
ul.appendChild(this.createListItem(item.title, item.id, item['@class'], parentId));
|
ul.appendChild(this.createListItem(item, parentId));
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
ul.appendChild(this.createListItem(data.displayName ? data.displayName : data.title, data.id, data['@class'], parentId));
|
ul.appendChild(this.createListItem(data, parentId));
|
||||||
}
|
}
|
||||||
parentElement.appendChild(ul);
|
parentElement.appendChild(ul);
|
||||||
}
|
}
|
||||||
|
|
||||||
createListItem(label, id, type, parentId) {
|
getIconByMIME(mime){
|
||||||
|
if(mime.startsWith("image")) return "image";
|
||||||
|
if(mime.startsWith("application/pdf")) return "picture_as_pdf";
|
||||||
|
if(mime.startsWith("application/zip")) return "archive";
|
||||||
|
if(mime.startsWith("application/xml")) return "code";
|
||||||
|
if(mime.match(/tar|compressed|gzip|gz|tgz/)) return 'archive';
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
getIconByExtension(name){
|
||||||
|
const tks = name.split(".")
|
||||||
|
if(tks.length === 0) return null;
|
||||||
|
const ext = tks[tks.length - 1]
|
||||||
|
if(ext.match(/java$|py$|^r$|^c$|ccp|lua|jl|^sh$|json|xml|xsl|xslt|md$|xq$|xqm$/i)) return "code";
|
||||||
|
if(ext.match(/js$/i)) return "javascript";
|
||||||
|
if(ext.match(/html$|css$|php$/i)) return ext;
|
||||||
|
if(ext.match(/kml$/i)) return "place";
|
||||||
|
if(ext.match(/ics$/i)) return "event";
|
||||||
|
if(ext.match(/csv$|xls$|ods$/i)) return "assessment";
|
||||||
|
if(ext.match(/txt$|odt$|rtf$|doc$|docx$/i)) return "description";
|
||||||
|
if(ext.match(/ppt$|odp$/i)) return "slideshow";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
createListItem(item, parentId) {
|
||||||
|
const label = item.displayName ? item.displayName : item.title
|
||||||
|
const id = item.id
|
||||||
|
const type = item["@class"]
|
||||||
|
const mime = item.content && item.content.mimeType ? item.content.mimeType : null
|
||||||
const li = document.createElement('li');
|
const li = document.createElement('li');
|
||||||
li.setAttribute(D4SStorageTree.dataname_attr, label);
|
li.setAttribute(D4SStorageTree.dataname_attr, label);
|
||||||
li.setAttribute(D4SStorageTree.dataid_attr, id);
|
li.setAttribute(D4SStorageTree.dataid_attr, id);
|
||||||
|
@ -434,14 +467,30 @@ class D4SStorageTree extends D4SStorageHtmlElement {
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
li.setAttribute(D4SStorageTree.parentid_attr, parentId);
|
li.setAttribute(D4SStorageTree.parentid_attr, parentId);
|
||||||
}
|
}
|
||||||
const icon = type.includes('FolderItem') || type.includes("SharedFolder")? "folder.svg" : "file-earmark.svg"
|
//const icon = type.includes('FolderItem') || type.includes("SharedFolder")? "folder.svg" : "file-earmark.svg"
|
||||||
|
var icon = "insert_drive_file";
|
||||||
|
if(type.includes('FolderItem')){
|
||||||
|
icon = "folder"
|
||||||
|
}else if(type.includes("SharedFolder")){
|
||||||
|
icon = "folder_shared"
|
||||||
|
}else{
|
||||||
|
const im = mime ? this.getIconByMIME(mime) : null
|
||||||
|
if(im) icon = im;
|
||||||
|
else{
|
||||||
|
const ie = this.getIconByExtension(label)
|
||||||
|
if(ie) icon = ie;
|
||||||
|
}
|
||||||
|
}
|
||||||
li.innerHTML = `
|
li.innerHTML = `
|
||||||
<img class="px-1" src="${this.srcBaseURL}/img/${icon}"</img>
|
<div class="li-title d-flex gap-1">
|
||||||
<span>${label}</span>
|
<span class="material-icons">${icon}</span>
|
||||||
|
<span>${label}</span>
|
||||||
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
li.addEventListener('click', (ev) => {
|
li.addEventListener('click', (ev) => {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
ev.preventDefault()
|
||||||
this.select(ev.currentTarget.getAttribute(D4SStorageTree.dataid_attr));
|
this.select(ev.currentTarget.getAttribute(D4SStorageTree.dataid_attr));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -668,6 +717,7 @@ class D4SStorageFolder extends D4SStorageHtmlElement {
|
||||||
const isFolder = item['@class'].includes('FolderItem')
|
const isFolder = item['@class'].includes('FolderItem')
|
||||||
filename.addEventListener('click', (ev) => {
|
filename.addEventListener('click', (ev) => {
|
||||||
ev.stopPropagation()
|
ev.stopPropagation()
|
||||||
|
ev.preventDefault()
|
||||||
if (isFolder) {
|
if (isFolder) {
|
||||||
const span = ev.currentTarget.querySelector(':nth-child(2)')
|
const span = ev.currentTarget.querySelector(':nth-child(2)')
|
||||||
if (span) {
|
if (span) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<body class="m-4">
|
<body class="m-4">
|
||||||
<d4s-boot-2 context="%2Fgcube%2Fdevsec%2FdevVRE"
|
<d4s-boot-2 context="%2Fgcube%2Fdevsec%2FdevVRE"
|
||||||
gateway="next.d4science.org"
|
gateway="next.dev.d4science.org"
|
||||||
redirect-url="https://cdn.dev.d4science.org/storage/"
|
redirect-url="https://cdn.dev.d4science.org/storage/"
|
||||||
url="https://accounts.dev.d4science.org/auth">
|
url="https://accounts.dev.d4science.org/auth">
|
||||||
<!-- redirect-url="http://localhost:8080/storage/" -->
|
<!-- redirect-url="http://localhost:8080/storage/" -->
|
||||||
|
|
Loading…
Reference in New Issue