ArcGIS Runtime SDK for Qt

Portal user info

Loading

Code

import QtQuick 2.6
import QtQuick.Controls 1.4
import Esri.ArcGISRuntime 100.3
import Esri.ArcGISExtras 1.1
import Esri.ArcGISRuntime.Toolkit.Dialogs 100.3

Rectangle {
    id: rootRectangle
    clip: true

    width: 800 * scaleFactor
    height: 600 * scaleFactor

    property real scaleFactor: System.displayScaleFactor
    property var user: portal.portalUser

    BusyIndicator {
        id: loadingIndicator
        anchors.centerIn: parent
        running: portal.loadStatus !== Enums.LoadStatusLoaded
    }

    property var detailNames: ["Full name", "Username", "Email", "Bio", "Who can see your profile?"]
    property var detailValue: ["fullName", "username", "email", "userDescription", "access"]

    Column {
        id: userDetailsColumn
        visible: portal.loadStatus === Enums.LoadStatusLoaded
        anchors {
            top: parent.top
            left: parent.left
            right: parent.right
            margins: 10 * scaleFactor
        }
        spacing: 10 * scaleFactor

        Text {
            text: user ? user.fullName + " Profile" : ("????")
            font.bold: true
            font.pointSize: 15
        }

        Image {
            source : user && user.thumbnailUrl.toString().length > 0 ? user.thumbnailUrl : "qrc:/Samples/CloudAndPortal/PortalUserInfo/placeholder_img.png"
            height: 32 * scaleFactor
            width: 32 * scaleFactor
        }
    }

    ListView {
        id: userList
        visible: portal.loadStatus === Enums.LoadStatusLoaded
        anchors {
            top: userDetailsColumn.bottom;
            bottom: midLine.top
            left: parent.left;
            right: parent.right;
            margins: 10 * scaleFactor
        }
        spacing: 10 * scaleFactor
        clip: true
        model: detailNames.length

        delegate: Column {
            Text {
                text: detailNames[index]
                font.bold: true
            }

            Text {
                text: {
                    if (!user)
                        return "????";

                    if(detailValue[index] !== "access")
                        return user[detailValue[index]];

                    if (user.access === Enums.PortalAccessOrganization)
                        return "Organization";
                    else if (user.access === Enums.PortalAccessPrivate)
                        return "Only you";
                    else if (user.access === Enums.PortalAccessPublic)
                        return "Everyone";
                    else if (user.access === Enums.PortalAccessShared)
                        return "Shared Groups";
                    return "????";
                }
                color: "grey"
            }
        }
    }

    Rectangle {
        id: midLine
        anchors {
            verticalCenter: parent.verticalCenter
            margins: 8 * scaleFactor
            left: parent.left
            right: parent.right
        }
        height: 4 * scaleFactor
        visible: portal.loadStatus === Enums.LoadStatusLoaded
        color: "lightgrey"
    }

    Column {
        id: portalDetailsColumn
        visible: portal.loadStatus === Enums.LoadStatusLoaded
        anchors {
            top: midLine.bottom
            left: parent.left
            right: parent.right
            margins: 10 * scaleFactor
        }
        spacing: 10 * scaleFactor

        Text {
            text: portal.portalInfo ? portal.portalInfo.organizationName : ""
            font.bold: true
            font.pointSize: 15
        }

        Image {
            source : portal.portalInfo ? portal.portalInfo.thumbnailUrl : ""
            height: 32 * scaleFactor
            width: 32 * scaleFactor
        }
    }

    property var infoLabels: ["Description", "Can Find External Content", "Can Share Items Externally"]
    property var infoValues: ["organizationDescription", "canSearchPublic", "canSharePublic"]

    ListView {
        id: infoList
        visible: portal.loadStatus === Enums.LoadStatusLoaded
        anchors {
            top: portalDetailsColumn.bottom
            bottom: parent.bottom
            left: parent.left
            right: parent.right
            margins: 10 * scaleFactor
        }
        spacing: 10 * scaleFactor
        clip: true
        model: infoValues.length

        delegate: Column {
            Text {
                text: portal.portalInfo ? infoLabels[index] : ""
                font.bold: true
            }

            Text {
                text: portal.portalInfo ? portal.portalInfo[infoValues[index]] : ""
                color: "grey"
            }
        }
    }

    Portal {
        id: portal
        credential: Credential {
            oAuthClientInfo: OAuthClientInfo {
                oAuthMode: Enums.OAuthModeUser
                clientId: "W3hPKzPbeJ0tr8aj"
            }
        }

        Component.onCompleted: load();

        onLoadStatusChanged: {
            if (loadStatus === Enums.LoadStatusFailedToLoad)
                retryLoad();
        }
    }

    /* Uncomment this section when running as standalone application
    AuthenticationView {
        id: authView
        authenticationManager: AuthenticationManager
    }
    */
}


In this topic
  1. Code