[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[reclaim-ui] 398/459: select attributes to overwrite
From: |
gnunet |
Subject: |
[reclaim-ui] 398/459: select attributes to overwrite |
Date: |
Fri, 11 Jun 2021 23:28:10 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository reclaim-ui.
commit 8f3bc1e4d2bfde48e463421da0d8a8ee502c705f
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Thu Dec 31 23:46:12 2020 +0900
select attributes to overwrite
---
src/app/edit-identity/edit-identity.component.html | 28 ++++-
src/app/edit-identity/edit-identity.component.ts | 119 +++++++++++++++++----
.../import-attributes.component.html | 2 +-
src/locales/de/messages.json | 6 +-
src/locales/en/messages.json | 6 +-
5 files changed, 132 insertions(+), 29 deletions(-)
diff --git a/src/app/edit-identity/edit-identity.component.html
b/src/app/edit-identity/edit-identity.component.html
index 319da0b..4e0f281 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -6,11 +6,31 @@
</div>
</div>
- <div class="card-body text-center fa-4x" *ngIf="importInProgress">
- <i class="fa fa-spinner fa-spin"></i>
- Please wait
+ <div class="card-body" *ngIf="importInProgress &&
attributesToOverwriteOnImport.length > 0">
+ <div class="alert alert-warning">{{
getMessage("edit_identity_html@importOverwriteInfo") }}</div>
+ <div *ngFor="let overwriteInfo of attributesToOverwriteOnImport"
style="margin: 1em" (click)="overwriteInfo[1] = !overwriteInfo[1]">
+ <i [className]="overwriteInfo[1] ? 'fa fa-toggle-on mr-2 text-primary'
: 'fa fa-toggle-off mr-2'"></i>
+ <b>{{ getDescription(overwriteInfo[0]) }}</b>
+ <span [className]="!overwriteInfo[1] ? 'ml-4 text-primary' :
'text-secondary ml-4'">{{
getAttrValue(getAttributeByName(overwriteInfo[0].name)) }}</span> <i
class="ml-1"
*ngIf="isClaimCred(getAttributeByName(overwriteInfo[0].name))">({{getMessage("attested")}})</i>
<i class="fa fa-arrow-right mr-2 ml-2"></i> <span
[className]="overwriteInfo[1] ? 'text-primary' : 'text-secondary'">{{
getAttrValue(overwriteInfo[0]) }}</span> <i class="ml-1"
*ngIf="isClaimCred(overwriteInfo[0])">({{ [...]
+ </div>
+ <button class="ml-1 btn btn-primary"
+ (click)="toggleAllOverwriteInfo()">
+ <b *ngIf="!allSetToOverride()">{{ getMessage("selectAll") }}</b>
+ <b *ngIf="allSetToOverride()">{{ getMessage("deselectAll") }}</b>
+ </button><br/>
+ <button class="ml-1 btn btn-primary" (click)="proceedAttributeImport()">
+ <span class="fa fa-download"></span> {{getMessage("import") }}
+ </button>
+ <button class="ml-1 btn btn-primary" (click)="abortAttributeImport()">
+ <span class="fa fa-download"></span> {{getMessage("Back") }}
+ </button>
+ </div>
+ <div class="text-center card-body" *ngIf="importInProgress &&
attributesToOverwriteOnImport.length == 0">
+ <div class="text-center fa fa-4x">
+ <i *ngIf="attributesToOverwriteOnImport.length == 0" class="fa fa-cog
fa-spin"></i>
+ </div>
</div>
- <div *ngIf="validImportEmail" class="col-sm alert alert-primary
alert-dismissible fade show my-2" role="alert" >
+ <div *ngIf="validImportEmail && !importInProgress" class="col-sm alert
alert-primary alert-dismissible fade show my-2" role="alert" >
{{getMessage("edit_identity_html@importInfo", {ISSUERNAME:
getImportIssuerName()})}}<br/>
<i>{{getMessage("Note")}}</i>{{getMessage("edit_credentials_html@linkAccountInfo2")}}
<br/>
diff --git a/src/app/edit-identity/edit-identity.component.ts
b/src/app/edit-identity/edit-identity.component.ts
index f2a48fb..32d7013 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -52,6 +52,8 @@ export class EditIdentityComponent implements OnInit {
//Attribute import
importIdProvider: IdProvider;
+ attributesToImport: Attribute[] = [];
+ attributesToOverwriteOnImport: any[] = [];
validImportEmail: boolean = false;
importInProgress: boolean = false;
scopes: Scope[];
@@ -81,6 +83,7 @@ export class EditIdentityComponent implements OnInit {
this.newCredential = new Credential('', '', '', 'JWT', '', 0, []);
this.loadImportScopesFromLocalStorage()
this.loadImportIdProviderFromLocalStorage();
+ this.importInProgress = true;
this.activatedRoute.params.subscribe(p => {
if (p['id'] === undefined) {
return;
@@ -612,14 +615,98 @@ export class EditIdentityComponent implements OnInit {
}
}
+ abortAttributeImport() {
+ this.importIdProvider.url = '';
+ this.importIdProvider.name = '';
+ this.attributesToImport = [];
+ this.attributesToOverwriteOnImport = [];
+ localStorage.removeItem('importIdProviderURL');
+ localStorage.removeItem('credentialCode');
+ localStorage.removeItem('importTargetComponent');
+ this.importInProgress = false;
+ this.oauthService.logOut();
+ this.updateAttributes();
+ }
+
+ proceedAttributeImport() {
+ let promises = [];
+ for (let attestation of this.attributesToImport) {
+ let skip = false;
+ for (let overwriteAttrInfo of this.attributesToOverwriteOnImport) {
+ if ((overwriteAttrInfo[0].name === attestation.name) &&
+ !overwriteAttrInfo[1]) {
+ skip = true;
+ }
+ }
+ if (!skip) {
+ promises.push(
+ from(this.reclaimService.addAttribute(this.identity, attestation)));
+ }
+ }
+ forkJoin(promises)
+ .pipe(
+ finalize(() => {
+ this.importIdProvider.url = '';
+ this.importIdProvider.name = '';
+ this.attributesToImport = [];
+ this.attributesToOverwriteOnImport = [];
+ localStorage.removeItem('importIdProviderURL');
+ localStorage.removeItem('credentialCode');
+ localStorage.removeItem('importTargetComponent');
+ this.importInProgress = false;
+ this.oauthService.logOut();
+ this.updateAttributes();
+ })
+ ).subscribe(res => {
+ console.log("Finished attribute import.");
+ },
+ err => {
+ console.log(err);
+ });
+
+ }
+
+ toggleAllOverwriteInfo() {
+ let target = !this.allSetToOverride();
+ for (let overwriteInfo of this.attributesToOverwriteOnImport) {
+ overwriteInfo[1] = target;
+ }
+ }
+
+ allSetToOverride() {
+ for (let overwriteInfo of this.attributesToOverwriteOnImport) {
+ if (!overwriteInfo[1]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ getAttrValue(attr: Attribute) {
+ if (attr.credential === this.getZeroId()) {
+ return attr.value;
+ }
+ return this.getCredValue(attr);
+ }
+
+ getAttributeByName(name: string) {
+ for (let attr of this.attributes) {
+ if (attr.name === name) {
+ return attr;
+ }
+ }
+ return null;
+ }
+
importAttributesFromCredential() {
this.importInProgress = true;
this.reclaimService.addCredential(this.identity,
this.newCredential).subscribe(res => {
console.log("Stored credential");
this.reclaimService.getCredentials(this.identity).subscribe(creds => {
+ this.credentials = creds;
this.reclaimService.getAttributes(this.identity).subscribe(attrs => {
- var promises = [];
var cred = null;
+ this.attributesToImport = [];
for (var c of creds) {
if (c.name == this.newCredential.name) {
cred = c;
@@ -646,36 +733,24 @@ export class EditIdentityComponent implements OnInit {
if (existAttr.name !== attr.name) {
continue;
}
+ console.log("Found conflicting attribute " + attr.name);
+ this.attributesToOverwriteOnImport.push([attestation, false]);
attestation.id = existAttr.id;
break;
}
- promises.push(
- from(this.reclaimService.addAttribute(this.identity,
attestation)));
+ this.attributesToImport.push(attestation);
}
- forkJoin(promises)
- .pipe(
- finalize(() => {
- this.importIdProvider.url = '';
- this.importIdProvider.name = '';
- localStorage.removeItem('importIdProviderURL');
- localStorage.removeItem('credentialCode');
- localStorage.removeItem('importTargetComponent');
- this.importInProgress = false;
- this.oauthService.logOut();
- this.updateAttributes();
- })
- ).subscribe(res => {
- console.log("Finished attribute import.");
- },
- err => {
- console.log(err);
- });
+ if (this.attributesToOverwriteOnImport.length > 0) {
+ console.log("Wait for user input");
+ return;
+ }
+ this.proceedAttributeImport();
});
});
});
}
- validateEmailForImport() {
+ private validateEmailForImport() {
var emailAddr = null;
for (let attr of this.attributes) {
if (attr.name !== 'email') {
diff --git a/src/app/import-attributes/import-attributes.component.html
b/src/app/import-attributes/import-attributes.component.html
index a49e9b4..153174f 100644
--- a/src/app/import-attributes/import-attributes.component.html
+++ b/src/app/import-attributes/import-attributes.component.html
@@ -33,7 +33,7 @@
<input placeholder="user@example.com" [(ngModel)]="webfingerEmail"
(keyup)="validateEmail()">
</div>
<button class="btn btn-primary fhg-link" (click)="import()"
[disabled]="!validEmail">
- <span class="fa fa-download"></span>
{{getMessage("import_attributes_html@import")}}
+ <span class="fa fa-download"></span> {{getMessage("import")}}
</button>
<i *ngIf="discoveringIdProvider" class="ml-1 fa fa-spinner
fa-spin"></i>
</div>
diff --git a/src/locales/de/messages.json b/src/locales/de/messages.json
index f42b7a5..57b13e2 100644
--- a/src/locales/de/messages.json
+++ b/src/locales/de/messages.json
@@ -10,6 +10,10 @@
"Save": "Speichern",
"Note": "Hinweis: ",
"Value": "Wert",
+ "selectAll": "Alles auswählen",
+ "deselectAll": "Alles abwählen",
+ "import": "Importieren",
+ "attested": "attestiert",
"authorization_request_html@personalInfo": "Persönliche Datenabfrage",
"authorization_request_html@verifyRequest": "Verifiziere Anfrage, bitte
warten…",
"authorization_request_html@chooseId1": "frägt persönliche Daten an.",
@@ -22,7 +26,6 @@
"authorization_request_html@retry": "Nochmal versuchen",
"authorization_request_html@cancelRequest": "Verifikation abbrechen",
"authorization_request_html@requestCancelled": "Anfrage abgebrochen",
- "import_attributes_html@import": "Import",
"edit_authorizations_html@manageAuths": "Autorisierungen verwalten für",
"edit_authorizations_html@authEntity": "Autorisierte Partei:",
"edit_authorizations_html@sharedAttributes": "Geteilte Attribute:",
@@ -51,6 +54,7 @@
"edit_credentials_ts@noAccount": "Kein Konto mit diese E-Email Addresse
gefunden",
"edit_credentials_ts@errorWrongAddress": "Ein Fehler ist aufgetreten - Der
Grund könnte eine falsche E-Email Adresse sein.",
"edit_identity_html@basicInfo": "Gebräuchliche Informationen",
+ "edit_identity_html@importOverwriteInfo": "Du hast einige der zu
importierenden Attribute bereits gesetzt. Wähle unten diejenigen Attribute aus,
welche mit den neuen, importierten Werten überschrieben werden sollen.",
"edit_identity_html@addAttributes": "Neue Attribute hinzufügen",
"edit_identity_html@addStandardClaim": "Fehlende gebräuchliche,
standardisierte Attribute:",
"edit_identity_html@addCustomClaim": "Benutzerdefinierte Attribute:",
diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json
index 1a30fcb..d214bb5 100644
--- a/src/locales/en/messages.json
+++ b/src/locales/en/messages.json
@@ -10,6 +10,10 @@
"Save": "Save",
"Note": "Note: ",
"Value": "Value",
+ "selectAll": "Select all",
+ "deselectAll": "Deselect all",
+ "import": "Import",
+ "attested": "attested",
"authorization_request_html@personalInfo": "Personal information request",
"authorization_request_html@verifyRequest": "Verifying request, please
stand by…",
"authorization_request_html@chooseId1": "asks you to share personal
information.",
@@ -22,7 +26,6 @@
"authorization_request_html@retry": "Retry",
"authorization_request_html@cancelRequest": "Cancel verification request",
"authorization_request_html@requestCancelled": "Request cancelled",
- "import_attributes_html@import": "Import",
"edit_authorizations_html@manageAuths": "Manage authorizations for",
"edit_authorizations_html@authEntity": "Authorized Entity:",
"edit_authorizations_html@sharedAttributes": "Shared attributes:",
@@ -51,6 +54,7 @@
"edit_credentials_ts@noAccount": "No account found with this email",
"edit_credentials_ts@errorWrongAddress": "An Error has occured - This may
have been caused by a wrong e-mail address.",
"edit_identity_html@basicInfo": "Basic user information",
+ "edit_identity_html@importOverwriteInfo": "You already have set some of
the attributes to be imported. Select below those attributes which you want to
overwrite with the new, imported values.",
"edit_identity_html@addAttributes": "Add new attributes",
"edit_identity_html@addStandardClaim": "Missing common, standardized
attributes:",
"edit_identity_html@addCustomClaim": "Custom attributes:",
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [reclaim-ui] 411/459: fix, (continued)
- [reclaim-ui] 411/459: fix, gnunet, 2021/06/11
- [reclaim-ui] 410/459: enable filtering, gnunet, 2021/06/11
- [reclaim-ui] 389/459: update, gnunet, 2021/06/11
- [reclaim-ui] 414/459: replace table, gnunet, 2021/06/11
- [reclaim-ui] 400/459: fix, gnunet, 2021/06/11
- [reclaim-ui] 425/459: fix logo, gnunet, 2021/06/11
- [reclaim-ui] 434/459: Added translation using Weblate (Portuguese (Brazil)), gnunet, 2021/06/11
- [reclaim-ui] 429/459: yarn upgrade, gnunet, 2021/06/11
- [reclaim-ui] 390/459: update dependencies, gnunet, 2021/06/11
- [reclaim-ui] 408/459: various fixes, gnunet, 2021/06/11
- [reclaim-ui] 398/459: select attributes to overwrite,
gnunet <=
- [reclaim-ui] 435/459: Translated using Weblate (Portuguese), gnunet, 2021/06/11
- [reclaim-ui] 417/459: slim down attribute import, gnunet, 2021/06/11
- [reclaim-ui] 415/459: table header, gnunet, 2021/06/11
- [reclaim-ui] 439/459: Added translation using Weblate (Russian), gnunet, 2021/06/11
- [reclaim-ui] 448/459: Translated using Weblate (French), gnunet, 2021/06/11
- [reclaim-ui] 402/459: fix icons, translations, gnunet, 2021/06/11
- [reclaim-ui] 441/459: Translated using Weblate (Portuguese), gnunet, 2021/06/11
- [reclaim-ui] 420/459: fix, gnunet, 2021/06/11
- [reclaim-ui] 443/459: Translated using Weblate (Spanish), gnunet, 2021/06/11
- [reclaim-ui] 449/459: Translated using Weblate (French), gnunet, 2021/06/11