2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

chartingfrontend: replaced deprecated jsonlist calls with jsonlist2 to be future proof

git-svn-id: https://svn.fhem.de/fhem/trunk@6917 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
johannnes 2014-11-08 13:03:05 +00:00
parent 13b26b28fc
commit d1de37d281
8 changed files with 353 additions and 476 deletions

View File

@ -273,17 +273,17 @@ UPD 2013-03-02_01:53:05 524 www/frontend/app/resources/icons/resultset_last.png
UPD 2013-04-03_07:27:17 733 www/frontend/app/resources/icons/add.png
UPD 2013-04-03_07:27:17 389 www/frontend/app/resources/icons/resultset_previous.png
UPD 2013-06-30_11:47:12 101 www/frontend/app/resources/application.css
UPD 2014-01-12_11:31:30 3028 www/frontend/app/app.js
UPD 2014-11-08_12:33:44 2976 www/frontend/app/app.js
UPD 2013-04-28_02:00:20 1205 www/frontend/app/view/ChartGridPanel.js
UPD 2013-07-07_12:12:08 16201 www/frontend/app/view/DevicePanel.js
UPD 2013-12-26_08:39:37 10257 www/frontend/app/view/TableDataGridPanel.js
UPD 2014-11-08_12:44:55 14475 www/frontend/app/view/DevicePanel.js
UPD 2014-11-08_12:52:12 9085 www/frontend/app/view/TableDataGridPanel.js
UPD 2014-04-23_05:47:51 65039 www/frontend/app/view/LineChartPanel.js
UPD 2014-01-12_12:09:17 5144 www/frontend/app/view/StatusPanel.js
UPD 2014-01-12_12:55:22 10486 www/frontend/app/view/Viewport.js
UPD 2014-01-12_04:44:35 22438 www/frontend/app/controller/MainController.js
UPD 2014-11-08_12:54:06 8578 www/frontend/app/view/Viewport.js
UPD 2014-11-08_01:05:40 20348 www/frontend/app/controller/MainController.js
UPD 2014-01-12_02:49:58 16562 www/frontend/app/controller/StatusController.js
UPD 2014-04-22_07:46:36 111977 www/frontend/app/controller/ChartController.js
UPD 2013-06-30_11:46:54 5415 www/frontend/app/controller/TableDataController.js
UPD 2014-11-08_12:36:47 111652 www/frontend/app/controller/ChartController.js
UPD 2014-11-08_12:53:12 5408 www/frontend/app/controller/TableDataController.js
UPD 2013-04-01_07:04:35 202 www/frontend/app/model/ReadingsModel.js
UPD 2013-04-01_07:04:36 338 www/frontend/app/model/SavedChartsModel.js
UPD 2013-04-01_07:04:34 11535 www/frontend/app/model/ChartModel.js

View File

