Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Various fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberboss committed May 8, 2020
1 parent dc750ac commit 61c4a9a
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public enum ChatBotCommand
public bool CanName => rightsProvider.ChatBotRights.HasFlag(ChatBotRights.WriteName);
public bool CanProvider => rightsProvider.ChatBotRights.HasFlag(ChatBotRights.WriteProvider);
public bool CanEnable => rightsProvider.ChatBotRights.HasFlag(ChatBotRights.WriteEnabled);
public bool CanChannelLimit => rightsProvider.ChatBotRights.HasFlag(ChatBotRights.WriteEnabled);
public bool CanChannelLimit => rightsProvider.ChatBotRights.HasFlag(ChatBotRights.WriteChannelLimit);

public bool Refreshing
{
Expand Down Expand Up @@ -197,6 +197,7 @@ public async Task RunCommand(ChatBotCommand command, CancellationToken cancellat
try
{
ChatBot = await chatBotsClient.Update(update, cancellationToken).ConfigureAwait(true);
NewChannelLimit = ChatBot.ChannelLimit.Value;
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,18 @@ public bool ChatDelete
newChatBotRights &= ~right;
}
}
public bool ChatChannelLimit
{
get => newChatBotRights.HasFlag(ChatBotRights.WriteChannelLimit);
set
{
var right = ChatBotRights.WriteChannelLimit;
if (value)
newChatBotRights |= right;
else
newChatBotRights &= ~right;
}
}

public bool StaticRead
{
Expand Down Expand Up @@ -792,6 +804,7 @@ void PostLoad()
this.RaisePropertyChanged(nameof(ChatName));
this.RaisePropertyChanged(nameof(ChatCreate));
this.RaisePropertyChanged(nameof(ChatDelete));
this.RaisePropertyChanged(nameof(ChatChannelLimit));

this.RaisePropertyChanged(nameof(StaticRead));
this.RaisePropertyChanged(nameof(StaticWrite));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ public async void AsyncStart()
var updatesTask = CheckForUpdates();
Connections = new List<ConnectionManagerViewModel>(settings.Connections.Select(x => CreateConnection(x)));
await updatesTask.ConfigureAwait(true);
var activeConnection = Connections.SingleOrDefault();
if (activeConnection != null)
PageContext.ActiveObject = activeConnection;
}

async Task CheckForUpdates()
Expand Down
24 changes: 22 additions & 2 deletions src/Tgstation.Server.ControlPanel/ViewModels/UserViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public User User
this.RaisePropertyChanged(nameof(InstanceRelocate));
this.RaisePropertyChanged(nameof(InstanceRename));
this.RaisePropertyChanged(nameof(InstanceUpdate));
this.RaisePropertyChanged(nameof(InstanceChatLimit));
this.RaisePropertyChanged(nameof(IsSystemUser));
}
}
Expand Down Expand Up @@ -291,6 +292,18 @@ public bool InstanceUpdate
newInstanceManagerRights &= ~right;
}
}
public bool InstanceChatLimit
{
get => newInstanceManagerRights.HasFlag(InstanceManagerRights.SetChatBotLimit);
set
{
var right = InstanceManagerRights.SetChatBotLimit;
if (value)
newInstanceManagerRights |= right;
else
newInstanceManagerRights &= ~right;
}
}

public string PasswordLength => $"Minimum Length: {serverInformation.MinimumPasswordLength}";

Expand Down Expand Up @@ -358,8 +371,15 @@ public bool CanRunCommand(UserCommand command)
case UserCommand.Close:
return true;
case UserCommand.Save:
if ((NewPassword != PasswordConfirm || (NewPassword?.Length ?? 0) < serverInformation.MinimumPasswordLength) || !CanEditPassword)
return false;
var changedPassword = (NewPassword?.Length ?? 0 + PasswordConfirm?.Length ?? 0) > 0;
if (changedPassword)
{
var validPassword = changedPassword && NewPassword == PasswordConfirm && (NewPassword?.Length ?? 0) < serverInformation.MinimumPasswordLength;

if (!CanEditPassword || !validPassword)
return false;
}

