Merge branch 'feature/MachineList' into 'main'

Machine List

Closes #32, #33, #34, and #35

See merge request fabinfra/fabaccess/borepin!37
This commit is contained in:
TheJoKlLa 2022-01-16 21:57:37 +00:00
commit f54382f5c3
28 changed files with 297 additions and 78 deletions

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -78,6 +78,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\PreferenceStorageService.cs" />
<Compile Include="Services\SecretStorage.cs" />
<Compile Include="Services\VersioningService.cs" />
<Compile Include="SplashActivity.cs" />
</ItemGroup>
<ItemGroup>
@ -188,4 +189,4 @@
<XmlPoke XmlInputPath="Properties\AndroidManifest.xml" Namespaces="&lt;Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' /&gt;" Query="manifest/@android:versionCode" Value="$(CI_PIPELINE_ID)" />
<XmlPoke XmlInputPath="Properties\AndroidManifest.xml" Namespaces="&lt;Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' /&gt;" Query="manifest/@android:versionName" Value="$(CI_COMMIT_TAG.SubString(1))" />
</Target>
</Project>
</Project>

View File

@ -1,5 +1,6 @@
using Borepin.Droid.Services;
using Borepin.Service.Storage;
using Borepin.Service.Versioning;
using Prism;
using Prism.Ioc;
@ -11,6 +12,7 @@ namespace Borepin.Droid
{
containerRegistry.Register<IPreferenceStorageService, PreferenceStorageService>();
containerRegistry.Register<ISecretStorageService, SecretStorage>();
containerRegistry.Register<IVersioningService, VersioningService>();
}
}
}

View File

@ -0,0 +1,30 @@
using Borepin.Service.Versioning;
using Xamarin.Essentials;
namespace Borepin.Droid.Services
{
public class VersioningService : IVersioningService
{
#region Constructors
public VersioningService()
{
VersionTracking.Track();
}
#endregion
public string CurrentBuild
{
get
{
return VersionTracking.CurrentBuild;
}
}
public string CurrentVersion
{
get
{
return VersionTracking.CurrentVersion;
}
}
}
}

View File

@ -100,6 +100,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\PreferenceStorageService.cs" />
<Compile Include="Services\SecretStorageService.cs" />
<Compile Include="Services\VersioningService.cs" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">

View File

@ -2,6 +2,7 @@
using Prism;
using Prism.Ioc;
using Borepin.Service.Storage;
using Borepin.Service.Versioning;
namespace Borepin.UWP
{
@ -11,6 +12,7 @@ namespace Borepin.UWP
{
containerRegistry.Register<IPreferenceStorageService, PreferenceStorageService>();
containerRegistry.Register<ISecretStorageService, SecretStorageService>();
containerRegistry.Register<IVersioningService, VersioningService>();
}
}
}

View File

@ -0,0 +1,30 @@
using Borepin.Service.Versioning;
using Xamarin.Essentials;
namespace Borepin.UWP.Services
{
public class VersioningService : IVersioningService
{
#region Constructors
public VersioningService()
{
VersionTracking.Track();
}
#endregion
public string CurrentBuild
{
get
{
return VersionTracking.CurrentBuild;
}
}
public string CurrentVersion
{
get
{
return VersionTracking.CurrentVersion;
}
}
}
}

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@ -52,11 +52,13 @@
<MtouchArch>ARM64</MtouchArch>
<MtouchDebug>true</MtouchDebug>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchInterpreter>-all</MtouchInterpreter>
<MtouchLink>None</MtouchLink>
<MtouchInterpreter>
</MtouchInterpreter>
<MtouchExtraArgs>--optimize=experimental-xforms-product-type</MtouchExtraArgs>
<MtouchSdkVersion />
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchEnableSGenConc>false</MtouchEnableSGenConc>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>none</DebugType>
@ -69,6 +71,9 @@
<MtouchExtraArgs>--optimize=experimental-xforms-product-type</MtouchExtraArgs>
<MtouchLink>SdkOnly</MtouchLink>
<CodesignKey>iPhone Distribution</CodesignKey>
<MtouchSdkVersion />
<MtouchEnableSGenConc>false</MtouchEnableSGenConc>
<MtouchInterpreter>-all</MtouchInterpreter>
</PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
<AppExtensionDebugBundleId />
@ -78,6 +83,7 @@
<Compile Include="AppDelegate.cs" />
<Compile Include="Services\PreferenceStorageService.cs" />
<Compile Include="Services\SecretStorageService.cs" />
<Compile Include="Services\VersioningService.cs" />
<None Include="Entitlements.plist" />
<None Include="Info.plist" />
<Compile Include="PlatformInitializer.cs" />
@ -198,4 +204,4 @@
<XmlPoke XmlInputPath="Info.plist" Query="//dict/key[. = 'CFBundleVersion']/following-sibling::string[1]" Value="$(CI_PIPELINE_ID)" />
<XmlPoke XmlInputPath="Info.plist" Query="//dict/key[. = 'CFBundleShortVersionString']/following-sibling::string[1]" Value="$(CI_COMMIT_TAG.SubString(1))" />
</Target>
</Project>
</Project>

