aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-02-20 18:23:05 +0800
committercrupest <crupest@outlook.com>2019-02-20 18:23:05 +0800
commit0ed96f534f75ebc2a7bdbec031a4674368d0420a (patch)
treefbc0862d757f2743b84c0abf93ccfb1e2c77ab22 /Timeline/ClientApp/src
parent5afa4248c5ec67d361a8f75e0ec0f1d12778e266 (diff)
downloadtimeline-0ed96f534f75ebc2a7bdbec031a4674368d0420a.tar.gz
timeline-0ed96f534f75ebc2a7bdbec031a4674368d0420a.tar.bz2
timeline-0ed96f534f75ebc2a7bdbec031a4674368d0420a.zip
Move some config of todo page to server side.
Diffstat (limited to 'Timeline/ClientApp/src')
-rw-r--r--Timeline/ClientApp/src/app/todo-list-page/todo-list.service.ts26
1 files changed, 13 insertions, 13 deletions
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<string> {
- return this.client.get('/api/TodoList/AzureDevOpsPat', {
- headers: {
- 'Accept': 'text/plain'
- },
- responseType: 'text'
- });
+ private getAzureDevOpsPat(): Observable<AzureDevOpsAccessInfo> {
+ return this.client.get<AzureDevOpsAccessInfo>('/api/TodoPage/AzureDevOpsAccessInfo');
}
getWorkItemList(): Observable<WorkItem[]> {
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<WiqlResult>(
- `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),