Skip to content

Commit

Permalink
Refs #2, Starting work on session information.
Browse files Browse the repository at this point in the history
  • Loading branch information
doumdi committed Mar 12, 2024
1 parent 1d3a2ae commit 8d42927
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BaseDataSource {
id: fetch
property int id_project: 0 // Empty Project

params: {"id_project": id_project, "list": true}
params: {"id_project": id_project, "full": true}
url: "/api/user/participants"
fieldIdName: "id_participant"
fieldDisplayName: "participant_name"
Expand Down
53 changes: 42 additions & 11 deletions Frontend/DashboardsViewer/content/delegates/ParticipantDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 2.15


Item {
id: myDelegate

signal participantClicked(int id);
height: parent ? 80 : 0
width: parent ? parent.width : 0

Rectangle {
id: myRectangle
width: 500
height: 80
anchors.fill: parent
color: "#cccccc"
border.color: "black"
border.width: 1
Expand All @@ -25,34 +23,67 @@ Item {
// Customize delegate appearance as needed
Text {
height: 20
Layout.fillWidth: true
text: "Name: " + participant_name
color: "red"
}

Text {
height: 20
Layout.fillWidth: true
text: "Enabled: " + participant_enabled
color: "green"
}

Text {
height: 20
Layout.fillWidth: true
text: "UUID: " + participant_uuid
color: "blue"
}

}
Component.onCompleted: function() {
// Look for last_session
if (model.participant_lastsession) {
var lastSession = new Date(model.participant_lastsession)
if (lastSession) {
var now = new Date()
var diff = now - lastSession

// Difference less than a day ?
if (diff < 1000 * 60 * 60 * 24) {
console.log("Less than a day")
myRectangle.color = "green"
}
else {
console.log("More than a day")
// Less than a week ?
if (diff < 1000 * 60 * 60 * 24 * 7) {
console.log("Less than a week")
myRectangle.color = "orange"
}
else {
console.log("More than a week")
myRectangle.color = "red"
}
}
}
else {
console.log("Invalid date")
myRectangle.color = "red"
}
}
}


MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
console.log("Clicked on: " + participant_name);
console.log("Id participant", id_participant);
console.log("Id project", id_project)
participantClicked(id_participant);
console.log("GenericItemDelegate clicked.")
model.dataSource.itemSelected(model[model.dataSource.fieldIdName])
}
}

}
} // Component
}
46 changes: 45 additions & 1 deletion Frontend/DashboardsViewer/content/delegates/SessionDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ Item {
Layout.fillWidth: true
}

Text {
id: text2
text: session_start_datetime + " Duration: " + session_duration
font.bold: true
font.pixelSize: 20
color: "black"
height: parent.height
Layout.fillWidth: true
}

}

MouseArea {
Expand All @@ -39,4 +49,38 @@ Item {
}
}
}
} // Component

Component.onCompleted: function() {
// Look for last_session
if (model.session_start_datetime) {
var lastSession = new Date(model.session_start_datetime)
if (lastSession) {
var now = new Date()
var diff = now - lastSession

// Difference less than a day ?
if (diff < 1000 * 60 * 60 * 24) {
console.log("Less than a day")
myRectangle.color = "green"
}
else {
console.log("More than a day")
// Less than a week ?
if (diff < 1000 * 60 * 60 * 24 * 7) {
console.log("Less than a week")
myRectangle.color = "orange"
}
else {
console.log("More than a week")
myRectangle.color = "red"
}
}
}
else {
console.log("Invalid date")
myRectangle.color = "red"
}
}
}

} // Item
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"id": "participantList",
"properties": {
"dataSource": {"type": "raw", "value": "participantListData"},
"delegate": {"type": "delegate", "value": "GenericItemDelegate"},
"delegate": {"type": "delegate", "value": "ParticipantDelegate"},
"Layout.fillWidth": {"type": "bool", "value": "true"},
"Layout.fillHeight": {"type": "bool", "value": "true"}
}
Expand Down

0 comments on commit 8d42927

Please sign in to comment.