[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[reclaim-ui] 159/459: more refactoring
From: |
gnunet |
Subject: |
[reclaim-ui] 159/459: more refactoring |
Date: |
Fri, 11 Jun 2021 23:24:11 +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 06a374032147df1112b221d70d2acde92e65ee11
Author: Schanzenbach, Martin <mschanzenbach@posteo.de>
AuthorDate: Tue Dec 10 20:08:57 2019 +0100
more refactoring
---
src/app/app-routing.module.ts | 8 +--
src/app/app.module.ts | 4 +-
.../authorization-request.component.css | 0
.../authorization-request.component.html | 40 +++++++++++++++
.../authorization-request.component.ts | 59 ++++++++++++++++++++++
src/app/identity-list/identity-list.component.html | 45 -----------------
src/app/identity-list/identity-list.component.ts | 57 ++-------------------
src/styles.scss | 2 +
8 files changed, 112 insertions(+), 103 deletions(-)
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 30f732c..9019e84 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -3,17 +3,19 @@ import { RouterModule, Routes } from '@angular/router';
import { IdentityListComponent } from
'./identity-list/identity-list.component';
import { NewIdentityComponent } from './new-identity/new-identity.component';
import { EditIdentityComponent } from
'./edit-identity/edit-identity.component';
+import { AuthorizationRequestComponent } from
'./authorization-request/authorization-request.component';
const routes: Routes = [
- { path: 'index.html', component: IdentityListComponent },
+ { path: '', component: IdentityListComponent },
// { path: 'identities', component: IdentityListComponent },
- { path: '', redirectTo: '/index.html', pathMatch: 'full' },
+ //{ path: '', redirectTo: '/index.html', pathMatch: 'full' },
{ path: 'new-identity', component: NewIdentityComponent },
{ path: 'edit-identity/:id', component: EditIdentityComponent },
+ { path: 'authorization-request', component: AuthorizationRequestComponent }
];
@NgModule({
- imports: [RouterModule.forRoot(routes, { useHash: false })],
+ imports: [RouterModule.forRoot(routes, { useHash: true })],
exports: [RouterModule]
})
export class AppRoutingModule { }
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 77d4efb..d1c8b7a 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -17,6 +17,7 @@ import { SearchPipe } from './search.pipe';
import { OpenIdService } from './open-id.service';
import { NewIdentityComponent } from './new-identity/new-identity.component';
import { EditIdentityComponent } from
'./edit-identity/edit-identity.component';
+import { AuthorizationRequestComponent } from
'./authorization-request/authorization-request.component';
@NgModule({
declarations: [
@@ -25,7 +26,8 @@ import { EditIdentityComponent } from
'./edit-identity/edit-identity.component';
ModalComponent,
SearchPipe,
NewIdentityComponent,
- EditIdentityComponent
+ EditIdentityComponent,
+ AuthorizationRequestComponent
],
imports: [
BrowserModule,
diff --git a/src/app/authorization-request/authorization-request.component.css
b/src/app/authorization-request/authorization-request.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/authorization-request/authorization-request.component.html
b/src/app/authorization-request/authorization-request.component.html
new file mode 100644
index 0000000..e323603
--- /dev/null
+++ b/src/app/authorization-request/authorization-request.component.html
@@ -0,0 +1,40 @@
+<div style="text-align: center;">
+ <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()" 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()">
+ <span class="fa fa-ban"></span> Cancel verification request
+ </button>
+</div>
+
diff --git a/src/app/authorization-request/authorization-request.component.ts
b/src/app/authorization-request/authorization-request.component.ts
new file mode 100644
index 0000000..96353f1
--- /dev/null
+++ b/src/app/authorization-request/authorization-request.component.ts
@@ -0,0 +1,59 @@
+import { Component, OnInit } from '@angular/core';
+import { Router } from '@angular/router';
+import { OpenIdService } from '../open-id.service';
+import { GnsService } from '../gns.service';
+
+@Component({
+ selector: 'app-authorization-request',
+ templateUrl: './authorization-request.component.html',
+ styleUrls: ['./authorization-request.component.css']
+})
+export class AuthorizationRequestComponent implements OnInit {
+ clientNameFound: Boolean;
+ clientName: String;
+
+ constructor(private oidcService: OpenIdService,
+ private gnsService: GnsService,
+ private router: Router) { }
+
+ ngOnInit() {
+ this.clientNameFound = false;
+ this.clientName = '-';
+ this.getClientName();
+ }
+
+ getClientName() {
+ this.clientNameFound = undefined;
+ this.clientName = this.oidcService.getClientId();
+ if (!this.oidcService.inOpenIdFlow()) {
+ return;
+ }
+ this.gnsService.getClientName(this.oidcService.getClientId())
+ .subscribe(record => {
+ const records = record.data;
+ console.log(records);
+ for (let i = 0; i < records.length; i++) {
+ if (records[i].record_type !== 'RECLAIM_OIDC_CLIENT') {
+ continue;
+ }
+ this.clientName = records[i].value;
+ this.clientNameFound = true;
+ return;
+ }
+ this.clientNameFound = false;
+ }, err => {
+ console.log(err);
+ this.clientNameFound = false;
+ });
+ }
+
+ cancelRequest() {
+ this.oidcService.cancelAuthorization().subscribe(() => {
+ console.log('Request cancelled');
+ this.router.navigate(['/']);
+ //Manually reset this component
+ });
+ }
+
+
+}
diff --git a/src/app/identity-list/identity-list.component.html
b/src/app/identity-list/identity-list.component.html
index bca97b5..7edb1e8 100644
--- a/src/app/identity-list/identity-list.component.html
+++ b/src/app/identity-list/identity-list.component.html
@@ -1,48 +1,3 @@
-<!-- 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>
diff --git a/src/app/identity-list/identity-list.component.ts
b/src/app/identity-list/identity-list.component.ts
index 17f1da4..b4971a3 100644
--- a/src/app/identity-list/identity-list.component.ts
+++ b/src/app/identity-list/identity-list.component.ts
@@ -55,8 +55,10 @@ export class IdentityListComponent implements OnInit {
this.modalOpened = false;
if (!this.oidcService.inOpenIdFlow()) {
this.oidcService.parseRouteParams(this.route.snapshot.queryParams);
+ if (this.oidcService.inOpenIdFlow()) {
+ this.router.navigate(['/authorization-request']);
+ }
}
- this.getClientName();
this.identityNameMapper = {};
this.updateIdentities();
this.errorInfos = [];
@@ -68,47 +70,6 @@ export class IdentityListComponent implements OnInit {
hideConfirmDelete() { this.showConfirmDelete = null; }
- getClientName() {
- this.clientNameFound = undefined;
- this.clientName = this.oidcService.getClientId();
- if (!this.oidcService.inOpenIdFlow()) {
- return;
- }
- this.gnsService.getClientName(this.oidcService.getClientId())
- .subscribe(record => {
- const records = record.data;
- console.log(records);
- for (let i = 0; i < records.length; i++) {
- if (records[i].record_type !== 'RECLAIM_OIDC_CLIENT') {
- continue;
- }
- this.clientName = records[i].value;
- this.clientNameFound = true;
- return;
- }
- this.clientNameFound = false;
- }, err => {
- console.log(err);
- this.clientNameFound = false;
- });
- }
-
- intToRGB(i) {
- i = this.hashCode(i);
- const c = (i & 0x00FFFFFF).toString(16).toUpperCase();
-
- return '#' +
- '00000'.substring(0, 6 - c.length) + c;
- }
-
- hashCode(str) {
- let hash = 0;
- for (let i = 0; i < str.length; i++) {
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
- }
- return hash;
- }
-
getMissingAttributes(identity) {
const scopes = this.getScopes();
let i;
@@ -164,18 +125,6 @@ export class IdentityListComponent implements OnInit {
});
}
- cancelRequest() {
- this.closeModal('OpenIdInfo');
- this.modalOpened = false;
- this.oidcService.cancelAuthorization().subscribe(() => {
- console.log('Request cancelled');
- this.requestedAttributes = {};
- this.missingAttributes = {};
- this.router.navigate(['/']);
- //Manually reset this component
- });
- }
-
loginIdentity(identity) {
this.oidcService.login(identity).subscribe(() => {
console.log('Successfully logged in');
diff --git a/src/styles.scss b/src/styles.scss
index d76e90c..a1c43dd 100644
--- a/src/styles.scss
+++ b/src/styles.scss
@@ -113,6 +113,8 @@ div.card-avatar-id {
.card-avatar .btn-primary:hover {
background-image: none;
color: #444;
+ border: none;
+ box-shadow: none;
background-color: #eee;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [reclaim-ui] 151/459: modal positioning, (continued)
- [reclaim-ui] 151/459: modal positioning, gnunet, 2021/06/11
- [reclaim-ui] 149/459: change wording, gnunet, 2021/06/11
- [reclaim-ui] 157/459: followup fix, gnunet, 2021/06/11
- [reclaim-ui] 150/459: more working, gnunet, 2021/06/11
- [reclaim-ui] 180/459: clarify optional attributes, gnunet, 2021/06/11
- [reclaim-ui] 166/459: return if redirect, gnunet, 2021/06/11
- [reclaim-ui] 156/459: better track oidc flow, gnunet, 2021/06/11
- [reclaim-ui] 160/459: hash does not work with webext, gnunet, 2021/06/11
- [reclaim-ui] 179/459: fix, gnunet, 2021/06/11
- [reclaim-ui] 161/459: no slash, gnunet, 2021/06/11
- [reclaim-ui] 159/459: more refactoring,
gnunet <=
- [reclaim-ui] 162/459: fix modal bug, gnunet, 2021/06/11
- [reclaim-ui] 163/459: style, gnunet, 2021/06/11
- [reclaim-ui] 158/459: fix styles; fix new and edit links, gnunet, 2021/06/11
- [reclaim-ui] 176/459: only show refs when requested, gnunet, 2021/06/11
- [reclaim-ui] 178/459: handle optional refs, gnunet, 2021/06/11
- [reclaim-ui] 184/459: fix save button, gnunet, 2021/06/11
- [reclaim-ui] 154/459: start extracting components, gnunet, 2021/06/11
- [reclaim-ui] 190/459: new api, gnunet, 2021/06/11
- [reclaim-ui] 164/459: update, gnunet, 2021/06/11
- [reclaim-ui] 182/459: actually add references to request, gnunet, 2021/06/11