protected BaseEventsViewModel(IApplicationService applicationService) { ApplicationService = applicationService; Events = new ReactiveCollection<Tuple<EventModel, EventBlock>>(); ReportRepository = true; GoToRepositoryCommand = new ReactiveCommand(); GoToRepositoryCommand.OfType<EventModel.RepoModel>().Subscribe(x => { var repoId = new RepositoryIdentifier(x.Name); var vm = CreateViewModel<RepositoryViewModel>(); vm.RepositoryOwner = repoId.Owner; vm.RepositoryName = repoId.Name; ShowViewModel(vm); }); GoToGistCommand = new ReactiveCommand(); GoToGistCommand.OfType<EventModel.GistEvent>().Subscribe(x => { var vm = CreateViewModel<GistViewModel>(); vm.Id = x.Gist.Id; vm.Gist = x.Gist; ShowViewModel(vm); }); LoadCommand.RegisterAsyncTask(t => this.RequestModel(CreateRequest(0, 100), t as bool?, response => { this.CreateMore(response, m => Events.MoreTask = m, d => Events.AddRange(CreateDataFromLoad(d))); Events.Reset(CreateDataFromLoad(response.Data)); })); }
private void GoToSubmodule(ContentModel x) { var nameAndSlug = x.GitUrl.Substring(x.GitUrl.IndexOf("/repos/", System.StringComparison.Ordinal) + 7); var repoId = new RepositoryIdentifier(nameAndSlug.Substring(0, nameAndSlug.IndexOf("/git", System.StringComparison.Ordinal))); var sha = x.GitUrl.Substring(x.GitUrl.LastIndexOf("/", System.StringComparison.Ordinal) + 1); ShowViewModel<SourceTreeViewModel>(new NavObject {Username = repoId.Owner, Repository = repoId.Name, Branch = sha}); }
private void GoToRepository(EventModel.RepoModel eventModel) { var repoId = new RepositoryIdentifier(eventModel.Name); ShowViewModel<RepositoryViewModel>(new RepositoryViewModel.NavObject { Username = repoId.Owner, Repository = repoId.Name }); }
private void GoToCommits(EventModel.RepoModel repoModel, string branch) { var repoId = new RepositoryIdentifier(repoModel.Name); ShowViewModel<ChangesetsViewModel>(new ChangesetsViewModel.NavObject { Username = repoId.Owner, Repository = repoId.Name, Branch = branch }); }
private void HandleNotification(NSDictionary data) { try { var viewDispatcher = Mvx.Resolve<Cirrious.MvvmCross.Views.IMvxViewDispatcher>(); var request = MvxViewModelRequest<CodeHub.Core.ViewModels.Repositories.RepositoryViewModel>.GetDefaultRequest(); var repoId = new RepositoryIdentifier(data["r"].ToString()); request.ParameterValues = new Dictionary<string, string>() {{"Username", repoId.Owner}, {"Repository", repoId.Name}}; viewDispatcher.ShowViewModel(request); } catch (Exception e) { Console.WriteLine("Handle Notifications issue: " + e); } }
private void GoToBranches(RepositoryIdentifier repoId) { ShowViewModel<BranchesAndTagsViewModel>(new BranchesAndTagsViewModel.NavObject { Username = repoId.Owner, Repository = repoId.Name, IsShowingBranches = true }); }
private void GoToChangeset(RepositoryIdentifier repo, string sha) { if (repo == null || string.IsNullOrEmpty(repo.Name) || string.IsNullOrEmpty(repo.Owner)) return; ShowViewModel<ChangesetViewModel>(new ChangesetViewModel.NavObject { Username = repo.Owner, Repository = repo.Name, Node = sha }); }
private void GoToTags(EventModel.RepoModel eventModel) { var repoId = new RepositoryIdentifier(eventModel.Name); var vm = CreateViewModel<BranchesAndTagsViewModel>(); vm.RepositoryOwner = repoId.Owner; vm.RepositoryName = repoId.Name; vm.SelectedFilter = BranchesAndTagsViewModel.ShowIndex.Tags; ShowViewModel(vm); }
private void GoToIssue(RepositoryIdentifier repo, long id) { if (repo == null || string.IsNullOrEmpty(repo.Name) || string.IsNullOrEmpty(repo.Owner)) return; ShowViewModel<IssueViewModel>(new IssueViewModel.NavObject { Username = repo.Owner, Repository = repo.Name, Id = id }); }
private void GoToTags(EventModel.RepoModel eventModel) { var repoId = new RepositoryIdentifier(eventModel.Name); ShowViewModel<BranchesAndTagsViewModel>(new BranchesAndTagsViewModel.NavObject { Username = repoId.Owner, Repository = repoId.Name, IsShowingBranches = false }); }
private void GoToCommits(EventModel.RepoModel repoModel, string branch) { var repoId = new RepositoryIdentifier(repoModel.Name); var vm = CreateViewModel<ChangesetsViewModel>(); vm.RepositoryOwner = repoId.Owner; vm.RepositoryName = repoId.Name; vm.Branch = branch; ShowViewModel(vm); }
private void GoToChangeset(RepositoryIdentifier repo, string sha) { if (repo == null || string.IsNullOrEmpty(repo.Name) || string.IsNullOrEmpty(repo.Owner)) return; var vm = CreateViewModel<ChangesetViewModel>(); vm.RepositoryOwner = repo.Owner; vm.RepositoryName = repo.Name; vm.Node = sha; ShowViewModel(vm); }
private void GoToPullRequests(RepositoryIdentifier repo) { if (repo == null || string.IsNullOrEmpty(repo.Name) || string.IsNullOrEmpty(repo.Owner)) return; var vm = CreateViewModel<PullRequestsViewModel>(); vm.RepositoryOwner = repo.Owner; vm.RepositoryName = repo.Name; ShowViewModel(vm); }
private void GoToIssue(RepositoryIdentifier repo, long id) { if (repo == null || string.IsNullOrEmpty(repo.Name) || string.IsNullOrEmpty(repo.Owner)) return; var vm = CreateViewModel<IssueViewModel>(); vm.RepositoryOwner = repo.Owner; vm.RepositoryName = repo.Name; vm.IssueId = id; }
public SourceTreeViewModel(IApplicationService applicationService) { Filter = applicationService.Account.Filters.GetFilter<SourceFilterModel>("SourceViewModel"); Content = new ReactiveCollection<ContentModel>(); GoToSubmoduleCommand = new ReactiveCommand(); GoToSubmoduleCommand.OfType<ContentModel>().Subscribe(x => { var nameAndSlug = x.GitUrl.Substring(x.GitUrl.IndexOf("/repos/", StringComparison.OrdinalIgnoreCase) + 7); var repoId = new RepositoryIdentifier(nameAndSlug.Substring(0, nameAndSlug.IndexOf("/git", StringComparison.OrdinalIgnoreCase))); var vm = CreateViewModel<SourceTreeViewModel>(); vm.Username = repoId.Owner; vm.Repository = repoId.Name; vm.Branch = x.Sha; ShowViewModel(vm); }); GoToSourceCommand = new ReactiveCommand(); GoToSourceCommand.OfType<ContentModel>().Subscribe(x => { var otherFiles = Content .Where(y => string.Equals(y.Type, "file", StringComparison.OrdinalIgnoreCase)) .Where(y => y.Size.HasValue && y.Size.Value > 0) .Select(y => new SourceViewModel.SourceItemModel { Name = y.Name, Path = y.Path, HtmlUrl = y.HtmlUrl, GitUrl = y.GitUrl }).ToArray(); var navObject = new SourceViewModel.NavObject { Branch = Branch, Username = Username, Repository = Repository, TrueBranch = TrueBranch, Items = otherFiles, CurrentItemIndex = Array.FindIndex(otherFiles, f => string.Equals(f.GitUrl, x.GitUrl, StringComparison.OrdinalIgnoreCase)) }; var vm = CreateViewModel<SourceViewModel>(navObject); ShowViewModel(vm); }); GoToSourceTreeCommand = new ReactiveCommand(); GoToSourceTreeCommand.OfType<ContentModel>().Subscribe(x => { var vm = CreateViewModel<SourceTreeViewModel>(); vm.Username = Username; vm.Branch = Branch; vm.Repository = Repository; vm.TrueBranch = TrueBranch; vm.Path = x.Path; ShowViewModel(vm); }); this.WhenAnyValue(x => x.Filter).Subscribe(filter => { if (filter == null) { Content.OrderFunc = null; } else { Content.OrderFunc = x => { switch (filter.OrderBy) { case SourceFilterModel.Order.FoldersThenFiles: x = x.OrderBy(y => y.Type).ThenBy(y => y.Name); break; default: x = x.OrderBy(y => y.Name); break; } return filter.Ascending ? x : x.Reverse(); }; } }); LoadCommand.RegisterAsyncTask(t => Content.SimpleCollectionLoad( applicationService.Client.Users[Username].Repositories[Repository].GetContent( Path ?? string.Empty, Branch ?? "master"), t as bool?)); }
private void GoToPullRequests(RepositoryIdentifier repo) { if (repo == null || string.IsNullOrEmpty(repo.Name) || string.IsNullOrEmpty(repo.Owner)) return; ShowViewModel<PullRequestsViewModel>(new PullRequestsViewModel.NavObject { Username = repo.Owner, Repository = repo.Name }); }
private void HandleNotification(NSDictionary data, bool fromBootup) { try { var viewDispatcher = Mvx.Resolve<Cirrious.MvvmCross.Views.IMvxViewDispatcher>(); var appService = Mvx.Resolve<IApplicationService>(); var repoId = new RepositoryIdentifier(data["r"].ToString()); var parameters = new Dictionary<string, string>() {{"Username", repoId.Owner}, {"Repository", repoId.Name}}; MvxViewModelRequest request; if (data.ContainsKey(new NSString("c"))) { request = MvxViewModelRequest<CodeHub.Core.ViewModels.ChangesetViewModel>.GetDefaultRequest(); parameters.Add("Node", data["c"].ToString()); parameters.Add("ShowRepository", "True"); } else if (data.ContainsKey(new NSString("i"))) { request = MvxViewModelRequest<CodeHub.Core.ViewModels.Issues.IssueViewModel>.GetDefaultRequest(); parameters.Add("Id", data["i"].ToString()); } else if (data.ContainsKey(new NSString("p"))) { request = MvxViewModelRequest<CodeHub.Core.ViewModels.PullRequests.PullRequestViewModel>.GetDefaultRequest(); parameters.Add("Id", data["p"].ToString()); } else { request = MvxViewModelRequest<CodeHub.Core.ViewModels.Repositories.RepositoryViewModel>.GetDefaultRequest(); } request.ParameterValues = parameters; var username = data["u"].ToString(); if (appService.Account == null || !appService.Account.Username.Equals(username)) { var user = appService.Accounts.FirstOrDefault(x => x.Username.Equals(username)); if (user != null) { appService.DeactivateUser(); appService.Accounts.SetDefault(user); } } appService.SetUserActivationAction(() => viewDispatcher.ShowViewModel(request)); if (appService.Account == null && !fromBootup) { var startupViewModelRequest = MvxViewModelRequest<CodeHub.Core.ViewModels.App.StartupViewModel>.GetDefaultRequest(); viewDispatcher.ShowViewModel(startupViewModelRequest); } } catch (Exception e) { Console.WriteLine("Handle Notifications issue: " + e); } }
private void GoToBranches(RepositoryIdentifier repoId) { var vm = CreateViewModel<BranchesAndTagsViewModel>(); vm.RepositoryOwner = repoId.Owner; vm.RepositoryName = repoId.Name; vm.SelectedFilter = BranchesAndTagsViewModel.ShowIndex.Branches; ShowViewModel(vm); }