Published
Edited
May 19, 2020
Insert cell
Insert cell
Insert cell
btn = {
const qs = '?google-scope=' + scope.replace('\n', ' ');
const url = scope !== '' ? authUrl + qs : authUrl;
const button = `<button style="" name=auth>Open Auth page</button>`;
const form = html`<form onsubmit="return false;">${button}</form>`;
form.auth.onclick = () => {
mutable win = window.open(url, '_blank');
};
return form;
}
Insert cell
Insert cell
Generators.observe(notify => {
const message = evt => {
if (evt.origin === authOrigin) {
if (evt.data === "url") {
win.postMessage({ url }, "*");
}
if (evt.data.updateCreds) {
const data = evt.data.updateCreds;
for (let k of Object.keys(data)) mutable creds[k] = data[k];
const a = publishAlert();
const k = writeKey(creds);
notify(data);
}
}
};
addEventListener("message", message);
return () => removeEventListener("message", message);
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
publishAlert = async () => {
const variables = {
channel: alert,
name: 'new-token',
value: 'read-key'
};
const opts = { fetchPolicy: 'no-cache' };
return await b.actions.publish({ client, variables, opts, raw: false });
}
Insert cell
writeKey = async creds => {
const variables = {
channel: alert,
name: key,
add_histo: false,
expiry: 1,
value: JSON.stringify(creds)
};
const opts = { fetchPolicy: 'no-cache' };
return await b.actions.write({ client, variables, opts, raw: false });
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more