Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions web/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 2 additions & 0 deletions web/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ 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 {MatProgressSpinnerModule} from '@angular/material/progress-spinner';

@NgModule({
declarations: [
AppComponent,
ApplyTokenComponent,
ProfileLogoComponent,
RootTeamPageComponent,
UserListComponent,
Expand Down
Empty file.
Empty file.
37 changes: 37 additions & 0 deletions web/src/app/apply-token/apply-token.component.spec.ts
Original file line number Diff line number Diff line change
@@ -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<ApplyTokenComponent>;
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test tests nothing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #39

});
});
28 changes: 28 additions & 0 deletions web/src/app/apply-token/apply-token.component.ts
Original file line number Diff line number Diff line change
@@ -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: 'imprint-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) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe to use AcitvatedRouteSnapshot instead of subscribing for a single value?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. It was port but need to be changed.)

const params = new HttpParams({fromString: fragment});
this.tokenService.saveToken(params.get('token'));
this.router.navigate(['/']).then(() => window.location.reload());
});
}

}