add animation and live update to table and pie widgets

This commit is contained in:
gabryon99 2020-04-22 23:45:04 +02:00
parent 1a0a53c0b4
commit df95482829
6 changed files with 124 additions and 40 deletions

View file

@ -10,16 +10,17 @@ export default class WidgetTemplate {
throw new Error('Cannot instantiate an abstract class!');
}
const intervalTime = params.intervalTime || 0;
this._defaultOptions = {
intervalTime: intervalTime,
widgetKey: params.widgetKey,
widgetName: params.widgetName,
widgetType: params.widgetType,
domId: `ntop-widget-${params.widgetKey}-${params.widgetType}`
widget: params.widget,
domId: `ntop-widget-${params.widget.widgetKey}-${params.widget.widgetType}`
};
this._data = params.data || [];
this._data = params.widget.widgetFetchedData || [];
this._intervalId = 0;
}
async _updateData() {
const response = await this._defaultOptions.widget.getWidgetData();
return response.data;
}
render() {
@ -31,7 +32,7 @@ export default class WidgetTemplate {
if (this._data.length == 0) {
const emptyContainer = document.createElement('div');
emptyContainer.classList = "border p-2";
emptyContainer.innerHTML = `Widget <i>${this._defaultOptions.widgetName}</i>: <b>No data was found.</b>`;
emptyContainer.innerHTML = `Widget <i>${this._defaultOptions.widget.widgetName}</i>: <b>No data was found.</b>`;
container.appendChild(emptyContainer);
}
@ -44,7 +45,6 @@ export class ChartTemplate extends WidgetTemplate {
constructor(params) {
super(params);
this._chart = {};
this._intervalId = 0;
this._width = params.width || 400;
this._height = params.height || 400;
}
@ -53,8 +53,7 @@ export class ChartTemplate extends WidgetTemplate {
if (!nv) throw new Error("NVD3 not found! Do you have included in your page?");
}
_addGraph() {}
_updateData() {}
_addGraph() { }
render() {
this._checkNVSupport();