public async Task <ObservableCollection <OrgViewModel> > FetchChildren()
        {
            var newOrgsList = new ObservableCollection <OrgViewModel>();

            var orgsResponse = await CloudFoundryService.GetOrgsForCfInstanceAsync(CloudFoundryInstance);

            if (orgsResponse.Succeeded)
            {
                var orgs = new ObservableCollection <CloudFoundryOrganization>(orgsResponse.Content);

                foreach (CloudFoundryOrganization org in orgs)
                {
                    var newOrg = new OrgViewModel(org, this, ParentTasExplorer, Services);
                    newOrgsList.Add(newOrg);
                }
            }
            else if (orgsResponse.FailureType == Toolkit.Services.FailureType.InvalidRefreshToken)
            {
                IsExpanded = false;
                ParentTasExplorer.AuthenticationRequired = true;
            }
            else
            {
                _dialogService.DisplayErrorDialog(_getOrgsFailureMsg, orgsResponse.Explanation);
            }

            return(newOrgsList);
        }
        public async Task <ObservableCollection <SpaceViewModel> > FetchChildren()
        {
            var newSpacesList = new ObservableCollection <SpaceViewModel>();

            var spacesResponse = await CloudFoundryService.GetSpacesForOrgAsync(Org);

            if (spacesResponse.Succeeded)
            {
                var spaces = new ObservableCollection <CloudFoundrySpace>(spacesResponse.Content);

                foreach (CloudFoundrySpace space in spaces)
                {
                    var newSpace = new SpaceViewModel(space, this, ParentTasExplorer, Services);
                    newSpacesList.Add(newSpace);
                }
            }
            else if (spacesResponse.FailureType == Toolkit.Services.FailureType.InvalidRefreshToken)
            {
                Parent.IsExpanded = false;
                ParentTasExplorer.AuthenticationRequired = true;
            }
            else
            {
                _dialogService.DisplayErrorDialog(_getSpacesFailureMsg, spacesResponse.Explanation);
            }

            return(newSpacesList);
        }
        public async Task <ObservableCollection <AppViewModel> > FetchChildren()
        {
            var newAppsList = new ObservableCollection <AppViewModel>();

            var appsResult = await CloudFoundryService.GetAppsForSpaceAsync(Space);

            if (appsResult.Succeeded)
            {
                foreach (CloudFoundryApp app in appsResult.Content)
                {
                    var newOrg = new AppViewModel(app, Services);
                    newAppsList.Add(newOrg);
                }
            }
            else if (appsResult.FailureType == Toolkit.Services.FailureType.InvalidRefreshToken)
            {
                Parent.Parent.IsExpanded = false;
                ParentTasExplorer.AuthenticationRequired = true;
            }
            else
            {
                _dialogService.DisplayErrorDialog(_getAppsFailureMsg, appsResult.Explanation);
            }

            return(newAppsList);
        }
예제 #4
0
        public async Task <List <OrgViewModel> > FetchChildren()
        {
            var newOrgsList = new List <OrgViewModel>();

            var orgs = await CloudFoundryService.GetOrgsForCfInstanceAsync(CloudFoundryInstance);

            foreach (CloudFoundryOrganization org in orgs)
            {
                var newOrg = new OrgViewModel(org, Services);
                newOrgsList.Add(newOrg);
            }

            return(newOrgsList);
        }
예제 #5
0
        public async Task <List <SpaceViewModel> > FetchChildren()
        {
            var newSpacesList = new List <SpaceViewModel>();

            var spaces = await CloudFoundryService.GetSpacesForOrgAsync(Org);

            foreach (CloudFoundrySpace space in spaces)
            {
                var newSpace = new SpaceViewModel(space, Services);
                newSpacesList.Add(newSpace);
            }

            return(newSpacesList);
        }
예제 #6
0
        public async Task <List <AppViewModel> > FetchChildren()
        {
            var newAppsList = new List <AppViewModel>();

            var apps = await CloudFoundryService.GetAppsForSpaceAsync(Space);

            foreach (CloudFoundryApp app in apps)
            {
                var newOrg = new AppViewModel(app, Services);
                newAppsList.Add(newOrg);
            }

            return(newAppsList);
        }
예제 #7
0
        protected override async Task LoadChildren()
        {
            var spaces = await CloudFoundryService.GetSpacesForOrgAsync(Org);

            if (spaces.Count == 0)
            {
                DisplayText += " (no spaces)";
            }

            var updatedSpacesList = new ObservableCollection <TreeViewItemViewModel>();

            foreach (CloudFoundrySpace space in spaces)
            {
                updatedSpacesList.Add(new SpaceViewModel(new CloudFoundrySpace(space.SpaceName, space.SpaceId, Org), Services));
            }

            Children = updatedSpacesList;
        }
예제 #8
0
        protected override async Task LoadChildren()
        {
            var apps = await CloudFoundryService.GetAppsForSpaceAsync(Space);

            if (apps.Count == 0)
            {
                DisplayText += " (no apps)";
            }

            var updatedAppsList = new ObservableCollection <TreeViewItemViewModel>();

            foreach (CloudFoundryApp app in apps)
            {
                updatedAppsList.Add(new AppViewModel(app, Services));
            }

            Children = updatedAppsList;
        }
