Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-service into dev
  • Loading branch information
SBriere committed Mar 1, 2024
2 parents fd7bf40 + 3614ea7 commit 8708e61
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 106 deletions.
1 change: 0 additions & 1 deletion Frontend/DashboardsViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ target_link_libraries(DashboardsViewerApp PRIVATE
Qt6::Qml
Qt6::Quick
opentera_libs_client_user_qmlplugin
dashboardviewer_qml_cpp_modules_config_parser_qml
dashboardviewer_qml_cpp_modules_config_parser_qmlplugin
dashboardsviewer_resources
)
Expand Down
2 changes: 1 addition & 1 deletion Frontend/DashboardsViewer/content/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ qt6_add_qml_module(content
dataSources/ParticipantSessionListDataSource.qml
# Delegates
delegates/ParticipantDelegate.qml
delegates/SessionDelegate.qml

RESOURCES
fonts/Arimo-VariableFont_wght.ttf
images/logos/LogoOpenTera.png

)
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,12 @@ 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 Component delegate: Component {
id: myDelegate

Rectangle {
id: myRectangle
width: parent.width
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: " + participant_name
color: "red"
}

Text {
height: 20
text: "Enabled: " + participant_enabled
color: "green"
}

Text {
height: 20
text: "UUID: " + participant_uuid
color: "blue"
}
}

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)
fetch.participantClicked(id_participant);
}
}
}
} // Component

property ListModel model: ListModel {
id: myModel
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,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: Component {
id: myDelegate

Rectangle {
id: myRectangle
width: parent.width
height: 80
color: "#cccccc"
border.color: "black"
border.width: 1
radius: 5

ColumnLayout {
id: columnLayout
anchors.fill: parent

Text {
id: text1
text: id_session + "(" + session_name + ")"
font.bold: true
font.pixelSize: 20
color: "black"
}

}

MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {

}
}
}
} // Component
property Component delegate: SessionDelegate {
id: myDelegate
}

property ListModel model: ListModel {
id: myModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts


Component {
Item {
id: myDelegate

// Default property values
property string participant_name: ""
property string participant_enabled: ""
property string participant_uuid: ""
property int id_participant: 0
property int id_project: 0

signal participantClicked(int id);


Rectangle {
id: myRectangle
width: 500
Expand Down Expand Up @@ -50,6 +42,7 @@ Component {
}
}


MouseArea {
id: mouseArea
anchors.fill: parent
Expand All @@ -60,5 +53,6 @@ Component {
participantClicked(id_participant);
}
}

}
} // Component
39 changes: 39 additions & 0 deletions Frontend/DashboardsViewer/content/delegates/SessionDelegate.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts

Item {
id: myDelegate

Rectangle {
id: myRectangle
width: 500
height: 80
color: "#cccccc"
border.color: "black"
border.width: 1
radius: 5

ColumnLayout {
id: columnLayout
anchors.fill: parent

Text {
id: text1
text: id_session + "(" + session_name + ")"
font.bold: true
font.pixelSize: 20
color: "black"
}

}

MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
console.log("SessionDelegate clicked");
}
}
}
} // Component
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ qt_add_qml_module(dashboardviewer_qml_cpp_modules_config_parser_qml
OUTPUT_DIRECTORY ${QT_QML_OUTPUT_DIRECTORY}/DashboardsViewer/ConfigParser
SOURCES ${dashboardviewer_qml_cpp_modules_config_parser_headers} ${dashboardviewer_qml_cpp_modules_config_parser_srcs}
)
target_link_libraries(dashboardviewer_qml_cpp_modules_config_parser_qml PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Qml)
target_include_directories(dashboardviewer_qml_cpp_modules_config_parser_qml PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(dashboardviewer_qml_cpp_modules_config_parser_qmlplugin PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Qml)
target_include_directories(dashboardviewer_qml_cpp_modules_config_parser_qmlplugin PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QDirIterator>
#include <QBuffer>
#include <QTextStream>
#include <QRegularExpression>

ConfigParser::ConfigParser(QObject *parent)
: QObject(parent)
Expand All @@ -21,6 +22,14 @@ ConfigParser::~ConfigParser()

}



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


QVariantList ConfigParser::parseConfig(const QString &configPath)
{
qDebug() << "ConfigParser::parseConfig() called with configPath: " << configPath;
Expand Down Expand Up @@ -189,19 +198,38 @@ void ConfigParser::writeProperties(const QJsonObject &properties, QTextStream &s

if (type == "string")
{
stream << " " << it.key() << ": \"" << property["value"].toString() << "\";\n";
stream << " " << it.key() << ": \"" << property["value"].toString() << "\"\n";
}
else if (type == "raw")
{
stream << " " << it.key() << ": " << property["value"].toString() << ";\n";
QString value = property["value"].toString();
if (isValidString(value))
{
stream << " " << it.key() << ": " << value << "\n";
}
else {
qDebug() << "Invalid value for raw type : " << value;
}
}
else if (type == "int")
{
stream << " " << it.key() << ": " << property["value"].toInt() << ";\n";
stream << " " << it.key() << ": " << property["value"].toInt() << "\n";
}
else if (type == "bool")
{
stream << " " << it.key() << ": " << property["value"].toString() << ";\n";
stream << " " << it.key() << ": " << property["value"].toString() << "\n";
}
else if (type == "delegate")
{
QString value = property["value"].toString();
if (isValidString(value))
{
stream << " " << it.key() << ": " << property["value"].toString() << "{}\n";
}
else
{
qDebug() << "Invalid value for delegate type : " << value;
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ConfigParser : public QObject


private:

bool isValidString(const QString &input);
void writeLayout(const QJsonObject &layout, QTextStream &stream);
void writeWidget(const QJsonObject &widget, QTextStream &stream);
void writeProperties(const QJsonObject &properties, QTextStream &stream);
Expand Down
6 changes: 3 additions & 3 deletions Frontend/DashboardsViewer/resources/json/TestDashboardv2.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"id": {"type": "raw", "value": "participantList"},
"Layout.alignment": {"type": "raw", "value": "Qt.AlignVCenter | Qt.AlignHCenter"},
"model": {"type": "raw", "value": "participantListData.model"},
"delegate": {"type": "raw", "value": "participantListData.delegate"}
"delegate": {"type": "delegate", "value": "ParticipantDelegate"}
}
},
{
Expand All @@ -87,7 +87,7 @@
"id": {"type": "raw", "value": "participantSessionList"},
"Layout.alignment": {"type": "raw", "value": "Qt.AlignVCenter | Qt.AlignHCenter"},
"model": {"type": "raw", "value": "participantSessionListData.model"},
"delegate": {"type": "raw", "value": "participantSessionListData.delegate"}
"delegate": {"type": "delegate", "value": "SessionDelegate"}
}
}
]
Expand Down Expand Up @@ -118,7 +118,7 @@
"target": {"object": "participantListData", "slot": "update", "args": []}
},
{
"source": {"object": "participantListData", "signal": "onParticipantClicked"},
"source": {"object": "participantList.delegate", "signal": "onParticipantClicked"},
"target": {"object": "participantSessionListData", "slot": "setParticipant", "args": ["id_participant"]}
}
]
Expand Down

0 comments on commit 8708e61

Please sign in to comment.