Skip to content

Commit

Permalink
Refs #2. Reworked DashboardSelector for projects and sites dashboards
Browse files Browse the repository at this point in the history
  • Loading branch information
SBriere committed Mar 15, 2024
1 parent 6026659 commit a698662
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 148 deletions.
2 changes: 1 addition & 1 deletion API/user/QueryDashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def post(self):
except ValueError:
# Bad json
return gettext('Invalid version definition - json not valid'), 400
except exc.SQLAlchemyError:
except exc.SQLAlchemyError as e:
return gettext('Unable to update dashboard version'), 400

return DashDashboards.get_by_id(json_dashboard['id_dashboard']).to_json()
Expand Down
1 change: 1 addition & 0 deletions Frontend/DashboardsViewer/content/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ qt6_add_qml_module(content
delegates/BaseDelegate.qml
delegates/ParticipantDelegate.qml
delegates/SessionDelegate.qml
delegates/SiteProjectDelegate.qml
delegates/GenericItemDelegate.qml

RESOURCES
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import DashboardsViewer 1.0

Item {
width: GridView.view.cellWidth - 10
height: GridView.view.cellHeight - 10

signal itemClicked(var id, var definition)

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

Text {
anchors.fill: parent
text: model.name
color: Constants.textColor
font.pixelSize: Constants.smallFontSize
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
style: Text.Outline
font.bold: true
}

MouseArea {
anchors.fill: parent
onClicked: function(){
//console.log("Click! " + model.id + " - " + model.definition);
itemClicked(model.id, model.definition);
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion Frontend/DashboardsViewer/content/screens/DashboardSelector.qml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ DashboardSelectorForm {
}
}

projectGridView.delegate.onItemClicked: function(id, definition){
stackview.push("Dashboard.qml")

// get current pushed element
var currentElement = stackview.currentItem;

// Set the element property
// TODO: Handle string definition direction
//currentElement.jsonFileName = definition;
}


BaseDataSource {
id: sitesDataSource
Expand Down Expand Up @@ -158,7 +169,10 @@ DashboardSelectorForm {
console.log(description, enabled, name, definition);


selectorForm.projetGridView.model.append({"name": name, "color": "Blue"})
selectorForm.projetGridView.model.append({"id": dashboard.id_dashboard,
"name": name,
"definition": definition,
"color": "Blue"})

}
}
Expand Down
250 changes: 104 additions & 146 deletions Frontend/DashboardsViewer/content/screens/DashboardSelectorForm.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import QtQuick.Layouts
import QtQuick.Effects

import "../ui"
import "../delegates"
import DashboardsViewer 1.0

Item {
Expand All @@ -12,7 +13,7 @@ Item {
property alias cmbSites: cmbSites
property alias cmbProjects: cmbProjects
property alias siteGridView: siteGridView
property alias projetGridView: projectGridView
property alias projectGridView: projectGridView

Item {
anchors.centerIn: parent
Expand All @@ -23,158 +24,115 @@ Item {
id: dlgMain
title: qsTr("Select dashboard to display")
anchors.fill: parent

Flickable {
id: flickMain
ColumnLayout {
id: layoutMain
anchors.fill: parent
anchors.topMargin: 10
anchors.bottomMargin: 10
clip: true
contentHeight: layoutMain.implicitHeight
interactive: height < contentHeight

ScrollBar.vertical: FlickableScrollBar {}

ColumnLayout {
id: layoutMain
anchors.fill: parent
anchors.leftMargin: 10
anchors.rightMargin: flickMain.interactive ? 15 : 10

Rectangle {
Layout.fillWidth: true
implicitHeight: rowFilters.implicitHeight + lblFilters.implicitHeight
+ rowFilters.anchors.margins * 2
anchors.margins: 10

Rectangle {
Layout.fillWidth: true

implicitHeight: rowFilters.implicitHeight + lblFilters.implicitHeight
+ rowFilters.anchors.margins * 2

radius: 10
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
//color: "#77000000"
color: "Red"
Text {
id: lblFilters
anchors.left: parent.left
anchors.top: parent.top
anchors.leftMargin: 10
text: qsTr("Filters")
color: "lightyellow"
font.pixelSize: Constants.smallFontSize
font.italic: true
}

RowLayout {
id: rowFilters
anchors.top: lblFilters.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 5
implicitHeight: 200

radius: 10
//color: "#77000000"
color: "Red"
Text {
id: lblFilters
anchors.left: parent.left
anchors.top: parent.top
anchors.leftMargin: 10
text: qsTr("Filters")
color: "lightyellow"
text: qsTr("Site")
Layout.leftMargin: 20
color: Constants.textColor
font.pixelSize: Constants.smallFontSize
font.italic: true
font.bold: true
style: Text.Outline
}

RowLayout {
id: rowFilters
anchors.top: lblFilters.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 5
implicitHeight: 200

Text {
text: qsTr("Site")
Layout.leftMargin: 20
color: Constants.textColor
font.pixelSize: Constants.smallFontSize
font.bold: true
style: Text.Outline
}

ComboBox {
id: cmbSites
Layout.fillWidth: true
Layout.fillHeight: true
model: ListModel {}
}
Text {
text: qsTr("Project")
color: Constants.textColor
font.pixelSize: Constants.smallFontSize
style: Text.Outline
font.bold: true
}

ComboBox {
id: cmbProjects
Layout.fillWidth: true
Layout.fillHeight: true
model: ListModel {}
}
}//RowLayout
} // First Rect

Rectangle {
id: siteProjectGrids
color: "White"
Layout.fillWidth: true
Layout.fillHeight: true
radius: 10
implicitHeight: 200


RowLayout {
//Fill the rest
//Where dashboards should be presented
id: siteProjectRowLayout
anchors.fill: parent

GridView {
id: siteGridView
Layout.fillWidth: true
Layout.fillHeight: true
cellWidth: 100
cellHeight: 100
model: ListModel {}
delegate: Rectangle {
color: Green
width: siteGridView.cellWidth
height: siteGridView.cellHeight

Text {
anchors.fill: parent
text: model.name
color: Constants.textColor
font.pixelSize: Constants.smallFontSize
style: Text.Outline
font.bold: true
}

MouseArea {
anchors.fill: parent

}
}
} // GridView 1

GridView {
id: projectGridView
Layout.fillWidth: true
Layout.fillHeight: true
model: ListModel {}
cellWidth: 100
cellHeight: 100
delegate: Rectangle {
color: "Red"
width: projectGridView.cellWidth
height: projectGridView.cellHeight

Text {
anchors.fill: parent
text: model.name
color: Constants.textColor
font.pixelSize: Constants.smallFontSize
style: Text.Outline
font.bold: true
}

MouseArea {
anchors.fill: parent

}
}
} // GridView 2
ComboBox {
id: cmbSites
Layout.fillWidth: true
Layout.fillHeight: true
model: ListModel {}
}
Text {
text: qsTr("Project")
color: Constants.textColor
font.pixelSize: Constants.smallFontSize
style: Text.Outline
font.bold: true
}

}//RowLayout (2)
} // Rectangle 2
} // ColumnLayout
} // Flickable
ComboBox {
id: cmbProjects
Layout.fillWidth: true
Layout.fillHeight: true
model: ListModel {}
}
} //RowLayout
} // First Rect
Rectangle {
id: siteProjectGrids
color: "white"
Layout.fillWidth: true
Layout.fillHeight: true
radius: 10
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
//implicitHeight: 600

//implicitHeight: siteProjectRowLayout.implicitHeight
RowLayout {
//Fill the rest
//Where dashboards should be presented
id: siteProjectRowLayout
anchors.fill: parent

//implicitHeight: siteGridView.implicitHeight
GridView {
id: siteGridView
Layout.fillWidth: true
Layout.fillHeight: true
cellWidth: 100
cellHeight: 100
clip: true
ScrollBar.vertical: FlickableScrollBar {}
model: ListModel {}
delegate: SiteProjectDelegate {}
} // GridView 1

GridView {
id: projectGridView
Layout.fillWidth: true
Layout.fillHeight: true
model: ListModel {}
cellWidth: 100
cellHeight: 100
clip: true

ScrollBar.vertical: FlickableScrollBar {}
delegate: SiteProjectDelegate {}
} // GridView 2
} //RowLayout (2)
} // Rectangle 2
} // ColumnLayout
} // BasicDialog
} // Item
} // Item

0 comments on commit a698662

Please sign in to comment.