Add user autorisations information
authorPhilippe Lelong <lelong.ph@meltemus.com>
Tue, 20 Dec 2016 13:40:06 +0000 (14:40 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Tue, 20 Dec 2016 15:02:47 +0000 (16:02 +0100)
Signed-off-by: Philippe Lelong <lelong.ph@meltemus.com>
HomeScreen/qml/Home.qml
HomeScreen/qml/images/Home/Install App.png [new file with mode: 0755]
HomeScreen/qml/images/Home/Logout-01.png
HomeScreen/qml/images/Home/Open Trunk.png [new file with mode: 0755]
HomeScreen/qml/images/Home/Update Software.png [new file with mode: 0755]
HomeScreen/qml/images/Home/View Online.png [new file with mode: 0755]
HomeScreen/qml/images/Home/home.qrc
HomeScreen/src2/usermanagement.cpp
HomeScreen/src2/usermanagement.h

index ed0d949..c44919d 100644 (file)
@@ -18,6 +18,8 @@
 import QtQuick 2.2
 import QtQuick.Layouts 1.1
 import QtQuick.Controls 1.0
+import QtQuick.Controls 1.4
+import QtQuick.Controls.Styles 1.4
 import Home 1.0
 
 Item {
@@ -128,6 +130,19 @@ Item {
     function changeFlag(flagImage) {
         flagLanguage.source = flagImage
     }
+    function setUser(type, auts) {
+        if(type === '') {
+            authorisations.visible = false
+        } else {
+            authorisations.visible = true
+            labelUserType.text = type
+            myModel.clear()
+            for (var i=0; i<auts.length; i++) {
+                if(auts[i] !== '')
+                    myModel.append({"name": auts[i]})
+            }
+        }
+    }
 
     GridView {
         anchors.centerIn: parent
@@ -179,6 +194,54 @@ Item {
             }
         }
     }
+    ListModel {
+        id: myModel
+        ListElement {
+            name: 'Install App'
+        }
+        ListElement {
+            name: 'Open Trunk'
+        }
+        ListElement {
+            name: 'Update Software'
+        }
+        ListElement {
+            name: 'View Online'
+        }
+    }
+    Item {
+        id: authorisations
+        anchors.fill: parent
+        visible: false
+        GridLayout {
+            id: gridAut
+            columns: 2
+            anchors.bottom: parent.bottom
+            anchors.left: parent.left
+            anchors.bottomMargin: 50
+            anchors.leftMargin: 20
+            Repeater {
+                model: myModel
+                Image {
+                    source: './images/' + model.name + '.png'
+                    width: sourceSize.width
+                    height: sourceSize.height
+                    visible: true
+                }
+            }
+        }
+        Label {
+            id: labelUserType
+            anchors.bottom: gridAut.top
+            anchors.bottomMargin: 10
+            anchors.left: gridAut.left
+            color: "white"
+            text: "Owner"
+            font.pixelSize: 30
+            font.family: "Roboto"
+        }
+    }
+
     Image {
         id: logout
         width: sourceSize.width
diff --git a/HomeScreen/qml/images/Home/Install App.png b/HomeScreen/qml/images/Home/Install App.png
new file mode 100755 (executable)
index 0000000..17da664
Binary files /dev/null and b/HomeScreen/qml/images/Home/Install App.png differ
index 0183565..5436ebc 100755 (executable)
Binary files a/HomeScreen/qml/images/Home/Logout-01.png and b/HomeScreen/qml/images/Home/Logout-01.png differ
diff --git a/HomeScreen/qml/images/Home/Open Trunk.png b/HomeScreen/qml/images/Home/Open Trunk.png
new file mode 100755 (executable)
index 0000000..8fdb660
Binary files /dev/null and b/HomeScreen/qml/images/Home/Open Trunk.png differ
diff --git a/HomeScreen/qml/images/Home/Update Software.png b/HomeScreen/qml/images/Home/Update Software.png
new file mode 100755 (executable)
index 0000000..dd107fd
Binary files /dev/null and b/HomeScreen/qml/images/Home/Update Software.png differ
diff --git a/HomeScreen/qml/images/Home/View Online.png b/HomeScreen/qml/images/Home/View Online.png
new file mode 100755 (executable)
index 0000000..d1fa287
Binary files /dev/null and b/HomeScreen/qml/images/Home/View Online.png differ
index a9d1dc3..4a02101 100644 (file)
@@ -24,5 +24,9 @@
         <file>french_flag.png</file>
         <file>us_flag.png</file>
         <file>Logout-01.png</file>
+        <file>Update Software.png</file>
+        <file>Open Trunk.png</file>
+        <file>Install App.png</file>
+        <file>View Online.png</file>
     </qresource>
 </RCC>
index 5daa1f5..9ea968f 100644 (file)
@@ -37,6 +37,11 @@ void UserManagement::slot_disconnect()
     QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, false));
     QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, false), Q_ARG(QVariant, ""));
     QMetaObject::invokeMethod(home, "changeFlag", Q_ARG(QVariant, "./images/us_flag.png"));
