diff --git a/Borepin/Borepin/Base/ConnectionModelBase.cs b/Borepin/Borepin/Base/ConnectionModelBase.cs
index 685f478..fc69cff 100644
--- a/Borepin/Borepin/Base/ConnectionModelBase.cs
+++ b/Borepin/Borepin/Base/ConnectionModelBase.cs
@@ -13,11 +13,14 @@ namespace Borepin.Base
{
#region Private Fields
protected readonly IAPI _API;
+ protected readonly IAPIService _APIService;
#endregion
#region Constructors
protected ConnectionModelBase(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService, pageDialogService)
{
+ _APIService = apiService;
+
_API = apiService.GetAPI();
_API.ConnectionStatusChanged += OnConnectionStatusChanged;
diff --git a/Borepin/Borepin/Page/UserListPage.xaml b/Borepin/Borepin/Page/UserListPage.xaml
index 91e45c8..edff8dd 100644
--- a/Borepin/Borepin/Page/UserListPage.xaml
+++ b/Borepin/Borepin/Page/UserListPage.xaml
@@ -32,7 +32,7 @@
-
+
diff --git a/Borepin/Borepin/Page/UserPage.xaml b/Borepin/Borepin/Page/UserPage.xaml
index d83adeb..a53bf37 100644
--- a/Borepin/Borepin/Page/UserPage.xaml
+++ b/Borepin/Borepin/Page/UserPage.xaml
@@ -2,7 +2,7 @@
@@ -19,9 +19,20 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/Borepin/Borepin/PageModel/MachinePageModel.cs b/Borepin/Borepin/PageModel/MachinePageModel.cs
index 2a3158f..8ef9fbc 100644
--- a/Borepin/Borepin/PageModel/MachinePageModel.cs
+++ b/Borepin/Borepin/PageModel/MachinePageModel.cs
@@ -134,11 +134,17 @@ namespace Borepin.PageModel
if (_API.IsConnected)
{
+ try
+ {
+ Machine.IManageInterface manageInterface = _Machine.Manage;
- Machine.IManageInterface manageInterface = _Machine.Manage;
-
- await manageInterface.ForceFree().ConfigureAwait(false);
- await LoadAPIData().ConfigureAwait(false);
+ await manageInterface.ForceFree().ConfigureAwait(false);
+ await LoadAPIData().ConfigureAwait(false);
+ }
+ catch (RpcException exception) when (string.Equals(exception.Message, "RPC connection is broken. Task would never return.", StringComparison.Ordinal))
+ {
+ Log.Debug("RPC Connection Loss");
+ }
}
IsBusy = false;
diff --git a/Borepin/Borepin/PageModel/UserListPageModel.cs b/Borepin/Borepin/PageModel/UserListPageModel.cs
index a7216d8..a9f4324 100644
--- a/Borepin/Borepin/PageModel/UserListPageModel.cs
+++ b/Borepin/Borepin/PageModel/UserListPageModel.cs
@@ -36,7 +36,7 @@ namespace Borepin.PageModel
viewmodel_list.Add(new_viewmodel);
}
- user_list.OrderBy(x => x.Username, StringComparison.OrdinalIgnoreCase.WithNaturalSort());
+ viewmodel_list.OrderBy(x => x.Instance.Username, StringComparison.OrdinalIgnoreCase.WithNaturalSort());
UserListItemViewModel_List = viewmodel_list;
}
#endregion
diff --git a/Borepin/Borepin/PageModel/UserPageModel.cs b/Borepin/Borepin/PageModel/UserPageModel.cs
index f9d4641..09b37ac 100644
--- a/Borepin/Borepin/PageModel/UserPageModel.cs
+++ b/Borepin/Borepin/PageModel/UserPageModel.cs
@@ -10,6 +10,10 @@ using Borepin.Service;
using Borepin.Base.Exceptions;
using Capnp.Rpc;
using System;
+using Borepin.ViewModel;
+using System.Collections.Generic;
+using NaturalSort.Extension;
+using System.Linq;
namespace Borepin.PageModel
{
@@ -47,10 +51,38 @@ namespace Borepin.PageModel
_User = (await _API.Session.UserSystem.Search.GetUserByName(_ID).ConfigureAwait(false)).Just;
UserItem = new UserVisualize(_User);
UserItem.LoadData();
+
+ IReadOnlyList role_list = await _API.Session.PermissionSystem.Info.GetRoleList().ConfigureAwait(false);
+ List user_role_list = new List(await _User.Info.ListRoles().ConfigureAwait(false));
+
+ List viewmodel_list = new List();
+ foreach (Role role in role_list)
+ {
+ PermissionSelectViewModel new_viewmodel = new PermissionSelectViewModel(_NavigationService, _PageDialogService, _APIService);
+ object[] array = new object[]
+ {
+ role,
+ _User,
+ user_role_list.Contains(role)
+ };
+
+ await new_viewmodel.LoadInstance(array).ConfigureAwait(false);
+ viewmodel_list.Add(new_viewmodel);
+ }
+
+ viewmodel_list.OrderBy(x => x.RoleName, StringComparison.OrdinalIgnoreCase.WithNaturalSort());
+ PermissionSelectViewModel_List = viewmodel_list;
}
#endregion
#region Fields
+ private IList _PermissionSelectViewModel_List;
+ public IList PermissionSelectViewModel_List
+ {
+ get => _PermissionSelectViewModel_List;
+ set => SetProperty(ref _PermissionSelectViewModel_List, value);
+ }
+
private UserVisualize _UserItem;
public UserVisualize UserItem
{
diff --git a/Borepin/Borepin/View/PermissionSelectView.xaml b/Borepin/Borepin/View/PermissionSelectView.xaml
new file mode 100644
index 0000000..49cd9ae
--- /dev/null
+++ b/Borepin/Borepin/View/PermissionSelectView.xaml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Borepin/Borepin/View/PermissionSelectView.xaml.cs b/Borepin/Borepin/View/PermissionSelectView.xaml.cs
new file mode 100644
index 0000000..30b7647
--- /dev/null
+++ b/Borepin/Borepin/View/PermissionSelectView.xaml.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+
+namespace Borepin.View
+{
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ public partial class PermissionSelectView : ContentView
+ {
+ public PermissionSelectView()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Borepin/Borepin/ViewModel/PermissionSelectViewModel.cs b/Borepin/Borepin/ViewModel/PermissionSelectViewModel.cs
new file mode 100644
index 0000000..e12f34f
--- /dev/null
+++ b/Borepin/Borepin/ViewModel/PermissionSelectViewModel.cs
@@ -0,0 +1,121 @@
+using Borepin.Base;
+using Borepin.Service;
+using Capnp.Rpc;
+using FabAccessAPI.Schema;
+using Prism.Commands;
+using Prism.Navigation;
+using Prism.Services;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace Borepin.ViewModel
+{
+ public class PermissionSelectViewModel : ConnectionModelBase
+ {
+ #region Private Fields
+ private User _User;
+ private Role _Role;
+ #endregion
+
+ #region Constructors
+ public PermissionSelectViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService, pageDialogService, apiService)
+ {
+ UpdateRoleCommand = new DelegateCommand(UpdateRoleCommandExecute);
+ }
+ #endregion
+
+ #region LoadData
+ public override Task LoadInstance(object instance)
+ {
+ if(instance is object[])
+ {
+ object[] array = instance as object[];
+ if (array[0] is Role && array[1] is User && array[2] is bool)
+ {
+ _Role = array[0] as Role;
+ _User = array[1] as User;
+
+ RoleName = _Role.Name;
+
+ CanChange = !((User.AdminInterface_Proxy)_User.Admin).IsNull;
+ IsChecked = (bool)array[2];
+ }
+ }
+ return Task.CompletedTask;
+ }
+ #endregion
+
+ #region Fields
+ private bool _IsChecked;
+ public bool IsChecked
+ {
+ get => _IsChecked;
+ set
+ {
+ SetProperty(ref _IsChecked, value);
+ UpdateRoleCommand.Execute(null);
+ }
+ }
+
+ private bool _CanChange;
+ public bool CanChange
+ {
+ get => _CanChange;
+ set
+ {
+ SetProperty(ref _CanChange, value);
+ }
+ }
+
+ private string _RoleName;
+ public string RoleName
+ {
+ get => _RoleName;
+ set => SetProperty(ref _RoleName, value);
+ }
+ #endregion
+
+ #region Commands
+ private ICommand _UpdateRoleCommand;
+ public ICommand UpdateRoleCommand
+ {
+ get => _UpdateRoleCommand;
+ set => SetProperty(ref _UpdateRoleCommand, value);
+ }
+ public async void UpdateRoleCommandExecute()
+ {
+ if(!CanChange)
+ {
+ return;
+ }
+
+ if(_API.IsConnected)
+ {
+ try
+ {
+ List user_role_list = new List(await _User.Info.ListRoles().ConfigureAwait(false));
+ if(IsChecked)
+ {
+ if(!user_role_list.Contains(_Role))
+ {
+ await _User.Admin.AddRole(_Role).ConfigureAwait(false);
+ }
+ }
+ else
+ {
+ if(user_role_list.Contains(_Role))
+ {
+ await _User.Admin.RemoveRole(_Role).ConfigureAwait(false);
+ }
+ }
+ }
+ catch (RpcException exception) when (string.Equals(exception.Message, "RPC connection is broken. Task would never return.", StringComparison.Ordinal))
+ {
+ Log.Debug("RPC Connection Loss");
+ }
+ }
+ }
+ #endregion
+ }
+}
diff --git a/external/capnproto-dotnetcore b/external/capnproto-dotnetcore
index 63e6385..086bbc2 160000
--- a/external/capnproto-dotnetcore
+++ b/external/capnproto-dotnetcore
@@ -1 +1 @@
-Subproject commit 63e63853c1d5ca9f223aa3627ad391ce434a0683
+Subproject commit 086bbc2497785d2cc63e9252df6f6d3ee7599579