Skip to content

Commit

Permalink
Merge branch 'Tevemadar:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Tevemadar authored Jan 15, 2025
2 parents 6e83d99 + 453905a commit c67c84a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions startpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function newseries(){
trycollect();
}
function cancel(){
delete state.filename;
document.getElementById("newseries").hidden=true;
startup();
}
Expand Down Expand Up @@ -112,8 +113,10 @@ function tryshow(){
document.getElementById("create").disabled=collection.length===0 || document.getElementById("atlas").selectedIndex===-1;
}

let dziproot;
function clear(){
collection=[];
dziproot=false;
oldisv=false;
tryshow();
}
Expand Down Expand Up @@ -141,6 +144,34 @@ function dzisection(dzi,filename){
document.getElementById("filetable").hidden=true;
const btns=document.getElementById("dzipbuttons");
btns.hidden=true;
const dzip=document.getElementById("dzip").value;
if(dzip){
bucket=document.getElementById("collab").value.replaceAll(/[^-\w().!]/g, "");
const slash=dzip.lastIndexOf("/");
dziproot=slash===-1?"":dzip.substring(0,slash+1);
const dzips=await dpjson(`${bucket}${dziproot.length?`?prefix=${dziproot}&`:"?"}delimiter=/&limit=10000`)
.then(obj=>obj.objects
.filter(item=>item.hasOwnProperty("name")&&item.name.endsWith(".dzip"))
.map(item=>item.name.substring(slash+1)));
// alert(JSON.stringify(dzips));
for(const dzip of dzips){
if(current!==ctime)return;
prg.innerText="Fetching DZI "+(collection.length+1)+"/"+dzips.length;
const zipdir=await netunzip(
()=>dpjson(`${bucket}/${dziproot}${dzip}?redirect=false`).then(json=>json.url));
for(const [_,entry] of zipdir.entries) {
if(entry.name.endsWith(".dzi")) {
const data=await zipdir.get(entry);
if(current!==ctime)return;
const dzi=new TextDecoder().decode(data);
collection.push(dzisection(dzi,dzip));
break;
}
}
}
tryshow();
return;
}
dzipbundles=new Map();
try{
bucket=document.getElementById("collab").value.replaceAll(/[^-\w().!]/g, "");
Expand Down Expand Up @@ -257,6 +288,18 @@ function dzisection(dzi,filename){
}));
tryshow();
}
async function dzip(){
const choice=await dppick({
bucket:document.getElementById("collab").value,
token:state.token,
title:"Pick a DZIP file",
extensions:[".dzip"]
});
if(choice.pick){
document.getElementById("dzip").value=choice.pick;
trycollect();
}
}
async function create(){
document.getElementById("create").disabled=true;
const series={
Expand All @@ -265,6 +308,7 @@ function dzisection(dzi,filename){
};
if(bucket)series.bucket=bucket;
if(oldisv)series.oldisv=oldisv;
if(dziproot!==false)series.dziproot=dziproot;
const upload=await fetch(
`https://data-proxy.ebrains.eu/api/v1/buckets/${state["clb-collab-id"]}/${state.filename}`,{
method: "PUT",
Expand Down Expand Up @@ -294,6 +338,7 @@ function dzisection(dzi,filename){
<div id="filename"></div>
<input oninput="import_link(event)" placeholder="Import LocaliZoom link"><br><br>
Enter name of image-chunk collab: <input id="collab" oninput="trycollect()"><br>
DZIP: <input id="dzip" oninput="trycollect()"> <button onclick="dzip()">Pick...</button><br>
Target atlas:
<select id="atlas" onchange="tryshow()">
<option value="WHS_SD_Rat_v4_39um">WHS SD Rat v4 39um</option>
Expand Down

0 comments on commit c67c84a

Please sign in to comment.