-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTrayWindowMainPage.xaml
216 lines (184 loc) · 9.88 KB
/
TrayWindowMainPage.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="Coder.Desktop.App.Views.Pages.TrayWindowMainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Coder.Desktop.App.Controls"
xmlns:converters="using:Coder.Desktop.App.Converters"
xmlns:viewModels="using:Coder.Desktop.App.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters:VpnLifecycleToBoolConverter x:Key="ConnectingBoolConverter" Unknown="true" Starting="true"
Stopping="true" />
<converters:VpnLifecycleToBoolConverter x:Key="NotConnectingBoolConverter" Started="true" Stopped="true" />
<converters:VpnLifecycleToBoolConverter x:Key="StoppedBoolConverter" Stopped="true" />
<converters:AgentStatusToColorConverter x:Key="AgentStatusToColorConverter" />
<converters:BoolToObjectConverter x:Key="ShowMoreLessTextConverter" TrueValue="Show less"
FalseValue="Show more" />
</Page.Resources>
<StackPanel
Orientation="Vertical"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Padding="20,20,20,30"
Spacing="10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
Text="Coder Connect"
FontSize="18"
VerticalAlignment="Center" />
<ProgressRing
Grid.Column="1"
IsActive="{x:Bind ViewModel.VpnLifecycle, Converter={StaticResource ConnectingBoolConverter}, Mode=OneWay}"
Width="24"
Height="24"
Margin="10,0"
HorizontalAlignment="Right" />
<ToggleSwitch
Grid.Column="2"
OnContent=""
OffContent=""
IsOn="{x:Bind ViewModel.VpnSwitchActive, Mode=TwoWay}"
IsEnabled="{x:Bind ViewModel.VpnLifecycle, Converter={StaticResource NotConnectingBoolConverter}, Mode=OneWay}"
Toggled="{x:Bind ViewModel.VpnSwitch_Toggled}"
Margin="0,0,-110,0"
HorizontalAlignment="Right" />
</Grid>
<controls:HorizontalRule />
<TextBlock
Text="{x:Bind ViewModel.VpnFailedMessage, Mode=OneWay}"
Foreground="Red"
Margin="0,6,0,6"
TextWrapping="Wrap"
Visibility="{x:Bind ViewModel.ShowFailedSection, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
<TextBlock
Text="Enable Coder Connect to view your workspaces."
TextWrapping="Wrap"
Margin="0,6,0,6"
Visibility="{x:Bind ViewModel.ShowEnableSection, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
<TextBlock
Text="Workspaces"
FontWeight="semibold"
Visibility="{x:Bind ViewModel.ShowWorkspacesHeader, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
<TextBlock
Text="There are no workspace agents to display."
TextWrapping="Wrap"
Margin="0,0,0,6"
Visibility="{x:Bind ViewModel.ShowNoAgentsSection, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
<ItemsRepeater
ItemsSource="{x:Bind ViewModel.VisibleAgents, Mode=OneWay}"
Visibility="{x:Bind ViewModel.ShowAgentsSection, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<ItemsRepeater.Layout>
<StackLayout Orientation="Vertical" />
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="viewModels:AgentViewModel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<HyperlinkButton
Grid.Column="0"
NavigateUri="{x:Bind DashboardUrl, Mode=OneWay}"
Margin="-12,0,0,0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left">
<StackPanel
Orientation="Horizontal"
HorizontalAlignment="Stretch"
Spacing="10">
<Canvas
HorizontalAlignment="Center"
VerticalAlignment="Center"
Height="14" Width="14"
Margin="0,1,0,0">
<Ellipse
Fill="{x:Bind ConnectionStatus, Converter={StaticResource AgentStatusToColorConverter}, Mode=OneWay}"
Opacity="0.2"
Width="14"
Height="14"
Canvas.Left="0"
Canvas.Top="0" />
<Ellipse
Fill="{x:Bind ConnectionStatus, Converter={StaticResource AgentStatusToColorConverter}, Mode=OneWay}"
Width="8"
Height="8"
VerticalAlignment="Center"
Canvas.Left="3"
Canvas.Top="3" />
</Canvas>
<!-- See .cs for why the Loaded event handler is needed -->
<!-- TODO: I couldn't get ellipsis to work without hardcoding a width here -->
<TextBlock
Loaded="AgentHostnameText_OnLoaded"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
HorizontalTextAlignment="Left"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"
Width="180">
<Run Text="{x:Bind Hostname, Mode=OneWay}"
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
<Run Text="{x:Bind HostnameSuffix, Mode=OneWay}"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
</TextBlock>
</StackPanel>
</HyperlinkButton>
<HyperlinkButton
Grid.Column="1"
x:Name="AgentHostnameCopyButton"
Command="{x:Bind CopyHostnameCommand}"
CommandParameter="{Binding ElementName=AgentHostnameCopyButton}"
Margin="0,0,-12,0"
VerticalAlignment="Stretch">
<FontIcon
Glyph=""
FontSize="16"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
</HyperlinkButton>
</Grid>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
<HyperlinkButton
Margin="-12,0,-12,0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left"
Visibility="{x:Bind ViewModel.ShowAgentOverflowButton, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"
Command="{x:Bind ViewModel.ToggleShowAllAgentsCommand}">
<TextBlock
Text="{x:Bind ViewModel.ShowAllAgents, Converter={StaticResource ShowMoreLessTextConverter}, Mode=OneWay}"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
</HyperlinkButton>
<controls:HorizontalRule />
<HyperlinkButton
NavigateUri="{x:Bind ViewModel.DashboardUrl, Mode=OneWay}"
Margin="-12,0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left">
<TextBlock Text="Create workspace" Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
</HyperlinkButton>
<controls:HorizontalRule />
<HyperlinkButton
Command="{x:Bind ViewModel.SignOutCommand, Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.VpnLifecycle, Converter={StaticResource StoppedBoolConverter}, Mode=OneWay}"
Margin="-12,0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left">
<TextBlock Text="Sign out" Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
</HyperlinkButton>
</StackPanel>
</Page>