View File

@ -1,5 +1,6 @@
using Borepin.iOS.Services;
using Borepin.Service.Storage;
using Borepin.Service.Versioning;
using Prism;
using Prism.Ioc;
@ -11,6 +12,7 @@ namespace Borepin.iOS
{
containerRegistry.Register<IPreferenceStorageService, PreferenceStorageService>();
containerRegistry.Register<ISecretStorageService, SecretStorageService>();
containerRegistry.Register<IVersioningService, VersioningService>();
}
}
}

View File

@ -0,0 +1,30 @@
using Borepin.Service.Versioning;
using Xamarin.Essentials;
namespace Borepin.iOS.Services
{
public class VersioningService : IVersioningService
{
#region Constructors
public VersioningService()
{
VersionTracking.Track();
}
#endregion
public string CurrentBuild
{
get
{
return VersionTracking.CurrentBuild;
}
}
public string CurrentVersion
{
get
{
return VersionTracking.CurrentVersion;
}
}
}
}

View File

@ -29,6 +29,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NaturalSort.Extension" Version="3.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Plugin.Multilingual" Version="1.0.2" />
<PackageReference Include="Prism.DryIoc.Forms" Version="8.1.97" />

View File

@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Globalization;
using Xamarin.Forms;
namespace Borepin.Converter
{
public class ListNotEmptyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if(value != null && value is IList)
{
ICollection collection = value as ICollection;
return collection.Count > 0;
}
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

View File

@ -4,11 +4,11 @@
x:Class="Borepin.Dialog.ConfirmDialog"
BackgroundColor="White">
<ContentView.Content>
<StackLayout>
<Label Text="{Binding Title}"/>
<Label Text="{Binding Message}"/>
<Button Text="Confirm" Command="{Binding ConfirmCommand}"/>
<Button Text="Abort" Command="{Binding AbortCommand}"/>
<StackLayout Background="{StaticResource EighthColor}" Padding="10">
<Label Text="{Binding Title}" Style="{StaticResource LabelStyle_Title}"/>
<Label Text="{Binding Message}" Style="{StaticResource Style_Label_Property_Text}"/>
<Button Text="Confirm" Command="{Binding ConfirmCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="Abort" Command="{Binding AbortCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
</ContentView.Content>
</ContentView>

View File

@ -16,7 +16,7 @@
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<Label Text="Username" Style="{StaticResource Style_Label_Property_Title}"></Label>
<Entry Text="{Binding Username}"/>
<Entry Text="{Binding Username}" IsSpellCheckEnabled="false"/>
<Label Text="Password" Style="{StaticResource Style_Label_Property_Title}"></Label>
<Entry Text="{Binding Password}" IsPassword="True"/>

View File

@ -16,7 +16,7 @@
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<Label Text="Host" Style="{StaticResource Style_Label_Property_Title}"></Label>
<Entry Text="{Binding Server}"/>
<Entry Text="{Binding Server}" Keyboard="Url" IsSpellCheckEnabled="false"/>
<Button Text="Connect to Server" Command="{Binding ConnectToServerCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="Scan QR-Code" Command="{Binding ScanCodeCommand}" Style="{StaticResource Style_Button_Primary}">
<Button.IsVisible>

View File

@ -5,9 +5,13 @@
x:Class="Borepin.Page.MachineListPage"
xmlns:converters="clr-namespace:Borepin.Converter"
Title="Machines">
<NavigationPage.TitleView>
<Button Text="Refresh" HorizontalOptions="End" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}" Command="{Binding RefreshCommand}"/>
</NavigationPage.TitleView>
<ContentPage.Resources>
<ResourceDictionary>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
<converters:ListNotEmptyConverter x:Key="ListNotEmptyConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
@ -20,21 +24,19 @@
<Button Text="Scan QR-Code" Command="{Binding ScanCodeCommand}" Style="{StaticResource Style_Button_Primary}">
<Button.IsVisible>
<OnPlatform x:TypeArguments="x:Boolean"
iOS="false"
Android="true"/>
iOS="False"
Android="True"/>
</Button.IsVisible>
</Button>
<RefreshView Command="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}">
<ListView ItemsSource="{Binding MachineListItemViewModel_List}" IsVisible="{Binding IsConnected}" SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:MachineListItemView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</RefreshView>
<ListView ItemsSource="{Binding MachineListItemViewModel_List}" SelectionMode="None" SeparatorColor="Transparent">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:MachineListItemView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
<Label Text="Please connect to Server" ></Label>

View File

@ -4,10 +4,16 @@
x:Class="Borepin.Page.MainPage"
Title="MainPage">
<FlyoutPage.Flyout>
<ContentPage Title="FabAccess">
<StackLayout Margin="0,50,0,0">
<Button Text="Machines" Command="{Binding NavigateCommand}" CommandParameter="MachineListPage" />
<Button Text="Servers" Command="{Binding NavigateCommand}" CommandParameter="ServerListPage" />
<ContentPage Title="FabAccess" BackgroundColor="{StaticResource SecondColor}">
<StackLayout>
<StackLayout Margin="0,50,0,0" VerticalOptions="FillAndExpand">
<Button Text="Machines" Command="{Binding NavigateCommand}" CommandParameter="MachineListPage" VerticalOptions="Start" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}"/>
<Button Text="Servers" Command="{Binding NavigateCommand}" CommandParameter="ServerListPage" VerticalOptions="Start" 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>
</StackLayout>
</ContentPage>
</FlyoutPage.Flyout>

