forked from Tevemadar/meshview-demo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtoken.php
90 lines (88 loc) · 3.38 KB
/
token.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
ob_start();
$token_params = http_build_query(array(
"grant_type" => "authorization_code",
"code" => filter_input(INPUT_GET, "code"),
"redirect_uri" => getenv("ebrains_redirect_mv"),
"client_id" => getenv("ebrains_id_mv"),
"client_secret" => getenv("ebrains_secret_mv")
));
$token_ch = curl_init(getenv("ebrains_token"));
curl_setopt_array($token_ch, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $token_params
));
$token_res = curl_exec($token_ch);
curl_close($token_ch);
$token_obj = json_decode($token_res, true);
$token = $token_obj["access_token"];
$json= json_decode(urldecode(filter_input(INPUT_GET, "state")), true);
$json["token"]=$token;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link href="style.css" rel="stylesheet">
<script src="mesh.js"></script>
<script src="points.js"></script>
<script src="shaders.js"></script>
<script src="matrix.js"></script>
<script src="main.js"></script>
<script src="dppick.js"></script>
<script src="netunzip.js"></script>
<script src="inflater.js"></script>
<script src="cloudloaders.js"></script>
<script>
const state=<?php echo json_encode($json);?>;
async function startup(){
const pre=document.getElementsByTagName("pre")[0];
pre.innerText="";
const choice=await dppick({
bucket:state["clb-collab-id"],
token:state.token,
title:"Select Nutil result pack or LocaliZoom file",
extensions:[".zip",".lz"],
nocancel:true
});
if(choice.pick.endsWith(".lz")){
const data=await loadlz(choice.pick);
atlasroot=atlasorg=data.lz.atlas;
document.body.innerHTML=await fetch("body.html").then(response=>response.text());
collab={filename:data.filename,json:data.cloud};
startmv();
return;
}
let {label,json,update,stop}=await loadzip(choice.pick,pre);
label={
"Allen Mouse Brain 2015":"ABA_Mouse_CCFv3_2015_25um",
"Allen Mouse Brain 2017":"ABA_Mouse_CCFv3_2017_25um",
"WHS Atlas Rat v2":"WHS_SD_Rat_v2_39um",
"WHS Atlas Rat v3":"WHS_SD_Rat_v3_39um",
"WHS Atlas Rat v4":"WHS_SD_Rat_v4_39um"
}[label];
if(label && json){
update("Starting MeshView ");
atlasroot=atlasorg=label;
document.body.innerHTML=await fetch("body.html").then(response=>response.text());
collab={filename:choice.pick,json};
stop();
startmv();
}else{
stop();
requestAnimationFrame(()=>{
requestAnimationFrame(()=>{
alert(choice.pick+" does not contain MeshView point cloud.");
startup();
});
});
}
}
</script>
</head>
<body onload="startup()">
<pre></pre>
</body>
</html>