aboutsummaryrefslogtreecommitdiff
path: root/src/app/identity-list/identity-list.component.html
blob: bca97b512a12fcc8d6eb270465f5641b4536d348 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!-- OpenId Authorization Screen -->
<oid-modal id="OpenIdInfo">
  <div style="text-align: center;">
    <div class="logo"><img src="assets/reclaim_icon.png"/></div>
    <hr>
    <span *ngIf="clientNameFound === undefined">
      <i class="fa fa-2x fa-circle-o-notch fa-spin fa-fw"></i> 
      <b class="fa-2x"> Verifying request, please stand by...</b>
    </span>
    <span *ngIf="clientNameFound">
      <i class="fa fa-2x fa-openid"></i> 
      <b class="fa-2x"> Authorization Request </b>
    </span> 
    <span *ngIf="clientNameFound !== undefined && !clientNameFound">
      <b class="fa-2x"> Authorization failed. </b>
    </span>
    <br/> 
  </div>
  <div *ngIf="clientNameFound"><strong>"{{ clientName }}"</strong>
    asks you to share personal information.<br/>
    Choose an identity to let it access the following information:
  </div>
  <ul *ngIf="clientNameFound">
    <li *ngFor="let attribute of getScopes()"><strong>{{attribute}}</strong>
  </ul>
  <div *ngIf="clientNameFound" style="text-align: center;">
    <button class="btn btn-danger m-1 mt-4" *ngIf="clientNameFound" (click)="cancelRequest(); closeModal('OpenIdInfo');" style="margin-bottom: -4%;">
      <span class="fa fa-ban"></span> Decline
    </button>
    <button class="btn btn-primary m-1 mt-4" *ngIf="clientNameFound" (click)="closeModal('OpenIdInfo');">
      <span class="fa fa-arrow-circle-right"></span> Select identity...
    </button>
  </div>
  <div *ngIf="clientNameFound !== undefined && !clientNameFound" style="text-align: center;">
    <button class="btn btn-primary mt-4" *ngIf="!clientNameFound" (click)="getClientName();">
      <span class="fa fa-openid"></span> Retry
    </button>
  </div>
  <div *ngIf="clientNameFound === undefined" style="text-align: center;">
    <button class="btn btn-danger mt-4" *ngIf="clientNameFound === undefined" (click)="cancelRequest(); closeModal('OpenIdInfo');">
      <span class="fa fa-ban"></span> Cancel verification request
    </button>
  </div>
</oid-modal>

<!-- GNUnet not running -->
<oid-modal id="GnunetInfo">
  <div class="logo"><img src="assets/reclaim_icon.png"/></div>
  <hr>
  <div style="text-align: center; font-size: 18px;">
    <strong> Unable to connect to GNUnet. <br/> Maybe it is not running? </strong>
  </div>
</oid-modal>

<!-- Buttons -->
<div *ngIf="canSearch()"  style="margin-top: 1em; text-align: center;">
  <!-- Identity search -->
  <form class="form-inline" style="display: table; margin: auto;">
    <div class="search-wrapper">
    <input class="form-control mr-sm-2" type="search" [(ngModel)]="searchTerm" name="searchTerm" placeholder="Search identities" style="border-radius: 2em;">
    </div>
  </form>
  <br/>
</div>

<!-- Cancel authorization -->
<div style="margin-bottom: 1em; text-align: center;">
  <button *ngIf="inOpenIdFlow() && clientNameFound" class="btn btn-danger mt-2" (click)="cancelRequest()">
    <span class="fa fa-ban"></span> Decline authorization request
  </button>
</div>

<!-- error infos -->
<div *ngFor="let err of errorInfos" class="alert alert-danger show" role="alert">
  <b>ERROR</b>
  <button class="btn btn-primary ml-4" (click)="errorInfos.splice(errorInfos.indexOf(err,0), 1)">
    <span>Dismiss</span>
  </button>
  <br/>
  {{err}}
</div>

<!-- No identities present -->
<div *ngIf="isConnected() && 0 == identities.length" style="text-align: center;" class="alert alert-secondary alert-dismissible fade show" role="alert">
  You don't have any identities yet.<br/><br/>
  <button class="btn btn-primary" [routerLink]="['/new-identity']">
    <span class="fa fa-plus"></span> Add your first identity!
  </button>
