gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[reclaim-ui] 245/459: improved scope display


From: gnunet
Subject: [reclaim-ui] 245/459: improved scope display
Date: Fri, 11 Jun 2021 23:25:37 +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 5a4dc9b56d0409383ebdb6598aeb860b2e3b42ab
Author: anna wimbauer <anna.wibauer@gmx.de>
AuthorDate: Mon Jul 20 09:07:31 2020 +0200

    improved scope display
---
 .../edit-attestations.component.html               |  2 +-
 .../edit-attestations.component.ts                 | 37 ++++++++++++++++++++--
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/src/app/edit-attestations/edit-attestations.component.html 
b/src/app/edit-attestations/edit-attestations.component.html
index 172fe8e..f7bf98f 100644
--- a/src/app/edit-attestations/edit-attestations.component.html
+++ b/src/app/edit-attestations/edit-attestations.component.html
@@ -29,7 +29,7 @@
       <div *ngIf="newIdProviderDiscovered() && !loggedIn()" class="mb-3 px-2">
           <div class="mx-n2">Available claims to request:</div>
           <div *ngFor="let scope of scopes" class="form-check mx-2">
-            <input type="checkbox" class="form-check-input" id="scopes" 
[(ngModel)]="scope.chosen">
+            <input type="checkbox" class="form-check-input" id="scopes" 
[disabled]="necessaryScope(scope.scope)" [(ngModel)]="scope.chosen">
             <label class="form-check-label" 
for="scope.chosen">{{scope.scope}}</label>
           </div>
         <button class="btn btn-primary mb-1 mt-2 fhg-link" 
(click)="loginFhgAccount()">
diff --git a/src/app/edit-attestations/edit-attestations.component.ts 
b/src/app/edit-attestations/edit-attestations.component.ts
index 4ddcec3..caf5009 100644
--- a/src/app/edit-attestations/edit-attestations.component.ts
+++ b/src/app/edit-attestations/edit-attestations.component.ts
@@ -42,7 +42,7 @@ export class EditAttestationsComponent implements OnInit {
     this.webfingerEmail = '';
     this.emailNotFoundAlertClosed = true;
     this.errorMassage = '';
-    this.scopes = [];
+    this.loadScopesFromLocalStorage()
     this.loadIdProviderFromLocalStorage();
     this.attestations = [];
     if (this.newIdProvider.url !== ''){
@@ -99,6 +99,7 @@ export class EditAttestationsComponent implements OnInit {
       console.log("Saved Attestation");
       console.log(res);
       this.resetNewIdProvider();
+      this.resetScopes();
       this.updateAttestations();
       this.newAttestation.name = '';
       this.newAttestation.value = '';
@@ -249,6 +250,7 @@ export class EditAttestationsComponent implements OnInit {
   cancelAdding(){
     this.logOutFromOauthService();
     this.resetNewIdProvider();
+    this.resetScopes();
     this.newAttestation.value = '';
     this.newAttestation.name = '';
   }
@@ -296,10 +298,28 @@ export class EditAttestationsComponent implements OnInit {
         }
         this.scopes.push(scopeInterface)
       });
-      console.log(this.scopes);
+      localStorage.setItem("scopes", JSON.stringify(this.scopes));
       });  
   }
 
+  loadScopesFromLocalStorage(){
+    this.scopes = [];
+    var loadedScopes = localStorage.getItem("scopes");
+    if (loadedScopes==null){
+      return
+    }
+    loadedScopes.split(',{').forEach(scopeObject => {
+      var scopeName = scopeObject.split(',')[0];
+      var scopeChosen = scopeObject.split(',')[1].slice(0, -1);
+      const scopeInterface: Scope = {
+        scope: scopeName.split(':')[1].slice(1,-1),
+        chosen: (/true/i).test(scopeChosen.split(':')[1]),
+      }
+      this.scopes.push(scopeInterface)
+    }
+      );
+  }
+
   newIdProviderDiscovered(){
     if (this.newIdProvider.url == ''){
       return false;
@@ -325,8 +345,21 @@ export class EditAttestationsComponent implements OnInit {
 
   cancelLinking(){
     this.resetNewIdProvider();
+    this.resetScopes();
     this.webfingerEmail = '';
   }
 
+  necessaryScope(scope){
+    if(scope=="openid"||scope=="profile"){
+      return true;
+    }
+    return false;
+  }
+
+  resetScopes(){
+    localStorage.removeItem("scopes");
+    this.scopes = [];
+  }
+
 
 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]