user import improvements
This commit is contained in:
@ -7,16 +7,16 @@
|
||||
|
||||
<div class="container">
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="userfile" HelpText="Select or upload a CSV file containing user information. The CSV file must be in the Template format specified." ResourceKey="UserFile">User File:</Label>
|
||||
<Label Class="col-sm-3" For="importfile" HelpText="Upload or select a tab delimited text file containing user information. The file must be in the Template format specified (Roles can be specified as a comma delimited list)." ResourceKey="ImportFile">Import File:</Label>
|
||||
<div class="col-sm-9">
|
||||
<FileManager Id="userfile" @ref="_filemanager" Filter="csv" />
|
||||
<FileManager Id="importfile" @ref="_filemanager" Filter="txt" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<button type="button" class="btn btn-success" @onclick="ImportUsers">@Localizer["Import"]</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||
<a class="btn btn-info" href="/users.csv" target="_new">@Localizer["Template"]</a>
|
||||
<a class="btn btn-info" href="/users.txt" target="_new">@Localizer["Template"]</a>
|
||||
|
||||
@code {
|
||||
private FileManager _filemanager;
|
||||
@ -32,14 +32,17 @@
|
||||
var fileid = _filemanager.GetFileId();
|
||||
if (fileid != -1)
|
||||
{
|
||||
if (await UserService.ImportUsersAsync(PageState.Site.SiteId, fileid))
|
||||
ShowProgressIndicator();
|
||||
var results = await UserService.ImportUsersAsync(PageState.Site.SiteId, fileid);
|
||||
if (bool.Parse(results["Success"]))
|
||||
{
|
||||
AddModuleMessage(Localizer["Message.Import.Success"], MessageType.Success);
|
||||
AddModuleMessage(string.Format(Localizer["Message.Import.Success"], results["Rows"], results["Users"]), MessageType.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddModuleMessage(Localizer["Message.Import.Failure"], MessageType.Error);
|
||||
}
|
||||
HideProgressIndicator();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -117,11 +117,11 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="UserFile.HelpText" xml:space="preserve">
|
||||
<value>Select or upload a CSV file containing user information. The CSV file must be in the Template format specified.</value>
|
||||
<data name="ImportFile.HelpText" xml:space="preserve">
|
||||
<value>Upload or select a tab delimited text file containing user information. The file must be in the Template format specified (Roles can be specified as a comma delimited list).</value>
|
||||
</data>
|
||||
<data name="UserFile.Text" xml:space="preserve">
|
||||
<value>User File:</value>
|
||||
<data name="ImportFile.Text" xml:space="preserve">
|
||||
<value>Import File:</value>
|
||||
</data>
|
||||
<data name="Error.Import" xml:space="preserve">
|
||||
<value>Error Importing Users</value>
|
||||
@ -130,10 +130,10 @@
|
||||
<value>Import</value>
|
||||
</data>
|
||||
<data name="Message.Import.Failure" xml:space="preserve">
|
||||
<value>User Import Failed</value>
|
||||
<value>User Import Failed. Please Review Your Event Log For More Detailed Information.</value>
|
||||
</data>
|
||||
<data name="Message.Import.Success" xml:space="preserve">
|
||||
<value>Users Imported Successfully</value>
|
||||
<value>Users Imported Successfully. {0} Rows Processed, {1} Users Imported.</value>
|
||||
</data>
|
||||
<data name="Message.Import.Validation" xml:space="preserve">
|
||||
<value>You Must Specify A User File For Import</value>
|
||||
|
@ -148,6 +148,6 @@ namespace Oqtane.Services
|
||||
/// </summary>
|
||||
/// <param name="fileId">ID of a <see cref="File"/></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> ImportUsersAsync(int siteId, int fileId);
|
||||
Task<Dictionary<string, string>> ImportUsersAsync(int siteId, int fileId);
|
||||
}
|
||||
}
|
||||
|
@ -127,9 +127,9 @@ namespace Oqtane.Services
|
||||
return string.Format(passwordValidationCriteriaTemplate, minimumlength, uniquecharacters, digitRequirement, uppercaseRequirement, lowercaseRequirement, punctuationRequirement);
|
||||
}
|
||||
|
||||
public async Task<bool> ImportUsersAsync(int siteId, int fileId)
|
||||
public async Task<Dictionary<string, string>> ImportUsersAsync(int siteId, int fileId)
|
||||
{
|
||||
return await PostJsonAsync<bool>($"{Apiurl}/import?siteid={siteId}&fileid={fileId}", true);
|
||||
return await PostJsonAsync<Dictionary<string, string>>($"{Apiurl}/import?siteid={siteId}&fileid={fileId}", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user