-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathTrayWindowMainPage.xaml
More file actions
380 lines (328 loc) · 20 KB
/
Copy pathTrayWindowMainPage.xaml
File metadata and controls
380 lines (328 loc) · 20 KB
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<?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: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:BoolToObjectConverter x:Key="ShowMoreLessTextConverter" TrueValue="Show less"
FalseValue="Show more" />
</Page.Resources>
<StackPanel
Orientation="Vertical"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Padding="20,20,20,20"
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}"
IsIndeterminate="{x:Bind ViewModel.VpnStartProgressIsIndeterminate, Mode=OneWay}"
Value="{x:Bind ViewModel.VpnStartProgressValueOrDefault, 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="{x:Bind ViewModel.VpnStartProgressMessageOrDefault, Mode=OneWay}"
TextWrapping="Wrap"
Margin="0,6,0,6"
Visibility="{x:Bind ViewModel.ShowVpnStartProgressSection, 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">
<StackPanel
Orientation="Vertical"
HorizontalAlignment="Stretch">
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<HyperlinkButton
Grid.Column="0"
Command="{x:Bind ToggleExpandedCommand, Mode=OneWay}"
Margin="-12,0,0,0"
Padding="8,5,8,6"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.Resources>
<converters:StringToBrushSelector
x:Key="StatusColor"
SelectedKey="{x:Bind Path=ConnectionStatus, Mode=OneWay}">
<converters:StringToBrushSelectorItem Key="Offline">
<converters:StringToBrushSelectorItem.Value>
<SolidColorBrush Color="#8e8e93" />
</converters:StringToBrushSelectorItem.Value>
</converters:StringToBrushSelectorItem>
<converters:StringToBrushSelectorItem Key="NoRecentHandshake">
<converters:StringToBrushSelectorItem.Value>
<SolidColorBrush Color="#ff3b30" />
</converters:StringToBrushSelectorItem.Value>
</converters:StringToBrushSelectorItem>
<converters:StringToBrushSelectorItem Key="Unhealthy">
<converters:StringToBrushSelectorItem.Value>
<SolidColorBrush Color="#ffcc01" />
</converters:StringToBrushSelectorItem.Value>
</converters:StringToBrushSelectorItem>
<converters:StringToBrushSelectorItem Key="Connecting">
<converters:StringToBrushSelectorItem.Value>
<SolidColorBrush Color="#ffcc01" />
</converters:StringToBrushSelectorItem.Value>
</converters:StringToBrushSelectorItem>
<converters:StringToBrushSelectorItem Key="Healthy">
<converters:StringToBrushSelectorItem.Value>
<SolidColorBrush Color="#34c759" />
</converters:StringToBrushSelectorItem.Value>
</converters:StringToBrushSelectorItem>
</converters:StringToBrushSelector>
</Grid.Resources>
<controls:ExpandChevron
Grid.Column="0"
Width="24"
Height="16"
Margin="0,0,0,0"
IsOpen="{x:Bind IsExpanded, Mode=OneWay}"
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
<!-- See .cs for why the Loaded event handler is needed -->
<TextBlock
Grid.Column="1"
Loaded="AgentHostnameText_OnLoaded"
VerticalAlignment="Center"
HorizontalTextAlignment="Left"
HorizontalAlignment="Stretch"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap">
<Run Text="{x:Bind ViewableHostname, Mode=OneWay}"
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
<Run Text="{x:Bind ViewableHostnameSuffix, Mode=OneWay}"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
</TextBlock>
<Canvas
Grid.Column="2"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Height="14" Width="14"
ToolTipService.ToolTip="{x:Bind ConnectionTooltip, Mode=OneWay}"
Margin="0,1,0,0">
<Ellipse
Fill="{Binding Source={StaticResource StatusColor}, Path=SelectedObject}"
Opacity="0.2"
Width="14"
Height="14"
Canvas.Left="0"
Canvas.Top="0" />
<Ellipse
Fill="{Binding Source={StaticResource StatusColor}, Path=SelectedObject}"
Width="8"
Height="8"
VerticalAlignment="Center"
Canvas.Left="3"
Canvas.Top="3" />
</Canvas>
</Grid>
</HyperlinkButton>
<HyperlinkButton
Grid.Column="1"
x:Name="AgentHostnameCopyButton"
Command="{x:Bind CopyHostnameCommand}"
CommandParameter="{Binding ElementName=AgentHostnameCopyButton}"
ToolTipService.ToolTip="Copy hostname to clipboard"
Padding="8,0"
VerticalAlignment="Stretch">
<FontIcon
Glyph=""
FontSize="16"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
</HyperlinkButton>
<HyperlinkButton
Grid.Column="2"
NavigateUri="{x:Bind DashboardUrl, Mode=OneWay}"
ToolTipService.ToolTip="Open in dashboard"
Margin="0,0,-12,0"
Padding="8,0"
VerticalAlignment="Stretch">
<FontIcon
Glyph=""
FontSize="16"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
</HyperlinkButton>
</Grid>
<controls:ExpandContent IsOpen="{x:Bind IsExpanded, Mode=OneWay}">
<Grid
Height="34"
Visibility="{x:Bind ShowExpandAppsMessage, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<TextBlock
Text="{x:Bind ExpandAppsMessage, Mode=OneWay}"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
TextAlignment="Center"
VerticalAlignment="Center"
Margin="0,-3,0,0" />
</Grid>
<ItemsRepeater
ItemsSource="{x:Bind VisibleApps, Mode=OneWay}"
Visibility="{x:Bind ShowExpandAppsMessage, Converter={StaticResource InverseBoolToVisibilityConverter}, Mode=OneWay}"
Height="34"
Margin="17,0">
<ItemsRepeater.Layout>
<StackLayout Orientation="Horizontal" />
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="viewModels:AgentAppViewModel">
<HyperlinkButton
x:Name="AppButton"
Padding="4"
Margin="2"
Command="{x:Bind OpenAppCommand}"
CommandParameter="{Binding ElementName=AppButton}"
Width="34"
Height="34"
ToolTipService.ToolTip="{x:Bind Details}">
<HyperlinkButton.Resources>
<SolidColorBrush x:Key="HyperlinkButtonBackground" Color="#1F000000"/>
<SolidColorBrush x:Key="HyperlinkButtonBackgroundPointerOver" Color="{ThemeResource SystemAccentColorDark1}" />
</HyperlinkButton.Resources>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Image
Source="{x:Bind IconImageSource, Mode=OneWay}"
ImageOpened="{x:Bind OnImageOpened}"
ImageFailed="{x:Bind OnImageFailed}"
Visibility="{x:Bind UseFallbackIcon, Converter={StaticResource InverseBoolToVisibilityConverter}, Mode=OneWay}"
Width="20"
Height="20"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<FontIcon
Glyph=""
FontSize="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Visibility="{x:Bind UseFallbackIcon, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
</Grid>
</HyperlinkButton>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</controls:ExpandContent>
</StackPanel>
</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
Command="{x:Bind ViewModel.ShowFileSyncListWindowCommand, Mode=OneWay}"
Margin="-12,0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left">
<!-- TODO: status icon if there is a problem -->
<TextBlock Text="File sync" Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
</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.ShowSettingsWindowCommand, Mode=OneWay}"
Margin="-12,-4,-12,-4"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left">
<TextBlock Text="Settings" Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
</HyperlinkButton>
<HyperlinkButton
Command="{x:Bind ViewModel.SignOutCommand, Mode=OneWay}"
Margin="-12,-4,-12,-4"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left">
<TextBlock Text="Sign out" Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
</HyperlinkButton>
<HyperlinkButton
Command="{x:Bind ViewModel.ExitCommand, Mode=OneWay}"
Margin="-12,-4,-12,-4"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left">
<TextBlock Text="Exit" Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
</HyperlinkButton>
</StackPanel>
</Page>