goto case UserCommand.Refresh;
case UserCommand.Refresh:
return !Refreshing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<TextBlock Text="New Path:" Margin="5,4,50,0" Grid.Column="0" Grid.Row="1"/>
<TextBox Background="White" IsEnabled="{Binding PageContext.ActiveObject.CanRelocate}" Text="{Binding PageContext.ActiveObject.NewPath, Mode=TwoWay}" Grid.Column="1" Grid.Row="1"/>
<TextBlock Text="Chat Bot Limit:" Margin="5,4,50,0" Grid.Column="0" Grid.Row="2"/>
<NumericUpDown Minimum="0" Maximum="65535" Height="25" IsEnabled="{Binding PageContext.ActiveObject.CanPort}" Value="{Binding PageContext.ActiveObject.NewChatBotLimit}" Grid.Row="2" Grid.Column="1"/>
<NumericUpDown Minimum="0" Maximum="65535" Height="25" IsEnabled="{Binding PageContext.ActiveObject.CanChatBot}" Value="{Binding PageContext.ActiveObject.NewChatBotLimit}" Grid.Row="2" Grid.Column="1"/>
</Grid>
<Rectangle HorizontalAlignment="Stretch" Fill="#A0A0A0" Height="1" Margin="0,5,0,0"/>
<Rectangle HorizontalAlignment="Stretch" Fill="#FFFFFF" Height="1" Margin="0,0,0,5"/>
Expand Down Expand Up @@ -81,7 +81,7 @@
<ColumnDefinition Width="15*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="Save" Command="{Binding PageContext.ActiveObject.Save}" Background="#CFD6E5" BorderBrush="#ADADAD"/>
<Button Grid.Column="2" Content="Fix Permissions" Command="{Binding PageContext.ActiveObject.FixPerms}" Background="#CFD6E5" BorderBrush="#ADADAD"/>
<Button Grid.Column="2" Content="Grant Permissions on This Instance" IsEnabled="{Binding PageContext.ActiveObject.CanGetPerms}" Command="{Binding PageContext.ActiveObject.FixPerms}" Background="#CFD6E5" BorderBrush="#ADADAD"/>
<Button Grid.Column="4" Content="{Binding PageContext.ActiveObject.DeleteText}" Command="{Binding PageContext.ActiveObject.Delete}" Background="#CFD6E5" BorderBrush="#ADADAD"/>
</Grid>
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.ChatDelete, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Delete Bot" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="1" Grid.Row="4" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.ChatChannelLimit, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Set Channel Limits" Margin="5,4,0,0" />
</DockPanel>
</Grid>
<Rectangle HorizontalAlignment="Stretch" Fill="#A0A0A0" Height="1" Margin="0,5,0,0"/>
<Rectangle HorizontalAlignment="Stretch" Fill="#FFFFFF" Height="1" Margin="0,0,0,5"/>
Expand Down
34 changes: 20 additions & 14 deletions src/Tgstation.Server.ControlPanel/Views/Pages/UserManager.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
</DockPanel>
<DockPanel Grid.Column="1" Grid.Row="0" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.AdminEditPassword, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Edit Own Password" Margin="5,4,0,0" IsVisible="{Binding !PageContext.ActiveObject.IsSystemUser}"/>
<TextBlock DockPanel.Dock="Right" Text="Edit Own Password (Not Applicable For System Users)" Margin="5,4,0,0" IsVisible="{Binding PageContext.ActiveObject.IsSystemUser}"/>
<TextBlock DockPanel.Dock="Right" Text="Edit Own Password" Margin="5,4,0,0" IsVisible="{Binding !PageContext.ActiveObject.IsSystemUser}"/>
</DockPanel>
<DockPanel Grid.Column="0" Grid.Row="1" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.AdminRestartServer, Mode=TwoWay}"/>
Expand Down Expand Up @@ -115,43 +115,49 @@
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<DockPanel Grid.Column="0" Grid.Row="0" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceRead, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Read Info of Accessible Instances" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="1" Grid.Row="0" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceList, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="View All Instances" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="1" Grid.Row="1" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceDelete, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Detach Instances" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="0" Grid.Row="1" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceCreate, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Create new Instances" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="0" Grid.Row="1" Margin="2">
<TextBlock Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2" Text="The following permissions additionally allow users to give themselves full permissions on an instance:" Margin="5,4,0,0" />
<DockPanel Grid.Column="0" Grid.Row="3" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceRename, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Rename Instances" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="1" Grid.Row="1" Margin="2">
<DockPanel Grid.Column="1" Grid.Row="3" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceRelocate, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Relocate Instances" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="0" Grid.Row="2" Margin="2">
<DockPanel Grid.Column="0" Grid.Row="4" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceOnline, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Online and Offline Instances" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="1" Grid.Row="2" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceDelete, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Detach Instances" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="0" Grid.Row="3" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceList, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="View All Instances" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="1" Grid.Row="3" Margin="2">
<DockPanel Grid.Column="1" Grid.Row="4" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceConfig, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Change Instance Configuration Modes" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="0" Grid.Row="4" Margin="2">
<DockPanel Grid.Column="0" Grid.Row="5" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceUpdate, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Manage Instance Auto Updating" Margin="5,4,0,0" />
</DockPanel>
<DockPanel Grid.Column="1" Grid.Row="5" Margin="2">
<CheckBox Background="White" IsChecked="{Binding PageContext.ActiveObject.InstanceChatLimit, Mode=TwoWay}"/>
<TextBlock DockPanel.Dock="Right" Text="Set Chat Bot Limits" Margin="5,4,0,0" />
</DockPanel>
</Grid>
<Rectangle HorizontalAlignment="Stretch" Fill="#A0A0A0" Height="1" Margin="0,5,0,0"/>
<Rectangle HorizontalAlignment="Stretch" Fill="#FFFFFF" Height="1" Margin="0,0,0,5"/>
Expand Down

0 comments on commit 61c4a9a

Please sign in to comment.