Skip to content

Commit

Permalink
Refs #2. Work in progress on Timeline widget
Browse files Browse the repository at this point in the history
  • Loading branch information
SBriere committed Mar 28, 2024
1 parent e6e2cfd commit 9c2e1a2
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 124 deletions.
2 changes: 1 addition & 1 deletion Frontend/DashboardsViewer/DashboardsViewer.qmlproject.qtds
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtDesignStudio 4.4.0, 2024-03-20T14:30:25. -->
<!-- Written by QtDesignStudio 4.4.0, 2024-03-28T14:03:03. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
116 changes: 0 additions & 116 deletions Frontend/DashboardsViewer/DashboardsViewer.qmlproject.qtds.1df10fa

This file was deleted.

3 changes: 2 additions & 1 deletion Frontend/DashboardsViewer/content/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ qt6_add_qml_module(content
ui/FlickableScrollBar.qml
# Widgets
widgets/BaseWidget.qml
widgets/ClockWidget.qml
widgets/ButtonWidget.qml
widgets/ClockWidget.qml
widgets/ListViewWidget.qml
widgets/SessionViewerWidget.qml
widgets/TimeLineWidget.qml

# Layouts
layouts/BaseLayout.qml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Item {

//Make sure model is empty
myModel.clear();
modelChanged();

//Print number of elements
//console.log("Number of elements: ", response.length);
Expand Down Expand Up @@ -82,12 +83,14 @@ Item {
response.dataSource = baseDataSource;
myModel.append(response);
}
modelChanged();
});

reply.requestFailed.connect(function(response, statusCode) {
error(response);
console.log("Failed", response, statusCode);
});

}

function update() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import OpenTeraLibs.UserClient 1.0
BaseDataSource {
id: fetch
property int id_participant: 0 // Empty Project
property bool withSessionTypes: false

params: {"id_participant": id_participant}
url: "/api/user/sessions"
Expand All @@ -14,6 +15,10 @@ BaseDataSource {

function setParticipant(id_participant) {
fetch.id_participant = id_participant;
params = {"id_participant": id_participant};
if (withSessionTypes){
params["with_session_type"] = true;
}
getAll();
}

Expand Down
2 changes: 1 addition & 1 deletion Frontend/DashboardsViewer/content/widgets/BaseWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Item {
property Item stackView: dashboardStackView ? dashboardStackView : null

Component.onCompleted: {
console.log("Using StackView: ", stackView)
// console.log("Using StackView: ", stackView)
}
}
73 changes: 73 additions & 0 deletions Frontend/DashboardsViewer/content/widgets/TimeLineWidget.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import DashboardsViewer 1.0
import "../dataSources"


BaseWidget {

property ParticipantSessionListDataSource dataSource: null

visible: dataSource !== null && dataSource.model && dataSource.model.count > 0

property real totalDuration: 0
property real startTimestamp: 0

Connections{
ignoreUnknownSignals: true
target: dataSource
onModelChanged: function() {
repeaterSessions.model = [];
if (dataSource.model.count < 1){
startTimestamp = 0;
totalDuration = 0;
return;
}
let end_timestamp = Math.ceil((Date.parse(dataSource.model.get(0).session_start_datetime) + dataSource.model.get(0).session_duration * 1000) / 1000);
startTimestamp = Math.ceil((Date.parse(dataSource.model.get(dataSource.model.count-1).session_start_datetime)) / 1000);
totalDuration = end_timestamp - startTimestamp;
//console.log(dataSource.model.get(0).id_session + " * " +dataSource.model.get(dataSource.model.count-1).id_session + " / start: " + startTimestamp + ", total: " + totalDuration);
//console.log(dataSource.model.get(0).session_start_datetime + " - " + dataSource.model.get(dataSource.model.count-1).session_start_datetime + " : " + totalDuration);

// Force and set session repeater, as we want to have variables set beforehand
repeaterSessions.model = dataSource.model;
}
}

function updateTimeline(){

}

Rectangle{
anchors.fill: parent
color: "black"

Rectangle{
id: recBase
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 20
anchors.rightMargin: 20
anchors.verticalCenter: parent.verticalCenter
height: 2* parent.height / 3
color: "darkred"
radius: 2

Repeater{
id: repeaterSessions
model: []

Rectangle{
property real relativeStartTimestamp: Math.ceil(Date.parse(model.session_start_datetime) / 1000) - startTimestamp
color: model.session_type_color ? model.session_type_color : "cyan"
border.color: "black"
border.width: 1
height: recBase.height
x: Math.ceil((relativeStartTimestamp / totalDuration) * recBase.width)
width: Math.max(5, (model.session_duration*1000 / totalDuration) * recBase.width)
opacity: model.session_status === 2 ? 1.0 : (model.session_status === 1 ? 0.75 : 0.5)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ConfigParser::~ConfigParser()


bool ConfigParser::isValidString(const QString &input) {
QRegularExpression regex("^[a-zA-Z0-9. |]+$");
QRegularExpression regex("^[a-zA-Z0-9. //|]+$");
return regex.match(input).hasMatch();
}

Expand Down
11 changes: 7 additions & 4 deletions Frontend/DashboardsViewer/resources/json/TestDashboardv2.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
"properties": {
"dataSource": {"type": "raw", "value": "participantListData"},
"delegate": {"type": "delegate", "value": "ParticipantDelegate"},
"Layout.fillWidth": {"type": "bool", "value": "true"},
"Layout.maximumWidth": {"type": "raw", "value": "Screen.width/5"},
"Layout.fillHeight": {"type": "bool", "value": "true"}
}
}
],

"layouts":[
{
"type": "CenteredColumnLayout",
Expand All @@ -31,11 +32,12 @@
},
"widgets": [
{
"type": "Rectangle",
"type": "TimeLineWidget",
"id": "wdgTimeline",
"properties": {
"dataSource": {"type": "raw", "value": "participantSessionListData"},
"Layout.fillWidth": {"type": "bool", "value": "true"},
"height": {"type": "int", "value": 100}
"implicitHeight": {"type": "int", "value": 100}
}
}
],
Expand Down Expand Up @@ -80,7 +82,8 @@
"type": "ParticipantSessionListDataSource",
"id": "participantSessionListData",
"properties": {
"id_participant": {"type": "int", "value": -1}
"id_participant": {"type": "int", "value": -1},
"withSessionTypes": {"type": "bool", "value": "true"}
}
}
],
Expand Down

0 comments on commit 9c2e1a2

Please sign in to comment.