View File

@ -8,6 +8,7 @@
<ContentPage.Resources>
<ResourceDictionary>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
<converters:ListNotEmptyConverter x:Key="ListNotEmptyConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
@ -15,28 +16,22 @@
<StackLayout IsVisible="{Binding IsBusy}">
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}" VerticalOptions="FillAndExpand">
<Label Text="Active Connection" IsVisible="{Binding HasActiveConnection}"/>
<ListView ItemsSource="{Binding ActiveConnection}" IsVisible="{Binding HasActiveConnection}" SelectionMode="None">
<StackLayout IsVisible="{Binding HasActiveConnection}">
<views:ServerListItemView BindingContext="{Binding ActiveConnection}" MinimumHeightRequest="50"/>
</StackLayout>
<Label Text="Last Connections" IsVisible="{Binding ServerListItemViewModel_List, Converter={StaticResource ListNotEmptyConverter}}"/>
<ListView ItemsSource="{Binding ServerListItemViewModel_List}" SelectionMode="None" SeparatorColor="Transparent" VerticalOptions="StartAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:ServerListItemView />
<views:ServerListItemView/>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Label Text="Last Connections"/>
<ListView ItemsSource="{Binding ServerListItemViewModel_List}" SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:ServerListItemView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Text="Connect to new Server" Command="{Binding AddInstancesCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="Connect to new Server" Command="{Binding AddInstancesCommand}" Style="{StaticResource Style_Button_Primary}" VerticalOptions="End"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>

View File