+    QMetaObject::invokeMethod(home, "setUser", Q_ARG(QVariant, ""), Q_ARG(QVariant, ""));
+    QVariantList list;
+    list << 2 << QString().setNum(++sequence) << "agl-identity-agent/logout" << true;
+    listToJson(list, &data);
+    slot_sendData();
 }
 
 void UserManagement::setUser(const User &user)
@@ -50,6 +55,21 @@ void UserManagement::setUser(const User &user)
     QMetaObject::invokeMethod(shortcutArea, "languageChanged", Q_ARG(QVariant, user.graphPreferredLanguage));
     QMetaObject::invokeMethod(statusArea, "languageChanged", Q_ARG(QVariant, user.graphPreferredLanguage));
     QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, !user.graphActions.contains("Exceed 100 Kph")));
+    QStringList t;
+    foreach(const QString &s, user.graphActions) {
+        if(!s.contains("Exceed"))
+            t.append(s);
+    }
+    QString type = user.policy;
+    if(user.graphPreferredLanguage == "fr") {
+        if(type == "Owner")
+            type = "Propriétaire";
+        else if(type == "Driver")
+            type = "Conducteur";
+        else if(type == "Maintainer")
+            type = "Maintenance";
+    }
+    QMetaObject::invokeMethod(home, "setUser", Q_ARG(QVariant, type), Q_ARG(QVariant, QVariant::fromValue(t)));
     if(user.ccNumberMasked.isEmpty())
         QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, false), Q_ARG(QVariant, ""));
     else
@@ -160,6 +180,7 @@ void UserManagement::onTextMessageReceived(QString message)
         user.postal_code = map["postal_code"].toString();
         user.first_name = map["first_name"].toString();
         user.keytoken = map["keytoken"].toString();
+        user.policy = map["graphPolicies"].toString();
         setUser(user);
     }
 }
@@ -243,14 +264,14 @@ void UserManagement::processTextMessage(QString message)
                               ":\"19\",\"ccExpMonth\":\"01\",\"description\":\"Original description\",\"groups\":[],\"last_name\":\""
                               "Jensen\",\"ccNumber\":\"111-2343-1121-111\",\"house_identifier\":\"ForgeRock\",\"phone\":\""
                               "+1 408 555 1862\",\"name\":\"bjensen\",\"state\":\"CA\",\"common_name\":\"Barbara Jensen\",\"fax\":\""
-                              "+1 408 555 1862\",\"postal_code\":\"94105\",\"first_name\":\"Barbara\",\"keytoken\":\"a123456\"}";
+                              "+1 408 555 1862\",\"postal_code\":\"94105\",\"first_name\":\"Barbara\",\"keytoken\":\"a123456\",\"graphPolicies\":\"Driver\"}";
     QString clientDetails_2 = "{\"postal_address\":\"201 Mission Street\",\"loc\":\"37.7914374,-122.3950694\""
                               ",\"country\":\"USA\",\"mail\":\"bjensen@example.com\",\"city\":\"San Francisco\",\"graphEmail\":"
                               "\"bjensen@example.com\",\"graphPreferredLanguage\":\"fr\",\"ccNumberMasked\":\"-222\",\"ccExpYear\""
                               ":\"19\",\"ccExpMonth\":\"01\",\"description\":\"Original description\",\"groups\":[],\"last_name\":\""
                               "Jensen\",\"ccNumber\":\"111-2343-1121-111\",\"house_identifier\":\"ForgeRock\",\"phone\":\""
                               "+1 408 555 1862\",\"name\":\"bjensen\",\"state\":\"CA\",\"common_name\":\"Barbara Jensen\",\"fax\":\""
-                              "+1 408 555 1862\",\"postal_code\":\"94105\",\"first_name\":\"José\",\"keytoken\":\"a123456\"}";
+                              "+1 408 555 1862\",\"postal_code\":\"94105\",\"first_name\":\"José\",\"keytoken\":\"a123456\",\"graphPolicies\":\"Maintainer\"}";
     QString clientDetails = clientDetails_1;
     if(sequence % 2 == 1)
         clientDetails = clientDetails_2;
index b374719..32db93f 100644 (file)
@@ -36,6 +36,7 @@ struct User {
     QString first_name;
     QString keytoken;
     QStringList graphActions;
+    QString policy;
 };
 
 class UserManagement : public QObject