Skip to content

Commit d884adf

Browse files
committed
Added page for contests import for better UX
1 parent 222012e commit d884adf

File tree

3 files changed

+133
-13
lines changed

3 files changed

+133
-13
lines changed

Servers/Administration/OJS.Servers.Administration/Extensions/WebApplicationExtensions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ namespace OJS.Servers.Administration.Extensions;
44
using Microsoft.AspNetCore.Http;
55
using Microsoft.Extensions.Configuration;
66
using Microsoft.Extensions.DependencyInjection;
7-
using OJS.Common;
87
using OJS.Data;
98
using OJS.Servers.Administration.Middleware;
109
using OJS.Servers.Infrastructure.Extensions;
1110
using OJS.Services.Administration.Business.Contests;
1211
using System;
13-
using static OJS.Common.GlobalConstants.Roles;
12+
using static OJS.Common.GlobalConstants;
13+
using static Common.GlobalConstants.Roles;
1414

1515
internal static class WebApplicationExtensions
1616
{
@@ -52,6 +52,10 @@ await contestsImportBusinessService.StreamImportContestsFromCategory(
5252
.RequireAuthorization(auth => auth.RequireRole(Administrator))
5353
.WithRequestTimeout(TimeSpan.FromMinutes(10));
5454

55+
// UI page for the contest import tool
56+
app.MapGet("/contest-import", () => Results.File("contest-import.html", MimeTypes.TextHtml))
57+
.RequireAuthorization(auth => auth.RequireRole(Administrator));
58+
5559
return app
5660
.UseAndMapHangfireDashboard();
5761
}
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
2-
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
4-
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
5-
</PropertyGroup>
6-
<ItemGroup>
7-
<ProjectReference Include="..\..\..\Services\Administration\OJS.Services.Administration.Business\OJS.Services.Administration.Business.csproj" />
8-
<ProjectReference Include="..\..\..\Services\Administration\OJS.Services.Administration.Data\OJS.Services.Administration.Data.csproj" />
9-
<ProjectReference Include="..\..\Infrastructure\OJS.Servers.Infrastructure\OJS.Servers.Infrastructure.csproj" />
10-
</ItemGroup>
11-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<ProjectReference Include="..\..\..\Services\Administration\OJS.Services.Administration.Business\OJS.Services.Administration.Business.csproj" />
8+
<ProjectReference Include="..\..\..\Services\Administration\OJS.Services.Administration.Data\OJS.Services.Administration.Data.csproj" />
9+
<ProjectReference Include="..\..\Infrastructure\OJS.Servers.Infrastructure\OJS.Servers.Infrastructure.csproj" />
10+
</ItemGroup>
11+
<ItemGroup>
12+
<Content Update="wwwroot\**\*">
13+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
14+
</Content>
15+
</ItemGroup>
16+
</Project>
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Contest Import Tool</title>
5+
<style>
6+
body {
7+
font-family: Arial, sans-serif;
8+
margin: 20px;
9+
line-height: 1.6;
10+
}
11+
.container {
12+
max-width: 1200px;
13+
margin: 0 auto;
14+
}
15+
.form-group {
16+
margin-bottom: 15px;
17+
}
18+
label {
19+
display: inline-block;
20+
width: 200px;
21+
font-weight: bold;
22+
}
23+
input[type="number"] {
24+
width: 100px;
25+
padding: 5px;
26+
}
27+
button {
28+
background-color: #4CAF50;
29+
color: white;
30+
padding: 10px 15px;
31+
border: none;
32+
border-radius: 4px;
33+
cursor: pointer;
34+
font-size: 16px;
35+
}
36+
button:hover {
37+
background-color: #45a049;
38+
}
39+
#result-container {
40+
margin-top: 20px;
41+
border: 1px solid #ddd;
42+
border-radius: 5px;
43+
padding: 20px;
44+
min-height: 400px;
45+
}
46+
iframe {
47+
width: 100%;
48+
height: 600px;
49+
border: none;
50+
}
51+
.info-box {
52+
background-color: #e7f3fe;
53+
border-left: 6px solid #2196F3;
54+
padding: 10px;
55+
margin-bottom: 15px;
56+
}
57+
</style>
58+
</head>
59+
<body>
60+
<div class="container">
61+
<h1>Contest Import Tool</h1>
62+
63+
<div class="info-box">
64+
<p>This tool allows you to import contests from one category to another. The results will stream in real-time as each contest is processed.</p>
65+
</div>
66+
67+
<form id="importForm">
68+
<div class="form-group">
69+
<label for="sourceId">Source Category ID:</label>
70+
<input type="number" id="sourceId" required min="1">
71+
</div>
72+
<div class="form-group">
73+
<label for="destId">Destination Category ID:</label>
74+
<input type="number" id="destId" required min="1">
75+
</div>
76+
<div class="form-group">
77+
<label for="dryRun">Dry Run (no actual changes):</label>
78+
<input type="checkbox" id="dryRun" checked>
79+
</div>
80+
<button type="submit">Start Import</button>
81+
</form>
82+
83+
<div id="result-container">
84+
<div id="placeholder">Import results will appear here...</div>
85+
<iframe id="resultFrame" style="display: none;"></iframe>
86+
</div>
87+
</div>
88+
89+
<script>
90+
document.getElementById('importForm').addEventListener('submit', function(e) {
91+
e.preventDefault();
92+
93+
const sourceId = document.getElementById('sourceId').value;
94+
const destId = document.getElementById('destId').value;
95+
const dryRun = document.getElementById('dryRun').checked;
96+
97+
if (!sourceId || !destId) {
98+
alert('Please enter both source and destination category IDs');
99+
return;
100+
}
101+
102+
const url = `/api/temp/ImportContestsFromCategory?sourceContestCategoryId=${sourceId}&destinationContestCategoryId=${destId}&dryRun=${dryRun}&stream=true`;
103+
104+
const iframe = document.getElementById('resultFrame');
105+
iframe.style.display = 'block';
106+
document.getElementById('placeholder').style.display = 'none';
107+
iframe.src = url;
108+
});
109+
</script>
110+
</body>
111+
</html>

0 commit comments

Comments
 (0)