RetroShare/retroshare-qml-app/src/TrustedNodeDetails.qml

200 lines
3.8 KiB
QML
Raw Normal View History

/*
* RetroShare Android QML App
* Copyright (C) 2017 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.7
import QtQuick.Controls 2.0
2017-06-23 12:39:18 -04:00
import "components/."
Item
{
id: nodeDetailsRoot
property string pgpName
property alias pgpId: pgpIdTxt.text
2017-06-23 12:39:18 -04:00
property bool isOnline
property string nodeCert
property var locations
2017-06-23 12:39:18 -04:00
Image
{
id: nodeStatusImage
source: isOnline?
"icons/state-ok.svg" :
"icons/state-offline.svg"
2017-06-23 12:39:18 -04:00
height: 128
sourceSize.height: height
2017-06-23 12:39:18 -04:00
fillMode: Image.PreserveAspectFit
anchors.top: parent.top
anchors.topMargin: 6
anchors.horizontalCenter: parent.horizontalCenter
}
Column
{
id: pgpColumn
2017-06-23 12:39:18 -04:00
anchors.top: nodeStatusImage.bottom
width: parent.width
2017-06-23 12:39:18 -04:00
Text
{
text: nodeDetailsRoot.pgpName.replace(" (Generated by RetroShare) <>", "")
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 20
}
Text
{
id: pgpIdTxt
anchors.horizontalCenter: parent.horizontalCenter
color: "darkslategrey"
}
}
JSONListModel
{
id: jsonModel
json: JSON.stringify(nodeDetailsRoot.locations)
}
ListView
{
2017-06-23 12:39:18 -04:00
width: parent.width * .75
anchors.top: pgpColumn.bottom
2017-06-23 12:39:18 -04:00
anchors.topMargin: 5
anchors.bottom: buttonsRow.top
model: jsonModel.model
2017-06-23 12:39:18 -04:00
anchors.horizontalCenter: parent.horizontalCenter
headerPositioning: ListView.OverlayHeader
clip: true
snapMode: ListView.SnapToItem
header:Rectangle
{
color: "aliceblue"
width: parent.width
z: 2
height: headetText.contentHeight + 10
radius: 10
Text
{
id: headetText
text: "Node locations ("+jsonModel.model.count+")"
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
font.italic: true
}
}
delegate: Column
{
height: 60
width: parent.width
leftPadding: 4
spacing: 4
Row
{
2017-06-23 12:39:18 -04:00
id: idRow
height: 30
2017-06-23 12:39:18 -04:00
spacing: 4
Image
{
id: statusImage
source: model.is_online ?
"icons/network-connect.svg" :
"icons/network-disconnect.svg"
height: parent.height - 4
sourceSize.height: height
fillMode: Image.PreserveAspectFit
anchors.verticalCenter: parent.verticalCenter
}
Text
{
id: locNameText
text: model.location
anchors.verticalCenter: parent.verticalCenter
}
}
2017-06-23 12:39:18 -04:00
TextAndIcon
{
width: parent.width
innerText: model.peer_id
anchors.horizontalCenter: parent.horizontalCenter
iconUrl: "/icons/keyring.svg"
}
}
}
Row
{
id: buttonsRow
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
spacing: 6
Button
{
text: qsTr("Revoke")
onClicked:
rsApi.request(
"/peers/"+nodeDetailsRoot.pgpId+"/delete", "",
function()
{ stackView.push("qrc:/TrustedNodesView.qml") })
}
Button
{
text: qsTr("Entrust")
visible: nodeDetailsRoot.nodeCert.length > 0
onClicked:
{
var jsonData =
{
cert_string: nodeCert,
flags:
{
allow_direct_download: true,
allow_push: false,
require_whitelist: false,
}
}
rsApi.request(
"PUT /peers", JSON.stringify(jsonData),
function()
{ stackView.push("qrc:/TrustedNodesView.qml") })
}
}
}
}