aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Timeline/ClientApp/src/app/todo-list-page/todo-list.service.ts26
-rw-r--r--Timeline/Configs/TodoListConfig.cs12
-rw-r--r--Timeline/Configs/TodoPageConfig.cs21
-rw-r--r--Timeline/Controllers/TodoListController.cs11
-rw-r--r--Timeline/Startup.cs2
-rw-r--r--Timeline/appsettings.json6
6 files changed, 46 insertions, 32 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),
diff --git a/Timeline/Configs/TodoListConfig.cs b/Timeline/Configs/TodoListConfig.cs
deleted file mode 100644
index a69e8d03..00000000
--- a/Timeline/Configs/TodoListConfig.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace Timeline.Configs
-{
- public class TodoListConfig
- {
- public string AzureDevOpsPat { get; set; }
- }
-}
diff --git a/Timeline/Configs/TodoPageConfig.cs b/Timeline/Configs/TodoPageConfig.cs
new file mode 100644
index 00000000..d49e9dc3
--- /dev/null
+++ b/Timeline/Configs/TodoPageConfig.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Timeline.Configs
+{
+ public class AzureDevOpsAccessInfo
+ {
+ public string Username { get; set; }
+ public string PersonalAccessToken { get; set; }
+ public string Organization { get; set; }
+ public string Project { get; set; }
+
+ }
+
+ public class TodoPageConfig
+ {
+ public AzureDevOpsAccessInfo AzureDevOpsAccessInfo { get; set; }
+ }
+}
diff --git a/Timeline/Controllers/TodoListController.cs b/Timeline/Controllers/TodoListController.cs
index b773ed2e..257c1d85 100644
--- a/Timeline/Controllers/TodoListController.cs
+++ b/Timeline/Controllers/TodoListController.cs
@@ -10,21 +10,20 @@ using Timeline.Configs;
namespace Timeline.Controllers
{
[Route("api/[controller]")]
- public class TodoListController : Controller
+ public class TodoPageController : Controller
{
- private readonly IOptionsMonitor<TodoListConfig> _config;
+ private readonly IOptionsMonitor<TodoPageConfig> _config;
- public TodoListController(IOptionsMonitor<TodoListConfig> config)
+ public TodoPageController(IOptionsMonitor<TodoPageConfig> config)
{
_config = config;
}
[HttpGet("[action]")]
[AllowAnonymous]
- [Produces("text/plain")]
- public ActionResult<string> AzureDevOpsPat()
+ public ActionResult<AzureDevOpsAccessInfo> AzureDevOpsAccessInfo()
{
- return Ok(_config.CurrentValue.AzureDevOpsPat);
+ return Ok(_config.CurrentValue.AzureDevOpsAccessInfo);
}
}
}
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs
index a6bde7fd..e06a98d5 100644
--- a/Timeline/Startup.cs
+++ b/Timeline/Startup.cs
@@ -41,7 +41,7 @@ namespace Timeline
});
- services.Configure<TodoListConfig>(Configuration.GetSection("TodoListConfig"));
+ services.Configure<TodoPageConfig>(Configuration.GetSection("TodoPageConfig"));
services.Configure<JwtConfig>(Configuration.GetSection("JwtConfig"));
var jwtConfig = Configuration.GetSection("JwtConfig").Get<JwtConfig>();
diff --git a/Timeline/appsettings.json b/Timeline/appsettings.json
index a914603c..8dc28bc8 100644
--- a/Timeline/appsettings.json
+++ b/Timeline/appsettings.json
@@ -7,5 +7,11 @@
"JwtConfig": {
"Issuer": "crupest.xyz",
"Audience": "crupest.xyz"
+ },
+ "TodoPageConfig": {
+ "AzureDevOpsAccessInfo": {
+ "Organization": "crupest-web",
+ "Project": "Timeline"
+ }
}
}