-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathHistoryView.qml
344 lines (298 loc) · 15 KB
/
HistoryView.qml
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
/* Copyright 2021 Esri
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.12
//------------------------------------------------------------------------------
import ArcGIS.AppFramework 1.0
//------------------------------------------------------------------------------
import "singletons" as Singletons
//------------------------------------------------------------------------------
Item {
// PROPERTIES //////////////////////////////////////////////////////////////
id: historyView
property bool exportHistoryExists: false
property bool uploadHistoryExists: false
// SIGNAL IMPLEMENTATIONS //////////////////////////////////////////////////
Component.onCompleted: {
}
//--------------------------------------------------------------------------
StackView.onActivating: {
mainView.appToolBar.enabled = true;
mainView.appToolBar.historyButtonEnabled = false;
mainView.appToolBar.settingsButtonEnabled = true;
mainView.appToolBar.backButtonEnabled = true;
mainView.appToolBar.backButtonVisible = true;
mainView.appToolBar.toolBarTitleLabel = Singletons.Strings.exportAndUploadHistory;
}
StackView.onActivated: {
getExportHistory();
getUploadHistory();
}
// UI //////////////////////////////////////////////////////////////////////
RowLayout {
anchors.fill: parent
anchors.margins: sf(10)
anchors.topMargin: 0
spacing: 0
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
Rectangle {
anchors.fill: parent
anchors.rightMargin: sf(10)
color: "#fff"
ColumnLayout {
spacing: 0
anchors.fill: parent
Rectangle {
Layout.preferredHeight: sf(50)
Layout.fillWidth: true
RowLayout {
anchors.fill: parent
Text {
id: exportHistoryLabel
Layout.fillHeight: true
Layout.fillWidth: true
text: Singletons.Strings.exportHistory
font.pointSize: Singletons.Config.mediumFontSizePoint
font.family: defaultFontFamily
verticalAlignment: Text.AlignVCenter
}
Rectangle {
Layout.fillHeight: true
Layout.preferredWidth: sf(150)
Button {
anchors.fill: parent
enabled: exportHistoryExists
visible: exportHistoryExists
background: Rectangle {
anchors.fill: parent
color: Singletons.Config.buttonStates(parent, "clear")
radius: app.info.properties.mainButtonRadius
border.width: parent.enabled ? app.info.properties.mainButtonBorderWidth : 0
border.color: "#fff"
}
Text {
color: app.info.properties.mainButtonBackgroundColor
anchors.centerIn: parent
textFormat: Text.RichText
text: Singletons.Strings.deleteHistory
font.pointSize: Singletons.Config.baseFontSizePoint
font.family: defaultFontFamily
}
onClicked: {
appDatabase.truncate("exports")
getExportHistory();
}
}
}
}
}
// ---------------------------------------------------------
Rectangle{
Layout.preferredHeight: sf(1)
Layout.fillWidth: true
Layout.bottomMargin: sf(10)
color: "#ddd"
}
// ---------------------------------------------------------
Item {
Layout.fillHeight: true
Layout.fillWidth: true
Flickable {
id: exportFlickable
anchors.fill: parent
contentHeight: exportHistoryTextArea.height
clip: true
flickableDirection: Flickable.VerticalFlick
TextArea {
id: exportHistoryTextArea
width: parent.width
textFormat: Text.RichText
readOnly: true
font.pointSize: Singletons.Config.baseFontSizePoint
color: app.info.properties.toolBarBackgroundColor
wrapMode: Text.Wrap
onLinkActivated: {
Qt.openUrlExternally(link);
}
Component.onCompleted: {
exportFlickable.contentY = 0;
}
}
}
}
}
}
}
//------------------------------------------------------------------
Rectangle {
Layout.preferredWidth: sf(1)
Layout.fillHeight: true
color: app.info.properties.toolBarBackgroundColor
}
//------------------------------------------------------------------
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
Rectangle {
anchors.fill: parent
anchors.leftMargin: sf(10)
color:"white"
ColumnLayout {
spacing: 0
anchors.fill: parent
Rectangle {
Layout.preferredHeight: sf(50)
Layout.fillWidth: true
RowLayout {
anchors.fill: parent
Text {
id: uploadHistoryLabel
Layout.fillHeight: true
Layout.fillWidth: true
text: Singletons.Strings.uploadHistory
font.pointSize: Singletons.Config.mediumFontSizePoint
font.family: defaultFontFamily
verticalAlignment: Text.AlignVCenter
}
Rectangle {
Layout.fillHeight: true
Layout.preferredWidth: sf(150)
Button {
anchors.fill: parent
enabled: uploadHistoryExists
visible: uploadHistoryExists
background: Rectangle {
anchors.fill: parent
color: Singletons.Config.buttonStates(parent, "clear")
radius: app.info.properties.mainButtonRadius
border.width: parent.enabled ? app.info.properties.mainButtonBorderWidth : 0
border.color: "#fff"
}
Text {
color: app.info.properties.mainButtonBackgroundColor
anchors.centerIn: parent
textFormat: Text.RichText
text: Singletons.Strings.deleteHistory
font.pointSize: Singletons.Config.baseFontSizePoint
font.family: defaultFontFamily
}
onClicked: {
appDatabase.truncate("uploads");
getUploadHistory();
}
}
}
}
}
// ---------------------------------------------------------
Rectangle {
Layout.preferredHeight: sf(1)
Layout.fillWidth: true
Layout.bottomMargin: sf(10)
color: "#ddd"
}
// ---------------------------------------------------------
Item {
Layout.fillHeight: true
Layout.fillWidth: true
Flickable {
id: uploadFlickable
anchors.fill: parent
contentHeight: uploadHistoryTextArea.height
clip: true
flickableDirection: Flickable.VerticalFlick
TextArea {
id: uploadHistoryTextArea
width: parent.width
textFormat: Text.RichText
readOnly: true
font.pointSize: Singletons.Config.baseFontSizePoint
color: app.info.properties.toolBarBackgroundColor
wrapMode: Text.Wrap
onLinkActivated: {
Qt.openUrlExternally(link);
}
Component.onCompleted: {
uploadFlickable.contentY = 0;
}
}
}
}
}
}
}
}
// METHODS /////////////////////////////////////////////////////////////////
function getExportHistory(){
var exportHistory = appDatabase.read("SELECT * FROM 'exports' WHERE user IS '%1' ORDER BY OBJECTID DESC".arg(portal.user.email));
exportHistoryTextArea.text = "";
if (exportHistory !== null && exportHistory.count > 0) {
for (var i=0; i < exportHistory.count; i++) {
var entry = exportHistory.get(i);
exportHistoryTextArea.append("<h3 style=\"color:darkorange;\">" + entry.title + "</h3>");
exportHistoryTextArea.append("<p>" + new Date(entry.transaction_date).toLocaleDateString() + " " + new Date(entry.transaction_date).toLocaleTimeString() + "</p>");
exportHistoryTextArea.append("<h4>Tile Service</h4>");
exportHistoryTextArea.append(entry.tile_service_name);
var extent = JSON.parse(entry.esri_geometry)
exportHistoryTextArea.append("<h4>Geometry</h4>");
exportHistoryTextArea.append("<p>" + JSON.stringify(extent.geometries) + "<br/>");
if (extent.hasOwnProperty("buffer")) {
exportHistoryTextArea.append("Buffer: " + entry.buffer + "</p><hr/>");
}
exportHistoryTextArea.append("Type: " + extent.geometryType + "</p><hr/>");
exportHistoryTextArea.append("<h4>Export Parameters</h4>");
exportHistoryTextArea.append("<p>Levels: " + entry.levels + "</p>");
exportHistoryTextArea.append("<p>Package Size: " + entry.package_size + "</p>");
exportHistoryTextArea.append("<p>Number of Tiles: " + entry.number_of_tiles + "</p>");
exportHistoryTextArea.append("<p>Description: " + entry.description + "</p>");
exportHistoryTextArea.append("<h4>File Information</h4>");
exportHistoryTextArea.append("<p>Local File Path: " + entry.local_filepath + "</p>");
exportHistoryTextArea.append("<a href=\"" + entry.download_url + "\">Download Link [link may have expired]</a>");
}
exportHistoryExists = true;
}
else {
exportHistoryTextArea.append("<p>No Export History Available<p>");
exportHistoryExists = false;
}
}
//--------------------------------------------------------------------------
function getUploadHistory(){
var uploadHistory = appDatabase.read("SELECT * FROM 'uploads' WHERE user IS '%1' ORDER BY OBJECTID DESC".arg(portal.user.email));
uploadHistoryTextArea.text = "";
if (uploadHistory !== null && uploadHistory.count > 0) {
for (var i=0; i < uploadHistory.count; i++) {
var entry = uploadHistory.get(i);
uploadHistoryTextArea.append("<h3 style=\"color:darkblue;\">" + entry.title + "</h3>");
uploadHistoryTextArea.append("<p>" + new Date(entry.transaction_date).toLocaleDateString() + " " + new Date(entry.transaction_date).toLocaleTimeString() + "</p>");
uploadHistoryTextArea.append("<p>Description: " + entry.description + "</p>");
uploadHistoryTextArea.append("<a href=\"" + entry.published_service_url + "\">Published ArcGIS Service Link</a>");
}
uploadHistoryExists = true;
}
else {
uploadHistoryTextArea.append("<p>No Upload History Available<p>");
uploadHistoryExists = false;
}
}
// END /////////////////////////////////////////////////////////////////////
}