diff --git a/src/ScadaLink.CentralUI/Components/Pages/Admin/Sites.razor b/src/ScadaLink.CentralUI/Components/Pages/Admin/Sites.razor index 8b71ac2..4495d1c 100644 --- a/src/ScadaLink.CentralUI/Components/Pages/Admin/Sites.razor +++ b/src/ScadaLink.CentralUI/Components/Pages/Admin/Sites.razor @@ -2,13 +2,25 @@ @using ScadaLink.Security @using ScadaLink.Commons.Entities.Sites @using ScadaLink.Commons.Interfaces.Repositories +@using ScadaLink.DeploymentManager @attribute [Authorize(Policy = AuthorizationPolicies.RequireAdmin)] @inject ISiteRepository SiteRepository +@inject ArtifactDeploymentService ArtifactDeploymentService

Site Management

- +
+ + +
@@ -64,7 +76,7 @@ Identifier Description Data Connections - Actions + Actions @@ -100,6 +112,9 @@ + @@ -123,6 +138,8 @@ private string? _formDescription; private string? _formError; + private bool _deploying; + private ToastNotification _toast = default!; private ConfirmDialog _confirmDialog = default!; @@ -246,4 +263,57 @@ _toast.ShowError($"Delete failed: {ex.Message}"); } } + + private async Task DeployArtifacts(Site site) + { + _deploying = true; + try + { + var command = await ArtifactDeploymentService.BuildDeployArtifactsCommandAsync(); + var result = await ArtifactDeploymentService.RetryForSiteAsync( + site.SiteIdentifier, command, "system"); + + if (result.IsSuccess) + _toast.ShowSuccess($"Artifacts deployed to '{site.Name}'."); + else + _toast.ShowError($"Deploy to '{site.Name}' failed: {result.Error}"); + } + catch (Exception ex) + { + _toast.ShowError($"Deploy to '{site.Name}' failed: {ex.Message}"); + } + finally + { + _deploying = false; + } + } + + private async Task DeployArtifactsToAllSites() + { + _deploying = true; + try + { + var command = await ArtifactDeploymentService.BuildDeployArtifactsCommandAsync(); + var result = await ArtifactDeploymentService.DeployToAllSitesAsync(command, "system"); + + if (result.IsSuccess) + { + var summary = result.Value!; + _toast.ShowSuccess( + $"Artifacts deployed: {summary.SuccessCount} succeeded, {summary.FailureCount} failed."); + } + else + { + _toast.ShowError($"Artifact deployment failed: {result.Error}"); + } + } + catch (Exception ex) + { + _toast.ShowError($"Artifact deployment failed: {ex.Message}"); + } + finally + { + _deploying = false; + } + } }