2017-04-13 10:47:27 -04:00
|
|
|
/*
|
|
|
|
* 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/."
|
2017-04-13 10:47:27 -04:00
|
|
|
|
|
|
|
Item
|
|
|
|
{
|
|
|
|
id: nodeDetailsRoot
|
|
|
|
|
|
|
|
property string pgpName
|
|
|
|
property alias pgpId: pgpIdTxt.text
|
2017-06-23 12:39:18 -04:00
|
|
|
property bool isOnline
|
2017-04-13 10:47:27 -04:00
|
|
|
|
|
|
|
property string nodeCert
|
|
|
|
|
|
|
|
property var locations
|
|
|
|
|
2017-06-23 12:39:18 -04:00
|
|
|
|
|
|
|
Image
|
|
|
|
{
|
|
|
|
id: nodeStatusImage
|
|
|
|
source: isOnline?
|
2017-07-07 08:28:41 -04:00
|
|
|
"icons/state-ok.svg" :
|
|
|
|
"icons/state-offline.svg"
|
2017-06-23 12:39:18 -04:00
|
|
|
|
2017-07-07 08:28:41 -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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-13 10:47:27 -04:00
|
|
|
Column
|
|
|
|
{
|
|
|
|
id: pgpColumn
|
|
|
|
|
2017-06-23 12:39:18 -04:00
|
|
|
anchors.top: nodeStatusImage.bottom
|
|
|
|
width: parent.width
|
2017-04-13 10:47:27 -04:00
|
|
|
|
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"
|
|
|
|
}
|
2017-04-13 10:47:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
JSONListModel
|
|
|
|
{
|
|
|
|
id: jsonModel
|
|
|
|
json: JSON.stringify(nodeDetailsRoot.locations)
|
|
|
|
}
|
|
|
|
|
|
|
|
ListView
|
|
|
|
{
|
2017-06-23 12:39:18 -04:00
|
|
|
width: parent.width * .75
|
2017-04-13 10:47:27 -04:00
|
|
|
anchors.top: pgpColumn.bottom
|
2017-06-23 12:39:18 -04:00
|
|
|
anchors.topMargin: 5
|
2017-04-13 10:47:27 -04:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-04-13 10:47:27 -04:00
|
|
|
delegate: Column
|
|
|
|
{
|
|
|
|
height: 60
|
|
|
|
width: parent.width
|
|
|
|
leftPadding: 4
|
|
|
|
spacing: 4
|
|
|
|
|
|
|
|
Row
|
|
|
|
{
|
2017-06-23 12:39:18 -04:00
|
|
|
id: idRow
|
2017-04-13 10:47:27 -04:00
|
|
|
height: 30
|
2017-06-23 12:39:18 -04:00
|
|
|
spacing: 4
|
2017-04-13 10:47:27 -04:00
|
|
|
|
|
|
|
Image
|
|
|
|
{
|
|
|
|
id: statusImage
|
|
|
|
source: model.is_online ?
|
2017-07-07 08:28:41 -04:00
|
|
|
"icons/network-connect.svg" :
|
|
|
|
"icons/network-disconnect.svg"
|
2017-04-13 10:47:27 -04:00
|
|
|
|
|
|
|
height: parent.height - 4
|
2017-07-07 08:28:41 -04:00
|
|
|
sourceSize.height: height
|
2017-04-13 10:47:27 -04:00
|
|
|
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"
|
|
|
|
|
|
|
|
}
|
2017-04-13 10:47:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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") })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|