Skip to content

Commit 96d3262

Browse files
committed
work
1 parent 24fae7d commit 96d3262

File tree

6 files changed

+110
-0
lines changed

6 files changed

+110
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace GradeManagement.Bll.Services;
2+
3+
public class GitHubAppService
4+
{
5+
public void CreateApp(string code)
6+
{
7+
8+
}
9+
}

grade-management-new/GradeManagement.Client/Pages/CreationWizard.razor

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@attribute [Authorize(Policy = Policy.RequireTeacher)]
1212

1313
@using GradeManagement.Client.Components.NewDialogs
14+
@using GradeManagement.Shared.Dtos.GitHubManifest
1415
@using MudExtensions
1516
@using MudBlazor.Extensions
1617
@using MudExtensions.Utilities
@@ -123,6 +124,16 @@
123124
</div>
124125
</ChildContent>
125126
</MudStepExtended>
127+
<MudStepExtended Icon="@Icons.Material.Filled.Code" Title="GitHub App" Optional="true">
128+
<ChildContent>
129+
<div class="d-flex flex-column align-center justify-center" style="height: 200px">
130+
<MudText>You finished the subject setup. The last step is to connect it to a GitHub App in your organization.</MudText>
131+
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="ConnectGitHubApp">
132+
Connect GitHub App
133+
</MudButton>
134+
</div>
135+
</ChildContent>
136+
</MudStepExtended>
126137

127138
<MudStepExtended Icon="@Icons.Material.Filled.Assessment" Title="Result Step" IsResultStep="true">
128139
<ChildContent>
@@ -296,6 +307,15 @@
296307
}
297308
}
298309

310+
private async Task ConnectGitHubApp()
311+
{
312+
GitHubAppManifest gitHubAppManifest = new();
313+
var url = $"https://github.com/organizations/{SubjectService.CurrentSubject.GitHubOrgName}/settings/apps/new";
314+
315+
using HttpClient client = new HttpClient();
316+
HttpResponseMessage response = await client.PostAsJsonAsync(url, gitHubAppManifest);
317+
}
318+
299319
private void NavigateToCourse()
300320
{
301321
if (_course != null)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace GradeManagement.Server.Controllers;
4+
5+
[Route("api/github")]
6+
[ApiController]
7+
public class GitHubAppController
8+
{
9+
[HttpGet]
10+
public async Task CreateGitHubApp([FromQuery] string code)
11+
{
12+
Console.WriteLine(code);
13+
}
14+
15+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace GradeManagement.Shared.Dtos.GitHubManifest;
4+
5+
public class DefaultPermissions
6+
{
7+
[JsonPropertyName("actions")]
8+
public string Actions { get; set; } = "write";
9+
[JsonPropertyName("administration")]
10+
public string Administration { get; set; } = "write";
11+
[JsonPropertyName("contents")]
12+
public string Contents { get; set; } = "write";
13+
[JsonPropertyName("issues")]
14+
public string Issues { get; set; } = "write";
15+
[JsonPropertyName("metadata")]
16+
public string Metadata { get; set; } = "read";
17+
[JsonPropertyName("pull_requests")]
18+
public string PullRequests { get; set; } = "write";
19+
[JsonPropertyName("workflows")]
20+
public string Workflows { get; set; } = "write";
21+
[JsonPropertyName("members")]
22+
public string Members { get; set; } = "read";
23+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace GradeManagement.Shared.Dtos.GitHubManifest;
4+
5+
public class GitHubAppManifest
6+
{
7+
[JsonPropertyName("name")]
8+
public string Name { get; set; } = "Ahk GitHub Monitor";
9+
[JsonPropertyName("url")]
10+
public string Url { get; set; } = "https://github.com/bmeaut/ahk-github-automation";
11+
[JsonPropertyName("hook_attributes")]
12+
public HookAttributes HookAttributes { get; set; } = new HookAttributes();
13+
[JsonPropertyName("redirect_url")]
14+
public string RedirectUrl { get; set; } = "https://app.mm-home.eu/api/github";
15+
[JsonPropertyName("callback_urls")]
16+
public List<string> CallbackUrls { get; set; } = new();
17+
/*[JsonPropertyName("setup_url")]
18+
public string SetupUrl { get; set; }*/
19+
/*[JsonPropertyName("description")]
20+
public string Description { get; set; }*/
21+
[JsonPropertyName("public")]
22+
public bool Public { get; set; } = false;
23+
24+
[JsonPropertyName("default_events")]
25+
public List<string> DefaultEvents { get; set; } =
26+
[
27+
"create", "issue_comment", "label", "pull_request", "pull_request_review", "pull_request_review_comment",
28+
"repository", "workflow_run"
29+
];
30+
[JsonPropertyName("default_permissions")]
31+
public DefaultPermissions DefaultPermissions { get; set; } = new DefaultPermissions();
32+
[JsonPropertyName("request_oauth_on_install")]
33+
public bool RequestOAuthOnInstall { get; set; } = false;
34+
[JsonPropertyName("setup_on_update")]
35+
public bool SetupOnUpdate { get; set; } = false;
36+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace GradeManagement.Shared.Dtos.GitHubManifest;
2+
3+
public class HookAttributes
4+
{
5+
public string Url { get; set; } = Environment.GetEnvironmentVariable("MONITOR_URL");
6+
public bool Active { get; set; } = true;
7+
}

0 commit comments

Comments
 (0)