Archived
Private
Public Access
1
0

Fixed minor issues + added language support

This commit is contained in:
2023-03-25 18:36:19 +01:00
parent 4422d8818a
commit 6dfb5a4b48
23 changed files with 334 additions and 83 deletions

View File

@@ -82,6 +82,8 @@ public class ProjectApi : IProjectApi {
await _docker.DeleteContainer(project.ContainerName);
await _proxy.RemoveLocation(project.ProxyId, project.CertificateId);
Directory.Delete(_options.Root + projectId, true);
_context.Projects.Remove(project);
await _context.SaveChangesAsync();

View File

@@ -1,4 +1,5 @@
using System.Text;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
using Microsoft.Extensions.Options;
using ProjectManager.Backend.Entities;

View File

@@ -88,6 +88,16 @@ public class ProjectController : ControllerBase {
return Redirect($"http://{_options.Host}:{project.Port}/_/");
}
[Authorized]
[HttpGet("{projectId}/url/string")]
public IActionResult GetProjectUrlHead(string projectId) {
var project = _projects.GetProject(projectId);
if (project == null) return NotFound();
if (project.OwnerId != _context.UserId) return Unauthorized();
if (_options.Enable) return Ok(new {url = $"https://{projectId}.{_options.Domain}/_/"});
return Ok(new {url = $"http://{_options.Host}:{project.Port}/_/"});
}
[Authorized]
[HttpGet("{projectId}/start")]
public async Task<IActionResult> StartProject(string projectId) {

View File

@@ -36,7 +36,7 @@ if (app.Environment.IsDevelopment()) {
app.UseCors(
options => options
.WithOrigins(new []{app.Configuration.GetSection("Frontend").Get<string>() ?? ""})
.WithOrigins(app.Configuration.GetSection("Frontend").Get<string>() ?? "")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials()
@@ -45,5 +45,10 @@ app.UseCors(
app.UseAuthorization();
app.MapControllers();
app.MapGet("", async context => {
context.Response.StatusCode = StatusCodes.Status200OK;
await context.Response.BodyWriter.WriteAsync("Ok"u8.ToArray());
await context.Response.BodyWriter.CompleteAsync();
});
app.Run();