diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2021-01-05 23:04:39 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2021-01-05 23:04:39 +0900 |
commit | 2af62d70239f368655bee6349ce0013886e83d2e (patch) | |
tree | 496a84feb6e67c3233b64e71be427e60c4c2ace9 | |
parent | 8abf541b3eb971fc67eeea95ffaaa68c9aa375fc (diff) | |
download | reclaim-ui-2af62d70239f368655bee6349ce0013886e83d2e.tar.gz reclaim-ui-2af62d70239f368655bee6349ce0013886e83d2e.zip |
quality of life improvements
-rw-r--r-- | src/app/edit-credentials/edit-credentials.component.html | 2 | ||||
-rw-r--r-- | src/app/edit-identity/edit-identity.component.html | 21 | ||||
-rw-r--r-- | src/app/edit-identity/edit-identity.component.ts | 2 | ||||
-rw-r--r-- | src/app/identity-list/identity-list.component.html | 7 | ||||
-rw-r--r-- | src/app/identity-list/identity-list.component.ts | 41 | ||||
-rw-r--r-- | src/locales/de/messages.json | 1 | ||||
-rw-r--r-- | src/locales/en/messages.json | 1 |
7 files changed, 55 insertions, 20 deletions
diff --git a/src/app/edit-credentials/edit-credentials.component.html b/src/app/edit-credentials/edit-credentials.component.html index 77b14a6..c5d7705 100644 --- a/src/app/edit-credentials/edit-credentials.component.html +++ b/src/app/edit-credentials/edit-credentials.component.html | |||
@@ -42,7 +42,7 @@ | |||
42 | </td> | 42 | </td> |
43 | <td> | 43 | <td> |
44 | <button class="btn btn-primary" (click)="deleteCredential(credential)"> | 44 | <button class="btn btn-primary" (click)="deleteCredential(credential)"> |
45 | <span class="fa fa-trash"></span> | 45 | <span class="fa fa-trash"></span> {{ getMessage("Delete") }} |
46 | </button> | 46 | </button> |
47 | </td> | 47 | </td> |
48 | <td> | 48 | <td> |
diff --git a/src/app/edit-identity/edit-identity.component.html b/src/app/edit-identity/edit-identity.component.html index a75569d..6a767d8 100644 --- a/src/app/edit-identity/edit-identity.component.html +++ b/src/app/edit-identity/edit-identity.component.html | |||
@@ -98,9 +98,11 @@ | |||
98 | <div class="col-sm" style="display:flex;"> | 98 | <div class="col-sm" style="display:flex;"> |
99 | <div style="flex:1;"> | 99 | <div style="flex:1;"> |
100 | <input *ngIf="!isClaimCred(newRequestedAttribute) && !isClaimCredentialRequested(newRequestedAttribute)" | 100 | <input *ngIf="!isClaimCred(newRequestedAttribute) && !isClaimCredentialRequested(newRequestedAttribute)" |
101 | placeholder="{{ getMessage('Value') }}" [(ngModel)]="newRequestedAttribute.value"> | 101 | placeholder="{{ getMessage('Value') }}" [(ngModel)]="newRequestedAttribute.value" |
102 | (keyup.enter)="canAddAttribute(newRequestedAttribute) && saveAttribute(newRequestedAttribute)"> | ||
102 | <select class="custom-select" | 103 | <select class="custom-select" |
103 | *ngIf="isClaimCredentialRequested(newRequestedAttribute) && credentials.length > 0" (change)="newRequestedAttribute.value=$event.target.value"> | 104 | *ngIf="isClaimCredentialRequested(newRequestedAttribute) && credentials.length > 0" |
105 | (change)="newRequestedAttribute.value=$event.target.value"> | ||
104 | <option [value]="getZeroId()" >{{ getMessage("edit_identity_html@selectClaim") }}</option> | 106 | <option [value]="getZeroId()" >{{ getMessage("edit_identity_html@selectClaim") }}</option> |
105 | <option *ngFor="let claim of credentialValuesForClaim(newRequestedAttribute)" value={{claim.name}}> | 107 | <option *ngFor="let claim of credentialValuesForClaim(newRequestedAttribute)" value={{claim.name}}> |
106 | {{claim.value}} <i>({{claim.name}})</i> | 108 | {{claim.value}} <i>({{claim.name}})</i> |
@@ -152,7 +154,8 @@ | |||
152 | </div> | 154 | </div> |
153 | <div class="col-sm" style="display:flex;"> | 155 | <div class="col-sm" style="display:flex;"> |
154 | <div style="flex:1;"> | 156 | <div style="flex:1;"> |
155 | <input *ngIf="!isClaimCred(newStandardAttribute)" placeholder="{{ getMessage('Value') }}" [(ngModel)]="newStandardAttribute.value"> | 157 | <input *ngIf="!isClaimCred(newStandardAttribute)" placeholder="{{ getMessage('Value') }}" [(ngModel)]="newStandardAttribute.value" |
158 | (keyup.enter)="canAddAttribute(newStandardAttribute) && saveAttribute(newStandardAttribute)"> | ||
156 | <select class="custom-select" | 159 | <select class="custom-select" |
157 | *ngIf="newStandardAttribute.credential !== '' && isClaimCred(newStandardAttribute)" (change)="newStandardAttribute.value=$event.target.value"> | 160 | *ngIf="newStandardAttribute.credential !== '' && isClaimCred(newStandardAttribute)" (change)="newStandardAttribute.value=$event.target.value"> |
158 | <option value="" >{{ getMessage("edit_identity_html@selectClaim") }}</option> | 161 | <option value="" >{{ getMessage("edit_identity_html@selectClaim") }}</option> |
@@ -186,11 +189,15 @@ | |||
186 | <div class="row mb-3" | 189 | <div class="row mb-3" |
187 | [class.alert-danger]="isInConflict(newAttribute)"> | 190 | [class.alert-danger]="isInConflict(newAttribute)"> |
188 | <div class="col-sm"> | 191 | <div class="col-sm"> |
189 | <input [class.text-danger]="!attributeNameValid(newAttribute)" placeholder="{{ getMessage('edit_identity_html@name') }}" [(ngModel)]="newAttribute.name"> | 192 | <input [class.text-danger]="!attributeNameValid(newAttribute)" |
193 | placeholder="{{ getMessage('edit_identity_html@name') }}" [(ngModel)]="newAttribute.name" | ||
194 | (keyup.enter)="canAddAttribute(newAttribute) && saveAttribute(newAttribute)"> | ||
190 | </div> | 195 | </div> |
191 | <div class="col-sm" style="display:flex;"> | 196 | <div class="col-sm" style="display:flex;"> |
192 | <div style="flex:1;"> | 197 | <div style="flex:1;"> |
193 | <input *ngIf="!isClaimCred(newAttribute)" placeholder="{{ getMessage('Value') }}" [(ngModel)]="newAttribute.value"> | 198 | <input *ngIf="!isClaimCred(newAttribute)" placeholder="{{ getMessage('Value') }}" |
199 | [(ngModel)]="newAttribute.value" | ||
200 | (keyup.enter)="canAddAttribute(newAttribute) && saveAttribute(newAttribute)"> | ||
194 | <select class="custom-select" | 201 | <select class="custom-select" |
195 | *ngIf="newAttribute.credential !== '' && isClaimCred(newAttribute)" (change)="newAttribute.value=$event.target.value"> | 202 | *ngIf="newAttribute.credential !== '' && isClaimCred(newAttribute)" (change)="newAttribute.value=$event.target.value"> |
196 | <option value="" >{{ getMessage("edit_identity_html@selectClaim") }}</option> | 203 | <option value="" >{{ getMessage("edit_identity_html@selectClaim") }}</option> |
@@ -247,7 +254,9 @@ | |||
247 | </div> | 254 | </div> |
248 | <div class="col-sm" style="display:flex;"> | 255 | <div class="col-sm" style="display:flex;"> |
249 | <div style="flex:1;" *ngIf="claim == claimInEdit"> | 256 | <div style="flex:1;" *ngIf="claim == claimInEdit"> |
250 | <input *ngIf="!isClaimCred(claim)" placeholder="{{ getMessage('Value') }}" [(ngModel)]="claim.value"> | 257 | <input *ngIf="!isClaimCred(claim)" placeholder="{{ getMessage('Value') }}" |
258 | [(ngModel)]="claim.value" | ||
259 | (keyup.enter)="canUpdateAttribute(claim) && saveAttribute(claim)"> | ||
251 | <select class="custom-select" | 260 | <select class="custom-select" |
252 | [(ngModel)]="claim.value" | 261 | [(ngModel)]="claim.value" |
253 | *ngIf="claim.credential !== '' && isClaimCred(claim)" (change)="credentialClaimSelected(claim, $event.target.value)"> | 262 | *ngIf="claim.credential !== '' && isClaimCred(claim)" (change)="credentialClaimSelected(claim, $event.target.value)"> |
diff --git a/src/app/edit-identity/edit-identity.component.ts b/src/app/edit-identity/edit-identity.component.ts index 0608f61..1869503 100644 --- a/src/app/edit-identity/edit-identity.component.ts +++ b/src/app/edit-identity/edit-identity.component.ts | |||
@@ -153,7 +153,7 @@ export class EditIdentityComponent implements OnInit { | |||
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | sortAttributes(attrs: Attribute[]) { | 156 | private sortAttributes(attrs: Attribute[]) { |
157 | return attrs.sort((a,b) => { | 157 | return attrs.sort((a,b) => { |
158 | if (this.getAttributePriority(a) > this.getAttributePriority(b)) { | 158 | if (this.getAttributePriority(a) > this.getAttributePriority(b)) { |
159 | return -1; | 159 | return -1; |
diff --git a/src/app/identity-list/identity-list.component.html b/src/app/identity-list/identity-list.component.html index a79a1f7..3f951ec 100644 --- a/src/app/identity-list/identity-list.component.html +++ b/src/app/identity-list/identity-list.component.html | |||
@@ -172,9 +172,14 @@ | |||
172 | </div> | 172 | </div> |
173 | <button class="btn btn-primary mt-3" (click)="openIdentity = identity" | 173 | <button class="btn btn-primary mt-3" (click)="openIdentity = identity" |
174 | *ngIf="(openIdentity != identity) && hasLotsOfAttributes(identity)"> | 174 | *ngIf="(openIdentity != identity) && hasLotsOfAttributes(identity)"> |
175 | <i class="fa fa-expand"></i> | 175 | <i class="fa fa-angle-down"></i> |
176 | {{ getMessage("identity_list_html@showAll") }} | 176 | {{ getMessage("identity_list_html@showAll") }} |
177 | </button> | 177 | </button> |
178 | <button class="btn btn-primary mt-3" (click)="openIdentity = null" | ||
179 | *ngIf="(openIdentity == identity)"> | ||
180 | <i class="fa fa-angle-up"></i> | ||
181 | {{ getMessage("identity_list_html@showLess") }} | ||
182 | </button> | ||
178 | </div> | 183 | </div> |
179 | </div> | 184 | </div> |
180 | <div *ngIf="inOpenIdFlow()"> | 185 | <div *ngIf="inOpenIdFlow()"> |
diff --git a/src/app/identity-list/identity-list.component.ts b/src/app/identity-list/identity-list.component.ts index 54ffac4..12d9ade 100644 --- a/src/app/identity-list/identity-list.component.ts +++ b/src/app/identity-list/identity-list.component.ts | |||
@@ -142,24 +142,43 @@ export class IdentityListComponent implements OnInit { | |||
142 | return this.oidcService.getClaimDescription(attr); | 142 | return this.oidcService.getClaimDescription(attr); |
143 | } | 143 | } |
144 | 144 | ||
145 | sortAttributeByStandardClaims(mylist: string[]) { | 145 | private sortAttributes(attrs: Attribute[]) { |
146 | return function(a1: Attribute, a2: Attribute) { | 146 | return attrs.sort((a,b) => { |
147 | var claimNames = mylist; | 147 | if (this.getAttributePriority(a) > this.getAttributePriority(b)) { |
148 | let idx1 = claimNames.indexOf(a1.name); | 148 | return -1; |
149 | let idx2 = claimNames.indexOf(a2.name); | 149 | } |
150 | if ((idx1 == -1) && (idx2 != -1)) { return 1;} | 150 | if (this.getAttributePriority(a) < this.getAttributePriority(b)) { |
151 | if ((idx2 == -1) && (idx1 != -1)) { return -1;} | 151 | return 1; |
152 | if (idx1 > idx2) {return 1;} | 152 | } |
153 | if (idx1 < idx2) {return -1;} | 153 | if (a.name > b.name) { |
154 | return -1; | ||
155 | } | ||
156 | if (a.name < b.name) { | ||
157 | return 1; | ||
158 | } | ||
154 | return 0; | 159 | return 0; |
155 | } | 160 | }); |
161 | } | ||
162 | |||
163 | private getAttributePriority(attr: Attribute) { | ||
164 | if (this.oidcService.isStandardProfileClaim(attr)) { | ||
165 | return 5; | ||
166 | } else if (this.oidcService.isStandardEmailClaim(attr)) { | ||
167 | return 6; | ||
168 | } else if (this.oidcService.isStandardAddressClaim(attr)) { | ||
169 | return 4; | ||
170 | } else if (this.oidcService.isStandardPhoneClaim(attr)) { | ||
171 | return 3; | ||
172 | } else { | ||
173 | return 2; | ||
174 | } | ||
156 | } | 175 | } |
157 | 176 | ||
158 | private updateAttributes(identity) { | 177 | private updateAttributes(identity) { |
159 | this.attributes[identity.pubkey] = []; | 178 | this.attributes[identity.pubkey] = []; |
160 | this.missingClaims[identity.pubkey] = []; | 179 | this.missingClaims[identity.pubkey] = []; |
161 | this.reclaimService.getAttributes(identity).subscribe(attributes => { | 180 | this.reclaimService.getAttributes(identity).subscribe(attributes => { |
162 | this.attributes[identity.pubkey] = attributes.sort(this.sortAttributeByStandardClaims(this.oidcService.getStandardClaimNames())); | 181 | this.attributes[identity.pubkey] = this.sortAttributes(attributes); |
163 | this.updateMissingClaims(identity); | 182 | this.updateMissingClaims(identity); |
164 | }, | 183 | }, |
165 | err => { | 184 | err => { |
diff --git a/src/locales/de/messages.json b/src/locales/de/messages.json index b390e6c..d64d1c2 100644 --- a/src/locales/de/messages.json +++ b/src/locales/de/messages.json | |||
@@ -108,6 +108,7 @@ | |||
108 | "identity_list_html@editId": "Identität ändern", | 108 | "identity_list_html@editId": "Identität ändern", |
109 | "identity_list_html@moreAttributes": "… und {{ATTRIBUTENUMBER}} weitere Attribute", | 109 | "identity_list_html@moreAttributes": "… und {{ATTRIBUTENUMBER}} weitere Attribute", |
110 | "identity_list_html@showAll": "Zeige alle Attribute", | 110 | "identity_list_html@showAll": "Zeige alle Attribute", |
111 | "identity_list_html@showLess": "Zeige weniger Attribute", | ||
111 | "identity_list_html@shareInfo1": "Teile hervorgehobene Informationen mit", | 112 | "identity_list_html@shareInfo1": "Teile hervorgehobene Informationen mit", |
112 | "identity_list_html@shareInfo2": "von dieser Identität.", | 113 | "identity_list_html@shareInfo2": "von dieser Identität.", |
113 | "identity_list_html@sharingDisabled": "Teilen nicht möglich", | 114 | "identity_list_html@sharingDisabled": "Teilen nicht möglich", |
diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 72b5ec9..9ec97cf 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json | |||
@@ -108,6 +108,7 @@ | |||
108 | "identity_list_html@editId": "Edit identity", | 108 | "identity_list_html@editId": "Edit identity", |
109 | "identity_list_html@moreAttributes": "… and {{ATTRIBUTENUMBER}} more attributes", | 109 | "identity_list_html@moreAttributes": "… and {{ATTRIBUTENUMBER}} more attributes", |
110 | "identity_list_html@showAll": "Show all attributes", | 110 | "identity_list_html@showAll": "Show all attributes", |
111 | "identity_list_html@showLess": "Show less attributes", | ||
111 | "identity_list_html@shareInfo1": "Share information marked with", | 112 | "identity_list_html@shareInfo1": "Share information marked with", |
112 | "identity_list_html@shareInfo2": "from this identity.", | 113 | "identity_list_html@shareInfo2": "from this identity.", |
113 | "identity_list_html@sharingDisabled": "Sharing disabled", | 114 | "identity_list_html@sharingDisabled": "Sharing disabled", |