-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomePage.qml
More file actions
202 lines (193 loc) · 8.49 KB
/
Copy pathHomePage.qml
File metadata and controls
202 lines (193 loc) · 8.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "statusEnum.js" as StatusEnum
import "constants.js" as Colors
Page {
id: page1
padding: 15;
background: Rectangle {
color: Colors.theme.bgColor
}
Rectangle {
width: 200
height: 30
color: Colors.theme.primaryColor
anchors.right: parent.right;
Text {
anchors.centerIn: parent
text: "История сбоев"
font.pointSize: 14
color: Colors.theme.bgColor
}
MouseArea {
anchors.fill: parent
onClicked: stackView.push(Qt.resolvedUrl("HistoryFailurePage.qml"))
}
}
ColumnLayout {
anchors.fill: parent
spacing: 30
RowLayout {
spacing: 20
Text {
text: "Текущий статус системы:"
font.pointSize: 16
}
Rectangle {
height: 30
width: 200
color: Colors.theme.primaryColor
Text {
anchors.centerIn: parent
text: StatusEnum.getStatusText(StatusEnum.StatusEnum.Running)
font.pointSize: 16
font.bold: true
color: Colors.theme.bgColor
}
}
}
Text {
id: test
text: "Cтатус элементов:"
font.pointSize: 16
}
Rectangle {
Layout.fillHeight: true;
Layout.fillWidth: true;
border.color: Colors.theme.primaryColor
clip: true;
ScrollView {
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
height: parent.height
width: parent.width
contentWidth: parent.width
contentHeight: {
if (microphoneModel.count % 2 === 0) {
return 143 * microphoneModel.count
} else {
return 143 * (microphoneModel.count + 1)
}
}
GridLayout {
id: grid
columns: 2
anchors.fill: parent
anchors.margins: 10
Repeater {
model: microphoneModel
anchors.top: parent.top
Item {
Layout.minimumWidth: grid.width / grid.columns - 5
height: 277
Rectangle {
anchors.fill: parent
anchors.top: parent.top
color: {
switch (model.status) {
case "Работает нормально":
return Colors.theme.lightGreen;
case "Вероятен сбой":
return Colors.theme.yellow;
case "Сбой":
return Colors.theme.red;
case "Микрофон не подключен":
return Colors.theme.lightGray;
default:
return Colors.theme.lightGray;
}
}
MouseArea {
anchors.fill: parent
onClicked: {
stackView.push(Qt.resolvedUrl("MicrophoneDetailsPage.qml"), { microphoneData: model })
}
}
Item {
anchors.fill: parent
anchors.margins: 20
Column {
anchors.verticalCenter: parent.verticalCenter
width: parent.width
spacing: 30
Text {
text: {
if (model.status !== "Микрофон не подключен") {
return "Микрофон " + model.microphone + ": " + model.type;
} else {
return "Микрофон " + model.microphone + ": " + "не подключен";
}
}
font.pointSize: 14
}
Column {
spacing: 10;
Row {
spacing: 20
Image {
width: 40
height: 40
source: {
switch (model.status) {
case "Работает нормально":
return "src/icon/work.svg";
case "Вероятен сбой":
return "src/icon/warning.svg";
case "Сбой":
return "src/icon/error.svg";
case "Микрофон не подключен":
return "src/icon/not_work.svg";
}
}
}
Text {
text: model.status
font.pointSize: 20
font.bold: true
}
}
Text {
text: {
if (model.status !== "Микрофон не подключен") {
return "Вероятность сбоя - " + model.probability;
} else {
return "Вероятность сбоя неизвестна";
}
}
font.pointSize: 14;
}
}
Text {
text: "Присвоенное устройство для анализа: " + model.analysisDevice
font.pointSize: 14;
anchors.horizontalCenter: parent.horizontalCenter
}
}}
}
}
}}
}
}
}
Component.onCompleted: {
var request = new XMLHttpRequest()
request.open('GET', 'http://127.0.0.1:8000/api/microphones')
request.onreadystatechange = function() {
if (request.readyState === XMLHttpRequest.DONE) {
if (request.status === 200) {
microphoneModel.clear()
var response = JSON.parse(request.responseText)
for (var i = 0; i < response.length; i++) {
microphoneModel.append(response[i])
}
} else {
console.log('Failed to load data')
}
}
}
request.send()
}
ListModel {
id: microphoneModel
}
}