mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 14:51:44 +01:00
Merge branch 'feature/server_tests' into 'main'
Machine Categories and Wiki See merge request fabinfra/fabaccess/borepin!58
This commit is contained in:
commit
b2903f9840
@ -81,6 +81,7 @@
|
||||
<Compile Include="Services\APIService.cs" />
|
||||
<Compile Include="Services\APIService_New.cs" />
|
||||
<Compile Include="Services\APIServiceConnection.cs" />
|
||||
<Compile Include="Services\BrowserService.cs" />
|
||||
<Compile Include="Services\PreferenceStorageService.cs" />
|
||||
<Compile Include="Services\SecretStorage.cs" />
|
||||
<Compile Include="Services\VersioningService.cs" />
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Borepin.Droid.Services;
|
||||
using Borepin.Service;
|
||||
using Borepin.Service.Browser;
|
||||
using Borepin.Service.Storage;
|
||||
using Borepin.Service.Versioning;
|
||||
using Prism;
|
||||
@ -14,6 +15,7 @@ namespace Borepin.Droid
|
||||
containerRegistry.Register<IPreferenceStorageService, PreferenceStorageService>();
|
||||
containerRegistry.Register<ISecretStorageService, SecretStorage>();
|
||||
containerRegistry.Register<IVersioningService, VersioningService>();
|
||||
containerRegistry.Register<IBrowserService, BrowserService>();
|
||||
|
||||
containerRegistry.RegisterSingleton<IAPIService, APIService>();
|
||||
}
|
||||
|
51
Borepin/Borepin.Android/Services/BrowserService.cs
Normal file
51
Borepin/Borepin.Android/Services/BrowserService.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Borepin.Service.Browser;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Essentials;
|
||||
|
||||
namespace Borepin.Droid.Services
|
||||
{
|
||||
public class BrowserService : IBrowserService
|
||||
{
|
||||
private Xamarin.Essentials.BrowserLaunchOptions _ConvertBrowserLaunchOptions(Service.Browser.BrowserLaunchOptions browserLaunchOptions)
|
||||
{
|
||||
return new Xamarin.Essentials.BrowserLaunchOptions()
|
||||
{
|
||||
Flags = (Xamarin.Essentials.BrowserLaunchFlags)browserLaunchOptions.Flags,
|
||||
LaunchMode = (Xamarin.Essentials.BrowserLaunchMode)browserLaunchOptions.LaunchMode,
|
||||
PreferredControlColor = browserLaunchOptions.PreferredControlColor,
|
||||
PreferredToolbarColor = browserLaunchOptions.PreferredToolbarColor,
|
||||
TitleMode = (Xamarin.Essentials.BrowserTitleMode)browserLaunchOptions.TitleMode
|
||||
};
|
||||
}
|
||||
public async Task OpenAsync(string uri)
|
||||
{
|
||||
await Browser.OpenAsync(uri).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(string uri, Service.Browser.BrowserLaunchMode browserLaunchMode)
|
||||
{
|
||||
await Browser.OpenAsync(uri, (Xamarin.Essentials.BrowserLaunchMode)browserLaunchMode).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(string uri, Service.Browser.BrowserLaunchOptions browserLaunchOptions)
|
||||
{
|
||||
await Browser.OpenAsync(uri, _ConvertBrowserLaunchOptions(browserLaunchOptions));
|
||||
}
|
||||
|
||||
public async Task OpenAsync(Uri uri)
|
||||
{
|
||||
await Browser.OpenAsync(uri).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(Uri uri, Service.Browser.BrowserLaunchMode browserLaunchMode)
|
||||
{
|
||||
await Browser.OpenAsync(uri, (Xamarin.Essentials.BrowserLaunchMode)browserLaunchMode).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(Uri uri, Service.Browser.BrowserLaunchOptions browserLaunchOptions)
|
||||
{
|
||||
await Browser.OpenAsync(uri, _ConvertBrowserLaunchOptions(browserLaunchOptions));
|
||||
}
|
||||
}
|
||||
}
|
@ -99,6 +99,7 @@
|
||||
<Compile Include="PlatformInitializer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\APIService.cs" />
|
||||
<Compile Include="Services\BrowserService.cs" />
|
||||
<Compile Include="Services\PreferenceStorageService.cs" />
|
||||
<Compile Include="Services\SecretStorageService.cs" />
|
||||
<Compile Include="Services\VersioningService.cs" />
|
||||
|
@ -4,6 +4,7 @@ using Prism.Ioc;
|
||||
using Borepin.Service.Storage;
|
||||
using Borepin.Service.Versioning;
|
||||
using Borepin.Service;
|
||||
using Borepin.Service.Browser;
|
||||
|
||||
namespace Borepin.UWP
|
||||
{
|
||||
@ -14,6 +15,7 @@ namespace Borepin.UWP
|
||||
containerRegistry.Register<IPreferenceStorageService, PreferenceStorageService>();
|
||||
containerRegistry.Register<ISecretStorageService, SecretStorageService>();
|
||||
containerRegistry.Register<IVersioningService, VersioningService>();
|
||||
containerRegistry.Register<IBrowserService, BrowserService>();
|
||||
|
||||
containerRegistry.RegisterSingleton<IAPIService, APIService>();
|
||||
}
|
||||
|
51
Borepin/Borepin.UWP/Services/BrowserService.cs
Normal file
51
Borepin/Borepin.UWP/Services/BrowserService.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Borepin.Service.Browser;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Essentials;
|
||||
|
||||
namespace Borepin.UWP.Services
|
||||
{
|
||||
public class BrowserService : IBrowserService
|
||||
{
|
||||
private Xamarin.Essentials.BrowserLaunchOptions _ConvertBrowserLaunchOptions(Service.Browser.BrowserLaunchOptions browserLaunchOptions)
|
||||
{
|
||||
return new Xamarin.Essentials.BrowserLaunchOptions()
|
||||
{
|
||||
Flags = (Xamarin.Essentials.BrowserLaunchFlags)browserLaunchOptions.Flags,
|
||||
LaunchMode = (Xamarin.Essentials.BrowserLaunchMode)browserLaunchOptions.LaunchMode,
|
||||
PreferredControlColor = browserLaunchOptions.PreferredControlColor,
|
||||
PreferredToolbarColor = browserLaunchOptions.PreferredToolbarColor,
|
||||
TitleMode = (Xamarin.Essentials.BrowserTitleMode)browserLaunchOptions.TitleMode
|
||||
};
|
||||
}
|
||||
public async Task OpenAsync(string uri)
|
||||
{
|
||||
await Browser.OpenAsync(uri).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(string uri, Service.Browser.BrowserLaunchMode browserLaunchMode)
|
||||
{
|
||||
await Browser.OpenAsync(uri, (Xamarin.Essentials.BrowserLaunchMode)browserLaunchMode).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(string uri, Service.Browser.BrowserLaunchOptions browserLaunchOptions)
|
||||
{
|
||||
await Browser.OpenAsync(uri, _ConvertBrowserLaunchOptions(browserLaunchOptions));
|
||||
}
|
||||
|
||||
public async Task OpenAsync(Uri uri)
|
||||
{
|
||||
await Browser.OpenAsync(uri).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(Uri uri, Service.Browser.BrowserLaunchMode browserLaunchMode)
|
||||
{
|
||||
await Browser.OpenAsync(uri, (Xamarin.Essentials.BrowserLaunchMode)browserLaunchMode).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(Uri uri, Service.Browser.BrowserLaunchOptions browserLaunchOptions)
|
||||
{
|
||||
await Browser.OpenAsync(uri, _ConvertBrowserLaunchOptions(browserLaunchOptions));
|
||||
}
|
||||
}
|
||||
}
|
@ -82,6 +82,7 @@
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="Services\APIService.cs" />
|
||||
<Compile Include="Services\BrowserService.cs" />
|
||||
<Compile Include="Services\PreferenceStorageService.cs" />
|
||||
<Compile Include="Services\SecretStorageService.cs" />
|
||||
<Compile Include="Services\VersioningService.cs" />
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Borepin.iOS.Services;
|
||||
using Borepin.Service;
|
||||
using Borepin.Service.Browser;
|
||||
using Borepin.Service.Storage;
|
||||
using Borepin.Service.Versioning;
|
||||
using Prism;
|
||||
@ -14,6 +15,7 @@ namespace Borepin.iOS
|
||||
containerRegistry.Register<IPreferenceStorageService, PreferenceStorageService>();
|
||||
containerRegistry.Register<ISecretStorageService, SecretStorageService>();
|
||||
containerRegistry.Register<IVersioningService, VersioningService>();
|
||||
containerRegistry.Register<IBrowserService, BrowserService>();
|
||||
|
||||
containerRegistry.RegisterSingleton<IAPIService, APIService>();
|
||||
}
|
||||
|
51
Borepin/Borepin.iOS/Services/BrowserService.cs
Normal file
51
Borepin/Borepin.iOS/Services/BrowserService.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Borepin.Service.Browser;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Essentials;
|
||||
|
||||
namespace Borepin.iOS.Services
|
||||
{
|
||||
public class BrowserService : IBrowserService
|
||||
{
|
||||
private Xamarin.Essentials.BrowserLaunchOptions _ConvertBrowserLaunchOptions(Service.Browser.BrowserLaunchOptions browserLaunchOptions)
|
||||
{
|
||||
return new Xamarin.Essentials.BrowserLaunchOptions()
|
||||
{
|
||||
Flags = (Xamarin.Essentials.BrowserLaunchFlags)browserLaunchOptions.Flags,
|
||||
LaunchMode = (Xamarin.Essentials.BrowserLaunchMode)browserLaunchOptions.LaunchMode,
|
||||
PreferredControlColor = browserLaunchOptions.PreferredControlColor,
|
||||
PreferredToolbarColor = browserLaunchOptions.PreferredToolbarColor,
|
||||
TitleMode = (Xamarin.Essentials.BrowserTitleMode)browserLaunchOptions.TitleMode
|
||||
};
|
||||
}
|
||||
public async Task OpenAsync(string uri)
|
||||
{
|
||||
await Browser.OpenAsync(uri).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(string uri, Service.Browser.BrowserLaunchMode browserLaunchMode)
|
||||
{
|
||||
await Browser.OpenAsync(uri, (Xamarin.Essentials.BrowserLaunchMode)browserLaunchMode).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(string uri, Service.Browser.BrowserLaunchOptions browserLaunchOptions)
|
||||
{
|
||||
await Browser.OpenAsync(uri, _ConvertBrowserLaunchOptions(browserLaunchOptions));
|
||||
}
|
||||
|
||||
public async Task OpenAsync(Uri uri)
|
||||
{
|
||||
await Browser.OpenAsync(uri).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(Uri uri, Service.Browser.BrowserLaunchMode browserLaunchMode)
|
||||
{
|
||||
await Browser.OpenAsync(uri, (Xamarin.Essentials.BrowserLaunchMode)browserLaunchMode).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task OpenAsync(Uri uri, Service.Browser.BrowserLaunchOptions browserLaunchOptions)
|
||||
{
|
||||
await Browser.OpenAsync(uri, _ConvertBrowserLaunchOptions(browserLaunchOptions));
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using FabAccessAPI;
|
||||
using Prism.Navigation;
|
||||
using Prism.Services;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Borepin.Base
|
||||
@ -109,7 +110,7 @@ namespace Borepin.Base
|
||||
{
|
||||
await LoadAPIData().ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
catch(Exception ex)
|
||||
{
|
||||
IsConnected = false;
|
||||
await _API.Disconnect().ConfigureAwait(false);
|
||||
|
@ -59,7 +59,7 @@ namespace Borepin.DialogModel
|
||||
IDialogParameters parameters = new DialogParameters()
|
||||
{
|
||||
{ "result", "confirm" },
|
||||
{ "instance", _Instance }
|
||||
{ "instance", _Instance },
|
||||
};
|
||||
RequestClose(parameters);
|
||||
}
|
||||
@ -75,7 +75,7 @@ namespace Borepin.DialogModel
|
||||
IDialogParameters parameters = new DialogParameters()
|
||||
{
|
||||
{ "result", "abort" },
|
||||
{ "instance", _Instance }
|
||||
{ "instance", _Instance },
|
||||
};
|
||||
RequestClose(parameters);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ namespace Borepin.DialogModel
|
||||
{
|
||||
{ "result", "scanned" },
|
||||
{ "value", ScanResult.Text },
|
||||
{ "instance", _Instance }
|
||||
{ "instance", _Instance },
|
||||
};
|
||||
RequestClose(parameters);
|
||||
}
|
||||
@ -90,7 +90,7 @@ namespace Borepin.DialogModel
|
||||
IDialogParameters parameters = new DialogParameters()
|
||||
{
|
||||
{ "result", "abort" },
|
||||
{ "instance", _Instance }
|
||||
{ "instance", _Instance },
|
||||
};
|
||||
RequestClose(parameters);
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ namespace Borepin.Model
|
||||
public ConnectionDataVisualize(ConnectionData connectionData)
|
||||
{
|
||||
_ConnectionData = connectionData;
|
||||
|
||||
LoadData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
19
Borepin/Borepin/Model/MachineViewModelListGroup.cs
Normal file
19
Borepin/Borepin/Model/MachineViewModelListGroup.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Borepin.ViewModel;
|
||||
using NaturalSort.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Borepin.Model
|
||||
{
|
||||
public class MachineViewModelListGroup : List<MachineListItemViewModel>
|
||||
{
|
||||
public string Category { get; set; }
|
||||
public void Sort_Machines()
|
||||
{
|
||||
List<MachineListItemViewModel> ordered = new List<MachineListItemViewModel>(this.OrderBy(x => x.Machine.Name, StringComparison.OrdinalIgnoreCase.WithNaturalSort()));
|
||||
Clear();
|
||||
AddRange(ordered);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using FabAccessAPI.Schema;
|
||||
using Prism.Mvvm;
|
||||
using System.Threading.Tasks;
|
||||
using static FabAccessAPI.Schema.Machine;
|
||||
|
||||
namespace Borepin.Model
|
||||
@ -14,24 +15,24 @@ namespace Borepin.Model
|
||||
public MachineVisualize(Machine machine)
|
||||
{
|
||||
_Machine = machine;
|
||||
|
||||
LoadData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public async void LoadData()
|
||||
public async Task LoadData()
|
||||
{
|
||||
//ID = _Machine.Id;
|
||||
//Space = new SpaceVisualize(_Machine.Space);
|
||||
Name = _Machine.Name;
|
||||
Description = _Machine.Description;
|
||||
Wiki = _Machine.Wiki;
|
||||
State = _Machine.State;
|
||||
Category = _Machine.Category;
|
||||
|
||||
if(_Machine.Manager.Just != null)
|
||||
{
|
||||
Manager = new UserVisualize(_Machine.Manager.Just);
|
||||
Manager.LoadData();
|
||||
await Manager.LoadData().ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -48,17 +49,17 @@ namespace Borepin.Model
|
||||
else
|
||||
{
|
||||
CurrentUser = new UserVisualize(machineInfoExtended.CurrentUser.Just);
|
||||
CurrentUser.LoadData();
|
||||
await CurrentUser.LoadData().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (machineInfoExtended.LastUser .Just== null)
|
||||
if (machineInfoExtended.LastUser.Just == null)
|
||||
{
|
||||
LastUser = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastUser = new UserVisualize(machineInfoExtended.LastUser.Just);
|
||||
LastUser.LoadData();
|
||||
await LastUser.LoadData().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -73,7 +74,7 @@ namespace Borepin.Model
|
||||
CanCheck = !((CheckInterface_Proxy)_Machine.Check).IsNull;
|
||||
CanManage = !((ManageInterface_Proxy)_Machine.Manage).IsNull;
|
||||
CanAdmin = !((AdminInterface_Proxy)_Machine.Admin).IsNull;
|
||||
CanNotUseByPermission = State == MachineState.free && CanUse == false;
|
||||
CanNotUseByPermission = State == MachineState.free && !CanUse;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -99,6 +100,13 @@ namespace Borepin.Model
|
||||
set => SetProperty(ref _Name, value);
|
||||
}
|
||||
|
||||
private string _Category;
|
||||
public string Category
|
||||
{
|
||||
get => _Category;
|
||||
set => SetProperty(ref _Category, value);
|
||||
}
|
||||
|
||||
private string _Description;
|
||||
public string Description
|
||||
{
|
||||
@ -106,6 +114,13 @@ namespace Borepin.Model
|
||||
set => SetProperty(ref _Description, value);
|
||||
}
|
||||
|
||||
private string _Wiki;
|
||||
public string Wiki
|
||||
{
|
||||
get => _Wiki;
|
||||
set => SetProperty(ref _Wiki, value);
|
||||
}
|
||||
|
||||
private MachineState _State;
|
||||
public MachineState State
|
||||
{
|
||||
|
@ -13,7 +13,6 @@ namespace Borepin.Model
|
||||
public SpaceVisualize(Space space)
|
||||
{
|
||||
_Space = space;
|
||||
LoadData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using FabAccessAPI.Schema;
|
||||
using Prism.Mvvm;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Borepin.Model
|
||||
{
|
||||
@ -13,16 +14,17 @@ namespace Borepin.Model
|
||||
public UserVisualize(User user)
|
||||
{
|
||||
_User = user;
|
||||
LoadData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region LoadData
|
||||
public void LoadData()
|
||||
public Task LoadData()
|
||||
{
|
||||
//ID = _User.Id;
|
||||
Username = _User.Username;
|
||||
//Space = new SpaceVisualize(_User.Space);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -29,7 +29,16 @@
|
||||
Android="True"/>
|
||||
</Button.IsVisible>
|
||||
</Button>
|
||||
<ListView ItemsSource="{Binding MachineListItemViewModel_List}" SelectionMode="None" SeparatorColor="Transparent">
|
||||
<ListView ItemsSource="{Binding MachineListItemViewModel_List}" SelectionMode="None" SeparatorColor="Transparent" IsGroupingEnabled="True" GroupDisplayBinding="{Binding Category}">
|
||||
<ListView.GroupHeaderTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<StackLayout Margin="0, 10, 0, 0">
|
||||
<Label Text="{Binding Category}"/>
|
||||
</StackLayout>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.GroupHeaderTemplate>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
|
@ -22,31 +22,38 @@
|
||||
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
|
||||
<StackLayout IsVisible="{Binding IsConnected}">
|
||||
<Label Text="{Binding MachineItem.Name}" Style="{StaticResource LabelStyle_Title}"/>
|
||||
<Label Text="{Binding MachineItem.Description}" Style="{StaticResource Style_Label_Text_Center}"/>
|
||||
<StackLayout IsVisible="{Binding MachineItem.CanUse}">
|
||||
<Button Text="{x:Static resource_text:TextResource.MachinePage_Use}" Command="{Binding UseMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<Grid IsVisible="{Binding IsConnected}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackLayout Grid.Row="0">
|
||||
<Label Text="{Binding MachineItem.Name}" Style="{StaticResource LabelStyle_Title}"/>
|
||||
<Label Text="{Binding MachineItem.Description}" Style="{StaticResource Style_Label_Text_Center}"/>
|
||||
<StackLayout Orientation="Horizontal" IsVisible="{Binding MachineItem.CurrentUser, Converter={StaticResource IsNotNullBoolConverter}}">
|
||||
<Label Text="{x:Static resource_text:TextResource.MachinePage_CurrentUser}" Style="{StaticResource Style_Label_Property_Title}"/>
|
||||
<Label Text="{Binding MachineItem.CurrentUser.Username}" Style="{StaticResource Style_Label_Property_Text}"/>
|
||||
</StackLayout>
|
||||
|
||||
<Button Text="{x:Static resource_text:TextResource.MachinePage_Use}" IsVisible="{Binding MachineItem.CanUse}" Command="{Binding UseMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<Label Text="{x:Static resource_text:TextResource.MachinePage_CanNotUseByPermission}" IsVisible="{Binding MachineItem.CanNotUseByPermission}" Style="{StaticResource Style_Label_Text_Center}"/>
|
||||
<Button Text="{x:Static resource_text:TextResource.MachinePage_GiveBack}" IsVisible="{Binding MachineItem.CanInUse}" Command="{Binding GiveBackMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding MachineItem.CanNotUseByPermission}">
|
||||
<Label Text="{x:Static resource_text:TextResource.MachinePage_CanNotUseByPermission}" Style="{StaticResource Style_Label_Text_Center}"/>
|
||||
<StackLayout Grid.Row="1" VerticalOptions="End">
|
||||
<Button VerticalOptions="End" Text="{x:Static resource_text:TextResource.MachinePage_OpenWiki}" IsVisible="{Binding MachineItem.Wiki, Converter={StaticResource IsNotNullBoolConverter}}" Command="{Binding OpenWikiCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding MachineItem.CanInUse}">
|
||||
<Button Text="{x:Static resource_text:TextResource.MachinePage_GiveBack}" Command="{Binding GiveBackMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding MachineItem.CurrentUser, Converter={StaticResource IsNotNullBoolConverter}}">
|
||||
<Label Text="{x:Static resource_text:TextResource.MachinePage_CurrentUser}" Style="{StaticResource Style_Label_Property_Title}"/>
|
||||
<Label Text="{Binding MachineItem.CurrentUser.Username}" Style="{StaticResource Style_Label_Property_Text}"/>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding MachineItem.LastUser, Converter={StaticResource IsNotNullBoolConverter}}">
|
||||
<Label Text="{x:Static resource_text:TextResource.MachinePage_LastUser}" Style="{StaticResource Style_Label_Property_Title}"/>
|
||||
<Label Text="{Binding MachineItem.LastUser.Username}" Style="{StaticResource Style_Label_Property_Text}"/>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding MachineItem.CanManage}">
|
||||
<StackLayout Grid.Row="2" VerticalOptions="End" IsVisible="{Binding MachineItem.CanManage}">
|
||||
<Label Text="{x:Static resource_text:TextResource.MachinePage_ManageMachine}" Style="{StaticResource Style_Label_Property_Title}"/>
|
||||
<StackLayout Margin="10, 0, 0, 20" Orientation="Horizontal" IsVisible="{Binding MachineItem.LastUser, Converter={StaticResource IsNotNullBoolConverter}}">
|
||||
<Label Text="{x:Static resource_text:TextResource.MachinePage_LastUser}" Style="{StaticResource Style_Label_Property_Title}"/>
|
||||
<Label Text="{Binding MachineItem.LastUser.Username}" Style="{StaticResource Style_Label_Property_Text}" Margin="10, 0, 0, 0"/>
|
||||
</StackLayout>
|
||||
<Button Text="{x:Static resource_text:TextResource.MachinePage_ForceFree}" Command="{Binding ForceFreeMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<Button Text="{x:Static resource_text:TextResource.MachinePage_ForceBlock}" Command="{Binding ForceBlockMachineCommand}" Style="{StaticResource Style_Button_Admin}"/>
|
||||
<Button Text="{x:Static resource_text:TextResource.MachinePage_ForceDisable}" Command="{Binding ForceDisableMachineCommand}" Style="{StaticResource Style_Button_Admin}"/>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</Grid>
|
||||
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}" IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}"></Label>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
|
@ -5,22 +5,27 @@
|
||||
xmlns:resource_text="clr-namespace:Borepin.Resources.Text">
|
||||
<FlyoutPage.Flyout>
|
||||
<ContentPage Title="FabAccess" BackgroundColor="{StaticResource SecondColor}">
|
||||
<StackLayout>
|
||||
<StackLayout Margin="0,50,0,0" VerticalOptions="FillAndExpand">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackLayout Grid.Row="0" IsVisible="{Binding IsConnected}" Margin="0, 50, 0, 0">
|
||||
<Button Text="{x:Static resource_text:TextResource.MainPage_Machines}" Command="{Binding NavigateCommand}" CommandParameter="MachineListPage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}"/>
|
||||
<Button Text="{x:Static resource_text:TextResource.MainPage_Users}" IsVisible="{Binding CanManageUsers}" Command="{Binding NavigateCommand}" CommandParameter="UserListPage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}"/>
|
||||
</StackLayout>
|
||||
<StackLayout Margin="0,50,0,50">
|
||||
<Button Text="{x:Static resource_text:TextResource.MainPage_Servers}" Command="{Binding NavigateCommand}" CommandParameter="ServerListPage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}" VerticalOptions="End"/>
|
||||
<StackLayout Grid.Row="1" VerticalOptions="End" Margin="0, 0, 0, 50">
|
||||
<StackLayout IsVisible="{Binding IsConnected}">
|
||||
<Button Text="{x:Static resource_text:TextResource.MainPage_Profile}" Command="{Binding NavigateCommand}" CommandParameter="ProfilePage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}" VerticalOptions="End"/>
|
||||
<Button Text="{x:Static resource_text:TextResource.MainPage_Profile}" Command="{Binding NavigateCommand}" CommandParameter="ProfilePage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}"/>
|
||||
</StackLayout>
|
||||
<Button Text="{x:Static resource_text:TextResource.MainPage_Servers}" Command="{Binding NavigateCommand}" CommandParameter="ServerListPage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}"/>
|
||||
</StackLayout>
|
||||
<StackLayout Margin="0,0,0,10">
|
||||
<Label Text="{Binding CurrentVersion, StringFormat='Version: {0}'}" VerticalOptions="End" Margin="10,0,0,0" TextColor="{StaticResource FirstColor}"/>
|
||||
<Label Text="{Binding CurrentBuild, StringFormat='Build: {0}'}" VerticalOptions="End" Margin="10,0,0,0" TextColor="{StaticResource FirstColor}"/>
|
||||
<StackLayout Grid.Row="2" Margin="10, 0, 0, 10" VerticalOptions="End">
|
||||
<Label Text="{Binding CurrentVersion, StringFormat='Version: {0}'}" Margin="10,0,0,0" TextColor="{StaticResource FirstColor}"/>
|
||||
<Label Text="{Binding CurrentBuild, StringFormat='Build: {0}'}" Margin="10,0,0,0" TextColor="{StaticResource FirstColor}"/>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</Grid>
|
||||
</ContentPage>
|
||||
</FlyoutPage.Flyout>
|
||||
</FlyoutPage>
|
||||
|
@ -17,11 +17,13 @@
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
|
||||
<StackLayout IsVisible="{Binding IsConnected}">
|
||||
<Label Text="{Binding UserItem.Username}" Style="{StaticResource LabelStyle_Title}"/>
|
||||
<Label Text="{x:Static resource_text:TextResource.ProfilePage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
|
||||
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_OldPassword}" Text="{Binding OldPassword}"/>
|
||||
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_NewPassword}" Text="{Binding NewPassword}"/>
|
||||
<Button Text="{x:Static resource_text:TextResource.ProfilePage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<Label Text="{Binding Username}" Style="{StaticResource LabelStyle_Title}"/>
|
||||
<StackLayout IsVisible="{Binding CanManage}">
|
||||
<Label Text="{x:Static resource_text:TextResource.ProfilePage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
|
||||
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_OldPassword}" Text="{Binding OldPassword}"/>
|
||||
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_NewPassword}" Text="{Binding NewPassword}"/>
|
||||
<Button Text="{x:Static resource_text:TextResource.ProfilePage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
|
||||
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>
|
||||
|
@ -31,11 +31,13 @@
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
<Label Text="{x:Static resource_text:TextResource.UserPage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
|
||||
<Entry Placeholder="{x:Static resource_text:TextResource.UserPage_NewPassword}" Text="{Binding NewPassword}"/>
|
||||
<Button Text="{x:Static resource_text:TextResource.UserPage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<StackLayout IsVisible="{Binding CanAdmin}">
|
||||
<Label Text="{x:Static resource_text:TextResource.UserPage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
|
||||
<Entry Placeholder="{x:Static resource_text:TextResource.UserPage_NewPassword}" Text="{Binding NewPassword}"/>
|
||||
<Button Text="{x:Static resource_text:TextResource.UserPage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
</StackLayout>
|
||||
<Button Grid.Row="1" Text="{x:Static resource_text:TextResource.DELETE}" Command="{Binding DeleteCommand}" Style="{StaticResource Style_Button_Admin}" VerticalOptions="End"/>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
|
||||
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>
|
||||
</StackLayout>
|
||||
|
@ -6,7 +6,6 @@ using Borepin.Base;
|
||||
using Borepin.Base.Exceptions;
|
||||
using Borepin.Service;
|
||||
using Borepin.Service.Storage;
|
||||
using Borepin.Service.Storage.Exceptions;
|
||||
using FabAccessAPI;
|
||||
using FabAccessAPI.Exceptions;
|
||||
using Prism.Commands;
|
||||
@ -47,6 +46,11 @@ namespace Borepin.PageModel.AddServerProcess
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task<object> CreateInstance()
|
||||
{
|
||||
return Task.FromResult<object>(_ConnectionData);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
@ -12,6 +12,7 @@ using NaturalSort.Extension;
|
||||
using System.Linq;
|
||||
using Borepin.Service;
|
||||
using static FabAccessAPI.Schema.Machine;
|
||||
using Borepin.Model;
|
||||
|
||||
namespace Borepin.PageModel
|
||||
{
|
||||
@ -28,41 +29,98 @@ namespace Borepin.PageModel
|
||||
#region Data
|
||||
public override async Task LoadAPIData()
|
||||
{
|
||||
User user_self = await _API.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
|
||||
|
||||
IReadOnlyList<Machine> machine_list = await _API.Session.MachineSystem.Info.GetMachineList().ConfigureAwait(false);
|
||||
|
||||
List<MachineListItemViewModel> viewmodel_list_user_assigned = new List<MachineListItemViewModel>();
|
||||
List<MachineListItemViewModel> viewmodel_list_not_user_assigned = new List<MachineListItemViewModel>();
|
||||
await _CreateMachineList(new List<Machine>(machine_list)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task _CreateMachineList(List<Machine> machine_list)
|
||||
{
|
||||
List<Task> tasks = new List<Task>();
|
||||
|
||||
List<MachineViewModelListGroup> viewmodel_group_list = new List<MachineViewModelListGroup>();
|
||||
MachineViewModelListGroup viewmodel_group_inusebyme = new MachineViewModelListGroup()
|
||||
{
|
||||
Category = Resources.Text.TextResource.InUseByMe,
|
||||
};
|
||||
MachineViewModelListGroup viewmodel_group_uncategorised = new MachineViewModelListGroup()
|
||||
{
|
||||
Category = null,
|
||||
};
|
||||
|
||||
foreach (Machine machine in machine_list)
|
||||
{
|
||||
if(!((InUseInterface_Proxy)machine.Inuse).IsNull)
|
||||
if (!((InUseInterface_Proxy)machine.Inuse).IsNull)
|
||||
{
|
||||
MachineListItemViewModel new_viewmodel = new MachineListItemViewModel(_NavigationService, _PageDialogService)
|
||||
{
|
||||
IsInUseByMe = true,
|
||||
};
|
||||
await new_viewmodel.LoadInstance(machine).ConfigureAwait(false);
|
||||
viewmodel_list_user_assigned.Add(new_viewmodel);
|
||||
tasks.Add(new_viewmodel.LoadInstance(machine));
|
||||
|
||||
new_viewmodel.Machine.Category = Resources.Text.TextResource.InUseByMe;
|
||||
|
||||
viewmodel_group_inusebyme.Add(new_viewmodel);
|
||||
}
|
||||
else if (machine.Category == null)
|
||||
{
|
||||
MachineListItemViewModel new_viewmodel = new MachineListItemViewModel(_NavigationService, _PageDialogService);
|
||||
tasks.Add(new_viewmodel.LoadInstance(machine));
|
||||
|
||||
viewmodel_group_inusebyme.Add(new_viewmodel);
|
||||
}
|
||||
else
|
||||
{
|
||||
MachineListItemViewModel new_viewmodel = new MachineListItemViewModel(_NavigationService, _PageDialogService);
|
||||
await new_viewmodel.LoadInstance(machine).ConfigureAwait(false);
|
||||
viewmodel_list_not_user_assigned.Add(new_viewmodel);
|
||||
tasks.Add(new_viewmodel.LoadInstance(machine));
|
||||
|
||||
MachineViewModelListGroup viewmodel_group = viewmodel_group_list.Find(x => string.Equals(x.Category, machine.Category, StringComparison.Ordinal));
|
||||
if (viewmodel_group != null)
|
||||
{
|
||||
viewmodel_group.Add(new_viewmodel);
|
||||
}
|
||||
else
|
||||
{
|
||||
MachineViewModelListGroup new_viewmodel_group = new MachineViewModelListGroup()
|
||||
{
|
||||
Category = machine.Category,
|
||||
};
|
||||
new_viewmodel_group.Add(new_viewmodel);
|
||||
viewmodel_group_list.Add(new_viewmodel_group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<MachineListItemViewModel> viewmodel_list_sorted = new List<MachineListItemViewModel>();
|
||||
viewmodel_list_sorted.AddRange(viewmodel_list_user_assigned.OrderBy(x => x.Machine.Name, StringComparison.OrdinalIgnoreCase.WithNaturalSort()));
|
||||
viewmodel_list_sorted.AddRange(viewmodel_list_not_user_assigned.OrderBy(x => x.Machine.Name, StringComparison.OrdinalIgnoreCase.WithNaturalSort()));
|
||||
MachineListItemViewModel_List = viewmodel_list_sorted;
|
||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
viewmodel_group_inusebyme.Sort_Machines();
|
||||
viewmodel_group_uncategorised.Sort_Machines();
|
||||
foreach(MachineViewModelListGroup viewmodel_group in viewmodel_group_list)
|
||||
{
|
||||
viewmodel_group.Sort_Machines();
|
||||
}
|
||||
|
||||
viewmodel_group_uncategorised.Category = Resources.Text.TextResource.Uncategorised;
|
||||
List<MachineViewModelListGroup> viewmodel_group_list_sorted = new List<MachineViewModelListGroup>();
|
||||
if(viewmodel_group_inusebyme.Count != 0)
|
||||
{
|
||||
viewmodel_group_list_sorted.Add(viewmodel_group_inusebyme);
|
||||
}
|
||||
|
||||
viewmodel_group_list_sorted.AddRange(new List<MachineViewModelListGroup>(viewmodel_group_list.OrderBy(x => x.Category, StringComparison.OrdinalIgnoreCase.WithNaturalSort())));
|
||||
|
||||
if (viewmodel_group_uncategorised.Count != 0)
|
||||
{
|
||||
viewmodel_group_list_sorted.Add(viewmodel_group_uncategorised);
|
||||
}
|
||||
|
||||
MachineListItemViewModel_List = viewmodel_group_list_sorted;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
private IList<MachineListItemViewModel> _MachineListItemViewModel_List;
|
||||
public IList<MachineListItemViewModel> MachineListItemViewModel_List
|
||||
private IList<MachineViewModelListGroup> _MachineListItemViewModel_List;
|
||||
public IList<MachineViewModelListGroup> MachineListItemViewModel_List
|
||||
{
|
||||
get => _MachineListItemViewModel_List;
|
||||
set => SetProperty(ref _MachineListItemViewModel_List, value);
|
||||
|
@ -10,6 +10,7 @@ using Borepin.Service;
|
||||
using Borepin.Base.Exceptions;
|
||||
using Capnp.Rpc;
|
||||
using System;
|
||||
using Borepin.Service.Browser;
|
||||
|
||||
namespace Borepin.PageModel
|
||||
{
|
||||
@ -18,14 +19,20 @@ namespace Borepin.PageModel
|
||||
#region Private Fields
|
||||
private string _ID;
|
||||
private Machine _Machine;
|
||||
private readonly IBrowserService _BrowserService;
|
||||
#endregion
|
||||
|
||||
#region Contructors
|
||||
public MachinePageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService, pageDialogService, apiService)
|
||||
public MachinePageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService, IBrowserService browserService) : base(navigationService, pageDialogService, apiService)
|
||||
{
|
||||
_BrowserService = browserService;
|
||||
|
||||
UseMachineCommand = new DelegateCommand(UseMachineCommandExecute);
|
||||
GiveBackMachineCommand = new DelegateCommand(GiveBackMachineCommandExecute);
|
||||
ForceFreeMachineCommand = new DelegateCommand(ForceFreeMachineCommandExecute);
|
||||
ForceBlockMachineCommand = new DelegateCommand(ForceBlockMachineCommandExecute);
|
||||
ForceDisableMachineCommand = new DelegateCommand(ForceDisableMachineCommandExecute);
|
||||
OpenWikiCommand = new DelegateCommand(OpenWikiCommandExecute);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -48,7 +55,7 @@ namespace Borepin.PageModel
|
||||
{
|
||||
_Machine = (await _API.Session.MachineSystem.Info.GetMachine(_ID).ConfigureAwait(false)).Just;
|
||||
MachineItem = new MachineVisualize(_Machine);
|
||||
MachineItem.LoadData();
|
||||
await MachineItem.LoadData().ConfigureAwait(false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -149,6 +156,86 @@ namespace Borepin.PageModel
|
||||
|
||||
IsBusy = false;
|
||||
}
|
||||
|
||||
private ICommand _ForceBlockMachineCommand;
|
||||
public ICommand ForceBlockMachineCommand
|
||||
{
|
||||
get => _ForceBlockMachineCommand;
|
||||
set => SetProperty(ref _ForceBlockMachineCommand, value);
|
||||
}
|
||||
|
||||
public async void ForceBlockMachineCommandExecute()
|
||||
{
|
||||
IsBusy = true;
|
||||
|
||||
if (_API.IsConnected)
|
||||
{
|
||||
try
|
||||
{
|
||||
Machine.IManageInterface manageInterface = _Machine.Manage;
|
||||
|
||||
await manageInterface.Block().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;
|
||||
}
|
||||
|
||||
private ICommand _ForceDisableMachineCommand;
|
||||
public ICommand ForceDisableMachineCommand
|
||||
{
|
||||
get => _ForceDisableMachineCommand;
|
||||
set => SetProperty(ref _ForceDisableMachineCommand, value);
|
||||
}
|
||||
|
||||
public async void ForceDisableMachineCommandExecute()
|
||||
{
|
||||
IsBusy = true;
|
||||
|
||||
if (_API.IsConnected)
|
||||
{
|
||||
try
|
||||
{
|
||||
Machine.IManageInterface manageInterface = _Machine.Manage;
|
||||
|
||||
await manageInterface.Disabled().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;
|
||||
}
|
||||
|
||||
private ICommand _OpenWikiCommand;
|
||||
public ICommand OpenWikiCommand
|
||||
{
|
||||
get => _OpenWikiCommand;
|
||||
set => SetProperty(ref _OpenWikiCommand, value);
|
||||
}
|
||||
|
||||
public async void OpenWikiCommandExecute()
|
||||
{
|
||||
if(_Machine != null && _Machine.Wiki != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _BrowserService.OpenAsync(_Machine.Wiki).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
//TODO: Do something
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -4,18 +4,10 @@ using Prism.Navigation;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using FabAccessAPI.Schema;
|
||||
using Borepin.Model;
|
||||
using Prism.Services;
|
||||
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;
|
||||
using Prism.Services.Dialogs;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Borepin.PageModel
|
||||
{
|
||||
@ -29,25 +21,22 @@ namespace Borepin.PageModel
|
||||
#endregion
|
||||
|
||||
#region Data
|
||||
public override Task LoadInstance(object instance)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override async Task LoadAPIData()
|
||||
{
|
||||
_UserItem = new UserVisualize(await _API.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false));
|
||||
_UserItem.LoadData();
|
||||
User self = await _API.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
|
||||
Username = self.Username;
|
||||
|
||||
CanManage = !((User.ManageInterface_Proxy)self.Manage).IsNull;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
private UserVisualize _UserItem;
|
||||
public UserVisualize UserItem
|
||||
private string _Username;
|
||||
public string Username
|
||||
{
|
||||
get => _UserItem;
|
||||
set => SetProperty(ref _UserItem, value);
|
||||
get => _Username;
|
||||
set => SetProperty(ref _Username, value);
|
||||
}
|
||||
|
||||
private string _OldPassword = null;
|
||||
@ -63,6 +52,13 @@ namespace Borepin.PageModel
|
||||
get => _NewPassword;
|
||||
set => SetProperty(ref _NewPassword, value);
|
||||
}
|
||||
|
||||
private bool _CanManage;
|
||||
public bool CanManage
|
||||
{
|
||||
get => _CanManage;
|
||||
set => SetProperty(ref _CanManage, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
@ -84,6 +80,8 @@ namespace Borepin.PageModel
|
||||
{
|
||||
User self = await _API.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
|
||||
await self.Manage.Pwd(OldPassword, NewPassword).ConfigureAwait(false);
|
||||
OldPassword = string.Empty;
|
||||
NewPassword = string.Empty;
|
||||
}
|
||||
}
|
||||
catch (RpcException exception) when (string.Equals(exception.Message, "RPC connection is broken. Task would never return.", StringComparison.Ordinal))
|
||||
|
@ -36,9 +36,9 @@ namespace Borepin.PageModel
|
||||
PossibleFormats = new List<BarcodeFormat>()
|
||||
{
|
||||
BarcodeFormat.QR_CODE,
|
||||
BarcodeFormat.EAN_13
|
||||
BarcodeFormat.EAN_13,
|
||||
// TODO add more Barcode Formats if needed
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
//set => SetProperty(ref _ScanOptions, value);
|
||||
|
@ -33,6 +33,8 @@ namespace Borepin.PageModel
|
||||
#region LoadData
|
||||
public override async Task LoadInstance(object instance)
|
||||
{
|
||||
List<Task> tasks = new List<Task>();
|
||||
|
||||
IList<ConnectionData> list = await _LoginStorageService.GetList().ConfigureAwait(false);
|
||||
if (_API.IsConnected)
|
||||
{
|
||||
@ -52,10 +54,11 @@ namespace Borepin.PageModel
|
||||
foreach (ConnectionData connectionData in list)
|
||||
{
|
||||
ServerListItemViewModel serverListItemViewModel = new ServerListItemViewModel(_NavigationService, _PageDialogService);
|
||||
await serverListItemViewModel.LoadInstance(connectionData).ConfigureAwait(false);
|
||||
tasks.Add(serverListItemViewModel.LoadInstance(connectionData));
|
||||
serverListItemViewModel_List.Add(serverListItemViewModel);
|
||||
|
||||
}
|
||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
ServerListItemViewModel_List = serverListItemViewModel_List;
|
||||
|
||||
IsBusy = false;
|
||||
|
@ -28,16 +28,20 @@ namespace Borepin.PageModel
|
||||
#region Data
|
||||
public override async Task LoadAPIData()
|
||||
{
|
||||
List<Task> tasks = new List<Task>();
|
||||
|
||||
IReadOnlyList<User> user_list = await _API.Session.UserSystem.Manage.GetUserList().ConfigureAwait(false);
|
||||
|
||||
List<UserListItemViewModel> viewmodel_list= new List<UserListItemViewModel>();
|
||||
foreach (User user in user_list)
|
||||
{
|
||||
UserListItemViewModel new_viewmodel = new UserListItemViewModel(_NavigationService, _PageDialogService);
|
||||
await new_viewmodel.LoadInstance(user).ConfigureAwait(false);
|
||||
tasks.Add(new_viewmodel.LoadInstance(user));
|
||||
viewmodel_list.Add(new_viewmodel);
|
||||
}
|
||||
|
||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
viewmodel_list.OrderBy(x => x.Instance.Username, StringComparison.OrdinalIgnoreCase.WithNaturalSort());
|
||||
UserListItemViewModel_List = viewmodel_list;
|
||||
}
|
||||
@ -86,7 +90,7 @@ namespace Borepin.PageModel
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/AddUserPage").ConfigureAwait(false);
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("AddUserPage").ConfigureAwait(false);
|
||||
if (result.Exception != null)
|
||||
{
|
||||
Log.Fatal(result.Exception, "Navigating failed");
|
||||
|
@ -24,7 +24,7 @@ namespace Borepin.PageModel
|
||||
#region Private Fields
|
||||
private string _ID;
|
||||
private User _User;
|
||||
private IDialogService _DialogService;
|
||||
private readonly IDialogService _DialogService;
|
||||
private bool _IsDialog;
|
||||
#endregion
|
||||
|
||||
@ -65,7 +65,7 @@ namespace Borepin.PageModel
|
||||
|
||||
_User = (await _API.Session.UserSystem.Search.GetUserByName(_ID).ConfigureAwait(false)).Just;
|
||||
UserItem = new UserVisualize(_User);
|
||||
UserItem.LoadData();
|
||||
await UserItem.LoadData().ConfigureAwait(false);
|
||||
|
||||
IReadOnlyList<Role> role_list = await _API.Session.PermissionSystem.Info.GetRoleList().ConfigureAwait(false);
|
||||
List<Role> user_role_list = new List<Role>(await _User.Info.ListRoles().ConfigureAwait(false));
|
||||
@ -78,7 +78,7 @@ namespace Borepin.PageModel
|
||||
{
|
||||
role,
|
||||
_User,
|
||||
user_role_list.Exists(x => string.Equals(x.Name, role.Name, StringComparison.Ordinal))
|
||||
user_role_list.Exists(x => string.Equals(x.Name, role.Name, StringComparison.Ordinal)),
|
||||
};
|
||||
|
||||
await new_viewmodel.LoadInstance(array).ConfigureAwait(false);
|
||||
@ -194,7 +194,20 @@ namespace Borepin.PageModel
|
||||
|
||||
public void UpdatePasswordCommandExecute()
|
||||
{
|
||||
_User.Manage.Pwd(null, NewPassword);
|
||||
IsBusy = true;
|
||||
if (_API.IsConnected)
|
||||
{
|
||||
try
|
||||
{
|
||||
_User.Admin.Pwd(NewPassword);
|
||||
NewPassword = string.Empty;
|
||||
}
|
||||
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;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -350,6 +350,15 @@ namespace Borepin.Resources.Text {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to In Use By Me.
|
||||
/// </summary>
|
||||
internal static string InUseByMe {
|
||||
get {
|
||||
return ResourceManager.GetString("InUseByMe", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You do not have the authorization to use this machine.
|
||||
///Ask in your Space if you can be trained on the machine to be unlocked for the machine..
|
||||
@ -370,7 +379,25 @@ namespace Borepin.Resources.Text {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Force Free.
|
||||
/// Looks up a localized string similar to Block Machine.
|
||||
/// </summary>
|
||||
internal static string MachinePage_ForceBlock {
|
||||
get {
|
||||
return ResourceManager.GetString("MachinePage_ForceBlock", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Disable Machine.
|
||||
/// </summary>
|
||||
internal static string MachinePage_ForceDisable {
|
||||
get {
|
||||
return ResourceManager.GetString("MachinePage_ForceDisable", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Free Machine.
|
||||
/// </summary>
|
||||
internal static string MachinePage_ForceFree {
|
||||
get {
|
||||
@ -405,6 +432,15 @@ namespace Borepin.Resources.Text {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open Wiki.
|
||||
/// </summary>
|
||||
internal static string MachinePage_OpenWiki {
|
||||
get {
|
||||
return ResourceManager.GetString("MachinePage_OpenWiki", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Use.
|
||||
/// </summary>
|
||||
@ -765,6 +801,15 @@ namespace Borepin.Resources.Text {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Uncategorised.
|
||||
/// </summary>
|
||||
internal static string Uncategorised {
|
||||
get {
|
||||
return ResourceManager.GetString("Uncategorised", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Add User.
|
||||
/// </summary>
|
||||
|
@ -215,6 +215,9 @@ You can also put down several servers and then connect to the desired server.</v
|
||||
<data name="HOST" xml:space="preserve">
|
||||
<value>Host</value>
|
||||
</data>
|
||||
<data name="InUseByMe" xml:space="preserve">
|
||||
<value>In Use By Me</value>
|
||||
</data>
|
||||
<data name="MachinePage_CanNotUseByPermission" xml:space="preserve">
|
||||
<value>You do not have the authorization to use this machine.
|
||||
Ask in your Space if you can be trained on the machine to be unlocked for the machine.</value>
|
||||
@ -222,8 +225,14 @@ Ask in your Space if you can be trained on the machine to be unlocked for the ma
|
||||
<data name="MachinePage_CurrentUser" xml:space="preserve">
|
||||
<value>Current User:</value>
|
||||
</data>
|
||||
<data name="MachinePage_ForceBlock" xml:space="preserve">
|
||||
<value>Block Machine</value>
|
||||
</data>
|
||||
<data name="MachinePage_ForceDisable" xml:space="preserve">
|
||||
<value>Disable Machine</value>
|
||||
</data>
|
||||
<data name="MachinePage_ForceFree" xml:space="preserve">
|
||||
<value>Force Free</value>
|
||||
<value>Free Machine</value>
|
||||
</data>
|
||||
<data name="MachinePage_GiveBack" xml:space="preserve">
|
||||
<value>GiveBack</value>
|
||||
@ -234,6 +243,9 @@ Ask in your Space if you can be trained on the machine to be unlocked for the ma
|
||||
<data name="MachinePage_ManageMachine" xml:space="preserve">
|
||||
<value>Manage Machine:</value>
|
||||
</data>
|
||||
<data name="MachinePage_OpenWiki" xml:space="preserve">
|
||||
<value>Open Wiki</value>
|
||||
</data>
|
||||
<data name="MachinePage_Use" xml:space="preserve">
|
||||
<value>Use</value>
|
||||
</data>
|
||||
@ -354,6 +366,9 @@ Ask in your Space if you can be trained on the machine to be unlocked for the ma
|
||||
<data name="TITLE_Users" xml:space="preserve">
|
||||
<value>Users</value>
|
||||
</data>
|
||||
<data name="Uncategorised" xml:space="preserve">
|
||||
<value>Uncategorised</value>
|
||||
</data>
|
||||
<data name="UserListPage_AddUser" xml:space="preserve">
|
||||
<value>Add User</value>
|
||||
</data>
|
||||
|
10
Borepin/Borepin/Service/Browser/BrowserLaunchFlags.cs
Normal file
10
Borepin/Borepin/Service/Browser/BrowserLaunchFlags.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Borepin.Service.Browser
|
||||
{
|
||||
public enum BrowserLaunchFlags
|
||||
{
|
||||
None = 0,
|
||||
LaunchAdjacent = 1,
|
||||
PresentAsPageSheet = 2,
|
||||
PresentAsFormSheet = 4,
|
||||
}
|
||||
}
|
8
Borepin/Borepin/Service/Browser/BrowserLaunchMode.cs
Normal file
8
Borepin/Borepin/Service/Browser/BrowserLaunchMode.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Borepin.Service.Browser
|
||||
{
|
||||
public enum BrowserLaunchMode
|
||||
{
|
||||
SystemPreferred = 0,
|
||||
External = 1,
|
||||
}
|
||||
}
|
14
Borepin/Borepin/Service/Browser/BrowserLaunchOptions.cs
Normal file
14
Borepin/Borepin/Service/Browser/BrowserLaunchOptions.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Borepin.Service.Browser
|
||||
{
|
||||
public class BrowserLaunchOptions
|
||||
{
|
||||
public BrowserLaunchFlags Flags;
|
||||
public BrowserLaunchMode LaunchMode;
|
||||
public Nullable<Color> PreferredControlColor;
|
||||
public Nullable<Color> PreferredToolbarColor;
|
||||
public BrowserTitleMode TitleMode;
|
||||
}
|
||||
}
|
9
Borepin/Borepin/Service/Browser/BrowserTitleMode.cs
Normal file
9
Borepin/Borepin/Service/Browser/BrowserTitleMode.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Borepin.Service.Browser
|
||||
{
|
||||
public enum BrowserTitleMode
|
||||
{
|
||||
Default = 0,
|
||||
Show = 1,
|
||||
Hide = 2,
|
||||
}
|
||||
}
|
17
Borepin/Borepin/Service/Browser/IBrowserService.cs
Normal file
17
Borepin/Borepin/Service/Browser/IBrowserService.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Borepin.Service.Browser
|
||||
{
|
||||
public interface IBrowserService
|
||||
{
|
||||
Task OpenAsync(string uri);
|
||||
Task OpenAsync(string uri, BrowserLaunchMode browserLaunchMode);
|
||||
Task OpenAsync(string uri, BrowserLaunchOptions browserLaunchOptions);
|
||||
Task OpenAsync(Uri uri);
|
||||
Task OpenAsync(Uri uri, BrowserLaunchMode browserLaunchMode);
|
||||
Task OpenAsync(Uri uri, BrowserLaunchOptions browserLaunchOptions);
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -20,15 +20,13 @@ namespace Borepin.ViewModel
|
||||
#endregion
|
||||
|
||||
#region LoadData
|
||||
public override Task LoadInstance(object instance)
|
||||
public override async Task LoadInstance(object instance)
|
||||
{
|
||||
if(instance is Machine)
|
||||
{
|
||||
Machine = new MachineVisualize(instance as Machine);
|
||||
Machine.LoadData();
|
||||
await Machine.LoadData().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -48,7 +46,7 @@ namespace Borepin.ViewModel
|
||||
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage/MachinePage", parameters).ConfigureAwait(false);
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("MachinePage", parameters).ConfigureAwait(false);
|
||||
if (result.Exception != null)
|
||||
{
|
||||
Log.Fatal(result.Exception, "Navigating failed");
|
||||
|
@ -58,7 +58,7 @@ namespace Borepin.ViewModel
|
||||
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage/ServerPage", parameters).ConfigureAwait(false);
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("ServerPage", parameters).ConfigureAwait(false);
|
||||
if (result.Exception != null)
|
||||
{
|
||||
Log.Fatal(result.Exception, "Navigating failed");
|
||||
|
@ -59,7 +59,7 @@ namespace Borepin.ViewModel
|
||||
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/UserListPage/UserPage", parameters).ConfigureAwait(false);
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("UserPage", parameters).ConfigureAwait(false);
|
||||
if (result.Exception != null)
|
||||
{
|
||||
Log.Fatal(result.Exception, "Navigating failed");
|
||||
|
Loading…
x
Reference in New Issue
Block a user