Prova connessione: timeout 30s, busy indicator, normalizzazione https://, log qDebug per debug su device
This commit is contained in:
@@ -6,6 +6,7 @@ Page {
|
||||
|
||||
property string testResult: ""
|
||||
property bool testOk: false
|
||||
property bool testing: false
|
||||
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
@@ -58,9 +59,20 @@ Page {
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Prova connessione"
|
||||
enabled: !page.testing
|
||||
onClicked: testConnection()
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: page.testing ? Theme.itemSizeSmall : 0
|
||||
BusyIndicator {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
running: page.testing
|
||||
size: BusyIndicatorSize.Small
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
x: Theme.horizontalPageMargin
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
@@ -75,12 +87,17 @@ Page {
|
||||
}
|
||||
|
||||
function testConnection() {
|
||||
var base = appSettings.baseUrl
|
||||
var base = appSettings.serverUrl.trim()
|
||||
if (base.length === 0) {
|
||||
page.testResult = "Inserisci l'indirizzo del server"
|
||||
page.testOk = false
|
||||
return
|
||||
}
|
||||
// normalizza: senza schema aggiunge https:// e lo salva nel campo
|
||||
if (base.indexOf("http://") !== 0 && base.indexOf("https://") !== 0)
|
||||
base = "https://" + base
|
||||
appSettings.serverUrl = base
|
||||
page.testing = true
|
||||
page.testResult = "Verifica in corso…"
|
||||
apiClient.getFeed(base + "/opds")
|
||||
}
|
||||
@@ -90,12 +107,14 @@ Page {
|
||||
onFeedReady: {
|
||||
if (pageStack.currentPage !== page)
|
||||
return
|
||||
page.testing = false
|
||||
page.testOk = true
|
||||
page.testResult = "Connessione OK: " + entries.length + " sezioni trovate"
|
||||
}
|
||||
onFeedError: {
|
||||
if (pageStack.currentPage !== page)
|
||||
return
|
||||
page.testing = false
|
||||
page.testOk = false
|
||||
page.testResult = message
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user