@@ -17,12 +17,12 @@ namespace K8sFileBrowser.ViewModels;
17
17
18
18
public class MainWindowViewModel : ViewModelBase
19
19
{
20
-
20
+
21
21
#region Properties
22
-
22
+
23
23
[ Reactive ]
24
24
public string ? Version { get ; set ; } = null ! ;
25
-
25
+
26
26
[ Reactive ]
27
27
public IEnumerable < ClusterContext > ClusterContexts { get ; set ; } = null ! ;
28
28
@@ -58,11 +58,11 @@ public class MainWindowViewModel : ViewModelBase
58
58
59
59
[ Reactive ]
60
60
public Message Message { get ; set ; } = null ! ;
61
-
61
+
62
62
#endregion Properties
63
63
64
64
#region Commands
65
-
65
+
66
66
public ReactiveCommand < Unit , Unit > DownloadCommand { get ; private set ; } = null ! ;
67
67
public ReactiveCommand < Unit , Unit > DownloadLogCommand { get ; private set ; } = null ! ;
68
68
public ReactiveCommand < Unit , Unit > ParentCommand { get ; private set ; } = null ! ;
@@ -96,7 +96,7 @@ public MainWindowViewModel()
96
96
}
97
97
98
98
#region Property Subscriptions
99
-
99
+
100
100
private void InitiallyLoadContexts ( IKubernetesService kubernetesService )
101
101
{
102
102
// load the cluster contexts when the view model is created
@@ -115,7 +115,7 @@ private void InitiallyLoadContexts(IKubernetesService kubernetesService)
115
115
. FirstOrDefault ( c => c . Name == kubernetesService . GetCurrentContext ( ) ) ;
116
116
} ) ;
117
117
}
118
-
118
+
119
119
private void RegisterReadNamespaces ( IKubernetesService kubernetesService )
120
120
{
121
121
// read the cluster contexts
@@ -130,7 +130,7 @@ private void RegisterReadNamespaces(IKubernetesService kubernetesService)
130
130
Namespaces = ns ;
131
131
} ) ;
132
132
}
133
-
133
+
134
134
private void RegisterReadPods ( )
135
135
{
136
136
// read the pods when the namespace changes
@@ -146,7 +146,7 @@ private void RegisterReadPods()
146
146
Pods = x ;
147
147
} ) ;
148
148
}
149
-
149
+
150
150
private void RegisterReadContainers ( )
151
151
{
152
152
// read the file information when the path changes
@@ -290,11 +290,11 @@ private void ConfigureOpenDirectoryCommand()
290
290
OpenCommand . ThrownExceptions . ObserveOn ( RxApp . MainThreadScheduler )
291
291
. Subscribe ( ShowErrorMessage ) ;
292
292
}
293
-
293
+
294
294
#endregion Configure Commands
295
295
296
296
#region Get Data
297
-
297
+
298
298
private static async Task < IEnumerable < Pod > > PodsAsync ( Namespace ? ns , IKubernetesService kubernetesService )
299
299
{
300
300
if ( ns == null )
@@ -346,67 +346,74 @@ private IList<FileInformation> GetFileInformation(IKubernetesService kubernetesS
346
346
Parent = parent
347
347
} ) . ToList ( ) ;
348
348
}
349
-
349
+
350
350
#endregion Get Data
351
-
351
+
352
352
#region Reset Data
353
-
353
+
354
354
private void ResetPath ( )
355
355
{
356
356
FileInformation = new List < FileInformation > ( ) ;
357
357
SelectedPath = null ;
358
358
SelectedContainer = null ;
359
- }
360
-
359
+ }
360
+
361
361
private void ResetContainers ( )
362
362
{
363
363
ResetPath ( ) ;
364
364
Containers = new List < Container > ( ) ;
365
365
SelectedPod = null ;
366
366
367
- }
368
-
367
+ }
368
+
369
369
private void ResetPods ( )
370
370
{
371
371
ResetContainers ( ) ;
372
372
SelectedNamespace = null ;
373
373
Pods = new List < Pod > ( ) ;
374
374
375
- }
376
-
375
+ }
376
+
377
377
private void ResetNamespaces ( )
378
378
{
379
379
ResetPods ( ) ;
380
380
Namespaces = new List < Namespace > ( ) ;
381
381
SelectedClusterContext = null ;
382
- }
383
-
382
+ }
383
+
384
384
#endregion Reset Data
385
-
385
+
386
386
#region show messages
387
-
387
+
388
388
private void ShowWorkingMessage ( string message )
389
389
{
390
- Message = new Message
390
+ RxApp . MainThreadScheduler . Schedule ( Action ) ;
391
+ return ;
392
+
393
+ void Action ( )
391
394
{
392
- IsVisible = true ,
393
- Text = message ,
394
- IsError = false
395
- } ;
395
+ Message = new Message
396
+ {
397
+ IsVisible = true ,
398
+ Text = message ,
399
+ IsError = false
400
+ } ;
401
+ }
396
402
}
397
403
398
404
private void ShowErrorMessage ( string message )
399
405
{
406
+ RxApp . MainThreadScheduler . Schedule ( Action ) ;
407
+ return ;
408
+
400
409
async void Action ( )
401
410
{
402
411
Message = new Message { IsVisible = true , Text = message , IsError = true } ;
403
412
await Task . Delay ( 7000 ) ;
404
413
HideWorkingMessage ( ) ;
405
414
}
406
-
407
- RxApp . MainThreadScheduler . Schedule ( Action ) ;
408
415
}
409
-
416
+
410
417
private void ShowErrorMessage ( Exception exception )
411
418
{
412
419
// ReSharper disable once TemplateIsNotCompileTimeConstantProblem
@@ -423,6 +430,6 @@ private void HideWorkingMessage()
423
430
IsError = false
424
431
} ) ;
425
432
}
426
-
433
+
427
434
#endregion show messages
428
435
}
0 commit comments