Show opening/closing animation for three minutes, fixes #10
This commit is contained in:
parent
979a981bfb
commit
4ea76dfcfc
17 changed files with 59 additions and 18 deletions
|
@ -77,7 +77,7 @@
|
|||
<body class="station">
|
||||
<main>
|
||||
<section>
|
||||
<cbase-currentstate timeseries="bar.open" interval="10">bar status</cbase-currentstate>
|
||||
<cbase-currentstate timeseries="bar.open" interval="10" showrecent="3">bar status</cbase-currentstate>
|
||||
</section>
|
||||
<section>
|
||||
<cbase-currentstate timeseries="bar.replicator.1" interval="120">club mate</cbase-currentstate>
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
<cbase-userlist interval="10"></cbase-userlist>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
<cbase-linechart timeseries="powermon.load" width="69" height="40"></cbase-linechart>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -9,6 +9,8 @@ class CurrentState extends Component {
|
|||
unknownword: props.string,
|
||||
status: props.boolean,
|
||||
statusknown: props.boolean,
|
||||
recent: props.boolean,
|
||||
showrecent: props.number,
|
||||
interval: props.number,
|
||||
};
|
||||
|
||||
|
@ -33,17 +35,25 @@ class CurrentState extends Component {
|
|||
}
|
||||
|
||||
fetchData() {
|
||||
const url = `http://openmct.cbrp3.c-base.org/telemetry/latest/${this.timeseries}`;
|
||||
const url = `http://openmct.cbrp3.c-base.org/telemetry/latest/${this.timeseries}?timestamp=true`;
|
||||
fetch(url)
|
||||
.then(data => data.json())
|
||||
.then((data) => {
|
||||
if (data === null) {
|
||||
this.statusknown = false;
|
||||
this.status = false;
|
||||
this.recent = false;
|
||||
return;
|
||||
}
|
||||
this.status = data;
|
||||
this.status = data.value;
|
||||
this.statusknown = true;
|
||||
const now = new Date();
|
||||
const changed = new Date(data.timestamp);
|
||||
if (((now - changed) / 60000) < this.showrecent) {
|
||||
this.recent = true;
|
||||
} else {
|
||||
this.recent = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -53,9 +63,34 @@ class CurrentState extends Component {
|
|||
root.removeChild(root.firstChild);
|
||||
}
|
||||
root.appendChild(render());
|
||||
const styles = document.createElement('style');
|
||||
styles.appendChild(document.createTextNode(`
|
||||
@-webkit-keyframes animaterecenton {
|
||||
from { background-color: #73d216; }
|
||||
to { background-color: #3465a4; }
|
||||
}
|
||||
.animaterecenton {
|
||||
-webkit-animation-name: animaterecenton;
|
||||
-webkit-animation-duration: 0.5s;
|
||||
-webkit-animation-iteration-count:infinite;
|
||||
-webkit-animation-direction: alternate;
|
||||
}
|
||||
@-webkit-keyframes animaterecentoff {
|
||||
from { background-color: #cc0000; }
|
||||
to { background-color: #edd400; }
|
||||
}
|
||||
.animaterecentoff {
|
||||
-webkit-animation-name: animaterecentoff;
|
||||
-webkit-animation-duration: 0.5s;
|
||||
-webkit-animation-iteration-count:infinite;
|
||||
-webkit-animation-direction: alternate;
|
||||
}
|
||||
`));
|
||||
root.appendChild(styles);
|
||||
}
|
||||
|
||||
render({ status, statusknown, trueword, falseword, unknownword }) {
|
||||
console.log(this.showrecent, this.recent);
|
||||
const el = document.createElement('div');
|
||||
el.style.width = '100%';
|
||||
el.style.height = '100%';
|
||||
|
@ -73,11 +108,17 @@ class CurrentState extends Component {
|
|||
if (trueword) {
|
||||
content = `${content} ${trueword}`;
|
||||
}
|
||||
if (this.recent) {
|
||||
el.className = 'animaterecenton';
|
||||
}
|
||||
} else {
|
||||
el.style.backgroundColor = '#cc0000';
|
||||
if (falseword) {
|
||||
content = `${content} ${falseword}`;
|
||||
}
|
||||
if (this.recent) {
|
||||
el.className = 'animaterecentoff';
|
||||
}
|
||||
}
|
||||
el.innerHTML = content;
|
||||
return el;
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
<cbase-userlist interval="10"></cbase-userlist>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
<cbase-linechart timeseries="clima.pm25.mainhall clima.pm25.arboretum" width="34" height="40" references="25 35"></cbase-linechart>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
<cbase-userlist interval="10"></cbase-userlist>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
<cbase-linechart timeseries="crew.online" width="69" height="40"></cbase-linechart>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
<cbase-userlist interval="10"></cbase-userlist>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
<cbase-linechart timeseries="crew.online" width="69" height="40"></cbase-linechart>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
<cbase-userlist interval="10"></cbase-userlist>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
<cbase-linechart timeseries="powermon.load" width="69" height="40"></cbase-linechart>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
<cbase-heatmap timeseries="clima.sound.soundlab" accumulate days="5" width="69" height="40"></cbase-heatmap>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
<cbase-userlist interval="10"></cbase-userlist>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
<cbase-heatmap timeseries="motion.weltenbaulab" accumulate days="5" width="69" height="40"></cbase-heatmap>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
<cbase-mpd mpd="mechblast" interval="2"></cbase-mpd>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
<cbase-linechart timeseries="powermon.load" width="69" height="40"></cbase-linechart>
|
||||
</section>
|
||||
<section id="drinks-status">
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="bar-status" timeseries="bar.open" interval="10" showrecent="3">bar</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-1" timeseries="bar.replicator.2" interval="120">berliner 1</cbase-currentstate>
|
||||
<cbase-currentstate id="replicator-beer-2" timeseries="bar.replicator.3" interval="120">berliner 2</cbase-currentstate>
|
||||
</section>
|
||||
|
|
Loading…
Reference in a new issue