Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
69 lines (62 sloc) 2.09 KB
const Spinny = {
view({children}) {
return m('.deadCenter', {style: {'text-align': 'center'}},
m('img', {src: 'spinny.svg'})
m('h3', children));
},
} ;
export const Layout = {
view({attrs:{tenants, tenant}, children}) {
return m('div',
m('nav',
Object.keys(tenants).map((t, key) =>
m('a', {
key,
href: `/${t}/widgets`,
style: `text-decoration: ${(t === tenant) ? 'underline' : 'none'}`,
oncreate: m.route.link,
onupdate: m.route.link,
}, t)),
m('a[href="https://loading.io/spinner/double-ring"]', {style: 'color: yellow'}, 'double ring spinner by loading.io')),
m('main', children));
},
};
export const Login = {
view({attrs: {user, logIn}}) {
return (user)
? m(Spinny, 'Logging in...')
: m('button.deadCenter', {onclick: logIn}, 'Log In');
},
};
export const WidgetsOverview = {
view({attrs: {tenant, tenants, widgets, analytics}}) {
if (!tenant || !widgets) {
return m(Spinny, 'Fetching listing...');
}
return [
m('section', tenants[tenant].map((done) => {
return m('div', {style: 'position:relative'}, (done)
? m('.deadCenter', 'Done')
: m(Spinny, `Crunching for ${tenant}...`));
})),
m('ul', widgets.map((l, key) => {
return m('li', {
key,
onclick: () => m.route.set(`/${tenant}/widgets/${l}`),
}, tenant + ':' + l);
})),
];
},
};
export const ErrorReport = {
view: ({attrs: {err}}) => {
return m('pre', (err || new Error('404')).stack);
},
};
export const WidgetDetail = {
view({attrs: {tenant, focusedWidget}}) {
return m('p', (focusedWidget)
? `Widget ${focusedWidget} for ${tenant}`
: m(Spinny, 'Loading widget...'));
},
};