From 0ed96f534f75ebc2a7bdbec031a4674368d0420a Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 20 Feb 2019 18:23:05 +0800 Subject: Move some config of todo page to server side. --- .../src/app/todo-list-page/todo-list.service.ts | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'Timeline/ClientApp/src') diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list.service.ts b/Timeline/ClientApp/src/app/todo-list-page/todo-list.service.ts index 0b54653b..0718b64b 100644 --- a/Timeline/ClientApp/src/app/todo-list-page/todo-list.service.ts +++ b/Timeline/ClientApp/src/app/todo-list-page/todo-list.service.ts @@ -3,6 +3,13 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs'; import { switchMap, concatMap, map, toArray } from 'rxjs/operators'; +interface AzureDevOpsAccessInfo { + username: string; + personalAccessToken: string; + organization: string; + project: string; +} + interface WiqlWorkItemResult { id: number; url: string; @@ -17,6 +24,7 @@ interface WorkItemResult { fields: { [name: string]: any }; } + export interface WorkItem { id: number; title: string; @@ -28,33 +36,25 @@ export interface WorkItem { }) export class TodoListService { - private username = 'crupest'; - private organization = 'crupest-web'; - private project = 'Timeline'; private titleFieldName = 'System.Title'; private stateFieldName = 'System.State'; constructor(private client: HttpClient) { } - private getAzureDevOpsPat(): Observable { - return this.client.get('/api/TodoList/AzureDevOpsPat', { - headers: { - 'Accept': 'text/plain' - }, - responseType: 'text' - }); + private getAzureDevOpsPat(): Observable { + return this.client.get('/api/TodoPage/AzureDevOpsAccessInfo'); } getWorkItemList(): Observable { return this.getAzureDevOpsPat().pipe( switchMap( - pat => { + accessInfo => { const headers = new HttpHeaders({ 'Accept': 'application/json', - 'Authorization': `Basic ${btoa(this.username + ':' + pat)}` + 'Authorization': `Basic ${btoa(accessInfo.username + ':' + accessInfo.personalAccessToken)}` }); return this.client.post( - `https://dev.azure.com/${this.organization}/${this.project}/_apis/wit/wiql?api-version=5.0`, { + `https://dev.azure.com/${accessInfo.organization}/${accessInfo.project}/_apis/wit/wiql?api-version=5.0`, { query: 'SELECT [System.Id] FROM workitems WHERE [System.TeamProject] = @project' }, { headers: headers }).pipe( switchMap(result => result.workItems), -- cgit v1.2.3