Merge branch 'main' of https://git.azuze.fr/kawa/SharepointToolbox-Web
This commit is contained in:
@@ -6,56 +6,57 @@
|
||||
@inject IElevationCoordinator Elevation
|
||||
@inject ITemplateService TemplateSvc
|
||||
@inject SharepointToolbox.Web.Infrastructure.Persistence.TemplateRepository TemplateRepo
|
||||
@inject TranslationSource T
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<h1 class="page-title">Site Templates</h1>
|
||||
<p class="page-subtitle">Capture site structure and apply to new sites.</p>
|
||||
<h1 class="page-title">@T["templates.page.title"]</h1>
|
||||
<p class="page-subtitle">@T["templates.page.subtitle"]</p>
|
||||
|
||||
@if (!Session.HasProfile) { <NoProfilePrompt /> return; }
|
||||
@if (UserContext.Role < UserRole.TechN1) { <WriteGuard /> return; }
|
||||
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:16px">
|
||||
<div class="card">
|
||||
<div class="card-title">Capture Template</div>
|
||||
<div class="card-title">@T["templates.capture"]</div>
|
||||
<SitePicker Profile="Session.CurrentProfile!" @bind-SelectedSites="_captureSites" Single="true" />
|
||||
<div class="form-group mt-8">
|
||||
<label class="form-label">Template Name</label>
|
||||
<input class="form-input" @bind="_captureName" placeholder="My Template" />
|
||||
<label class="form-label">@T["templates.name"]</label>
|
||||
<input class="form-input" @bind="_captureName" placeholder="@T["templates.name.placeholder"]" />
|
||||
</div>
|
||||
<div class="flex-row" style="flex-wrap:wrap">
|
||||
<label><input type="checkbox" @bind="_capLibraries" /> Libraries</label>
|
||||
<label><input type="checkbox" @bind="_capFolders" /> Folders</label>
|
||||
<label><input type="checkbox" @bind="_capGroups" /> Permission groups</label>
|
||||
<label><input type="checkbox" @bind="_capLibraries" /> @T["templates.opt.libraries"]</label>
|
||||
<label><input type="checkbox" @bind="_capFolders" /> @T["templates.opt.folders"]</label>
|
||||
<label><input type="checkbox" @bind="_capGroups" /> @T["templates.opt.permissions"]</label>
|
||||
</div>
|
||||
<button class="btn btn-primary mt-8" @onclick="CaptureTemplate" disabled="@_running">
|
||||
@(_running ? "Capturing…" : "Capture")
|
||||
@(_running ? T["templates.btn.capturing"] : T["templates.btn.capture"])
|
||||
</button>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" />
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-title">Apply Template</div>
|
||||
<div class="card-title">@T["templates.apply"]</div>
|
||||
@if (_selectedTemplate == null)
|
||||
{
|
||||
<div class="alert alert-info">Select a template from the list below.</div>
|
||||
<div class="alert alert-info">@T["templates.apply.selectprompt"]</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="alert alert-info">Template: <strong>@_selectedTemplate.Name</strong></div>
|
||||
<div class="alert alert-info">@T["templates.apply.selectedlabel"] <strong>@_selectedTemplate.Name</strong></div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">New Site Title</label>
|
||||
<label class="form-label">@T["templates.newtitle"]</label>
|
||||
<input class="form-input" @bind="_newTitle" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">New Site Alias</label>
|
||||
<label class="form-label">@T["templates.newalias"]</label>
|
||||
<input class="form-input" @bind="_newAlias" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Admin Center URL</label>
|
||||
<label class="form-label">@T["templates.adminurl"]</label>
|
||||
<input class="form-input" @bind="_adminUrl" placeholder="https://contoso-admin.sharepoint.com" />
|
||||
</div>
|
||||
<button class="btn btn-primary" @onclick="ApplyTemplate" disabled="@_running">
|
||||
@(_running ? "Applying…" : "Apply Template")
|
||||
@(_running ? T["templates.btn.applying"] : T["templates.apply"])
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
@@ -65,21 +66,21 @@
|
||||
@if (!string.IsNullOrEmpty(_successMsg)) { <div class="alert alert-success mt-8">@_successMsg</div> }
|
||||
|
||||
<div class="card" style="margin-top:16px">
|
||||
<div class="card-title">Saved Templates</div>
|
||||
<div class="card-title">@T["templates.list"]</div>
|
||||
@if (_templates.Count == 0)
|
||||
{
|
||||
<div class="text-muted">No templates saved.</div>
|
||||
<div class="text-muted">@T["templates.empty"]</div>
|
||||
}
|
||||
@foreach (var t in _templates)
|
||||
{
|
||||
<div class="flex-row" style="padding:8px 0;border-bottom:1px solid var(--border)">
|
||||
<div>
|
||||
<div style="font-weight:600">@t.Name</div>
|
||||
<div class="text-muted">@t.SiteType · @t.CapturedAt.ToString("yyyy-MM-dd") · @t.Libraries.Count libraries</div>
|
||||
<div class="text-muted">@t.SiteType · @t.CapturedAt.ToString("yyyy-MM-dd") · @string.Format(T["templates.libraries.suffix"], t.Libraries.Count)</div>
|
||||
</div>
|
||||
<div class="spacer"></div>
|
||||
<button class="btn btn-secondary btn-sm" @onclick="() => _selectedTemplate = t">Use</button>
|
||||
<button class="btn btn-danger btn-sm" @onclick="() => DeleteTemplate(t)">Delete</button>
|
||||
<button class="btn btn-secondary btn-sm" @onclick="() => _selectedTemplate = t">@T["templates.btn.use"]</button>
|
||||
<button class="btn btn-danger btn-sm" @onclick="() => DeleteTemplate(t)">@T["templates.delete"]</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -116,9 +117,9 @@
|
||||
template.Name = string.IsNullOrWhiteSpace(_captureName) ? $"Template-{DateTime.Now:yyyyMMdd}" : _captureName;
|
||||
await TemplateRepo.SaveAsync(template);
|
||||
_templates = (await TemplateRepo.GetAllAsync()).ToList();
|
||||
_successMsg = $"Template '{template.Name}' saved.";
|
||||
_successMsg = string.Format(T["templates.status.saved"], template.Name);
|
||||
}
|
||||
catch (OperationCanceledException) { _status = "Cancelled."; }
|
||||
catch (OperationCanceledException) { _status = T["templates.status.cancelled"]; }
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
finally { _running = false; await InvokeAsync(StateHasChanged); }
|
||||
}
|
||||
@@ -136,9 +137,9 @@
|
||||
{
|
||||
var ctx = await SessionMgr.GetOrCreateContextAsync(adminUrl, Session.CurrentProfile!, _cts.Token);
|
||||
var url = await TemplateSvc.ApplyTemplateAsync(ctx, _selectedTemplate, _newTitle, _newAlias, progress, _cts.Token);
|
||||
_successMsg = $"Site created: {url}";
|
||||
_successMsg = string.Format(T["templates.status.sitecreated"], url);
|
||||
}
|
||||
catch (OperationCanceledException) { _status = "Cancelled."; }
|
||||
catch (OperationCanceledException) { _status = T["templates.status.cancelled"]; }
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
finally { _running = false; await InvokeAsync(StateHasChanged); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user