mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-11 07:11:52 +02:00
[ui] simplify loading of statistics file
* NodeLog: remove intermediate property for Loader * StatViewer * keep only one function to load source file * only send request only after the previous one fully completed * update deltaTime before initializing charts * reset "sourceModified" property when source changes
This commit is contained in:
parent
1822bbe13d
commit
bedda0c5b6
2 changed files with 29 additions and 38 deletions
|
@ -93,11 +93,6 @@ FocusScope {
|
||||||
if(!chunksLV.count || chunksLV.currentChunk)
|
if(!chunksLV.count || chunksLV.currentChunk)
|
||||||
logComponentLoader.source = Filepath.stringToUrl(currentFile);
|
logComponentLoader.source = Filepath.stringToUrl(currentFile);
|
||||||
|
|
||||||
if(currentItem.fileProperty === "statisticsFile") {
|
|
||||||
logComponentLoader.componentNb = 1
|
|
||||||
} else {
|
|
||||||
logComponentLoader.componentNb = 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TabButton {
|
TabButton {
|
||||||
|
@ -123,9 +118,8 @@ FocusScope {
|
||||||
clip: true
|
clip: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
property int componentNb: 0
|
|
||||||
property url source
|
property url source
|
||||||
sourceComponent: componentNb === 0 ? textFileViewerComponent : statViewerComponent
|
sourceComponent: fileSelector.currentItem.fileProperty === "statisticsFile" ? statViewerComponent : textFileViewerComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
|
|
|
@ -15,7 +15,7 @@ Item {
|
||||||
property var sourceModified: undefined
|
property var sourceModified: undefined
|
||||||
property var jsonObject
|
property var jsonObject
|
||||||
property int nbReads: 1
|
property int nbReads: 1
|
||||||
property var deltaTime: 1
|
property real deltaTime: 1
|
||||||
|
|
||||||
property var cpuLineSeries: []
|
property var cpuLineSeries: []
|
||||||
property int nbCores: 0
|
property int nbCores: 0
|
||||||
|
@ -64,47 +64,47 @@ Item {
|
||||||
"#BF360C"
|
"#BF360C"
|
||||||
]
|
]
|
||||||
|
|
||||||
onSourceChanged: function() {
|
onSourceChanged: {
|
||||||
|
sourceModified = undefined;
|
||||||
resetCharts()
|
resetCharts()
|
||||||
readSourceFile()
|
readSourceFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
interval: root.deltaTime * 60000; running: true; repeat: true
|
id: reloadTimer
|
||||||
onTriggered: function() {
|
interval: root.deltaTime * 60000; running: true; repeat: false
|
||||||
var xhr = new XMLHttpRequest;
|
onTriggered: readSourceFile()
|
||||||
xhr.open("GET", source);
|
|
||||||
|
|
||||||
xhr.onreadystatechange = function() {
|
|
||||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
||||||
|
|
||||||
if(sourceModified === undefined || sourceModified < xhr.getResponseHeader('Last-Modified')) {
|
|
||||||
var jsonString = xhr.responseText;
|
|
||||||
|
|
||||||
jsonObject= JSON.parse(jsonString);
|
|
||||||
root.jsonObject = jsonObject;
|
|
||||||
resetCharts()
|
|
||||||
sourceModified = xhr.getResponseHeader('Last-Modified')
|
|
||||||
root.createCharts()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
xhr.send();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function readSourceFile() {
|
function readSourceFile() {
|
||||||
|
if(!Filepath.urlToString(source).endsWith("statistics"))
|
||||||
|
return;
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest;
|
var xhr = new XMLHttpRequest;
|
||||||
xhr.open("GET", source);
|
xhr.open("GET", source);
|
||||||
|
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status == 200) {
|
||||||
var jsonString = xhr.responseText;
|
|
||||||
|
|
||||||
jsonObject= JSON.parse(jsonString);
|
if(sourceModified === undefined || sourceModified < xhr.getResponseHeader('Last-Modified')) {
|
||||||
root.jsonObject = jsonObject;
|
var jsonObject;
|
||||||
|
|
||||||
root.createCharts()
|
try {
|
||||||
|
jsonObject = JSON.parse(xhr.responseText);
|
||||||
|
}
|
||||||
|
catch(exc)
|
||||||
|
{
|
||||||
|
console.warning("Failed to parse statistics file: " + source)
|
||||||
|
root.jsonObject = {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
root.jsonObject = jsonObject;
|
||||||
|
resetCharts();
|
||||||
|
sourceModified = xhr.getResponseHeader('Last-Modified')
|
||||||
|
root.createCharts();
|
||||||
|
reloadTimer.restart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.send();
|
xhr.send();
|
||||||
|
@ -119,16 +119,13 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createCharts() {
|
function createCharts() {
|
||||||
|
root.deltaTime = jsonObject.interval / 60.0;
|
||||||
initCpuChart()
|
initCpuChart()
|
||||||
initRamChart()
|
initRamChart()
|
||||||
initGpuChart()
|
initGpuChart()
|
||||||
|
|
||||||
root.deltaTime = jsonObject.interval /60
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**************************
|
/**************************
|
||||||
*** CPU ***
|
*** CPU ***
|
||||||
**************************/
|
**************************/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue