-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #2, Simplify data sources, make id external to properties
- Loading branch information
Showing
8 changed files
with
159 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
Frontend/DashboardsViewer/content/dataSources/BaseDataSource.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,50 @@ | ||
import QtQuick 2.15 | ||
import OpenTeraLibs.UserClient 1.0 | ||
|
||
Item { | ||
id: baseDataSource | ||
property string url: "" // Empty URL | ||
property ListModel model: ListModel { | ||
id: myModel | ||
} | ||
property var params: Object() | ||
property string fieldIdName: "id_" | ||
property string fieldDisplayName: "disp_" | ||
property string iconPath: "qrc:/genericIcon" | ||
property bool autoFetch: false | ||
|
||
signal error(var errorMessage); | ||
|
||
function getAll() { | ||
var reply = UserClient.get(url, params); | ||
|
||
reply.requestSucceeded.connect(function(response, statusCode) { | ||
console.log("Success", response, statusCode); | ||
|
||
//Make sure model is empty | ||
myModel.clear(); | ||
|
||
//Add session | ||
response.forEach(function(item) { | ||
myModel.append(item) | ||
}); | ||
}); | ||
|
||
reply.requestFailed.connect(function(response, statusCode) { | ||
error(response); | ||
console.log("Failed", response, statusCode); | ||
}); | ||
} | ||
|
||
function update() { | ||
getAll(); | ||
} | ||
|
||
Component.onCompleted: function() { | ||
//Get data from user client | ||
if (baseDataSource.autoFetch) | ||
{ | ||
getAll(); | ||
} | ||
} | ||
} |
64 changes: 7 additions & 57 deletions
64
Frontend/DashboardsViewer/content/dataSources/ParticipantListDataSource.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,16 @@ | ||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
import QtQuick.Layouts | ||
import OpenTeraLibs.UserClient 1.0 | ||
import "../delegates" | ||
|
||
Item { | ||
|
||
property string url: "" // Empty URL | ||
property int id_project: 0 // Empty Project | ||
property ListModel model: ListModel { | ||
id: myModel | ||
} | ||
|
||
BaseDataSource { | ||
id: fetch | ||
signal dataReady(var data); | ||
signal error(string message); | ||
signal participantClicked(int id_participant); | ||
|
||
function getAll() { | ||
var params = {"id_project": id_project}; | ||
var reply = UserClient.get(url, params); | ||
|
||
reply.requestSucceeded.connect(function(response, statusCode) { | ||
console.log("Success", response, statusCode); | ||
|
||
//Make sure model is empty | ||
myModel.clear(); | ||
|
||
//Add participants to model | ||
//TODO filter fields | ||
response.forEach(function(item) { | ||
|
||
var filteredItem = {}; | ||
|
||
//Filter fields | ||
filteredItem.participant_name = item.participant_name; | ||
filteredItem.id_participant = item.id_participant; | ||
filteredItem.participant_uuid = item.participant_uuid; | ||
filteredItem.participant_enabled = item.participant_enabled; | ||
filteredItem.id_project = item.id_project; | ||
|
||
myModel.append(filteredItem); | ||
}); | ||
|
||
}); | ||
|
||
reply.requestFailed.connect(function(response, statusCode) { | ||
error(response); | ||
console.log("Failed", response, statusCode); | ||
}); | ||
|
||
} | ||
|
||
function update() { | ||
getAll(); | ||
} | ||
|
||
Component.onCompleted: function() { | ||
//Get data from user client | ||
getAll(); | ||
} | ||
property int id_project: 0 // Empty Project | ||
|
||
params: {"id_project": id_project} | ||
url: "/api/user/participants" | ||
fieldIdName: "id_participant" | ||
fieldDisplayName: "participant_name" | ||
iconPath: "qrc:/genericIcon" | ||
} | ||
|
||
|
57 changes: 7 additions & 50 deletions
57
Frontend/DashboardsViewer/content/dataSources/ParticipantSessionListDataSource.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,15 @@ | ||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
import QtQuick.Layouts | ||
import OpenTeraLibs.UserClient 1.0 | ||
import "../delegates" | ||
|
||
Item { | ||
|
||
property string url: "/api/user/sessions" // Empty URL | ||
property int id_participant: 0 // Empty Participant | ||
property Component delegate: SessionDelegate { | ||
id: myDelegate | ||
} | ||
|
||
property ListModel model: ListModel { | ||
id: myModel | ||
} | ||
|
||
BaseDataSource { | ||
id: fetch | ||
signal dataReady(var data); | ||
signal error(string message); | ||
|
||
|
||
function setParticipant(id) { | ||
id_participant = id; | ||
update(); | ||
} | ||
|
||
|
||
function getAll() { | ||
var params = {"id_participant": id_participant}; | ||
var reply = UserClient.get(url, params); | ||
|
||
reply.requestSucceeded.connect(function(response, statusCode) { | ||
console.log("Success", response, statusCode); | ||
|
||
//Make sure model is empty | ||
myModel.clear(); | ||
|
||
//Add session | ||
response.forEach(function(item) { | ||
myModel.append(item) | ||
}); | ||
}); | ||
|
||
reply.requestFailed.connect(function(response, statusCode) { | ||
error(response); | ||
console.log("Failed", response, statusCode); | ||
}); | ||
|
||
} | ||
|
||
function update() { | ||
getAll(); | ||
} | ||
property int id_participant: 0 // Empty Project | ||
|
||
params: {"id_participant": id_participant} | ||
url: "/api/user/sessions" | ||
fieldIdName: "id_session" | ||
fieldDisplayName: "session_name" | ||
iconPath: "qrc:/genericIcon" | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
Frontend/DashboardsViewer/content/delegates/GenericItemDelegate.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
import QtQuick.Layouts | ||
|
||
Item { | ||
property string fieldIdName: "id_" | ||
property string fieldDisplayName: "disp_" | ||
property string iconPath: "qrc:/genericIcon" | ||
|
||
id: myDelegate | ||
|
||
signal itemClicked(int id); | ||
|
||
Rectangle { | ||
id: myRectangle | ||
width: 500 | ||
height: 80 | ||
color: "#cccccc" | ||
border.color: "black" | ||
border.width: 1 | ||
radius: 5 | ||
|
||
ColumnLayout { | ||
id: columnLayout | ||
anchors.fill: parent | ||
|
||
|
||
// Customize delegate appearance as needed | ||
Text { | ||
height: 20 | ||
text: "Name: " + model[fieldDisplayName] | ||
color: "red" | ||
} | ||
/* | ||
Text { | ||
height: 20 | ||
text: "Enabled: " + participant_enabled | ||
color: "green" | ||
} | ||
Text { | ||
height: 20 | ||
text: "UUID: " + participant_uuid | ||
color: "blue" | ||
} | ||
*/ | ||
} | ||
Component.onCompleted: function() { | ||
console.log("GenericItemDelegate"); | ||
} | ||
|
||
|
||
MouseArea { | ||
id: mouseArea | ||
anchors.fill: parent | ||
onClicked: { | ||
itemClicked(model[fieldIdName]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.