Cloud support / Dropbox OAuth reference client (#659)

* bioms shouldn't be masked or the style selection box is useless
* fix: misleading comment
* Fix: calculating absolute flux from precipitation normal-value.
* Fix: River automatic rerender on regeneration.
* Dropbox OAuth implementation and Cloud framework
* add some space
* removing unnecessary logs, defer script load

Created by: Mészáros Gergely <monk@geotronic.hu>
This commit is contained in:
Gergely Mészáros, Ph.D 2021-09-07 22:36:09 +02:00 committed by GitHub
parent f7d72c2255
commit 2d3f465d68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 256 additions and 57 deletions

View file

@ -12,16 +12,34 @@ function quickLoad() {
});
}
function loadFromDropbox() {
const options = {
success: function (files) {
const url = files[0].link;
loadMapFromURL(url);
},
linkType: "direct",
extensions: [".map"]
};
Dropbox.choose(options);
async function loadFromDropbox(fileName) {
const map = document.querySelector("#loadFromDropbox select").value;
console.log('loading dropbox map', map);
const blob = await Cloud.providers.dropbox.load(map);
uploadMap(blob);
}
async function createSharableDropboxLink() {
const mapFile = document.querySelector("#loadFromDropbox select").value;
const sharableLink = document.getElementById("sharableLink");
const sharableLinkContainer = document.getElementById("sharableLinkContainer");
let url
try {
url = await Cloud.providers.dropbox.getLink(mapFile);
} catch {
tip("Dropbox API error. Can not create link.", true, "error", 2000);
return
}
const fmg = window.location.href.split("?")[0];
const reallink= `${fmg}?maplink=${url}`;
// voodoo magic required by the yellow god of CORS
const link = reallink.replace('www.dropbox.com/s/', 'dl.dropboxusercontent.com/1/view/')
const shortLink = link.slice(0, 50) + "...";
sharableLinkContainer.style.display = "block";
sharableLink.innerText = shortLink;
sharableLink.setAttribute("href", link);
}
function loadMapPrompt(blob) {