mirror of
https://github.com/zaphar/Heracles.git
synced 2025-07-23 04:29:48 -04:00
feat: support timspan attributes on the element
This commit is contained in:
parent
a36a59b900
commit
9529271b28
@ -18,6 +18,9 @@ class TimeseriesGraph extends HTMLElement {
|
|||||||
#intervalId;
|
#intervalId;
|
||||||
#pollSeconds;
|
#pollSeconds;
|
||||||
#label;
|
#label;
|
||||||
|
#start;
|
||||||
|
#duration;
|
||||||
|
#step_duration;
|
||||||
#targetNode = null;
|
#targetNode = null;
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -46,6 +49,15 @@ class TimeseriesGraph extends HTMLElement {
|
|||||||
case 'label':
|
case 'label':
|
||||||
this.#label = newValue;
|
this.#label = newValue;
|
||||||
break;
|
break;
|
||||||
|
case 'start':
|
||||||
|
this.#start = newValue;
|
||||||
|
break;
|
||||||
|
case 'duration':
|
||||||
|
this.#duration = newValue;
|
||||||
|
break;
|
||||||
|
case 'step-duration':
|
||||||
|
this.#step_duration = newValue;
|
||||||
|
break;
|
||||||
default: // do nothing;
|
default: // do nothing;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -58,6 +70,9 @@ class TimeseriesGraph extends HTMLElement {
|
|||||||
this.#height = this.getAttribute('height') || this.#height;
|
this.#height = this.getAttribute('height') || this.#height;
|
||||||
this.#pollSeconds = this.getAttribute('poll-seconds') || this.#pollSeconds;
|
this.#pollSeconds = this.getAttribute('poll-seconds') || this.#pollSeconds;
|
||||||
this.#label = this.getAttribute('label') || null;
|
this.#label = this.getAttribute('label') || null;
|
||||||
|
this.#start = this.getAttribute('start') || null;
|
||||||
|
this.#duration = this.getAttribute('duration') || null;
|
||||||
|
this.#step_duration = this.getAttribute('step-duration') || null;
|
||||||
this.resetInterval()
|
this.resetInterval()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +108,16 @@ class TimeseriesGraph extends HTMLElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUri() {
|
||||||
|
if (this.#start && this.#duration && this.#step_duration) {
|
||||||
|
return this.#uri + "?start=" + this.#start + "&duration=" + this.#duration + "&step_duration=" + this.#step_duration;
|
||||||
|
} else {
|
||||||
|
return this.#uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fetchData() {
|
async fetchData() {
|
||||||
const response = await fetch(this.#uri);
|
const response = await fetch(this.getUri());
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user