예제 #1
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter != null)
            {
                OfflineMode = true;
                cache.Fill  = (SolidColorBrush)Application.Current.Resources["AcrylicMessageBackground"];
            }
            grid.Opacity         = 0;
            grid.Visibility      = Visibility.Collapsed;
            LoadingRing.IsActive = true;
            base.OnNavigatedTo(e);

            LoadingRing.Visibility = Visibility.Visible;
            status = await StatusPage.GetStatus();

            if (status == null)
            {
                FailedToLoad.Visibility = Visibility.Visible;
                return;
            }
            else
            {
                FailedToLoad.Visibility = Visibility.Collapsed;
            }
            if (status.Incidents != null)
            {
                foreach (var incident in status.Incidents)
                {
                    if (incident.Status != "resolved")
                    {
                        List <SimpleComponent> updates = new List <SimpleComponent>();
                        for (int i = 0; i < incident.IncidentUpdates.Length; i++)
                        {
                            updates.Add(new SimpleComponent()
                            {
                                Status      = incident.IncidentUpdates[i].Status,
                                Description = incident.IncidentUpdates[i].Body,
                                Name        = incident.IncidentUpdates[i].UpdatedAt.ToString("t")
                            });
                        }
                        ComplexComponent sc = new ComplexComponent()
                        {
                            Name   = incident.Name,
                            Status = incident.Status,
                            Color  = ColorFromStatus(incident.Status),
                            Items  = updates
                        };

                        if (!string.IsNullOrWhiteSpace(sc.Name))
                        {
                            IncidentsPanel.Items.Add(sc);
                        }
                    }
                }
            }

            if (IncidentsPanel.Items.Count > 0)
            {
                IncidentsPanel.Visibility    = Visibility.Visible;
                IncidentsScroller.Visibility = Visibility.Visible;
            }
            else
            {
                IncidentsPanel.Visibility    = Visibility.Collapsed;
                IncidentsScroller.Visibility = Visibility.Collapsed;
            }

            if (status.Status != null)
            {
                var statusBrush = ColorFromStatus(status.Status.Indicator);
                statusColor = statusBrush.Color;
                statusContainer.Background = statusBrush;
                border.BorderBrush         = statusBrush;
                //dayDuration.Foreground = statusBrush;
                //weekDuration.Foreground = statusBrush;
                //monthDuration.Foreground = statusBrush;
                IncidentsScroller.Background = new SolidColorBrush(statusBrush.Color)
                {
                    Opacity = 0.25
                };
                statusDescription.Text     = status.Status.Description;
                statusContainer.Visibility = Visibility.Visible;
            }
            if (status.Components != null)
            {
                foreach (var component in status.Components)
                {
                    SimpleComponent sc = new SimpleComponent()
                    {
                        Name        = component.Name,
                        Status      = component.Status.Replace("_", " "),
                        Color       = ColorFromStatus(component.Status),
                        Description = component.Description
                    };
                    ComponentsPanel.Items.Add(sc);
                }
            }
            grid.Visibility = Visibility.Visible;
            scale2.CenterY  = grid.ActualHeight / 2;
            scale2.CenterX  = grid.ActualWidth / 2;
            LoadIn.Begin();
            ShowMetrics("day");
        }