Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a relative base URL to allow hosting of app in OMERO.web #59

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
12 changes: 8 additions & 4 deletions src/dataloaders/DataLoaderUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ async function loadBinaryData(datasource: string, name: string) {
}
//send json args and return json/array buffer response
export async function getPostData(url: string, args, return_type = "json") {
let headers = {
"Accept": "application/json,text/plain,*/*",
"Content-Type": "application/json"
}
if (window["CSRF_TOKEN"]) {
headers["X-CSRFToken"] = window["CSRF_TOKEN"];
}
const resp = await fetch(url, {
method: "POST",
body: JSON.stringify(args),
headers: {
"Accept": "application/json,text/plain,*/*",
"Content-Type": "application/json"
}
headers,
});
if (return_type === "json") {
return await resp.json();
Expand Down
10 changes: 7 additions & 3 deletions src/dataloaders/DataLoaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ function processArrayBuffer(data,columns,size){
function getArrayBufferDataLoader(url){
return async(columns,dataSource,size)=>{
//get the data
let headers = {
"Content-Type": "application/json"
}
if (window["CSRF_TOKEN"]) {
headers["X-CSRFToken"] = window["CSRF_TOKEN"];
}
const response = await fetch(url,{
method:"POST",
body:JSON.stringify({columns:columns,data_source:dataSource}),
headers: {
'Content-Type': 'application/json'
}
headers,
});
//the data is any arraybuffer containing each individual
//column's raw data
Expand Down
3 changes: 2 additions & 1 deletion src/modules/static_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const isPopout = urlParams.get('popout') === "true";
const dir = urlParams.get('dir') || (isPopout ? '' : flaskURL);
const root = dir.endsWith("/") ? dir.substring(0, dir.length-1) : dir;
//hack to load data from local API
const staticFolder = !dir.startsWith("/project");
const staticFolder = !(dir.startsWith("/project") || dir.startsWith("project"));

// set title of page to the data directory
document.title = !staticFolder ? 'MDV - local project' : `MDV - ${root}`;
Expand Down Expand Up @@ -80,5 +80,6 @@ async function loadData() {
});
}, 100);
}

datasources.forEach((ds, i) => extraFeatures(i));
};