You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
152 lines
5.6 KiB
152 lines
5.6 KiB
{{define "users_update_content"}}
|
|
<div class="page-header">
|
|
<h2>User Updates</h2>
|
|
<p>Upload a CSV to update existing ServiceTrade users and assign additional roles.</p>
|
|
</div>
|
|
|
|
<div class="page-content">
|
|
<div class="content">
|
|
<h3 class="submenu-header">Upload Update CSV</h3>
|
|
{{if .FlashError}}
|
|
<div class="error-message">{{.FlashError}}</div>
|
|
{{end}}
|
|
{{if .FlashSuccess}}
|
|
<div class="info-message">{{.FlashSuccess}}</div>
|
|
{{end}}
|
|
<form action="/users/update/upload" method="POST" enctype="multipart/form-data">
|
|
{{if .CSRFField}}{{.CSRFField}}{{end}}
|
|
{{if .CSRFCookie}}<input type="hidden" name="csrfToken" value="{{.CSRFCookie}}">{{end}}
|
|
<label for="users-update-csv">CSV file</label>
|
|
<input id="users-update-csv" name="csvFile" type="file" accept=".csv" class="card-input" required>
|
|
<button type="submit" class="btn-primary">Process Updates</button>
|
|
</form>
|
|
<div class="info-message" style="margin-top: 1rem;">
|
|
Provide either <strong>userId</strong> or <strong>username</strong> for each row. Use <strong>new_username</strong> to change an account's username. All other columns match the create template; only non-empty values are applied. Roles column should list human-readable role names (comma, semicolon, or pipe separated).
|
|
</div>
|
|
</div>
|
|
|
|
{{if .RolesError}}
|
|
<div class="content" style="margin-top:1rem;">
|
|
<div class="error-message">{{.RolesError}}</div>
|
|
</div>
|
|
{{end}}
|
|
|
|
{{if .Roles}}
|
|
<div class="content" style="margin-top:1rem;">
|
|
<h3 class="submenu-header">Available Roles</h3>
|
|
<p>Use the role names from this list in the CSV roles column.</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
<th>Global</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{range .Roles}}
|
|
<tr>
|
|
<td>{{.ID}}</td>
|
|
<td>{{.Name}}</td>
|
|
<td>{{.Description}}</td>
|
|
<td>{{if .Global}}Yes{{else}}No{{end}}</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{{end}}
|
|
|
|
{{if .UpdateSummary}}
|
|
<div class="content" style="margin-top:1rem;">
|
|
<h3 class="submenu-header">Update Summary</h3>
|
|
<p>
|
|
Processed file: <strong>{{.UpdateSummary.ProcessedFilename}}</strong> at {{.UpdateSummary.ProcessedAt.Format "2006-01-02 15:04 MST"}}.
|
|
</p>
|
|
<ul>
|
|
<li>Total rows: {{.UpdateSummary.TotalRows}}</li>
|
|
<li>Users updated: {{.UpdateSummary.UsersUpdated}}</li>
|
|
<li>Rows failed: {{.UpdateSummary.RowsFailed}}</li>
|
|
<li>Role assignments succeeded: {{.UpdateSummary.RoleAssignments}}</li>
|
|
<li>Role assignments failed: {{.UpdateSummary.RoleAssignmentErrors}}</li>
|
|
<li>Lookups by username: {{.UpdateSummary.LookupsByUsername}}</li>
|
|
<li>Lookups by userId: {{.UpdateSummary.LookupsByID}}</li>
|
|
</ul>
|
|
</div>
|
|
{{end}}
|
|
|
|
{{if .UpdateResults}}
|
|
<div class="content" style="margin-top:1rem;">
|
|
<h3 class="submenu-header">Update Details</h3>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Row</th>
|
|
<th>User</th>
|
|
<th>Lookup</th>
|
|
<th>Updated Fields</th>
|
|
<th>Result</th>
|
|
<th>Role Assignments</th>
|
|
<th>Processing Time</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{range .UpdateResults}}
|
|
<tr>
|
|
<td>{{.Row}}</td>
|
|
<td>
|
|
{{if .UserID}}
|
|
#{{.UserID}}
|
|
{{end}}
|
|
{{if .Username}}
|
|
({{.Username}})
|
|
{{end}}
|
|
</td>
|
|
<td>{{.LookupMethod}}</td>
|
|
<td>
|
|
{{if .UpdatedFields}}
|
|
<ul>
|
|
{{range .UpdatedFields}}
|
|
<li>{{.}}</li>
|
|
{{end}}
|
|
</ul>
|
|
{{else}}
|
|
—
|
|
{{end}}
|
|
</td>
|
|
<td>
|
|
{{if .Error}}
|
|
<div class="error-message">{{.Error}}</div>
|
|
{{else if .Updated}}
|
|
Updated
|
|
{{else}}
|
|
Skipped
|
|
{{end}}
|
|
</td>
|
|
<td>
|
|
{{if .RoleAssignments}}
|
|
<ul>
|
|
{{range .RoleAssignments}}
|
|
<li>
|
|
{{if .Success}}✅{{else}}⚠️{{end}}
|
|
{{if .Role}}{{.Role}} ({{.RoleID}}){{else}}{{.Token}}{{end}} — {{.Message}}
|
|
</li>
|
|
{{end}}
|
|
</ul>
|
|
{{else if .Error}}
|
|
—
|
|
{{else}}
|
|
No roles provided
|
|
{{end}}
|
|
</td>
|
|
<td>{{.ProcessingTime}}</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|
|
|
|
|