@ -4,7 +4,7 @@
Ext.Loader.setConfig({
enabled: true,
disableCaching: false,
disableCaching: true,
paths: {
'FHEM': 'app'
}
@ -13,7 +13,7 @@ Ext.Loader.setConfig({
Ext.application({
name: 'FHEM Frontend',
requires: [
'FHEM.view.Viewport'
'FHEM.view.Viewport'
],
controllers: [
@ -27,7 +27,7 @@ Ext.application({
// Gather information from FHEM to display status, devices, etc.
var me = this,
url = '../../../fhem?cmd=jsonlist&XHR=1';
url = '../../../fhem?cmd=jsonlist2&XHR=1';
Ext.Ajax.request({
method: 'GET',
@ -38,22 +38,22 @@ Ext.application({
Ext.getBody().unmask();
try {
FHEM.info = Ext.decode(response.responseText);
FHEM.version = FHEM.info.Results[0].devices[0].ATTR.version;
if (window.location.href.indexOf("frontenddev") > 0) {
FHEM.appPath = 'www/frontenddev/app/';
} else {
FHEM.appPath = 'www/frontend/app/';
}
FHEM.filelogs = [];
Ext.each(FHEM.info.Results, function(result) {
if (result.list === "DbLog" && result.devices[0].NAME) {
FHEM.dblogname = result.devices[0].NAME;
if (result.Internals.TYPE === "DbLog" && result.Internals.NAME) {
FHEM.dblogname = result.Internals.NAME;
}
if (result.list === "FileLog" && result.devices.length > 0) {
FHEM.filelogs = result.devices;
if (result.Internals.TYPE === "FileLog") {
FHEM.filelogs.push(result);
}
});
if ((!FHEM.dblogname || Ext.isEmpty(FHEM.dblogname)) && !FHEM.filelogs) {
if ((!FHEM.dblogname || Ext.isEmpty(FHEM.dblogname)) && Ext.isEmpty(FHEM.filelogs)) {
Ext.Msg.alert("Error", "Could not find a DbLog or FileLog Configuration. Do you have them already defined?");
} else {
Ext.create("FHEM.view.Viewport", {

View File

@ -156,8 +156,8 @@ Ext.define('FHEM.controller.ChartController', {
var fileLogNames = [];
Ext.each(FHEM.filelogs, function(log) {
if (log.REGEXP && log.REGEXP !== "fakelog" && log.NAME !== "") {
var devObj = { "DEVICE": log.NAME};
if (log.Internals.REGEXP && log.Internals.REGEXP !== "fakelog" && log.Internals.NAME !== "") {
var devObj = { "DEVICE": log.Internals.NAME};
fileLogNames.push(devObj);
}
});
@ -200,9 +200,9 @@ Ext.define('FHEM.controller.ChartController', {
logname = selectionArray[0];
}
Ext.each(FHEM.filelogs, function(log) {
if (log.NAME === logname) {
if (log.Internals.NAME === logname) {
// found the filelog entry, getting the logfile to load values
currentlogfile = log.currentlogfile;
currentlogfile = log.Internals.currentlogfile;
return false;
}
});
@ -759,9 +759,9 @@ Ext.define('FHEM.controller.ChartController', {
cmd;
if (logtype && logtype === "filelog") {
Ext.each(FHEM.filelogs, function(log) {
if (log.NAME === device) {
if (log.Internals.NAME === device) {
// found the filelog entry, getting the logfile to load values
currentlogfile = log.currentlogfile;
currentlogfile = log.Internals.currentlogfile;
return false;
}
});
@ -2292,81 +2292,78 @@ Ext.define('FHEM.controller.ChartController', {
* handling the moving of nodes in tree, saving new position of saved charts in db
*/
movenodeintree: function(treeview, action, collidatingrecord) {
var me = this,
unsorted = Ext.ComponentQuery.query('treepanel button[name=unsortedtree]')[0].pressed;
var me = this;
//only save orders when in sorted mode
if (!unsorted) {
Ext.ComponentQuery.query('treepanel')[0].setLoading(true);
var rec = action.records[0],
id = rec.raw.data.ID;
if (rec.raw.data && rec.raw.data.ID &&
(rec.raw.data.TYPE === "savedchart" || rec.raw.data.TYPE === "savedfilelogchart") &&
!rec.raw.data.template) {
var rootNode = this.getMaintreepanel().getRootNode();
rootNode.cascadeBy(function(node) {
if (node.raw && node.raw.data && node.raw.data.ID && node.raw.data.ID === id) {
//updating whole folder to get indexes right
Ext.each(node.parentNode.childNodes, function(node) {
var ownerfolder = node.parentNode.data.text,
index = node.parentNode.indexOf(node);
Ext.ComponentQuery.query('treepanel')[0].setLoading(true);
var rec = action.records[0],
id = rec.raw.data.ID;
if (rec.raw.data && rec.raw.data.ID &&
(rec.raw.data.TYPE === "savedchart" || rec.raw.data.TYPE === "savedfilelogchart") &&
!rec.raw.data.template) {
var rootNode = this.getMaintreepanel().getRootNode();
rootNode.cascadeBy(function(node) {
if (node.raw && node.raw.data && node.raw.data.ID && node.raw.data.ID === id) {
//updating whole folder to get indexes right
Ext.each(node.parentNode.childNodes, function(node) {
var ownerfolder = node.parentNode.data.text,
index = node.parentNode.indexOf(node);
if (node.raw.data && node.raw.data.ID && node.raw.data.VALUE) {
var chartid = node.raw.data.ID,
chartconfig = node.raw.data.VALUE;
chartconfig.parentFolder = ownerfolder;
chartconfig.treeIndex = index;
var encodedchartconfig = Ext.encode(chartconfig),
url = '../../../fhem?cmd=get+' + FHEM.dblogname + '+-+webchart+""+""+""+updatechart+""+""+' + chartid + '+' + encodedchartconfig + '&XHR=1';
if (node.raw.data && node.raw.data.ID && node.raw.data.VALUE) {
var chartid = node.raw.data.ID,
chartconfig = node.raw.data.VALUE;
chartconfig.parentFolder = ownerfolder;
chartconfig.treeIndex = index;
var encodedchartconfig = Ext.encode(chartconfig),
url = '../../../fhem?cmd=get+' + FHEM.dblogname + '+-+webchart+""+""+""+updatechart+""+""+' + chartid + '+' + encodedchartconfig + '&XHR=1';
// check for filelog or dblog
if (node.raw.data.TYPE === "savedfilelogchart") {
// check for filelog or dblog
if (node.raw.data.TYPE === "savedfilelogchart") {
if (Ext.Array.contains(FHEM.filelogcharts, rec.raw.data) === true) {
Ext.Array.remove(FHEM.filelogcharts, rec.raw.data);
var newRec = rec.raw.data;
newRec.parentFolder = ownerfolder;
newRec.treeIndex = index;
FHEM.filelogcharts.push(newRec);
if (Ext.Array.contains(FHEM.filelogcharts, rec.raw.data) === true) {
Ext.Array.remove(FHEM.filelogcharts, rec.raw.data);
var newRec = rec.raw.data;
newRec.parentFolder = ownerfolder;
newRec.treeIndex = index;
FHEM.filelogcharts.push(newRec);
//
me.updateFileLogCharts();
}
} else {
Ext.Ajax.request({
method: 'GET',
disableCaching: false,
url: url,
success: function(response){
Ext.ComponentQuery.query('treepanel')[0].setLoading(false);
var json = Ext.decode(response.responseText);
if (json && json.success === "true" || json.data && json.data.length === 0) {
//be quiet
} else if (json && json.msg) {
Ext.Msg.alert("Error", "The new position could not be saved, error Message is:<br><br>" + json.msg);
} else {
Ext.Msg.alert("Error", "The new position could not be saved!");
}
},
failure: function() {
Ext.ComponentQuery.query('treepanel')[0].setLoading(false);
if (json && json.msg) {
Ext.Msg.alert("Error", "The new position could not be saved, error Message is:<br><br>" + json.msg);
} else {
Ext.Msg.alert("Error", "The new position could not be saved!");
}
}
});
me.updateFileLogCharts();
}
} else {
Ext.Ajax.request({
method: 'GET',
disableCaching: false,
url: url,
success: function(response){
Ext.ComponentQuery.query('treepanel')[0].setLoading(false);
var json = Ext.decode(response.responseText);
if (json && json.success === "true" || json.data && json.data.length === 0) {
//be quiet
} else if (json && json.msg) {
Ext.Msg.alert("Error", "The new position could not be saved, error Message is:<br><br>" + json.msg);
} else {
Ext.Msg.alert("Error", "The new position could not be saved!");
}
},
failure: function() {
Ext.ComponentQuery.query('treepanel')[0].setLoading(false);
if (json && json.msg) {
Ext.Msg.alert("Error", "The new position could not be saved, error Message is:<br><br>" + json.msg);
} else {
Ext.Msg.alert("Error", "The new position could not be saved!");
}
}
});
}
});
}
});
}
}
});
}
});
}
Ext.ComponentQuery.query('treepanel')[0].setLoading(false);
}
});
});

View File

@ -66,12 +66,6 @@ Ext.define('FHEM.controller.MainController', {
'button[name=restartfhem]': {
click: this.restartFhem
},
'button[name=unsortedtree]': {
click: this.setupTree
},
'button[name=sortedtree]': {
click: this.setupTree
},
'panel[name=statuspanel]': {
saveconfig: this.saveObjectToUserConfig
}
@ -88,9 +82,6 @@ Ext.define('FHEM.controller.MainController', {
me.createFHEMPanel();
me.createDevicePanel();
me.createLineChartPanel();
me.createDatabaseTablePanel();
me.showFHEMStatusPanel();
me.getMainviewport().show();
me.getMainviewport().getEl().setOpacity(0);
@ -101,18 +92,16 @@ Ext.define('FHEM.controller.MainController', {
remove: false
});
if (Ext.isDefined(FHEM.version)) {
var sp = this.getStatustextfield();
sp.setText(FHEM.version + "; Frontend Version: 1.0.8 - 2014-01-12");
}
var sp = this.getStatustextfield();
sp.setText("Frontend Version: 1.1.0 - 2014-11-08");
this.setupTree(false);
this.setupTree();
},
/**
* setup west accordion / treepanel
*/
setupTree: function(unsorted) {
setupTree: function() {
var me = this,
rootNode = { text:"root", expanded: true, children: []},
oldRootNode = me.getMaintreepanel().getRootNode();
@ -121,78 +110,50 @@ Ext.define('FHEM.controller.MainController', {
if (oldRootNode) {
oldRootNode.removeAll();
}
if (unsorted && unsorted.name === 'unsortedtree') {
//setup the tree "unsorted"
Ext.each(FHEM.info.Results, function(result) {
if (result.list && !Ext.isEmpty(result.list)) {
if (result.devices && result.devices.length > 0) {
var blacklist = ['dummy', 'notify', 'Global', 'telnet', 'DbLog', 'FileLog', 'FHEMWEB', 'weblink'];
if (Ext.Array.contains(blacklist, result.list)) {
node = {text: result.list, expanded: false, children: []};
} else {
node = {text: result.list, expanded: true, children: []};
//sort / create items by room
var rooms = [];
Ext.each(FHEM.info.Results, function(result) {
// get all rooms
if (result.Attributes && result.Attributes.room) {
var roomArray = result.Attributes.room.split(",");
Ext.each(roomArray, function(room) {
if (!Ext.Array.contains(rooms, room)) {
var roomfolder;
if (room === "Unsorted") {
roomfolder = {text: room, leaf: false, expanded: false, children: []};
rootNode.children.push(roomfolder);
} else if (room !== "hidden") {
roomfolder = {text: room, leaf: false, expanded: true, children: []};
rootNode.children.push(roomfolder);
}
Ext.each(result.devices, function(device) {
var subnode = {text: device.NAME, leaf: true, data: device};
node.children.push(subnode);
}, this);
} else {
node = {text: result.list, leaf: true};
rooms.push(room);
}
rootNode.children.push(node);
});
}
});
Ext.each(FHEM.info.Results, function(result) {
if (result.Attributes && result.Attributes.room && result.Attributes.room !== "hidden") {
//get room
Ext.each(rootNode.children, function(room) {
if (room.text === result.Attributes.room) {
var subnode = {text: result.Internals.NAME, leaf: true, data: result};
room.children.push(subnode);
return false;
}
});
}
});
this.getMaintreepanel().setRootNode(rootNode);
this.addChartsToTree();
} else {
//sort / create items by room
me.getMaintreepanel().setRootNode(rootNode);
var root = me.getMaintreepanel().getRootNode();
Ext.each(FHEM.info.Results, function(result) {
if (result.list && !Ext.isEmpty(result.list)) {
if (result.devices && result.devices.length > 0) {
Ext.each(result.devices, function(device) {
if (device.ATTR && device.ATTR.room) {
//first we check if we have comma separated multiple rooms
var roomArray = device.ATTR.room.split(",");
Ext.each(roomArray, function(room) {
//check if room exists
var resultnode = root.findChild("text", room, true),
subnode = {text: device.NAME, leaf: true, data: device};
if (!resultnode) {
//create roomfolder
var roomfolder;
if (room !== "hidden") {
if (room === "Unsorted") {
roomfolder = {text: room, leaf: false, expanded: false, children: []};
} else {
roomfolder = {text: room, leaf: false, expanded: true, children: []};
}
roomfolder.children.push(subnode);
root.appendChild(roomfolder);
}
} else {
resultnode.appendChild(subnode);
root.appendChild(resultnode);
}
});
}
}, this);
} else {
node = {text: result.list, leaf: true};
root.appendChild(node);
}
}
});
this.addChartsToTree();
}
});
me.getMaintreepanel().setRootNode(rootNode);
this.addChartsToTree();
},
/**
*
*/
addChartsToTree: function() {
//load the saved charts store with configured dblog name
//load the saved charts store with configured dblog name
var me = this,
store = Ext.create('FHEM.store.SavedChartsStore', {});
store.getProxy().url = '../../../fhem?cmd=get+' + FHEM.dblogname + '+-+webchart+""+""+""+getcharts&XHR=1';
@ -212,10 +173,9 @@ Ext.define('FHEM.controller.MainController', {
}
store.each(function(rec) {
var chartchild,
unsortedMode = Ext.ComponentQuery.query('button[name=unsortedtree]')[0].pressed;
var chartchild;
if (!unsortedMode && rec.raw && rec.raw.VALUE && rec.raw.VALUE.parentFolder) {
if (rec.raw && rec.raw.VALUE && rec.raw.VALUE.parentFolder) {
var ownerFolder = rec.raw.VALUE.parentFolder,
index = rec.raw.VALUE.treeIndex,
parentNode = rootNode.findChild("text", ownerFolder, true);
@ -432,10 +392,10 @@ Ext.define('FHEM.controller.MainController', {
Ext.Ajax.request({
method: 'GET',
disableCaching: false,
url: '../../../fhem?cmd=jsonlist&XHR=1',
url: '../../../fhem?cmd=jsonlist2&XHR=1',
success: function(response){
if (response.responseText !== "Unknown command JsonList, try help↵") {
if (response.responseText !== "Unknown command JsonList2, try help↵") {
//restarting the frontend
window.location.reload();
} else {
@ -528,12 +488,12 @@ Ext.define('FHEM.controller.MainController', {
if (record.raw.leaf === true) {
var panel = Ext.ComponentQuery.query('devicepanel')[0];
var title;
if (record.raw.ATTR &&
record.raw.ATTR.alias &&
!Ext.isEmpty(record.raw.ATTR.alias)) {
title = record.raw.data.ATTR.alias;
if (record.raw.data.Attributes &&
record.raw.data.Attributes.alias &&
!Ext.isEmpty(record.raw.data.Attributes.alias)) {
title = record.raw.data.Attributes.alias;
} else {
title = record.raw.data.NAME;
title = record.raw.data.Internals.NAME;
}
panel.setTitle(title);
panel.record = record;
@ -564,6 +524,10 @@ Ext.define('FHEM.controller.MainController', {
*/
showLineChartPanel: function() {
var panel = Ext.ComponentQuery.query('linechartpanel')[0];
if (!panel) {
this.createLineChartPanel();
panel = Ext.ComponentQuery.query('linechartpanel')[0];
}
this.hideCenterPanels();
panel.show();
},
@ -602,6 +566,10 @@ Ext.define('FHEM.controller.MainController', {
*/
showDatabaseTablePanel: function() {
var panel = Ext.ComponentQuery.query('tabledatagridpanel')[0];
if (!panel) {
this.createDatabaseTablePanel();
panel = Ext.ComponentQuery.query('tabledatagridpanel')[0];
}
this.hideCenterPanels();
panel.show();
},

View File

@ -36,7 +36,7 @@ Ext.define('FHEM.controller.TableDataController', {
checkedradio = Ext.ComponentQuery.query('radiogroup[name=tddynamictime]')[0],
starttimepicker = Ext.ComponentQuery.query('datefield[name=tdstarttimepicker]')[0],
endtimepicker = Ext.ComponentQuery.query('datefield[name=tdendtimepicker]')[0],
gridpanel = Ext.ComponentQuery.query('gridpanel[name=tabledatagridpanel]')[0];
gridpanel = Ext.ComponentQuery.query('gridpanel[name=tdgridpanel]')[0];
//check if timerange or dynamic time should be used
checkedradio.eachBox(function(box, idx){

View File

@ -132,7 +132,7 @@ Ext.define('FHEM.view.DevicePanel', {
// Starting a task to update the device readings
var task = {
run: function(){
me.getDeviceData(me.record.raw.data.NAME);
me.getDeviceData(me.title);
},
interval: 5000 //5 seconds
};
@ -150,7 +150,7 @@ Ext.define('FHEM.view.DevicePanel', {
*/
sendCommand: function(command, value) {
var me = this,
url = '../../../fhem?cmd=set ' + me.record.raw.data.NAME + ' '+ command;
url = '../../../fhem?cmd=set ' + me.record.raw.data.Internals.NAME + ' '+ command;
if (value && !Ext.isEmpty(value)) {
url += ' ' + value;
@ -189,7 +189,7 @@ Ext.define('FHEM.view.DevicePanel', {
// trigger an update nearly immediately to set new values
var task = new Ext.util.DelayedTask(function(){
me.getDeviceData(me.record.raw.data.NAME);
me.getDeviceData(me.record.raw.data.Internals.NAME);
});
task.delay(1000);
@ -209,20 +209,12 @@ Ext.define('FHEM.view.DevicePanel', {
updateControls: function(results) {
var me = this,
allSets = results.sets,
allSets = [],
controlfieldset = me.down('panel[name=container] fieldset[name=controlfieldset]');
if (controlfieldset.items.length <= 0) {
if (results.ATTR.webCmd) {
Ext.each(results.sets, function(set) {
var split = set.split(":");
if (split[0] === results.ATTR.webCmd) {
// overriding all sets as we only need the user defined webcmd now
allSets = set;
}
});
}
allSets = results.PossibleSets.split(" ");
Ext.each(allSets, function(set) {
//check for button / slider
@ -256,12 +248,10 @@ Ext.define('FHEM.view.DevicePanel', {
});
var current;
Ext.each(results.READINGS, function(reading) {
Ext.iterate(reading, function(k,v) {
if (k === text) {
current = v;
}
});
Ext.iterate(results.Readings, function(k,v) {
if (k === text) {
current = v.Value;
}
});
var combo = Ext.create('Ext.form.ComboBox', {
@ -285,12 +275,10 @@ Ext.define('FHEM.view.DevicePanel', {
Ext.each(splitvals, function(val) {
var pressed = false;
Ext.each(results.READINGS, function(reading) {
Ext.iterate(reading, function(k,v) {
if (k === text && v === val || k === text && val === "0" && v === "null") {
pressed = true;
}
});
Ext.iterate(results.Readings, function(k,v) {
if (k === text && v.Value === val || k === text && val === "0" && v.Value === "null") {
pressed = true;
}
});
var control = Ext.create('Ext.button.Button', {
@ -323,12 +311,10 @@ Ext.define('FHEM.view.DevicePanel', {
var xtype = item.getXType(),
current;
Ext.each(results.READINGS, function(reading) {
Ext.iterate(reading, function(k,v) {
if (k === subfieldset.title) {
current = v;
}
});
Ext.iterate(results.Readings, function(k,v) {
if (k === subfieldset.title) {
current = v.Value;
}
});
if (xtype === "combobox") {
@ -358,67 +344,45 @@ Ext.define('FHEM.view.DevicePanel', {
var me = this,
devicedata = [],
readingsdata = [],
devicegrid = me.down('panel[name=container] grid[name=devicedata]'),
devicestore = devicegrid.getStore(),
readingsgrid = me.down('panel[name=container] grid[name=readingsgrid]'),
readingsstore = readingsgrid.getStore();
Ext.iterate(readings, function(key, value) {
if (key !== 'ATTR' && key !== 'attrs' &&
key !== 'ATTRIBUTES' && key !== 'sets' &&
key !== 'READINGS' && key !== 'CHANGETIME') {
if (typeof value === "object") {
Ext.iterate(value, function(k, v) {
var obj = {
key: k,
value: v
};
devicedata.push(obj);
});
} else {
var obj = {
key: key,
value: value
};
devicedata.push(obj);
}
}
Ext.iterate(readings.Internals, function(k, v) {
var obj = {
key: k,
value: v
};
devicedata.push(obj);
});
devicestore.loadData(devicedata);
var readingcollection = readings.READINGS,
readingsdata = [];
Ext.each(readingcollection, function(readings) {
Ext.each(readings, function(reading) {
Ext.iterate(reading, function(key, value) {
var obj;
if (typeof value === "object") {
obj = {
key: key,
value: value.VAL,
measured: value.TIME
};
readingsdata.push(obj);
} else if (key !== "measured") {
obj = {
key: key,
value: value,
measured: ''
};
readingsdata.push(obj);
} else {
// as the measured time belongs to the last dataset, we merge it..
readingsdata[readingsdata.length - 1].measured = value;
}
});
});
Ext.iterate(readings.Readings, function(key, value) {
var obj;
if (typeof value === "object") {
obj = {
key: key,
value: value.Value,
measured: value.Time
};
readingsdata.push(obj);
} else if (key !== "measured") {
obj = {
key: key,
value: value,
measured: ''
};
readingsdata.push(obj);
} else {
// as the measured time belongs to the last dataset, we merge it..
readingsdata[readingsdata.length - 1].measured = value;
}
});
readingsstore.loadData(readingsdata);
@ -432,7 +396,7 @@ Ext.define('FHEM.view.DevicePanel', {
Ext.Ajax.request({
method: 'GET',
disableCaching: false,
url: '../../../fhem?cmd=jsonlist&XHR=1',
url: '../../../fhem?cmd=jsonlist2&XHR=1',
scope: me,
success: function(response){
me.setLoading(false);
@ -441,11 +405,10 @@ Ext.define('FHEM.view.DevicePanel', {
var devicejson;
Ext.each(json.Results, function(result) {
Ext.each(result.devices, function(device) {
if (device.NAME === name) {
devicejson = device;
}
});
if (result.Internals.NAME === name) {
devicejson = result;
return false;
}
});
if (devicejson && devicejson !== "") {
me.updateControls(devicejson);

View File

@ -10,6 +10,10 @@ Ext.define('FHEM.view.TableDataGridPanel', {
title: 'Table Data',
layout: 'fit',
height: '100%',
/**
*
*/
@ -17,7 +21,9 @@ Ext.define('FHEM.view.TableDataGridPanel', {
var me = this;
me.callParent(arguments);
if (!FHEM.dblogname) {
Ext.Msg.alert("Error", "This function is currently only available to users of DbLog!");
}
me.tablestore = Ext.create('FHEM.store.TableDataStore');
@ -35,180 +41,163 @@ Ext.define('FHEM.view.TableDataGridPanel', {
},
autoLoad: false
});
me.on("afterlayout", function() {
if (!FHEM.dblogname) {
Ext.Msg.alert("Error", "This function is currently only available to users of DbLog!");
}
me.devicestore.load();
me.devicestore.load();
me.add(
{
xtype: 'fieldset',
title: 'Configure Database Query',
maxHeight: 165,
items: [
{
xtype: 'fieldset',
layout: 'column',
defaults: {
margin: '5 5 5 10'
},
items: [
{
xtype: 'combobox',
name: 'tddevicecombo',
fieldLabel: 'Select Device',
labelWidth: 90,
store: me.devicestore,
allowBlank: false,
queryMode: 'local',
displayField: 'DEVICE',
valueField: 'DEVICE',
listeners: {
select: function(combo) {
var device = combo.getValue(),
readingscombo = combo.up().down('combobox[name=tdreadingscombo]'),
readingsstore = readingscombo.getStore(),
readingsproxy = readingsstore.getProxy();
readingsproxy.url = '../../../fhem?cmd=get+' + FHEM.dblogname + '+-+webchart+""+""+' + device + '+getreadings&XHR=1';
readingsstore.load();
readingscombo.setDisabled(false);
}
}
},
{
xtype: 'combobox',
name: 'tdreadingscombo',
fieldLabel: 'Select Reading',
allowBlank: false,
disabled: true,
labelWidth: 90,
inputWidth: 110,
store: Ext.create('FHEM.store.ReadingsStore', {
proxy: {
type: 'ajax',
method: 'POST',
url: '../../../fhem?cmd=get+' + FHEM.dblogname + '+-+webchart+""+""+-+getreadings&XHR=1',
reader: {
type: 'json',
root: 'data',
totalProperty: 'totalCount'
}
},
autoLoad: false
}),
displayField: 'READING',
valueField: 'READING'
}
]
me.items = [
{
xtype: 'fieldset',
title: 'Configure Database Query',
maxHeight: 165,
items: [
{
xtype: 'fieldset',
layout: 'column',
defaults: {
margin: '5 5 5 10'
},
{
xtype: 'fieldset',
layout: 'column',
title: 'Select Timerange',
defaults: {
margin: '0 0 0 10'
},
items: [
{
xtype: 'radiofield',
fieldLabel: 'Timerange',
labelWidth: 60,
name: 'tdrb',
checked: true,
inputValue: 'timerange',
listeners: {
change: function(tdrb, newval, oldval) {
if (newval === false) {
tdrb.up().down('datefield[name=tdstarttimepicker]').setDisabled(true);
tdrb.up().down('datefield[name=tdendtimepicker]').setDisabled(true);
} else {
tdrb.up().down('datefield[name=tdstarttimepicker]').setDisabled(false);
tdrb.up().down('datefield[name=tdendtimepicker]').setDisabled(false);
}
}
items: [
{
xtype: 'combobox',
name: 'tddevicecombo',
fieldLabel: 'Select Device',
labelWidth: 90,
store: me.devicestore,
allowBlank: false,
queryMode: 'local',
displayField: 'DEVICE',
valueField: 'DEVICE',
listeners: {
select: function(combo) {
var device = combo.getValue(),
readingscombo = combo.up().down('combobox[name=tdreadingscombo]'),
readingsstore = readingscombo.getStore(),
readingsproxy = readingsstore.getProxy();
readingsproxy.url = '../../../fhem?cmd=get+' + FHEM.dblogname + '+-+webchart+""+""+' + device + '+getreadings&XHR=1';
readingsstore.load();
readingscombo.setDisabled(false);
}
},
{
xtype: 'datefield',
name: 'tdstarttimepicker',
format: 'Y-m-d H:i:s',
fieldLabel: 'Starttime',
allowBlank: false,
labelWidth: 70
},
{
xtype: 'datefield',
name: 'tdendtimepicker',
format: 'Y-m-d H:i:s',
fieldLabel: 'Endtime',
allowBlank: false,
labelWidth: 70
},
{
xtype: 'radiogroup',
name: 'tddynamictime',
fieldLabel: 'or select a dynamic time',
labelWidth: 140,
allowBlank: true,
defaults: {
labelWidth: 42,
padding: "0 25px 0 0",
checked: false
}
},
{
xtype: 'combobox',
name: 'tdreadingscombo',
fieldLabel: 'Select Reading',
allowBlank: false,
disabled: true,
labelWidth: 90,
inputWidth: 110,
store: Ext.create('FHEM.store.ReadingsStore', {
proxy: {
type: 'ajax',
method: 'POST',
url: '../../../fhem?cmd=get+' + FHEM.dblogname + '+-+webchart+""+""+-+getreadings&XHR=1',
reader: {
type: 'json',
root: 'data',
totalProperty: 'totalCount'
}
},
items: [
{ fieldLabel: 'yearly', name: 'tdrb', inputValue: 'year' },
{ fieldLabel: 'monthly', name: 'tdrb', inputValue: 'month' },
{ fieldLabel: 'weekly', name: 'tdrb', inputValue: 'week' },
{ fieldLabel: 'daily', name: 'tdrb', inputValue: 'day' },
{ fieldLabel: 'hourly', name: 'tdrb', inputValue: 'hour' }
]
}
]
autoLoad: false
}),
displayField: 'READING',
valueField: 'READING'
}
]
},
{
xtype: 'fieldset',
layout: 'column',
title: 'Select Timerange',
defaults: {
margin: '0 0 0 10'
},
{
xtype: 'button',
text: 'Apply Filter',
name: 'applytablefilter',
width: '120'
}
]
},
{
xtype: 'gridpanel',
maxHeight: me.up().getHeight() - 290,
name: 'tabledatagridpanel',
store: me.tablestore,
width: '100%',
loadMask: true,
selModel: {
pruneRemoved: false
items: [
{
xtype: 'radiofield',
fieldLabel: 'Timerange',
labelWidth: 60,
name: 'tdrb',
checked: true,
inputValue: 'timerange',
listeners: {
change: function(tdrb, newval, oldval) {
if (newval === false) {
tdrb.up().down('datefield[name=tdstarttimepicker]').setDisabled(true);
tdrb.up().down('datefield[name=tdendtimepicker]').setDisabled(true);
} else {
tdrb.up().down('datefield[name=tdstarttimepicker]').setDisabled(false);
tdrb.up().down('datefield[name=tdendtimepicker]').setDisabled(false);
}
}
}
},
{
xtype: 'datefield',
name: 'tdstarttimepicker',
format: 'Y-m-d H:i:s',
fieldLabel: 'Starttime',
allowBlank: false,
labelWidth: 70
},
{
xtype: 'datefield',
name: 'tdendtimepicker',
format: 'Y-m-d H:i:s',
fieldLabel: 'Endtime',
allowBlank: false,
labelWidth: 70
},
{
xtype: 'radiogroup',
name: 'tddynamictime',
fieldLabel: 'or select a dynamic time',
labelWidth: 140,
allowBlank: true,
defaults: {
labelWidth: 42,
padding: "0 25px 0 0",
checked: false
},
items: [
{ fieldLabel: 'yearly', name: 'tdrb', inputValue: 'year' },
{ fieldLabel: 'monthly', name: 'tdrb', inputValue: 'month' },
{ fieldLabel: 'weekly', name: 'tdrb', inputValue: 'week' },
{ fieldLabel: 'daily', name: 'tdrb', inputValue: 'day' },
{ fieldLabel: 'hourly', name: 'tdrb', inputValue: 'hour' }
]
}
]
},
multiSelect: true,
viewConfig: {
trackOver: false
},
verticalScroller:{
//trailingBufferZone: 20, // Keep 200 records buffered in memory behind scroll
//leadingBufferZone: 50 // Keep 5000 records buffered in memory ahead of scroll
},
columns: [
{ text: 'TIMESTAMP', dataIndex: 'TIMESTAMP', width: 240, sortable: false },
{ text: 'DEVICE', dataIndex: 'DEVICE', width: '10%', sortable: false },
{ text: 'TYPE', dataIndex: 'TYPE', width: '7%', sortable: false },
{ text: 'EVENT', dataIndex: 'EVENT', width: '20%', sortable: false },
{ text: 'READING', dataIndex: 'READING', width: '12%', sortable: false },
{ text: 'VALUE', dataIndex: 'VALUE', width: '20%', sortable: false },
{ text: 'UNIT', dataIndex: 'UNIT', width: '5%', sortable: false }
]
}
);
}, me, {single: true});
{
xtype: 'button',
text: 'Apply Filter',
name: 'applytablefilter',
width: '120'
}
]
},
{
xtype: 'gridpanel',
name: 'tdgridpanel',
title: 'Data',
collapsible: true,
titleCoolapse: true,
store: me.tablestore,
loadMask: true,
columns: [
{ text: 'TIMESTAMP', dataIndex: 'TIMESTAMP', width: 240, sortable: false },
{ text: 'DEVICE', dataIndex: 'DEVICE', width: '10%', sortable: false },
{ text: 'TYPE', dataIndex: 'TYPE', width: '7%', sortable: false },
{ text: 'EVENT', dataIndex: 'EVENT', width: '20%', sortable: false },
{ text: 'READING', dataIndex: 'READING', width: '12%', sortable: false },
{ text: 'VALUE', dataIndex: 'VALUE', width: '20%', sortable: false },
{ text: 'UNIT', dataIndex: 'UNIT', width: '5%', sortable: false }
]
}
];
me.callParent(arguments);
}
});

View File

@ -138,23 +138,6 @@ Ext.define('FHEM.view.Viewport', {
"true",
"children": []
},
tbar: [
{
xtype: 'button',
name: 'unsortedtree',
toggleGroup: 'treeorder',
allowDepress: false,
text: 'Unsorted'
},
{
xtype: 'button',
name: 'sortedtree',
toggleGroup: 'treeorder',
allowDepress: false,
text: 'Order by Room',
pressed: true
}
],
listeners: {
'itemcontextmenu': function(scope, rec, item, index, e, eOpts) {
e.preventDefault();
@ -208,29 +191,6 @@ Ext.define('FHEM.view.Viewport', {
{
xtype: 'statuspanel'
}
// {
// region: 'center',
// title: 'Welcome',
// layout: 'hbox',
// bodyStyle: 'padding:5px 5px 0',
// items: [
// {
// xtype: 'image',
// src: '../../fhem/images/default/fhemicon.png',
// height: 132,
// width: 120
// },
// {
// xtype: 'text',
// name: 'statustextfield',
// padding: '50 0 0 20',
// width: 400,
// height: 130,
// html: '<br>Welcome to the new FHEM Frontend.<br>For Informations, Problems and discussion, visit the <a href="http://forum.fhem.de/index.php?t=msg&th=10439&start=0&rid=0">FHEM Forums</a>'
// }
// ],
// height: '100%'
// }
]
});