@ -14,12 +14,19 @@
<StackLayout IsVisible="{Binding IsBusy}">
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{Binding Connection_Item.Address}"/>
<Button IsVisible="{Binding InstanceIsActiveConnection, Converter={StaticResource InvertBoolConverter}}" Text="Connect" Command="{Binding ConnectCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button IsVisible="{Binding InstanceIsActiveConnection}" Text="Disconnect" Command="{Binding DisconnectCommand}" Style="{StaticResource Style_Button_Admin}"/>
<Button Text="Delete" Command="{Binding DeleteCommand}" Style="{StaticResource Style_Button_Admin}"/>
</StackLayout>
<Grid IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}" VerticalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<StackLayout Grid.Row="0">
<Label Text="{Binding DisplayAddress}" Style="{StaticResource LabelStyle_Title}"/>
<Label Text="{Binding Connection_Item.Username}" Style="{StaticResource Style_Label_Text_Center}"/>
<Button IsVisible="{Binding InstanceIsActiveConnection, Converter={StaticResource InvertBoolConverter}}" Text="Connect" Margin="0,10,0,0" Command="{Binding ConnectCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button IsVisible="{Binding InstanceIsActiveConnection}" Text="Disconnect" Margin="0,10,0,0" Command="{Binding DisconnectCommand}" Style="{StaticResource Style_Button_Admin}"/>
</StackLayout>
<Button Grid.Row="1" Text="Delete" Command="{Binding DeleteCommand}" Style="{StaticResource Style_Button_Admin}" VerticalOptions="End"/>
</Grid>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -10,6 +10,10 @@ using FabAccessAPI.Schema;
using Prism.Services.Dialogs;
using Prism.Services;
using Prism.AppModel;
using static FabAccessAPI.Schema.Machine;
using System;
using NaturalSort.Extension;
using System.Linq;
namespace Borepin.PageModel
{
@ -45,19 +49,37 @@ namespace Borepin.PageModel
IsConnected = true;
IMachineSystem machineInterface = await _BFFHService.GetMachineSystemInterface().ConfigureAwait(false);
IMachineSystem machineSystem = await _BFFHService.GetMachineSystemInterface().ConfigureAwait(false);
MachineSystem.IInfoInterface machine_infoInterface = await machineSystem.Info().ConfigureAwait(false);
MachineSystem.IInfoInterface infoInterface = await machineInterface.Info().ConfigureAwait(false);
IUserSystem userSystem = await _BFFHService.GetUserSystemInterface().ConfigureAwait(false);
UserSystem.IInfoInterface user_infoInterface = await userSystem.Info().ConfigureAwait(false);
User user_self = (await user_infoInterface.GetUserSelf().ConfigureAwait(false)).Item1;
IReadOnlyList<Machine> machine_list = await infoInterface.GetMachineList().ConfigureAwait(false);
IReadOnlyList<Machine> machine_list = await machine_infoInterface.GetMachineList().ConfigureAwait(false);
List<MachineListItemViewModel> viewmodel_list = new List<MachineListItemViewModel>();
List<MachineListItemViewModel> viewmodel_list_user_assigned = new List<MachineListItemViewModel>();
List<MachineListItemViewModel> viewmodel_list_not_user_assigned = new List<MachineListItemViewModel>();
foreach (Machine machine in machine_list)
{
viewmodel_list.Add(new MachineListItemViewModel(machine));
if(!((InUseInterface_Proxy)machine.Inuse).IsNull)
{
MachineListItemViewModel new_viewmodel = new MachineListItemViewModel(machine)
{
IsUserAssigned = true
};
viewmodel_list_user_assigned.Add(new_viewmodel);
}
else
{
viewmodel_list_not_user_assigned.Add(new MachineListItemViewModel(machine));
}
}
MachineListItemViewModel_List = viewmodel_list;
List<MachineListItemViewModel> viewmodel_list_sorted = new List<MachineListItemViewModel>();
viewmodel_list_sorted.AddRange(viewmodel_list_user_assigned.OrderBy(x => x.Name, StringComparison.OrdinalIgnoreCase.WithNaturalSort()));
viewmodel_list_sorted.AddRange(viewmodel_list_not_user_assigned.OrderBy(x => x.Name, StringComparison.OrdinalIgnoreCase.WithNaturalSort()));
MachineListItemViewModel_List = viewmodel_list_sorted;
IsBusy = false;
}
@ -181,6 +203,7 @@ namespace Borepin.PageModel
public override async void OnNavigatedTo(INavigationParameters parameters)
{
IsBusy = true;
await LoadData().ConfigureAwait(false);
}
#endregion

View File