예제 #9
0
        protected override async Task LoadChildren()
        {
            var orgs = await CloudFoundryService.GetOrgsForCfInstanceAsync(CloudFoundryInstance);

            if (orgs.Count == 0)
            {
                DisplayText += " (no orgs)";
            }

            var updatedOrgsList = new ObservableCollection <TreeViewItemViewModel>();

            foreach (CloudFoundryOrganization org in orgs)
            {
                var newOrg = new OrgViewModel(org, Services);
                updatedOrgsList.Add(newOrg);
            }

            Children = updatedOrgsList;
        }
예제 #10
0
        public async Task DeleteApp(object window = null)
        {
            try
            {
                var deleteResult = await CloudFoundryService.DeleteAppAsync(CfApp, removeRoutes : DeleteRoutes);

                if (!deleteResult.Succeeded)
                {
                    Logger.Error(_deleteAppErrorMsg + " {AppName}. {DeleteResult}", CfApp.AppName, deleteResult.ToString());
                    _errorDialogService.DisplayErrorDialog($"{_deleteAppErrorMsg} {CfApp.AppName}.", deleteResult.Explanation);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(_deleteAppErrorMsg + " {AppName}. {AppDeletionException}", CfApp.AppName, ex.Message);
                _errorDialogService.DisplayErrorDialog($"{_deleteAppErrorMsg} {CfApp.AppName}.", $"Something unexpected happened while deleting {CfApp.AppName}");
            }

            CfApp = null;
            DialogService.CloseDialog(window, true);
        }
        protected internal override async Task LoadChildren()
        {
            var orgsResponse = await CloudFoundryService.GetOrgsForCfInstanceAsync(CloudFoundryInstance);

            if (orgsResponse.Succeeded)
            {
                if (orgsResponse.Content.Count == 0)
                {
                    var noChildrenList = new ObservableCollection <TreeViewItemViewModel>
                    {
                        EmptyPlaceholder,
                    };

                    Children            = noChildrenList;
                    HasEmptyPlaceholder = true;
                }
                else
                {
                    var updatedOrgsList = new ObservableCollection <TreeViewItemViewModel>();
                    foreach (CloudFoundryOrganization org in orgsResponse.Content)
                    {
                        var newOrg = new OrgViewModel(org, this, ParentTasExplorer, Services);
                        updatedOrgsList.Add(newOrg);
                    }

                    Children            = updatedOrgsList;
                    HasEmptyPlaceholder = false;
                }

                IsLoading = false;
            }
            else
            {
                IsLoading = false;

                _dialogService.DisplayErrorDialog(_getOrgsFailureMsg, orgsResponse.Explanation);

                IsExpanded = false;
            }
        }
        protected internal override async Task LoadChildren()
        {
            var appsResult = await CloudFoundryService.GetAppsForSpaceAsync(Space);

            if (appsResult.Succeeded)
            {
                if (appsResult.Content.Count == 0)
                {
                    var noChildrenList = new ObservableCollection <TreeViewItemViewModel>
                    {
                        EmptyPlaceholder,
                    };

                    Children            = noChildrenList;
                    HasEmptyPlaceholder = true;
                }
                else
                {
                    var updatedAppsList = new ObservableCollection <TreeViewItemViewModel>();
                    foreach (CloudFoundryApp app in appsResult.Content)
                    {
                        updatedAppsList.Add(new AppViewModel(app, Services));
                    }

                    Children            = updatedAppsList;
                    HasEmptyPlaceholder = false;
                }

                IsLoading = false;
            }
            else
            {
                IsLoading = false;

                _dialogService.DisplayErrorDialog(_getAppsFailureMsg, appsResult.Explanation);

                IsExpanded = false;
            }
        }
        public TasExplorerViewModel(IServiceProvider services)
            : base(services)
        {
            _errorDialogService     = services.GetRequiredService <IErrorDialog>();
            _threadingService       = services.GetRequiredService <IThreadingService>();
            _dataPersistenceService = services.GetRequiredService <IDataPersistenceService>();
            _confirmDelete          = services.GetRequiredService <IAppDeletionConfirmationViewModel>();
            _viewLocatorService     = services.GetRequiredService <IViewLocatorService>();

            string existingSavedConnectionName    = _dataPersistenceService.ReadStringData(ConnectionNameKey);
            string existingSavedConnectionAddress = _dataPersistenceService.ReadStringData(ConnectionAddressKey);
            bool   savedConnectionCredsExist      = CloudFoundryService.IsValidConnection();

            if (existingSavedConnectionName == null || existingSavedConnectionAddress == null || !savedConnectionCredsExist)
            {
                TasConnection = null;
            }
            else
            {
                var restoredConnection = new CloudFoundryInstance(name: existingSavedConnectionName, apiAddress: existingSavedConnectionAddress);

                SetConnection(restoredConnection);
            }
        }