From 94fa749f283564f9e4ffa1cf136c956e3c27fc19 Mon Sep 17 00:00:00 2001 From: bondikbondik Date: Mon, 4 May 2020 18:11:56 +0200 Subject: [PATCH 1/3] apply Token function --- web/src/app/app-routing.module.ts | 2 + web/src/app/app.module.ts | 6 +-- .../apply-token/apply-token.component.html | 0 .../apply-token/apply-token.component.scss | 0 .../apply-token/apply-token.component.spec.ts | 37 +++++++++++++++++++ .../app/apply-token/apply-token.component.ts | 28 ++++++++++++++ 6 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 web/src/app/apply-token/apply-token.component.html create mode 100644 web/src/app/apply-token/apply-token.component.scss create mode 100644 web/src/app/apply-token/apply-token.component.spec.ts create mode 100644 web/src/app/apply-token/apply-token.component.ts diff --git a/web/src/app/app-routing.module.ts b/web/src/app/app-routing.module.ts index 7bca924..87b77fe 100644 --- a/web/src/app/app-routing.module.ts +++ b/web/src/app/app-routing.module.ts @@ -3,9 +3,11 @@ import { Routes, RouterModule } from '@angular/router'; import {RootTeamPageComponent} from './static-pages/root-team-page/root-team-page.component'; import {GithubOrganisationStats} from './_models/github-organisation-stats'; import {GithubOrganisationPageComponent} from './github/github-organisation-page/github-organisation-page.component'; +import {ApplyTokenComponent} from "./apply-token/apply-token.component"; const routes: Routes = [ + {path: 'applyToken', component: ApplyTokenComponent}, {path: '', redirectTo: '/union/github.com/org/web-tree', pathMatch: 'full'}, {path: 'root-team', component: RootTeamPageComponent}, {path: 'union/github.com/org/:organisation', component: GithubOrganisationPageComponent}, diff --git a/web/src/app/app.module.ts b/web/src/app/app.module.ts index 3dc3174..43e959f 100644 --- a/web/src/app/app.module.ts +++ b/web/src/app/app.module.ts @@ -19,11 +19,12 @@ import {ImprintService} from './_services/imprint.service'; import {MatListModule} from '@angular/material/list'; import {MatBadgeModule} from '@angular/material/badge'; import { GithubOrganisationPageComponent } from './github/github-organisation-page/github-organisation-page.component'; -import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; +import {ApplyTokenComponent} from "./apply-token/apply-token.component"; @NgModule({ declarations: [ AppComponent, + ApplyTokenComponent, ProfileLogoComponent, RootTeamPageComponent, UserListComponent, @@ -39,8 +40,7 @@ import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; MatMenuModule, MatButtonModule, MatListModule, - MatBadgeModule, - MatProgressSpinnerModule + MatBadgeModule ], providers: [ TokenService, diff --git a/web/src/app/apply-token/apply-token.component.html b/web/src/app/apply-token/apply-token.component.html new file mode 100644 index 0000000..e69de29 diff --git a/web/src/app/apply-token/apply-token.component.scss b/web/src/app/apply-token/apply-token.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/web/src/app/apply-token/apply-token.component.spec.ts b/web/src/app/apply-token/apply-token.component.spec.ts new file mode 100644 index 0000000..50c4b79 --- /dev/null +++ b/web/src/app/apply-token/apply-token.component.spec.ts @@ -0,0 +1,37 @@ +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; + +import {ApplyTokenComponent} from './apply-token.component'; +import {ActivatedRoute, Router} from '@angular/router'; +import {TokenService} from '../_services/token.service'; + +describe('ApplyTokenComponent', () => { + let component: ApplyTokenComponent; + let fixture: ComponentFixture; + let activatedRoute: ActivatedRoute; + let router: Router; + + beforeEach(async(() => { + activatedRoute = jasmine.createSpyObj('ActivatedRoute', ['']); + router = jasmine.createSpyObj('Router', ['']); + activatedRoute.fragment = jasmine.createSpyObj('Subscribe', ['subscribe']); + TestBed.configureTestingModule({ + declarations: [ApplyTokenComponent], + providers: [ + TokenService, + {provide: ActivatedRoute, useValue: activatedRoute}, + {provide: Router, useValue: router}, + ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ApplyTokenComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/web/src/app/apply-token/apply-token.component.ts b/web/src/app/apply-token/apply-token.component.ts new file mode 100644 index 0000000..536761f --- /dev/null +++ b/web/src/app/apply-token/apply-token.component.ts @@ -0,0 +1,28 @@ +import {Component, OnInit} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; +import {HttpParams} from '@angular/common/http'; +import {TokenService} from '../_services/token.service'; + +@Component({ + selector: 'app-apply-token', + templateUrl: './apply-token.component.html', + styleUrls: ['./apply-token.component.scss'] +}) +export class ApplyTokenComponent implements OnInit { + + constructor( + private route: ActivatedRoute, + private router: Router, + private tokenService: TokenService + ) { + } + + ngOnInit() { + this.route.fragment.subscribe((fragment: string) => { + const params = new HttpParams({fromString: fragment}); + this.tokenService.saveToken(params.get('token')); + this.router.navigate(['/']).then(() => window.location.reload()); + }); + } + +} From 9f25c0b4cb08eba60f4e787dee9030f271245c40 Mon Sep 17 00:00:00 2001 From: bondikbondik Date: Mon, 4 May 2020 19:21:07 +0200 Subject: [PATCH 2/3] apply Token function --- web/src/app/app-routing.module.ts | 2 +- web/src/app/app.module.ts | 2 +- web/src/app/apply-token/apply-token.component.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/app/app-routing.module.ts b/web/src/app/app-routing.module.ts index 87b77fe..fdc73e1 100644 --- a/web/src/app/app-routing.module.ts +++ b/web/src/app/app-routing.module.ts @@ -3,7 +3,7 @@ import { Routes, RouterModule } from '@angular/router'; import {RootTeamPageComponent} from './static-pages/root-team-page/root-team-page.component'; import {GithubOrganisationStats} from './_models/github-organisation-stats'; import {GithubOrganisationPageComponent} from './github/github-organisation-page/github-organisation-page.component'; -import {ApplyTokenComponent} from "./apply-token/apply-token.component"; +import {ApplyTokenComponent} from './apply-token/apply-token.component'; const routes: Routes = [ diff --git a/web/src/app/app.module.ts b/web/src/app/app.module.ts index 43e959f..8ba1c48 100644 --- a/web/src/app/app.module.ts +++ b/web/src/app/app.module.ts @@ -19,7 +19,7 @@ import {ImprintService} from './_services/imprint.service'; import {MatListModule} from '@angular/material/list'; import {MatBadgeModule} from '@angular/material/badge'; import { GithubOrganisationPageComponent } from './github/github-organisation-page/github-organisation-page.component'; -import {ApplyTokenComponent} from "./apply-token/apply-token.component"; +import {ApplyTokenComponent} from './apply-token/apply-token.component'; @NgModule({ declarations: [ diff --git a/web/src/app/apply-token/apply-token.component.ts b/web/src/app/apply-token/apply-token.component.ts index 536761f..794d376 100644 --- a/web/src/app/apply-token/apply-token.component.ts +++ b/web/src/app/apply-token/apply-token.component.ts @@ -4,7 +4,7 @@ import {HttpParams} from '@angular/common/http'; import {TokenService} from '../_services/token.service'; @Component({ - selector: 'app-apply-token', + selector: 'imprint-app-apply-token', templateUrl: './apply-token.component.html', styleUrls: ['./apply-token.component.scss'] }) From 765726d665d5021c5af8124c3ef856342675cd60 Mon Sep 17 00:00:00 2001 From: Max Levitskiy Date: Mon, 4 May 2020 19:40:45 +0200 Subject: [PATCH 3/3] Fix progress spinner --- web/src/app/app.module.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/src/app/app.module.ts b/web/src/app/app.module.ts index 8ba1c48..ca75d30 100644 --- a/web/src/app/app.module.ts +++ b/web/src/app/app.module.ts @@ -20,6 +20,7 @@ import {MatListModule} from '@angular/material/list'; import {MatBadgeModule} from '@angular/material/badge'; import { GithubOrganisationPageComponent } from './github/github-organisation-page/github-organisation-page.component'; import {ApplyTokenComponent} from './apply-token/apply-token.component'; +import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; @NgModule({ declarations: [ @@ -40,7 +41,8 @@ import {ApplyTokenComponent} from './apply-token/apply-token.component'; MatMenuModule, MatButtonModule, MatListModule, - MatBadgeModule + MatBadgeModule, + MatProgressSpinnerModule ], providers: [ TokenService,