mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 23:01:52 +01:00
Fixed: Remove User
This commit is contained in:
parent
3020024270
commit
3158295d6b
@ -56,6 +56,9 @@
|
|||||||
<Compile Update="Page\ScanURNPage.xaml.cs">
|
<Compile Update="Page\ScanURNPage.xaml.cs">
|
||||||
<DependentUpon>ScanURNPage.xaml</DependentUpon>
|
<DependentUpon>ScanURNPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="Page\ProfilePage.xaml.cs">
|
||||||
|
<DependentUpon>ProfilePage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Page\UserPage.xaml.cs">
|
<Compile Update="Page\UserPage.xaml.cs">
|
||||||
<DependentUpon>UserPage.xaml</DependentUpon>
|
<DependentUpon>UserPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using FabAccessAPI.Schema;
|
using FabAccessAPI.Schema;
|
||||||
using Prism.Mvvm;
|
using Prism.Mvvm;
|
||||||
|
|
||||||
namespace Borepin.Model
|
namespace Borepin.Model
|
||||||
|
@ -2,8 +2,14 @@
|
|||||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="Borepin.Page.AddUserPage"
|
x:Class="Borepin.Page.AddUserPage"
|
||||||
|
xmlns:converters="clr-namespace:Borepin.Converter"
|
||||||
xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
|
xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
|
||||||
Title="{x:Static resource_text:TextResource.TITLE_AddUser}">
|
Title="{x:Static resource_text:TextResource.TITLE_AddUser}">
|
||||||
|
<ContentPage.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</ContentPage.Resources>
|
||||||
<ContentPage.Content>
|
<ContentPage.Content>
|
||||||
<StackLayout Padding="20">
|
<StackLayout Padding="20">
|
||||||
<StackLayout IsVisible="{Binding IsBusy}">
|
<StackLayout IsVisible="{Binding IsBusy}">
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
</StackLayout>
|
</StackLayout>
|
||||||
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
|
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
|
||||||
<StackLayout IsVisible="{Binding IsConnected}">
|
<StackLayout IsVisible="{Binding IsConnected}">
|
||||||
<Label Text="{Binding UserItem.Name}" Style="{StaticResource LabelStyle_Title}"/>
|
<Label Text="{Binding UserItem.Username}" Style="{StaticResource LabelStyle_Title}"/>
|
||||||
<ListView ItemsSource="{Binding PermissionSelectViewModel_List}" SelectionMode="None" SeparatorColor="Transparent">
|
<ListView ItemsSource="{Binding PermissionSelectViewModel_List}" SelectionMode="None" SeparatorColor="Transparent">
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
using Borepin.Base;
|
using Borepin.Base;
|
||||||
using Prism.Commands;
|
using Prism.Commands;
|
||||||
using Prism.Navigation;
|
using Prism.Navigation;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using FabAccessAPI.Schema;
|
using FabAccessAPI.Schema;
|
||||||
using Borepin.Model;
|
|
||||||
using Prism.Services;
|
using Prism.Services;
|
||||||
using Borepin.Service;
|
using Borepin.Service;
|
||||||
using Borepin.Base.Exceptions;
|
|
||||||
using Capnp.Rpc;
|
using Capnp.Rpc;
|
||||||
using System;
|
using System;
|
||||||
using static FabAccessAPI.Schema.UserSystem.ManageInterface;
|
using static FabAccessAPI.Schema.UserSystem.ManageInterface;
|
||||||
@ -66,7 +63,7 @@ namespace Borepin.PageModel
|
|||||||
case AddUserErrorEnum.alreadyExists:
|
case AddUserErrorEnum.alreadyExists:
|
||||||
Device.BeginInvokeOnMainThread(async () =>
|
Device.BeginInvokeOnMainThread(async () =>
|
||||||
{
|
{
|
||||||
await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_UnableServer, Resources.Text.TextResource.OK).ConfigureAwait(false);
|
await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_AddUserFailed, Resources.Text.TextResource.ALERT_UserExist, Resources.Text.TextResource.OK).ConfigureAwait(false);
|
||||||
|
|
||||||
IsBusy = false;
|
IsBusy = false;
|
||||||
});
|
});
|
||||||
@ -74,7 +71,7 @@ namespace Borepin.PageModel
|
|||||||
case AddUserErrorEnum.usernameInvalid:
|
case AddUserErrorEnum.usernameInvalid:
|
||||||
Device.BeginInvokeOnMainThread(async () =>
|
Device.BeginInvokeOnMainThread(async () =>
|
||||||
{
|
{
|
||||||
await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, "Unable to connect to server.", Resources.Text.TextResource.OK).ConfigureAwait(false);
|
await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_AddUserFailed, Resources.Text.TextResource.ALERT_UsernameInvalid, Resources.Text.TextResource.OK).ConfigureAwait(false);
|
||||||
|
|
||||||
IsBusy = false;
|
IsBusy = false;
|
||||||
});
|
});
|
||||||
@ -82,7 +79,7 @@ namespace Borepin.PageModel
|
|||||||
case AddUserErrorEnum.passwordInvalid:
|
case AddUserErrorEnum.passwordInvalid:
|
||||||
Device.BeginInvokeOnMainThread(async () =>
|
Device.BeginInvokeOnMainThread(async () =>
|
||||||
{
|
{
|
||||||
await _PageDialogService.DisplayAlertAsync("Connection failed", "Unable to connect to server.", "Ok").ConfigureAwait(false);
|
await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_AddUserFailed, Resources.Text.TextResource.ALERT_PasswordInvalid, Resources.Text.TextResource.OK).ConfigureAwait(false);
|
||||||
|
|
||||||
IsBusy = false;
|
IsBusy = false;
|
||||||
});
|
});
|
||||||
|
@ -30,8 +30,8 @@ namespace Borepin.PageModel
|
|||||||
#region LoadData
|
#region LoadData
|
||||||
public override Task LoadAPIData()
|
public override Task LoadAPIData()
|
||||||
{
|
{
|
||||||
//UserSystem.ManageInterface_Proxy manageInterface = (UserSystem.ManageInterface_Proxy)_API.Session.UserSystem.Manage;
|
UserSystem.ManageInterface_Proxy manageInterface = (UserSystem.ManageInterface_Proxy)_API.Session.UserSystem.Manage;
|
||||||
//CanManageUsers = !manageInterface.IsNull;
|
CanManageUsers = !manageInterface.IsNull;
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,15 @@ namespace Borepin.PageModel
|
|||||||
#region Private Fields
|
#region Private Fields
|
||||||
private string _ID;
|
private string _ID;
|
||||||
private User _User;
|
private User _User;
|
||||||
private bool IsDialog = false;
|
|
||||||
private IDialogService _DialogService;
|
private IDialogService _DialogService;
|
||||||
|
private bool _IsDialog;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Contructors
|
#region Contructors
|
||||||
public UserPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService, IDialogService dialogService) : base(navigationService, pageDialogService, apiService)
|
public UserPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService, IDialogService dialogService) : base(navigationService, pageDialogService, apiService)
|
||||||
{
|
{
|
||||||
_DialogService = dialogService;
|
_DialogService = dialogService;
|
||||||
|
DeleteCommand = new DelegateCommand(DeleteCommandExecute);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -41,6 +42,10 @@ namespace Borepin.PageModel
|
|||||||
if(instance is string)
|
if(instance is string)
|
||||||
{
|
{
|
||||||
_ID = instance as string;
|
_ID = instance as string;
|
||||||
|
}
|
||||||
|
else if(instance == null && _IsDialog)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -52,6 +57,11 @@ namespace Borepin.PageModel
|
|||||||
|
|
||||||
public override async Task LoadAPIData()
|
public override async Task LoadAPIData()
|
||||||
{
|
{
|
||||||
|
if(_IsDialog)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_User = (await _API.Session.UserSystem.Search.GetUserByName(_ID).ConfigureAwait(false)).Just;
|
_User = (await _API.Session.UserSystem.Search.GetUserByName(_ID).ConfigureAwait(false)).Just;
|
||||||
UserItem = new UserVisualize(_User);
|
UserItem = new UserVisualize(_User);
|
||||||
UserItem.LoadData();
|
UserItem.LoadData();
|
||||||
@ -67,7 +77,7 @@ namespace Borepin.PageModel
|
|||||||
{
|
{
|
||||||
role,
|
role,
|
||||||
_User,
|
_User,
|
||||||
user_role_list.Contains(role)
|
user_role_list.Exists(x => string.Equals(x.Name, role.Name, StringComparison.Ordinal))
|
||||||
};
|
};
|
||||||
|
|
||||||
await new_viewmodel.LoadInstance(array).ConfigureAwait(false);
|
await new_viewmodel.LoadInstance(array).ConfigureAwait(false);
|
||||||
@ -78,7 +88,7 @@ namespace Borepin.PageModel
|
|||||||
PermissionSelectViewModel_List = viewmodel_list;
|
PermissionSelectViewModel_List = viewmodel_list;
|
||||||
|
|
||||||
CanAdmin = !((UserSystem.ManageInterface_Proxy)_API.Session.UserSystem.Manage).IsNull;
|
CanAdmin = !((UserSystem.ManageInterface_Proxy)_API.Session.UserSystem.Manage).IsNull;
|
||||||
CanManage = !((User.AdminInterface_Proxy)_User.Manage).IsNull;
|
CanManage = !((User.ManageInterface_Proxy)_User.Manage).IsNull;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -129,7 +139,7 @@ namespace Borepin.PageModel
|
|||||||
{ "instance", _User },
|
{ "instance", _User },
|
||||||
};
|
};
|
||||||
|
|
||||||
IsDialog = true;
|
_IsDialog = true;
|
||||||
_DialogService.ShowDialog("ConfirmDialog", parameters, DeleteCommandExecute_Dialog);
|
_DialogService.ShowDialog("ConfirmDialog", parameters, DeleteCommandExecute_Dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,10 +147,16 @@ namespace Borepin.PageModel
|
|||||||
{
|
{
|
||||||
if (string.Equals(result.Parameters.GetValue<string>("result"), "confirm", StringComparison.Ordinal))
|
if (string.Equals(result.Parameters.GetValue<string>("result"), "confirm", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
if(_API.IsConnected)
|
IsBusy = true;
|
||||||
|
if (_API.IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
foreach(PermissionSelectViewModel viewModel in PermissionSelectViewModel_List)
|
||||||
|
{
|
||||||
|
viewModel.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
await _API.Session.UserSystem.Manage.RemoveUser(_User).ConfigureAwait(false);
|
await _API.Session.UserSystem.Manage.RemoveUser(_User).ConfigureAwait(false);
|
||||||
|
|
||||||
Device.BeginInvokeOnMainThread(async () =>
|
Device.BeginInvokeOnMainThread(async () =>
|
||||||
|
@ -159,6 +159,15 @@ namespace Borepin.Resources.Text {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Add User failed.
|
||||||
|
/// </summary>
|
||||||
|
internal static string ALERT_AddUserFailed {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ALERT_AddUserFailed", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Unable to authenticate to server..
|
/// Looks up a localized string similar to Unable to authenticate to server..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -177,6 +186,15 @@ namespace Borepin.Resources.Text {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Password is invalid..
|
||||||
|
/// </summary>
|
||||||
|
internal static string ALERT_PasswordInvalid {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ALERT_PasswordInvalid", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to QR Code is invalid.
|
/// Looks up a localized string similar to QR Code is invalid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -204,6 +222,24 @@ namespace Borepin.Resources.Text {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to User allready exist..
|
||||||
|
/// </summary>
|
||||||
|
internal static string ALERT_UserExist {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ALERT_UserExist", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Username is invalid..
|
||||||
|
/// </summary>
|
||||||
|
internal static string ALERT_UsernameInvalid {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ALERT_UsernameInvalid", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to It's Bionade.
|
/// Looks up a localized string similar to It's Bionade.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -151,12 +151,18 @@
|
|||||||
<data name="ALERT_AddressInvalid" xml:space="preserve">
|
<data name="ALERT_AddressInvalid" xml:space="preserve">
|
||||||
<value>Server address is invaild.</value>
|
<value>Server address is invaild.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ALERT_AddUserFailed" xml:space="preserve">
|
||||||
|
<value>Add User failed</value>
|
||||||
|
</data>
|
||||||
<data name="ALERT_AuthServer" xml:space="preserve">
|
<data name="ALERT_AuthServer" xml:space="preserve">
|
||||||
<value>Unable to authenticate to server.</value>
|
<value>Unable to authenticate to server.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ALERT_ConnectionFailed" xml:space="preserve">
|
<data name="ALERT_ConnectionFailed" xml:space="preserve">
|
||||||
<value>Connection failed</value>
|
<value>Connection failed</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ALERT_PasswordInvalid" xml:space="preserve">
|
||||||
|
<value>Password is invalid.</value>
|
||||||
|
</data>
|
||||||
<data name="Alert_QRInvalid" xml:space="preserve">
|
<data name="Alert_QRInvalid" xml:space="preserve">
|
||||||
<value>QR Code is invalid</value>
|
<value>QR Code is invalid</value>
|
||||||
</data>
|
</data>
|
||||||
@ -166,6 +172,12 @@
|
|||||||
<data name="ALERT_UnexpectedError" xml:space="preserve">
|
<data name="ALERT_UnexpectedError" xml:space="preserve">
|
||||||
<value>Unexpected Error.</value>
|
<value>Unexpected Error.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ALERT_UserExist" xml:space="preserve">
|
||||||
|
<value>User allready exist.</value>
|
||||||
|
</data>
|
||||||
|
<data name="ALERT_UsernameInvalid" xml:space="preserve">
|
||||||
|
<value>Username is invalid.</value>
|
||||||
|
</data>
|
||||||
<data name="Bionade" xml:space="preserve">
|
<data name="Bionade" xml:space="preserve">
|
||||||
<value>It's Bionade</value>
|
<value>It's Bionade</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -12,7 +12,7 @@ using System.Windows.Input;
|
|||||||
|
|
||||||
namespace Borepin.ViewModel
|
namespace Borepin.ViewModel
|
||||||
{
|
{
|
||||||
public class PermissionSelectViewModel : ConnectionModelBase
|
public class PermissionSelectViewModel : ConnectionModelBase, IDisposable
|
||||||
{
|
{
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
private User _User;
|
private User _User;
|
||||||
@ -91,21 +91,21 @@ namespace Borepin.ViewModel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_API.IsConnected)
|
if(_API.IsConnected && _User != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<Role> user_role_list = new List<Role>(await _User.Info.ListRoles().ConfigureAwait(false));
|
List<Role> user_role_list = new List<Role>(await _User.Info.ListRoles().ConfigureAwait(false));
|
||||||
if(IsChecked)
|
if(IsChecked)
|
||||||
{
|
{
|
||||||
if(!user_role_list.Contains(_Role))
|
if(!user_role_list.Exists(x => string.Equals(x.Name, _Role.Name, StringComparison.Ordinal)))
|
||||||
{
|
{
|
||||||
await _User.Admin.AddRole(_Role).ConfigureAwait(false);
|
await _User.Admin.AddRole(_Role).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(user_role_list.Contains(_Role))
|
if(user_role_list.Exists(x => string.Equals(x.Name, _Role.Name, StringComparison.Ordinal)))
|
||||||
{
|
{
|
||||||
await _User.Admin.RemoveRole(_Role).ConfigureAwait(false);
|
await _User.Admin.RemoveRole(_Role).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -116,6 +116,12 @@ namespace Borepin.ViewModel
|
|||||||
Log.Debug("RPC Connection Loss");
|
Log.Debug("RPC Connection Loss");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_User = null;
|
||||||
|
_Role = null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user