@ -2,6 +2,7 @@
using System.Threading.Tasks;
using System.Windows.Input;
using Borepin.Base;
using Borepin.Service.Versioning;
using Prism.Navigation;
using Xamarin.Forms;
@ -9,9 +10,15 @@ namespace Borepin.PageModel
{
public class MainPageModel : PageModelBase
{
#region Private Members
private readonly IVersioningService _VersioningService;
#endregion
#region Constructors
public MainPageModel(INavigationService navigationService) : base(navigationService)
public MainPageModel(INavigationService navigationService, IVersioningService versioningService) : base(navigationService)
{
_VersioningService = versioningService;
NavigateCommand = new Command<string>(NavigateCommandExecute);
}
#endregion
@ -19,10 +26,29 @@ namespace Borepin.PageModel
#region LoadData
public override Task LoadData()
{
CurrentVersion = _VersioningService.CurrentVersion;
CurrentBuild = _VersioningService.CurrentBuild;
return Task.CompletedTask;
}
#endregion
#region Fields
private string _CurrentVersion;
public string CurrentVersion
{
get => _CurrentVersion;
set => SetProperty(ref _CurrentVersion, value);
}
private string _CurrentBuild;
public string CurrentBuild
{
get => _CurrentBuild;
set => SetProperty(ref _CurrentBuild, value);
}
#endregion
#region Commands
private ICommand _NavigationCommand;
public ICommand NavigateCommand
@ -42,9 +68,9 @@ namespace Borepin.PageModel
}
public override void OnNavigatedTo(INavigationParameters parameters)
public override async void OnNavigatedTo(INavigationParameters parameters)
{
await LoadData().ConfigureAwait(false);
}
#endregion
}

View File

