gnunet-svn
[Top][All Lists]
Advanced

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

[reclaim-ui] 75/459: ticket list fixed attributes and added revoke confi


From: gnunet
Subject: [reclaim-ui] 75/459: ticket list fixed attributes and added revoke confirmation
Date: Fri, 11 Jun 2021 23:22:47 +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 3e8dc2aa27c0d71b1bed94c1ffb4e9c22f1ef0ff
Author: Alexia Pagkopoulou <a.pagkopoulou@tum.de>
AuthorDate: Fri Jun 7 13:14:55 2019 +0200

    ticket list fixed attributes and added revoke confirmation
---
 src/app/identity-list/identity-list.component.html | 17 ++++++--
 src/app/identity-list/identity-list.component.ts   | 48 +++++++++++++++++-----
 src/app/namestore.service.ts                       |  4 ++
 3 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/src/app/identity-list/identity-list.component.html 
b/src/app/identity-list/identity-list.component.html
index 20e164a..af8d7a9 100644
--- a/src/app/identity-list/identity-list.component.html
+++ b/src/app/identity-list/identity-list.component.html
@@ -116,13 +116,24 @@
             </td>
             <td>
               <div style="min-width: 15em">
-                {{showSharedAttributes(ticket)}}
+                {{ticketAttributeMapper[ticket.audience]}}
               </div>
             </td>
             <td>
+              
+              
+              <button class="btn btn-primary" *ngIf="showConfirmRevoke != 
ticket" (click)="confirmRevoke(ticket)">
+                <span class="fa fa-unlink"></span> Revoke
+              </button>
+              <div class="alert alert-danger fade show" 
*ngIf="showConfirmRevoke == ticket">
+                Do you really want to revoke this ticket?<br/><br/>
               <button class="btn btn-primary" 
(click)="revokeTicket(identityInEdit, ticket)">
                 <span class="fa fa-unlink"></span> Revoke
               </button>
+              <button class="btn btn-primary" (click)="hideConfirmRevoke()">
+                <span class="fa fa-close"></span> Cancel
+              </button>
+              </div>
             </td>
           </tr>
         </tbody>
@@ -146,11 +157,11 @@
     <div class="card-avatar card-img-top">
       <div class="card-avatar-character text-dark">
         <div class="icon m-1 text-uppercase" 
[style.background-color]="intToRGB(identity.pubkey)">{{ identity.name[0]}}</div>
-        <span class="m-1" styl="display: inline-block">{{ 
identity.name}}</span>
+        <span class="m-1" styl="display: inline-block">{{identity.name}}</span>
         <button class="btn btn-primary" *ngIf="showConfirmDelete != identity" 
(click)="confirmDelete(identity)">
           <span class="fa fa-trash"></span>
         </button>
-                <button class="btn btn-primary" *ngIf="showConfirmDelete != 
identity" (click)="editIdentity(identity)">
+        <button class="btn btn-primary" *ngIf="showConfirmDelete != identity" 
(click)="editIdentity(identity)">
           <span class="fa fa-edit"></span>
         </button>
       </div>
diff --git a/src/app/identity-list/identity-list.component.ts 
b/src/app/identity-list/identity-list.component.ts
index 96e74ef..ec91100 100644
--- a/src/app/identity-list/identity-list.component.ts
+++ b/src/app/identity-list/identity-list.component.ts
@@ -34,7 +34,9 @@ export class IdentityListComponent implements OnInit {
   identityNameMapper: any;
   showTicketsIdentity: Identity;
   showConfirmDelete: any;
+  showConfirmRevoke: any;
   connected: any;
+  ticketAttributeMapper: any;
 
   constructor(private route: ActivatedRoute, private router: Router,
               private oidcService: OpenIdService,
@@ -51,11 +53,13 @@ export class IdentityListComponent implements OnInit {
     this.tickets = {};
     this.identities = [];
     this.showConfirmDelete = null;
+    this.showConfirmRevoke = null;
     this.newAttribute = new Attribute ('', '', '', 'STRING');
     this.requestedAttributes = {};
     this.missingAttributes = {};
     this.clientName = "-";
     this.connected = false;
+    this.ticketAttributeMapper = {};
     this.oidcService.parseRouteParams(this.route.snapshot.queryParams);
     // On opening the options page, fetch stored settings and update the UI 
with
     // them.
@@ -109,7 +113,11 @@ export class IdentityListComponent implements OnInit {
 
   confirmDelete(identity) { this.showConfirmDelete = identity; }
 
+  confirmRevoke(ticket) { this.showConfirmRevoke = ticket; }
+
   hideConfirmDelete() { this.showConfirmDelete = null; }
+  
+  hideConfirmRevoke() { this.showConfirmRevoke = null; }
 
   getClientName()
   {
@@ -228,8 +236,26 @@ export class IdentityListComponent implements OnInit {
         this.identityNameMapper[ticket.audience] = records.data[i].value;
         break;
       }   
-    },
-      error => console.debug(error.message)); 
+    }); 
+  }
+
+  private mapAttributes(identity, ticket)
+  {    
+    this.namestoreService.getNames(identity).subscribe(names => {
+      this.ticketAttributeMapper[ticket.audience] = [];
+      names = names.filter(name => name.record_name === 
ticket.rnd.toLowerCase());
+      for (var i = 0; i < names.length; i++) {
+        names[i].data.forEach(record => {
+          if (record.record_type === 'RECLAIM_ATTR_REF') {            
+            this.attributes[identity.pubkey]
+              .filter(attr => attr.id === record.value)
+              .map(attr => {
+                this.ticketAttributeMapper[ticket.audience].push(attr.name);
+              });
+          }
+        });
+      } 
+    });
   }
 
   private updateTickets(identity)
@@ -240,7 +266,10 @@ export class IdentityListComponent implements OnInit {
         return;
       }
       this.tickets[identity.pubkey] = tickets;
-      tickets.forEach(ticket => this.mapAudience(ticket));
+      tickets.forEach(ticket => {
+        this.mapAudience(ticket);
+        this.mapAttributes(identity, ticket);
+      });
     }); 
   }
   
@@ -256,7 +285,10 @@ export class IdentityListComponent implements OnInit {
   revokeTicket(identity, ticket)
   {
     this.reclaimService.revokeTicket(ticket).subscribe(
-        data => { this.updateTickets(identity); });
+      data => { 
+        this.updateAttributes(identity);
+        this.updateTickets(identity); 
+      });
   }
 
 
@@ -280,12 +312,6 @@ export class IdentityListComponent implements OnInit {
     });
   }
 
-  showSharedAttributes(ticket)
-  {
-    return ["attr1", "attr2"];
-    //TODO 
-  }
-
   saveAttribute(identity, attribute)
   {
     return this.reclaimService.addAttribute(identity, attribute)
@@ -511,5 +537,5 @@ export class IdentityListComponent implements OnInit {
 
        isConnected() {
                return this.connected;
-       }
+  }
 }
diff --git a/src/app/namestore.service.ts b/src/app/namestore.service.ts
index 21a4939..2157098 100644
--- a/src/app/namestore.service.ts
+++ b/src/app/namestore.service.ts
@@ -10,6 +10,10 @@ export class NamestoreService {
 
   constructor(private http: HttpClient, private config: ConfigService) { }
 
+  getNames(identity) {
+    return this.http.get<any>(this.config.get().apiUrl + '/namestore/' + 
identity.name);
+  }
+
   deleteName(identity: Identity, name: string) {
     return this.http.delete(this.config.get().apiUrl + '/namestore/?label=' + 
name + "&name=" + identity.name);
   }

-- 
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]