@page "/clusters/new" @using System.ComponentModel.DataAnnotations @using ZB.MOM.WW.OtOpcUa.Admin.Services @using ZB.MOM.WW.OtOpcUa.Configuration.Entities @using ZB.MOM.WW.OtOpcUa.Configuration.Enums @inject ClusterService ClusterSvc @inject GenerationService GenerationSvc @inject NavigationManager Nav

New cluster

Stable internal ID. Lowercase alphanumeric + hyphens; ≤ 64 chars.
@if (!string.IsNullOrEmpty(_error)) {
@_error
}
Cancel
@code { private sealed class Input { [Required, RegularExpression("^[a-z0-9-]{1,64}$", ErrorMessage = "Lowercase alphanumeric + hyphens only")] public string ClusterId { get; set; } = string.Empty; [Required, StringLength(128)] public string Name { get; set; } = string.Empty; [StringLength(32)] public string Enterprise { get; set; } = "zb"; [StringLength(32)] public string Site { get; set; } = "dev"; public RedundancyMode RedundancyMode { get; set; } = RedundancyMode.None; } private Input _input = new(); private bool _submitting; private string? _error; private async Task CreateAsync() { _submitting = true; _error = null; try { var cluster = new ServerCluster { ClusterId = _input.ClusterId, Name = _input.Name, Enterprise = _input.Enterprise, Site = _input.Site, RedundancyMode = _input.RedundancyMode, NodeCount = _input.RedundancyMode == RedundancyMode.None ? (byte)1 : (byte)2, Enabled = true, CreatedBy = "admin-ui", }; await ClusterSvc.CreateAsync(cluster, createdBy: "admin-ui", CancellationToken.None); await GenerationSvc.CreateDraftAsync(cluster.ClusterId, createdBy: "admin-ui", CancellationToken.None); Nav.NavigateTo($"/clusters/{cluster.ClusterId}"); } catch (Exception ex) { _error = ex.Message; } finally { _submitting = false; } } }