mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-23 02:51:26 -07:00
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using System.Windows;
|
|
using System.Windows.Input;
|
|
using Bloxstrap.Integrations;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
namespace Bloxstrap.UI.ViewModels.ContextMenu
|
|
{
|
|
internal class ServerInformationViewModel : NotifyPropertyChangedViewModel
|
|
{
|
|
private readonly ActivityWatcher _activityWatcher;
|
|
|
|
public string InstanceId => _activityWatcher.Data.JobId;
|
|
|
|
public string ServerType => _activityWatcher.Data.ServerType.ToTranslatedString();
|
|
|
|
public string ServerLocation { get; private set; } = Strings.Common_Loading;
|
|
|
|
public Visibility ServerLocationVisibility => App.Settings.Prop.ShowServerDetails ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
public ICommand CopyInstanceIdCommand => new RelayCommand(CopyInstanceId);
|
|
|
|
public ServerInformationViewModel(Watcher watcher)
|
|
{
|
|
_activityWatcher = watcher.ActivityWatcher!;
|
|
|
|
if (ServerLocationVisibility == Visibility.Visible)
|
|
QueryServerLocation();
|
|
}
|
|
|
|
public async void QueryServerLocation()
|
|
{
|
|
string? location = await _activityWatcher.Data.QueryServerLocation();
|
|
|
|
if (String.IsNullOrEmpty(location))
|
|
ServerLocation = Strings.Common_NotAvailable;
|
|
else
|
|
ServerLocation = location;
|
|
|
|
OnPropertyChanged(nameof(ServerLocation));
|
|
}
|
|
|
|
private void CopyInstanceId() => Clipboard.SetDataObject(InstanceId);
|
|
}
|
|
}
|