diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-22 01:39:09 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-22 01:39:09 +0200 |
commit | 26e02b898d3f4e63c942d2742cb920aec9e6489c (patch) | |
tree | cd69d3caf4cb71b7c0310691ffe735cb874a62e9 | |
parent | aba499f81e0e260c6bf6410e28203fa0b05264db (diff) | |
download | kube-26e02b898d3f4e63c942d2742cb920aec9e6489c.tar.gz kube-26e02b898d3f4e63c942d2742cb920aec9e6489c.zip |
Display corresponding account information with log entry
-rw-r--r-- | components/kube/contents/ui/LogView.qml | 38 | ||||
-rw-r--r-- | framework/src/accounts/accountsmodel.cpp | 24 | ||||
-rw-r--r-- | framework/src/accounts/accountsmodel.h | 4 |
3 files changed, 62 insertions, 4 deletions
diff --git a/components/kube/contents/ui/LogView.qml b/components/kube/contents/ui/LogView.qml index f3297ac6..0d01ed6f 100644 --- a/components/kube/contents/ui/LogView.qml +++ b/components/kube/contents/ui/LogView.qml | |||
@@ -50,9 +50,7 @@ Controls.SplitView { | |||
50 | } | 50 | } |
51 | 51 | ||
52 | onCurrentItemChanged: { | 52 | onCurrentItemChanged: { |
53 | if (details.resourceId) { | 53 | details.resourceId = currentItem.currentData.resource |
54 | details.resourceId = currentItem.currentData.resource | ||
55 | } | ||
56 | details.message = currentItem.currentData.message | 54 | details.message = currentItem.currentData.message |
57 | details.timestamp = currentItem.currentData.timestamp | 55 | details.timestamp = currentItem.currentData.timestamp |
58 | } | 56 | } |
@@ -123,9 +121,25 @@ Controls.SplitView { | |||
123 | id: details | 121 | id: details |
124 | property date timestamp | 122 | property date timestamp |
125 | property string message | 123 | property string message |
126 | //TODO get account name from resource id | ||
127 | property string resourceId: "" | 124 | property string resourceId: "" |
125 | property string accountId: "" | ||
126 | property string accountName: "" | ||
128 | color: Kube.Colors.backgroundColor | 127 | color: Kube.Colors.backgroundColor |
128 | Repeater { | ||
129 | model: Kube.AccountsModel { | ||
130 | id: accountsModel | ||
131 | resourceId: details.resourceId | ||
132 | } | ||
133 | Item { | ||
134 | property string account: model.accountId | ||
135 | property string accountName: model.name | ||
136 | onAccountChanged: { | ||
137 | details.accountId = account | ||
138 | details.accountName = name | ||
139 | } | ||
140 | visible: false | ||
141 | } | ||
142 | } | ||
129 | Rectangle { | 143 | Rectangle { |
130 | anchors { | 144 | anchors { |
131 | fill: parent | 145 | fill: parent |
@@ -136,6 +150,22 @@ Controls.SplitView { | |||
136 | anchors.fill: parent | 150 | anchors.fill: parent |
137 | columns: 2 | 151 | columns: 2 |
138 | Kube.Label { | 152 | Kube.Label { |
153 | text: qsTr("Account:") | ||
154 | visible: details.accountName | ||
155 | } | ||
156 | Kube.Label { | ||
157 | text: details.accountName | ||
158 | visible: details.accountName | ||
159 | } | ||
160 | Kube.Label { | ||
161 | text: qsTr("Account Id:") | ||
162 | visible: details.accountId | ||
163 | } | ||
164 | Kube.Label { | ||
165 | text: details.accountId | ||
166 | visible: details.accountId | ||
167 | } | ||
168 | Kube.Label { | ||
139 | text: qsTr("Resource Id:") | 169 | text: qsTr("Resource Id:") |
140 | visible: details.resourceId | 170 | visible: details.resourceId |
141 | } | 171 | } |
diff --git a/framework/src/accounts/accountsmodel.cpp b/framework/src/accounts/accountsmodel.cpp index 8b46f4d3..153cdc45 100644 --- a/framework/src/accounts/accountsmodel.cpp +++ b/framework/src/accounts/accountsmodel.cpp | |||
@@ -103,3 +103,27 @@ QByteArray AccountsModel::accountId() const | |||
103 | { | 103 | { |
104 | return {}; | 104 | return {}; |
105 | } | 105 | } |
106 | |||
107 | void AccountsModel::setResourceId(const QByteArray &resourceId) | ||
108 | { | ||
109 | qWarning() << "Setting resource id" << resourceId; | ||
110 | if (resourceId.isEmpty()) { | ||
111 | setSourceModel(nullptr); | ||
112 | mModel.clear(); | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | Sink::Store::fetchOne<SinkResource>(Sink::Query{}.filter(resourceId)).guard(this).then([this] (const Sink::ApplicationDomain::SinkResource &resource) { | ||
117 | Sink::Query query; | ||
118 | query.filter(resource.getAccount()); | ||
119 | query.request<SinkAccount::Name>(); | ||
120 | query.request<SinkAccount::Icon>(); | ||
121 | query.request<SinkAccount::Status>(); | ||
122 | runQuery(query); | ||
123 | }).exec(); | ||
124 | } | ||
125 | |||
126 | QByteArray AccountsModel::resourceId() const | ||
127 | { | ||
128 | return {}; | ||
129 | } | ||
diff --git a/framework/src/accounts/accountsmodel.h b/framework/src/accounts/accountsmodel.h index 2c82a8b9..4991f7e0 100644 --- a/framework/src/accounts/accountsmodel.h +++ b/framework/src/accounts/accountsmodel.h | |||
@@ -33,6 +33,7 @@ class AccountsModel : public QIdentityProxyModel | |||
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | 34 | ||
35 | Q_PROPERTY (QByteArray accountId READ accountId WRITE setAccountId) | 35 | Q_PROPERTY (QByteArray accountId READ accountId WRITE setAccountId) |
36 | Q_PROPERTY (QByteArray resourceId READ resourceId WRITE setResourceId) | ||
36 | public: | 37 | public: |
37 | enum Status { | 38 | enum Status { |
38 | OfflineStatus, | 39 | OfflineStatus, |
@@ -61,6 +62,9 @@ public: | |||
61 | void setAccountId(const QByteArray &id); | 62 | void setAccountId(const QByteArray &id); |
62 | QByteArray accountId() const; | 63 | QByteArray accountId() const; |
63 | 64 | ||
65 | void setResourceId(const QByteArray &id); | ||
66 | QByteArray resourceId() const; | ||
67 | |||
64 | private: | 68 | private: |
65 | void runQuery(const Sink::Query &query); | 69 | void runQuery(const Sink::Query &query); |
66 | QSharedPointer<QAbstractItemModel> mModel; | 70 | QSharedPointer<QAbstractItemModel> mModel; |