<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:vm="clr-namespace:PSCHelpdesk.Plugins.HetznerServer.ViewModels"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="PSCHelpdesk.Plugins.HetznerServer.Views.ServerView"
             x:DataType="vm:ServerViewModel">
    <Design.DataContext>
        <vm:ServerViewModel></vm:ServerViewModel>
    </Design.DataContext>
    <SplitView IsPaneOpen="{Binding IsPagePaneOpen }"
               DisplayMode="Inline"
               OpenPaneLength="300" PanePlacement="Right">
        <DataGrid Margin="20" ItemsSource="{Binding Server}" 
                  AutoGenerateColumns="False" IsReadOnly="True" 
                  GridLinesVisibility="All"
                  BorderThickness="1" BorderBrush="Gray"
                  Name="ServerTable">
            <Interaction.Behaviors>
                <EventTriggerBehavior EventName="SelectionChanged">
                    <InvokeCommandAction Command="{Binding #ServerTable.((vm:ServerViewModel)DataContext).SelectionChanged}" PassEventArgsToCommand="true"></InvokeCommandAction>
                </EventTriggerBehavior>
            </Interaction.Behaviors>
            <DataGrid.Columns>
                <DataGridTextColumn Header="Id"  Binding="{Binding Id}"/>
                <DataGridTextColumn Header="Name" Binding="{Binding Name}" />
                <DataGridTextColumn Header="Status" Binding="{Binding Status}" />
                <DataGridTextColumn Header="Type" Binding="{Binding Type}" />
                <DataGridTextColumn Header="IpV4" Binding="{Binding Ipv4}" />
                <DataGridTextColumn Header="IpV6" Binding="{Binding Ipv6}" />
                <DataGridTemplateColumn Width="*" Header="">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button
                                HorizontalAlignment="Center"
                                HorizontalContentAlignment="Center"
                                Background="#232323"
                                Command="{Binding #ServerTable.((vm:ServerViewModel)DataContext).ShowServerDetails}"
                                CommandParameter="{Binding .}"
                                Content="View"
                                Foreground="White" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="*" Header="">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button
                                HorizontalAlignment="Center"
                                HorizontalContentAlignment="Center"
                                Background="#232323"
                                Command="{Binding #ServerTable.((vm:ServerViewModel)DataContext).OpenSSH}"
                                CommandParameter="{Binding .}"
                                Content="Open SSH"
                                Foreground="White" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="*" Header="">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button
                                HorizontalAlignment="Center"
                                HorizontalContentAlignment="Center"
                                Background="#232323"
                                Command="{Binding #ServerTable.((vm:ServerViewModel)DataContext).OpenSCP}"
                                CommandParameter="{Binding .}"
                                Content="Open SCP"
                                Foreground="White" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
        <SplitView.Pane>
            <TextBlock Text="{Binding SelectedServer.Name}"
                       FontSize="24"
                       VerticalAlignment="Center"
                       HorizontalAlignment="Center"/>
        </SplitView.Pane>
    </SplitView>
</UserControl>