</div>

<!-- Identity cards -->
<!-- No match -->
<div *ngIf="canSearch()">
  <div *ngIf="(identities | search: searchTerm).length == 0" style="text-align: center;" class="alert alert-secondary alert-dismissible fade show" role="alert">No matching identities.</div>
</div>
<!-- Cards -->
<div class="card-columns p-2">
  <div class="card" *ngFor="let identity of identities | search: searchTerm">
    <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>-->
        <i class="fa fa-user-circle"></i>
        <span class="m-1" style="display: inline-block"><i> {{identity.name}}</i></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" [routerLink]="['/edit-identity', identity.name]">
          <span class="fa fa-edit"></span>
        </button>
      </div>
    </div>
    <div class="alert alert-danger fade show" *ngIf="showConfirmDelete == identity">
      Do you really want to delete this identity?<br/><br/>
      <button class="btn btn-primary" (click)="deleteIdentity(identity)">
        <span class="fa fa-trash"></span> Delete
      </button>
      <button class="btn btn-primary" (click)="hideConfirmDelete()">
        <span class="fa fa-close"></span> Cancel
      </button>
    </div>
    <div class="alert alert-secondary fade show" *ngIf="!hasAttributes(identity)">
      This identity has no attributes. Maybe try <a class="buttonlink" [routerLink]="['/edit-identity', identity.name]">adding some?</a>
    </div>
    <div *ngIf="isAttributeMissing(identity)" class="alert alert-danger alert-dismissible fade show" role="alert">
      <span class="fa fa-openid"></span> This identity cannot be used because it's missing requested attributes: 
      <ul>
        <li *ngFor="let attr of getMissing(identity)">{{attr}}</li>
      </ul>
      <button class="btn btn-primary" [routerLink]="['/edit-identity', identity.name]">
        <span class="fa fa-plus"></span> Add
      </button>
    </div>
    <div class="card-body">
      <!-- Attribute table --> 
      <div>
        <h6 class="card-subtitle mb-2" *ngIf="hasAttributes(identity)">
          <strong>Information:</strong>
        </h6>
        <table class="table pb-1">
          <tbody>
            <tr [class.openid]="inOpenIdFlow()" [class.text-primary]="isRequested(identity, attribute)"
               *ngFor="let attribute of attributes[identity.pubkey]">
              <td>
                <div style="min-width: 15em"><span *ngIf="isRequested(identity, attribute)" class="fa fa-openid"></span> {{attribute.name}}</div>
              </td>
              <td>
                <div *ngIf="attribute.value.length <= 20" style="min-width: 15em">{{attribute.value}}</div>
                <div *ngIf="attribute.value.length > 20" style="min-width: 15em">{{attribute.value.substring(0, 15)}}<span style="color:#eee">[...]</span></div>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <div style="margin-bottom: 1em" *ngIf="(0 < attributes[identity.pubkey]?.length) && inOpenIdFlow()" class="text-primary">
        Only attributes marked with <span class="fa fa-openid" ></span> will be shared.
      </div>
      <div>

        <div>
          <button *ngIf="canAuthorize(identity)" [disabled]="!inOpenIdFlow() || isAttributeMissing(identity) || !clientNameFound" (click)="loginIdentity(identity)" class="btn btn-primary mr-1 openid-login">
            <span *ngIf="clientNameFound"><i class="fa fa-openid"></i> Share from this identity</span>
            <span *ngIf="!clientNameFound"><i class="fa fa-exclamation-circle"></i> Sharing disabled</span>
          </button>
        </div>
      </div>
      <div style="text-align:center">
        <img src="assets/reclaim_icon.png" style="width: 5em;opacity: 0.3;">
      </div>
    </div>
  </div>

  <!-- New identity card -->
  <div class="card identity-new" [routerLink]="['/new-identity']" *ngIf="0 != identities.length">
    <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>-->
        <i class="fa fa-user-circle"></i>
        <span class="m-1" style="display: inline-block"><i> New Identity</i></span>
      </div>
    </div>
    <div class="card-body">
      <div style="text-align:center" class="mb-4">
        <i>Click to add a new identity.</i>
      </div>
      <div style="text-align:center">
        <img src="assets/reclaim_icon.png" style="width: 5em;opacity: 0.3;">
      </div>
    </div>
  </div>
</div>