Merge pull request 'master' (#9) from master into prod

Reviewed-on: #9
This commit is contained in:
Marco Lettere 2024-02-02 19:10:46 +01:00
commit c4c6c2bb15
2 changed files with 61 additions and 28 deletions

View File

@ -15,9 +15,20 @@ class CCPExecutionForm extends HTMLElement{
this.#rootdoc = this.attachShadow({ "mode" : "open"})
this.connectNewExecutionRequest()
this.render()
const params = new URLSearchParams(window.location.search)
if(params.get('execution')){
const execution = { id : params.get('execution') }
this.prepareFromExecution(execution)
} else if(params.get('method')){
this.#method = params.get('method')
this.loadMethod()
} else {
this.showMethod()
}
}
static get observedAttributes() {
return ["method"];
@ -81,7 +92,7 @@ class CCPExecutionForm extends HTMLElement{
<button id="execute_method_button" class="btn btn-info">Execute</button>
</div>
<div class="col-6">
<div class="">
<div class="mb-3">
<label>Generate code for:</label>
<div class="d-flex">
<select name="language-selector" class="form-control" style="padding:2px">
@ -97,6 +108,12 @@ class CCPExecutionForm extends HTMLElement{
</button>
</div>
</div>
<div>
<label>Direct link</label>
<div class="d-flex">
<a name="direct_link_method" href="${window.location.href}">${window.location.href}</a>
</div>
</div>
</div>
</div>
</form>
@ -387,6 +404,10 @@ class CCPExecutionForm extends HTMLElement{
return false
}
},
{
target: "a[name=direct_link_method]",
apply : (e,d)=>e.href = e.textContent = window.location.origin + window.location.pathname + "?method=" + d.id
}
]
}

View File

@ -119,9 +119,10 @@ class CCPExecutionHistory extends HTMLElement {
<ul>
<li></li>
</ul>
<div class="d-flex justify-content-end" style="gap: 3px;">
<label>Generate code for:</label>
<select name="language-selector" class="form-control" style="max-width:10rem;height:inherit;padding:2px">
<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>
<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>
<option value="application/vnd.jupyter+python" data-ext="ipynb" title="Generate Jupyter notebook with Python 3 cells">Jupyter Python3</option>
@ -133,6 +134,12 @@ class CCPExecutionHistory extends HTMLElement {
</svg>
</button>
</div>
<div class="d-flex align-items-middle" style="gap:5px">
<div class="d-flex">
<a name="direct_link_execution" href="${window.location.href}">${window.location.href}</a>
</div>
</div>
</div>
</details>
</li>
</ul>
@ -158,8 +165,9 @@ class CCPExecutionHistory extends HTMLElement {
<div class="d-flex" 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>
<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>
@ -657,6 +665,10 @@ class CCPExecutionHistory extends HTMLElement {
this.generateCode(id, lang, `${id}.${ext}`)
}
},
{
target : "a[name=direct_link_execution]",
apply : (e,d)=>e.href = e.textContent = window.location.origin + window.location.pathname + "?execution=" + d.id
},
{
target : "div[name=logterminalcontainer]",
apply : (e,d)=>{