@ -8,7 +8,6 @@ using Prism.Commands;
using Prism.Navigation;
using Borepin.Service.BFFH;
using Borepin.Base;
using System;
namespace Borepin.PageModel
{
@ -34,10 +33,7 @@ namespace Borepin.PageModel
IList<Connection> list = await _BFFHService.GetConnections().ConfigureAwait(false);
if (_BFFHService.IsConnected)
{
ActiveConnection = new List<ServerListItemViewModel>
{
new ServerListItemViewModel(_BFFHService.CurrentConnection),
};
ActiveConnection = new ServerListItemViewModel(_BFFHService.CurrentConnection);
list.Remove(_BFFHService.CurrentConnection);
@ -62,8 +58,8 @@ namespace Borepin.PageModel
set => SetProperty(ref _ServerListItemViewModel_List, value);
}
private IList<ServerListItemViewModel> _ActiveConnection;
public IList<ServerListItemViewModel> ActiveConnection
private ServerListItemViewModel _ActiveConnection;
public ServerListItemViewModel ActiveConnection
{
get => _ActiveConnection;
set => SetProperty(ref _ActiveConnection, value);

View File

@ -7,6 +7,7 @@ using Prism.Navigation;
using Prism.Services;
using Prism.Services.Dialogs;
using System;
using System.Globalization;
using System.Threading.Tasks;
using System.Windows.Input;
@ -46,6 +47,11 @@ namespace Borepin.PageModel
InstanceIsActiveConnection = false;
}
if(_Connection_Item != null && _Connection_Item.Address != null)
{
DisplayAddress = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", _Connection_Item.Address.Host, _Connection_Item.Address.Port);
}
IsBusy = false;
return Task.CompletedTask;
}
@ -59,6 +65,13 @@ namespace Borepin.PageModel
set => SetProperty(ref _Connection_Item, value);
}
private string _DisplayAddress;
public string DisplayAddress
{
get => _DisplayAddress;
set => SetProperty(ref _DisplayAddress, value);
}
private bool _InstanceIsActiveConnection;
public bool InstanceIsActiveConnection
{
@ -78,6 +91,11 @@ namespace Borepin.PageModel
{
IsBusy = true;
if(_BFFHService.IsConnected)
{
await _BFFHService.Disconnect().ConfigureAwait(true);
}
try
{
await _BFFHService.Connect(Connection_Item).ConfigureAwait(true);
@ -159,13 +177,13 @@ namespace Borepin.PageModel
}
public override void OnNavigatedTo(INavigationParameters parameters)
public override async void OnNavigatedTo(INavigationParameters parameters)
{
if(Connection_Item == null)
{
Connection_Item = parameters["instance"] as Connection;
LoadData();
await LoadData().ConfigureAwait(false);
}
}
#endregion

View File

@ -157,6 +157,7 @@ namespace Borepin.Service.BFFH
if (! await _AuthenticatePlainAsync(connection.Username, password).ConfigureAwait(false))
{
await Disconnect().ConfigureAwait(false);
throw new AuthenticatingFailedException();
}
@ -195,6 +196,7 @@ namespace Borepin.Service.BFFH
if (!await _AuthenticatePlainAsync(connection.Username, password).ConfigureAwait(false))
{
await Disconnect().ConfigureAwait(false);
throw new AuthenticatingFailedException();
}

View File

@ -0,0 +1,8 @@
namespace Borepin.Service.Versioning
{
public interface IVersioningService
{
string CurrentBuild { get; }
string CurrentVersion { get; }
}
}

View File

@ -15,7 +15,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5" />
<ColumnDefinition Width="6*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="1" />
</Grid.ColumnDefinitions>
@ -24,8 +24,11 @@
<RowDefinition Height="1"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Name}" Style="{StaticResource LabelStyle_Primary}"/>
<Label Grid.Row="0" Grid.Column="2" Text="{Binding State, Converter={StaticResource MachineStateStringConverter}}" TextColor="{Binding State, Converter={StaticResource MachineStateColorConverter}}" Style="{StaticResource LabelStyle_Second}" HorizontalTextAlignment="End" />
<Button Grid.Row="0" Grid.Column="3" Margin="0, 3, 0, 3" Text="->" Command="{Binding Source={RelativeSource AncestorType={x:Type pagemodel:MachineListPageModel}}, Path=SelectInstanceCommand}" CommandParameter="{Binding .}" Style="{StaticResource Style_Button_Primary}"/>
<StackLayout Grid.Row="0" Grid.Column="2" Orientation="Horizontal" HorizontalOptions="End">
<Label Text="{Binding State, Converter={StaticResource MachineStateStringConverter}}" TextColor="{Binding State, Converter={StaticResource MachineStateColorConverter}}" Style="{StaticResource LabelStyle_Second}"/>
<Label Text="by Me" IsVisible="{Binding IsUserAssigned}" Style="{StaticResource LabelStyle_Second}"/>
</StackLayout>
<Button Grid.Row="0" Grid.Column="3" Margin="0, 3, 0, 3" Text="➔" Command="{Binding Source={RelativeSource AncestorType={x:Type pagemodel:MachineListPageModel}}, Path=SelectInstanceCommand}" CommandParameter="{Binding .}" Style="{StaticResource Style_Button_Primary}"/>
<BoxView Grid.Row="1" Grid.ColumnSpan="5" BackgroundColor="{StaticResource FifthColor}"/>
</Grid>
</ContentView.Content>

View File

@ -16,9 +16,9 @@
<RowDefinition Height="*"/>
<RowDefinition Height="1"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Address, StringFormat='{0}'}" Style="{StaticResource LabelStyle_Primary}"/>
<Label Grid.Row="0" Grid.Column="2" Text="{Binding Username}" Style="{StaticResource LabelStyle_Second}" HorizontalTextAlignment="End" />
<Button Grid.Row="0" Grid.Column="3" Margin="0, 3, 0, 3" Text="->" Command="{Binding Source={RelativeSource AncestorType={x:Type pagemodel:ServerListPageModel}}, Path=SelectInstanceCommand}" CommandParameter="{Binding .}" Style="{StaticResource Style_Button_Primary}"/>
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Address, StringFormat='{0}'}" Style="{StaticResource LabelStyle_Primary}" VerticalOptions="Center"/>
<Label Grid.Row="0" Grid.Column="2" Text="{Binding Username}" Style="{StaticResource LabelStyle_Second}" HorizontalTextAlignment="End" VerticalOptions="Center"/>
<Button Grid.Row="0" Grid.Column="3" Margin="0, 3, 0, 3" Text="" Command="{Binding Source={RelativeSource AncestorType={x:Type pagemodel:ServerListPageModel}}, Path=SelectInstanceCommand}" CommandParameter="{Binding .}" Style="{StaticResource Style_Button_Primary}" VerticalOptions="Center"/>
<BoxView Grid.Row="1" Grid.ColumnSpan="5" BackgroundColor="{StaticResource FifthColor}"/>
</Grid>
</ContentView.Content>

View File

@ -33,5 +33,12 @@ namespace Borepin.ViewModel
get => _State;
set => SetProperty(ref _State, value);
}
private bool _IsUserAssigned = false;
public bool IsUserAssigned
{
get => _IsUserAssigned;
set => SetProperty(ref _IsUserAssigned, value);
}
}
}

View File

@ -1,6 +1,5 @@
using Borepin.Model;
using Prism.Mvvm;
using System;
namespace Borepin.ViewModel
{
@ -32,8 +31,5 @@ namespace Borepin.ViewModel
set => SetProperty(ref _Username, value);
}
#endregion
#region Methods
#endregion
}
}