mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 14:51:44 +01:00
Fix Views List
This commit is contained in:
parent
224891cadb
commit
c39b5bce3d
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using FabAccessAPI.Schema;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Xamarin.Forms;
|
||||
|
||||
@ -8,9 +9,9 @@ namespace Borepin.Converter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
switch((FabAccessAPI.Schema.Machine.MachineState)value)
|
||||
switch((Machine.MachineState)value)
|
||||
{
|
||||
case (FabAccessAPI.Schema.Machine.MachineState.free):
|
||||
case Machine.MachineState.free:
|
||||
return (Color)Application.Current.Resources["FirstColor"];
|
||||
default:
|
||||
return (Color)Application.Current.Resources["SixthColor"];
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using FabAccessAPI.Schema;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Xamarin.Forms;
|
||||
|
||||
@ -8,19 +9,19 @@ namespace Borepin.Converter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
switch((FabAccessAPI.Schema.Machine.MachineState)value)
|
||||
switch((Machine.MachineState)value)
|
||||
{
|
||||
case (FabAccessAPI.Schema.Machine.MachineState.free):
|
||||
case Machine.MachineState.free:
|
||||
return "Free";
|
||||
case (FabAccessAPI.Schema.Machine.MachineState.inUse):
|
||||
case Machine.MachineState.inUse:
|
||||
return "In Use";
|
||||
case (FabAccessAPI.Schema.Machine.MachineState.toCheck):
|
||||
case Machine.MachineState.toCheck:
|
||||
return "To Check";
|
||||
case (FabAccessAPI.Schema.Machine.MachineState.reserved):
|
||||
case Machine.MachineState.reserved:
|
||||
return "Reserved";
|
||||
case (FabAccessAPI.Schema.Machine.MachineState.blocked):
|
||||
case Machine.MachineState.blocked:
|
||||
return "Blocked";
|
||||
case (FabAccessAPI.Schema.Machine.MachineState.disabled):
|
||||
case Machine.MachineState.disabled:
|
||||
return "Disabled";
|
||||
default:
|
||||
return "Unknown";
|
||||
|
54
Borepin/Borepin/Model/ConnectionDataVisualize.cs
Normal file
54
Borepin/Borepin/Model/ConnectionDataVisualize.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using FabAccessAPI;
|
||||
using Prism.Mvvm;
|
||||
|
||||
namespace Borepin.Model
|
||||
{
|
||||
public class ConnectionDataVisualize : BindableBase
|
||||
{
|
||||
#region Private Fields
|
||||
public readonly ConnectionData _ConnectionData;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public ConnectionDataVisualize(ConnectionData connectionData)
|
||||
{
|
||||
_ConnectionData = connectionData;
|
||||
|
||||
LoadData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public async void LoadData()
|
||||
{
|
||||
|
||||
Host = _ConnectionData.Host.Host;
|
||||
Port = _ConnectionData.Host.Port;
|
||||
Username = _ConnectionData.Username;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
private string _Host;
|
||||
public string Host
|
||||
{
|
||||
get => _Host;
|
||||
set => SetProperty(ref _Host, value);
|
||||
}
|
||||
|
||||
private int _Port;
|
||||
public int Port
|
||||
{
|
||||
get => _Port;
|
||||
set => SetProperty(ref _Port, value);
|
||||
}
|
||||
|
||||
private string _Username;
|
||||
public string Username
|
||||
{
|
||||
get => _Username;
|
||||
set => SetProperty(ref _Username, value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -12,20 +12,14 @@ using System;
|
||||
using NaturalSort.Extension;
|
||||
using System.Linq;
|
||||
using Borepin.Service;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Borepin.PageModel
|
||||
{
|
||||
public class MachineListPageModel : ConnectionModelBase
|
||||
{
|
||||
#region Private Fields
|
||||
private Machine _NextMachine;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public MachineListPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService, pageDialogService, apiService)
|
||||
{
|
||||
SelectInstanceCommand = new DelegateCommand<object>(SelectInstanceCommandExecute);
|
||||
ScanCodeCommand = new DelegateCommand(async () => await ScanCodeCommandExecute().ConfigureAwait(false));
|
||||
RefreshCommand = new DelegateCommand(async ()=> await RefreshCommandExecute().ConfigureAwait(true));
|
||||
}
|
||||
@ -44,21 +38,24 @@ namespace Borepin.PageModel
|
||||
{
|
||||
if(!((InUseInterface_Proxy)machine.Inuse).IsNull)
|
||||
{
|
||||
MachineListItemViewModel new_viewmodel = new MachineListItemViewModel(machine)
|
||||
MachineListItemViewModel new_viewmodel = new MachineListItemViewModel(_NavigationService, _PageDialogService)
|
||||
{
|
||||
IsUserAssigned = true,
|
||||
IsInUseByMe = true,
|
||||
};
|
||||
await new_viewmodel.LoadInstance(machine).ConfigureAwait(false);
|
||||
viewmodel_list_user_assigned.Add(new_viewmodel);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewmodel_list_not_user_assigned.Add(new MachineListItemViewModel(machine));
|
||||
MachineListItemViewModel new_viewmodel = new MachineListItemViewModel(_NavigationService, _PageDialogService);
|
||||
await new_viewmodel.LoadInstance(machine).ConfigureAwait(false);
|
||||
viewmodel_list_not_user_assigned.Add(new_viewmodel);
|
||||
}
|
||||
}
|
||||
|
||||
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()));
|
||||
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;
|
||||
}
|
||||
#endregion
|
||||
@ -96,31 +93,6 @@ namespace Borepin.PageModel
|
||||
IsRefreshing = false;
|
||||
}
|
||||
|
||||
private ICommand _SelectInstanceCommand;
|
||||
public ICommand SelectInstanceCommand
|
||||
{
|
||||
get => _SelectInstanceCommand;
|
||||
set => SetProperty(ref _SelectInstanceCommand, value);
|
||||
}
|
||||
public void SelectInstanceCommandExecute(object obj)
|
||||
{
|
||||
MachineListItemViewModel viewmodel = obj as MachineListItemViewModel;
|
||||
|
||||
NavigationParameters parameters = new NavigationParameters
|
||||
{
|
||||
{ "instance", viewmodel.Instance.Id },
|
||||
};
|
||||
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
INavigationResult result = await _NavigationService.NavigateAsync($"MachinePage", parameters).ConfigureAwait(false);
|
||||
if (result.Exception != null)
|
||||
{
|
||||
Log.Fatal(result.Exception, "Navigating failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private ICommand _ScanCodeCommand;
|
||||
public ICommand ScanCodeCommand
|
||||
{
|
||||
@ -156,38 +128,8 @@ namespace Borepin.PageModel
|
||||
return;
|
||||
}
|
||||
|
||||
_NextMachine = machine;
|
||||
IsBusy = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IPageLifecycleAware
|
||||
public void OnAppearing()
|
||||
{
|
||||
if(_NextMachine != null)
|
||||
{
|
||||
NavigationParameters parameters = new NavigationParameters
|
||||
{
|
||||
{ "id", _NextMachine.Id},
|
||||
};
|
||||
|
||||
_NextMachine = null;
|
||||
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("MachinePage", parameters).ConfigureAwait(false);
|
||||
if (result.Exception != null)
|
||||
{
|
||||
Log.Fatal(result.Exception, "Navigating failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDisappearing()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,8 @@ namespace Borepin.PageModel
|
||||
IList<ConnectionData> list = await _LoginStorageService.GetList().ConfigureAwait(false);
|
||||
if (_API.IsConnected)
|
||||
{
|
||||
ActiveConnection = new ServerListItemViewModel(_API.ConnectionData);
|
||||
ActiveConnection = new ServerListItemViewModel(_NavigationService, _PageDialogService);
|
||||
await ActiveConnection.LoadInstance(_API.ConnectionData).ConfigureAwait(false);
|
||||
|
||||
list.Remove(_API.ConnectionData);
|
||||
|
||||
@ -48,7 +49,13 @@ namespace Borepin.PageModel
|
||||
HasActiveConnection = false;
|
||||
}
|
||||
|
||||
ServerListItemViewModel_List = list.Select(x => new ServerListItemViewModel(x)).ToList();
|
||||
ServerListItemViewModel_List = new List<ServerListItemViewModel>();
|
||||
foreach (ConnectionData connectionData in list)
|
||||
{
|
||||
ServerListItemViewModel serverListItemViewModel = new ServerListItemViewModel(_NavigationService, _PageDialogService);
|
||||
await serverListItemViewModel.LoadInstance(connectionData).ConfigureAwait(false);
|
||||
ServerListItemViewModel_List.Add(serverListItemViewModel);
|
||||
}
|
||||
|
||||
IsBusy = false;
|
||||
}
|
||||
|
@ -23,12 +23,12 @@
|
||||
<RowDefinition Height="*"/>
|
||||
<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="1" Text="{Binding Machine.Name}" Style="{StaticResource LabelStyle_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}"/>
|
||||
<Label Text="{Binding Machine.State, Converter={StaticResource MachineStateStringConverter}}" TextColor="{Binding Machine.State, Converter={StaticResource MachineStateColorConverter}}" Style="{StaticResource LabelStyle_Second}"/>
|
||||
<Label Text="by Me" IsVisible="{Binding IsInUseByMe}" 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}"/>
|
||||
<Button Grid.Row="0" Grid.Column="3" Margin="0, 3, 0, 3" Text="➔" Command="{Binding SelectInstanceCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<BoxView Grid.Row="1" Grid.ColumnSpan="5" BackgroundColor="{StaticResource FifthColor}"/>
|
||||
</Grid>
|
||||
</ContentView.Content>
|
||||
|
@ -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}" 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"/>
|
||||
<Label Grid.Row="0" Grid.Column="1" Text="{Binding ConnectionData.Host, StringFormat='{0}'}" Style="{StaticResource LabelStyle_Primary}" VerticalOptions="Center"/>
|
||||
<Label Grid.Row="0" Grid.Column="2" Text="{Binding ConnectionData.Username}" Style="{StaticResource LabelStyle_Second}" HorizontalTextAlignment="End" VerticalOptions="Center"/>
|
||||
<Button Grid.Row="0" Grid.Column="3" Margin="0, 3, 0, 3" Text="➔" Command="{Binding SelectInstanceCommand}" Style="{StaticResource Style_Button_Primary}" VerticalOptions="Center"/>
|
||||
<BoxView Grid.Row="1" Grid.ColumnSpan="5" BackgroundColor="{StaticResource FifthColor}"/>
|
||||
</Grid>
|
||||
</ContentView.Content>
|
||||
|
@ -1,44 +1,77 @@
|
||||
using Prism.Mvvm;
|
||||
using FabAccessAPI.Schema;
|
||||
using FabAccessAPI.Schema;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Borepin.Base;
|
||||
using Prism.Navigation;
|
||||
using Prism.Services;
|
||||
using Prism.Commands;
|
||||
using Xamarin.Forms;
|
||||
using Borepin.Model;
|
||||
|
||||
namespace Borepin.ViewModel
|
||||
{
|
||||
public class MachineListItemViewModel : BindableBase
|
||||
public class MachineListItemViewModel : PageModelBase
|
||||
{
|
||||
public MachineListItemViewModel(Machine instance)
|
||||
#region Constructors
|
||||
public MachineListItemViewModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService, pageDialogService)
|
||||
{
|
||||
_Instance = instance;
|
||||
SelectInstanceCommand = new DelegateCommand(SelectInstanceCommandExecute);
|
||||
}
|
||||
#endregion
|
||||
|
||||
Name = instance.Name;
|
||||
State = instance.State;
|
||||
#region LoadData
|
||||
public override Task LoadInstance(object instance)
|
||||
{
|
||||
if(instance is Machine)
|
||||
{
|
||||
Machine = new MachineVisualize(instance as Machine);
|
||||
Machine.LoadData();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
private ICommand _SelectInstanceCommand;
|
||||
public ICommand SelectInstanceCommand
|
||||
{
|
||||
get => _SelectInstanceCommand;
|
||||
set => SetProperty(ref _SelectInstanceCommand, value);
|
||||
}
|
||||
public void SelectInstanceCommandExecute()
|
||||
{
|
||||
NavigationParameters parameters = new NavigationParameters
|
||||
{
|
||||
{ "instance", Machine._Machine.Id },
|
||||
};
|
||||
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage/MachinePage", parameters).ConfigureAwait(false);
|
||||
if (result.Exception != null)
|
||||
{
|
||||
Log.Fatal(result.Exception, "Navigating failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Machine _Instance;
|
||||
public Machine Instance
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
private MachineVisualize _Machine;
|
||||
public MachineVisualize Machine
|
||||
{
|
||||
get => _Instance;
|
||||
set => SetProperty(ref _Instance, value);
|
||||
get => _Machine;
|
||||
set => SetProperty(ref _Machine, value);
|
||||
}
|
||||
|
||||
private string _Name;
|
||||
public string Name
|
||||
private bool _IsInUseByMe = false;
|
||||
public bool IsInUseByMe
|
||||
{
|
||||
get => _Name;
|
||||
set => SetProperty(ref _Name, value);
|
||||
}
|
||||
|
||||
private Machine.MachineState _State;
|
||||
public Machine.MachineState State
|
||||
{
|
||||
get => _State;
|
||||
set => SetProperty(ref _State, value);
|
||||
}
|
||||
|
||||
private bool _IsUserAssigned = false;
|
||||
public bool IsUserAssigned
|
||||
{
|
||||
get => _IsUserAssigned;
|
||||
set => SetProperty(ref _IsUserAssigned, value);
|
||||
get => _IsInUseByMe;
|
||||
set => SetProperty(ref _IsInUseByMe, value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,69 @@
|
||||
using Borepin.Model;
|
||||
using Borepin.Base;
|
||||
using Borepin.Model;
|
||||
using FabAccessAPI;
|
||||
using Prism.Mvvm;
|
||||
using Prism.Commands;
|
||||
using Prism.Navigation;
|
||||
using Prism.Services;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Borepin.ViewModel
|
||||
{
|
||||
public class ServerListItemViewModel : BindableBase
|
||||
public class ServerListItemViewModel : PageModelBase
|
||||
{
|
||||
#region Constructors
|
||||
public ServerListItemViewModel(ConnectionData instance)
|
||||
public ServerListItemViewModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService, pageDialogService)
|
||||
{
|
||||
Instance = instance;
|
||||
Address = instance.Host.Host;
|
||||
Username = instance.Username;
|
||||
SelectInstanceCommand = new DelegateCommand(SelectInstanceCommandExecute);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region LoadData
|
||||
public override Task LoadInstance(object instance)
|
||||
{
|
||||
if(instance is ConnectionData)
|
||||
{
|
||||
ConnectionData = new ConnectionDataVisualize(instance as ConnectionData);
|
||||
ConnectionData.LoadData();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
public readonly ConnectionData Instance;
|
||||
|
||||
private string _Address;
|
||||
public string Address
|
||||
private ConnectionDataVisualize _ConnectionData;
|
||||
public ConnectionDataVisualize ConnectionData
|
||||
{
|
||||
get => _Address;
|
||||
set => SetProperty(ref _Address, value);
|
||||
get => _ConnectionData;
|
||||
set => SetProperty(ref _ConnectionData, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private string _Username;
|
||||
public string Username
|
||||
#region Commands
|
||||
private ICommand _SelectInstanceCommand;
|
||||
public ICommand SelectInstanceCommand
|
||||
{
|
||||
get => _Username;
|
||||
set => SetProperty(ref _Username, value);
|
||||
get => _SelectInstanceCommand;
|
||||
set => SetProperty(ref _SelectInstanceCommand, value);
|
||||
}
|
||||
public void SelectInstanceCommandExecute()
|
||||
{
|
||||
NavigationParameters parameters = new NavigationParameters
|
||||
{
|
||||
{ "instance", ConnectionData._ConnectionData },
|
||||
};
|
||||
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage/ServerPage", parameters).ConfigureAwait(false);
|
||||
if (result.Exception != null)
|
||||
{
|
||||
Log.Fatal(result.Exception, "Navigating failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace FabAccessAPI
|
||||
public Mechanism Mechanism;
|
||||
public string Username;
|
||||
public Dictionary<string, object> Properties;
|
||||
public bool IsDefault;
|
||||
public DateTime LastTime;
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
|
Loading…
x
Reference in New Issue
Block a user