diff options
author | crupest <crupest@outlook.com> | 2019-02-18 19:56:13 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-02-18 19:56:13 +0800 |
commit | 1f0a978ad2b8e5bcd57eef37baca93e00fd6b20b (patch) | |
tree | 8e1e2ac2dd6df278f59a97a37e5d374bc2644843 /Timeline/ClientApp/src | |
parent | 9756acc50f5f228968cf45d9e73c8dd3b4eacc6a (diff) | |
download | timeline-1f0a978ad2b8e5bcd57eef37baca93e00fd6b20b.tar.gz timeline-1f0a978ad2b8e5bcd57eef37baca93e00fd6b20b.tar.bz2 timeline-1f0a978ad2b8e5bcd57eef37baca93e00fd6b20b.zip |
Add get pat api.
Diffstat (limited to 'Timeline/ClientApp/src')
-rw-r--r-- | Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.css | 4 | ||||
-rw-r--r-- | Timeline/ClientApp/src/app/todo-list.service.ts | 39 |
2 files changed, 30 insertions, 13 deletions
diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.css b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.css index 43bd26d8..c17267c5 100644 --- a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.css +++ b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.css @@ -6,3 +6,7 @@ width: 1.2rem; height: 1.2rem; } + +mat-list-item { + margin: 10px; +} diff --git a/Timeline/ClientApp/src/app/todo-list.service.ts b/Timeline/ClientApp/src/app/todo-list.service.ts index b1bc5ff3..238919d3 100644 --- a/Timeline/ClientApp/src/app/todo-list.service.ts +++ b/Timeline/ClientApp/src/app/todo-list.service.ts @@ -28,28 +28,41 @@ export interface WorkItem { export class TodoListService { private username = 'crupest'; - private pat = 'ehnmegogmk6r7qlkpy6zdl2hnfl6ntqbvggzxvvgp4a5vhr7lmnq'; private organization = 'crupest-web'; private project = 'Timeline'; private fieldId = 'System.Title'; - private headers: HttpHeaders; - constructor(private client: HttpClient) { - this.headers = new HttpHeaders({ - 'Accept': 'application/json', - 'Authorization': `Basic ${btoa(this.username + ':' + this.pat)}` + constructor(private client: HttpClient) { } + + private getAzureDevOpsPat(): Observable<string> { + return this.client.get('/api/TodoList/AzureDevOpsPat', { + headers: { + 'Accept': 'text/plain' + }, + responseType: 'text' }); } getWorkItemList(): Observable<WorkItem[]> { - return this.client.post<WiqlResult>(`https://dev.azure.com/${this.organization}/${this.project}/_apis/wit/wiql?api-version=5.0`, { - query: 'SELECT [System.Id] FROM workitems WHERE [System.TeamProject] = @project' - }, { headers: this.headers }).pipe( - switchMap(result => result.workItems), - concatMap(result => this.client.get<WorkItemResult>(result.url, {headers: this.headers})), - map(result => <WorkItem>{ id: result.id, title: result.fields[this.fieldId] }), - toArray() + return this.getAzureDevOpsPat().pipe( + switchMap( + pat => { + const headers = new HttpHeaders({ + 'Accept': 'application/json', + 'Authorization': `Basic ${btoa(this.username + ':' + pat)}` + }); + return this.client.post<WiqlResult>( + `https://dev.azure.com/${this.organization}/${this.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), + concatMap(result => this.client.get<WorkItemResult>(result.url, { headers: headers })), + map(result => <WorkItem>{ id: result.id, title: result.fields[this.fieldId] }), + toArray() + ); + } + ) ); } } |