First changes for the upcoming server login.

This commit is contained in:
Scharel Clemens 2018-10-18 00:33:47 +02:00
parent 73990602dd
commit 811bb27a09
6 changed files with 91 additions and 7 deletions

View file

@ -14,7 +14,7 @@ The [Sailfish OS SDK](https://sailfishos.org/wiki/Application_SDK) is used to wr
## Planned features ## Planned features
(The ordering represents the priority for the implementation) (The ordering represents the priority for the implementation)
- Login screen for the nextcloud account (using the [Login Flow](https://docs.nextcloud.com/server/14/developer_manual/client_apis/LoginFlow/index.html)) - Login screen for the nextcloud account (using the [Login Flow](https://docs.nextcloud.com/server/14/developer_manual/client_apis/LoginFlow/index.html) if possible)
- Create new notes - Create new notes
- Delete notes - Delete notes
- Edit notes - Edit notes

View file

@ -26,7 +26,8 @@ DISTFILES += qml/harbour-nextcloudnotes.qml \
rpm/harbour-nextcloudnotes.yaml \ rpm/harbour-nextcloudnotes.yaml \
translations/*.ts \ translations/*.ts \
harbour-nextcloudnotes.desktop \ harbour-nextcloudnotes.desktop \
qml/pages/NotePage.qml qml/pages/NotePage.qml \
qml/pages/LoginPage.qml
SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172 SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172

View file

@ -11,7 +11,7 @@ ApplicationWindow
id: appSettings id: appSettings
path: "/apps/harbour-nextcloudnotes/settings" path: "/apps/harbour-nextcloudnotes/settings"
property string lastUpdate: qsTr("never") property string lastUpdate: qsTr("never")
property url server: "https://127.0.0.1" + "/index.php/apps/notes/api/v0.2/notes" property url server: "https://127.0.0.1"
property string username: "test" property string username: "test"
property string password // TODO provide password before testing. Just use revocable passwords for testing! property string password // TODO provide password before testing. Just use revocable passwords for testing!
} }

48
qml/pages/LoginPage.qml Normal file
View file

@ -0,0 +1,48 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
Page {
id: page
allowedOrientations: Orientation.Portrait
SilicaFlickable {
id: webView
anchors.fill: parent
PullDownMenu {
MenuItem {
text: qsTr("Reload")
onClicked: webView.reload()
}
}
PageHeader {
title: qsTr("Login")
}
Column {
TextField {
focus: true
width: parent.width
placeholderText: qsTr("https://cloud.nextcloud.com")
label: qsTr("Nextcloud server")
inputMethodHints: Qt.ImhUrlCharactersOnly
}
TextField {
width: parent.width
placeholderText: qsTr("Username")
label: qsTr("Nextcloud user")
inputMethodHints: Qt.ImhUrlCharactersOnly
}
TextField {
width: parent.width
placeholderText: qsTr("Password")
label: qsTr("Nextcloud App-Password")
inputMethodHints: Qt.ImhUrlCharactersOnly
}
}
}
}

View file

@ -14,16 +14,16 @@ Item {
function callApi(method, data) { function callApi(method, data) {
busy = true busy = true
var endpoint = "" var endpoint = appSettings.server + "/index.php/apps/notes/api/v0.2/notes"
if (data && (method === "GET" || method === "PUT" || method === "DELETE")) if (data && (method === "GET" || method === "PUT" || method === "DELETE"))
if (data.id) if (data.id)
endpoint = "/" + data.id endpoint = endpoint + "/" + data.id
var apiReq = new XMLHttpRequest var apiReq = new XMLHttpRequest
apiReq.open(method, appSettings.server + endpoint, true) apiReq.open(method, endpoint, true)
apiReq.setRequestHeader('User-Agent', 'SailfishOS/harbour-nextcloudnotes') apiReq.setRequestHeader('User-Agent', 'SailfishOS/harbour-nextcloudnotes')
apiReq.setRequestHeader('OCS-APIRequest', 'true') apiReq.setRequestHeader('OCS-APIRequest', 'true')
apiReq.setRequestHeader("Content-Type", "application/json"); apiReq.setRequestHeader("Content-Type", "application/json")
apiReq.setRequestHeader("Authorization", "Basic " + Qt.btoa(appSettings.username + ":" + appSettings.password)) apiReq.setRequestHeader("Authorization", "Basic " + Qt.btoa(appSettings.username + ":" + appSettings.password))
apiReq.onreadystatechange = function() { apiReq.onreadystatechange = function() {
if (apiReq.readyState === XMLHttpRequest.DONE) { if (apiReq.readyState === XMLHttpRequest.DONE) {

View file

@ -43,6 +43,41 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>LoginFlow</name>
<message>
<source>Reload</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>https://cloud.nextcloud.com</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Nextcloud server</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Username</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Nextcloud user</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Nextcloud App-Password</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>harbour-nextcloudnotes</name> <name>harbour-nextcloudnotes</name>
<message> <message>