aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/todo-list.service.ts
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-02-18 19:56:13 +0800
committercrupest <crupest@outlook.com>2019-02-18 19:56:13 +0800
commit1f0a978ad2b8e5bcd57eef37baca93e00fd6b20b (patch)
tree8e1e2ac2dd6df278f59a97a37e5d374bc2644843 /Timeline/ClientApp/src/app/todo-list.service.ts
parent9756acc50f5f228968cf45d9e73c8dd3b4eacc6a (diff)
downloadtimeline-1f0a978ad2b8e5bcd57eef37baca93e00fd6b20b.tar.gz
timeline-1f0a978ad2b8e5bcd57eef37baca93e00fd6b20b.tar.bz2
timeline-1f0a978ad2b8e5bcd57eef37baca93e00fd6b20b.zip
Add get pat api.
Diffstat (limited to 'Timeline/ClientApp/src/app/todo-list.service.ts')
-rw-r--r--Timeline/ClientApp/src/app/todo-list.service.ts39
1 files changed, 26 insertions, 13 deletions
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()
+ );
+ }
+ )
);
}
}