removed unused views
parent
4a6c7fce74
commit
25f20a1ada
|
@ -1,19 +0,0 @@
|
|||
const m = require('mithril');
|
||||
|
||||
const BatteryView = {
|
||||
view: function(vnode) {
|
||||
if (vnode.attrs.percent === undefined) return null;
|
||||
let classes = [];
|
||||
if (vnode.attrs.is_charging) classes.push("is-charging");
|
||||
if (vnode.attrs.percent <= 20) classes.push("is-danger");
|
||||
else if (vnode.attrs.percent <= 40) classes.push("is-warning");
|
||||
return m('.battery-status', { class: classes.join(" ") }, [
|
||||
m('progress', {
|
||||
value:(vnode.attrs.percent || null),
|
||||
max:"100"
|
||||
}, vnode.attrs.percent)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BatteryView;
|
|
@ -1,65 +0,0 @@
|
|||
const m = require('mithril');
|
||||
const Weather = require('../models/weather');
|
||||
const BatteryView = require('./BatteryView.js');
|
||||
|
||||
var CurrentView = {
|
||||
|
||||
intervalID: null,
|
||||
autorefresh_enabled: true,
|
||||
oninit: function() {
|
||||
CurrentView.intervalID = setInterval(CurrentView.autorefresh, 30000);
|
||||
return Weather.loadCurrent();
|
||||
},
|
||||
view: function() {
|
||||
|
||||
let timeHeading = null;
|
||||
if (Weather.current !== null && Weather.current.time) {
|
||||
const currentTime = new Date(Weather.current.time*1000);
|
||||
timeHeading = m('h2.subtitle',
|
||||
'as of ' + currentTime.toLocaleString()
|
||||
);
|
||||
}
|
||||
|
||||
return m('div.section', [m('div.container',
|
||||
(Weather.current == null) ? [m('.notification', 'Loading current conditions...')] : [
|
||||
m('h1.title', 'Current Conditions'),
|
||||
timeHeading,
|
||||
m('.level', [
|
||||
m('.level-item.has-text-centered', m("div",[
|
||||
m('p.heading"', 'Temperature'),
|
||||
m('p.title', Weather.current.temperature + ' °C')
|
||||
])),
|
||||
m('.level-item.has-text-centered', m("div",[
|
||||
m('p.heading"', 'Pressure'),
|
||||
m('p.title', Weather.current.pressure + ' mbar')
|
||||
])),
|
||||
m('.level-item.has-text-centered', m("div",[
|
||||
m('p.heading"', 'Humidity'),
|
||||
m('p.title', Weather.current.humidity + '%')
|
||||
])),
|
||||
]),
|
||||
m('.field.is-grouped', [
|
||||
m('.control', m('button.button.is-small', {
|
||||
disabled: CurrentView.autorefresh_enabled,
|
||||
onclick: CurrentView.refresh
|
||||
}, 'Refresh')),
|
||||
m('.control', m('label.checkbox', [ m('input[type=checkbox]',{
|
||||
checked: CurrentView.autorefresh_enabled,
|
||||
onchange: function(e) { CurrentView.autorefresh_enabled = e.target.checked; }
|
||||
}), " Auto"])),
|
||||
m('.control', m(BatteryView, { ...Weather.current.battery })),
|
||||
])
|
||||
])]);
|
||||
},
|
||||
|
||||
autorefresh: function() {
|
||||
if (CurrentView.autorefresh_enabled) CurrentView.refresh();
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
Weather.loadCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = CurrentView;
|
Loading…
Reference in New Issue