예제 #1
0
        public void UrlSource_OvertaksUrlGeneration()
        {
            page1.DirectUrl = "/hello";

            string url = parser.BuildUrl(page1);

            url.ShouldBe("/hello/");
        }
예제 #2
0
        public void BuildUrl_InvokesEvent()
        {
            UrlEventArgs lastEvent = null;

            parser.BuiltUrl += (s, e) => lastEvent = e;

            parser.BuildUrl(page1_1);

            lastEvent.AffectedItem.ShouldBe(page1_1);
        }
예제 #3
0
        private void PutCollectionNameInTheUrl()
        {
            var urlParser  = new UrlParser(UrlUtil.Url);
            var collection = SelectedCollection.Value;

            if (collection == null)
            {
                return;
            }
            var name = collection.Name;

            initialSelectedCollectionName = name;
            if (urlParser.GetQueryParam("collection") != name)
            {
                if (name != "")
                {
                    urlParser.SetQueryParam("collection", name);
                }
                else
                {
                    urlParser.RemoveQueryParam("collection");
                }

                UrlUtil.Navigate(urlParser.BuildUrl());
            }
        }
예제 #4
0
        private void RefreshCollectionsList()
        {
            DatabaseCommands.GetTermsCount(CollectionsIndex, "Tag", "", 1024)
            .ContinueOnSuccess(collections =>
            {
                var collectionModels =
                    new CollectionModel[] { new AllDocumentsCollectionModel {
                                                Count = Database.Value.Statistics.Value == null ? 0 : (int)Database.Value.Statistics.Value.CountOfDocuments
                                            }, new RavenDocumentsCollectionModel() }
                .Concat(
                    collections
                    .Where(x => x.Count > 0)
                    .Select(col => new CollectionModel {
                    Name = col.Name, Count = col.Count
                }))
                .ToList();

                Collections.Match(collectionModels, () => AfterUpdate(collectionModels));
            })
            .Catch(ex =>
            {
                var urlParser = new UrlParser(UrlUtil.Url);
                if (urlParser.RemoveQueryParam("collection"))
                {
                    UrlUtil.Navigate(urlParser.BuildUrl());
                }
                ApplicationModel.Current.AddErrorNotification(ex, "Unable to retrieve collections from server.");
            });
        }
예제 #5
0
        public void PagesOutsideStartPage_AreReferenced_ThroughTheirRewrittenUrl()
        {
            host   = new Host(wrapper, 10, 1);
            parser = new UrlParser(persister, wrapper, host, new HostSection());

            CreateDefaultStructure();
            ContentItem root = CreateOneItem <PageItem>(10, "root", null);

            startItem.AddTo(root);
            ContentItem outside1 = CreateOneItem <PageItem>(11, "outside1", root);

            mocks.ReplayAll();

            Assert.AreEqual(parser.BuildUrl(root), root.FindPath(PathData.DefaultAction).RewrittenUrl.ToString());
            Assert.AreEqual(parser.BuildUrl(outside1), outside1.FindPath(PathData.DefaultAction).RewrittenUrl.ToString());
        }
예제 #6
0
        public override void Execute(object parameter)
        {
            bool shouldRedirect = true;

            var urlParser = new UrlParser(UrlUtil.Url);

            if (urlParser.GetQueryParam("database") == databaseName)
            {
                shouldRedirect = false;
            }

            urlParser.SetQueryParam("database", databaseName);

            var server = ApplicationModel.Current.Server.Value;

            server.SetCurrentDatabase(urlParser);
            server.SelectedDatabase.Value.AsyncDatabaseCommands
            .EnsureSilverlightStartUpAsync()
            .Catch();

            View.UpdateAllFromServer();

            if (shouldRedirect)
            {
                UrlUtil.Navigate(urlParser.BuildUrl());
            }
        }
        public override void Execute(object parameter)
        {
            bool shouldRedirect = true;

            var urlParser = new UrlParser(UrlUtil.Url);

            if (urlParser.GetQueryParam("database") == databaseName)
            {
                shouldRedirect = false;
            }

            urlParser.SetQueryParam("database", databaseName);

            var server = ApplicationModel.Current.Server.Value;

            server.SetCurrentDatabase(urlParser);
            server.SelectedDatabase.Value.AsyncDatabaseCommands
            .EnsureSilverlightStartUpAsync()
            .Catch();

            var updateAllFromServer = View.UpdateAllFromServer();

            refreshStaticModels
            .Except(updateAllFromServer.Select(x => x.GetType()))
            .Select(model => (Model)Activator.CreateInstance(model))
            .ForEach(model => model.ForceTimerTicked());


            if (shouldRedirect)
            {
                UrlUtil.Navigate(urlParser.BuildUrl());
            }
        }
예제 #8
0
 public override Task TimerTickedAsync()
 {
     return(DatabaseCommands.GetTermsCount("Raven/DocumentsByEntityName", "Tag", "", 100)
            .ContinueOnSuccess(Update)
            .CatchIgnore <WebException>(() =>
     {
         var urlParser = new UrlParser(UrlUtil.Url);
         if (urlParser.RemoveQueryParam("name"))
         {
             UrlUtil.Navigate(urlParser.BuildUrl());
         }
         ApplicationModel.Current.AddNotification(new Notification("Unable to retrieve collections from server.", NotificationLevel.Error));
     }));
 }
예제 #9
0
        private void NavigateToPage(int pageOffset)
        {
            var skip1 = Skip + pageOffset * PageSize;

            Skip = (short)skip1;

            if (IsSkipBasedOnTheUrl)
            {
                var urlParser = new UrlParser(UrlUtil.Url);
                urlParser.SetQueryParam("skip", Skip);
                UrlUtil.Navigate(urlParser.BuildUrl());
            }

            OnPagerChanged();
        }
예제 #10
0
        public override void Execute(object parameter)
        {
            var urlParser = new UrlParser("/edit");

            if (string.IsNullOrEmpty(viewableDocument.Id))
            {
                var key = ProjectionData.Projections.First(x => x.Value == viewableDocument).Key;
                urlParser.SetQueryParam("projection", key);
            }
            else
            {
                urlParser.SetQueryParam("id", viewableDocument.Id);
            }

            UrlUtil.Navigate(urlParser.BuildUrl());
        }
예제 #11
0
        public override void Execute(object parameter)
        {
            var urlParser = new UrlParser("/edit");

            if (string.IsNullOrEmpty(viewableDocument.Id))
            {
                var projection = viewableDocument.InnerDocument.ToJson().ToString(Formatting.None);
                urlParser.SetQueryParam("projection", projection);
            }
            else
            {
                urlParser.SetQueryParam("id", viewableDocument.Id);
            }

            UrlUtil.Navigate(urlParser.BuildUrl());
        }
        public override void Execute(object parameter)
        {
            var urlParser = new UrlParser("/edit");
            var friendly  = (parameter as FriendlyDocument);

            if (friendly != null)
            {
                urlParser.SetQueryParam(friendly.IsProjection ? "projection" : "id", friendly.Id);

                if (friendly.NeighborsIds != null)
                {
                    urlParser.SetQueryParam("neighbors", string.Join(",", friendly.NeighborsIds));
                }
            }

            UrlUtil.Navigate(urlParser.BuildUrl());
        }
예제 #13
0
        private void PutCollectionNameInTheUrl()
        {
            var urlParser  = new UrlParser(UrlUtil.Url);
            var collection = SelectedCollection.Value;

            if (collection == null)
            {
                return;
            }
            var name = collection.Name;

            initialSelectedDatabaseName = name;
            if (urlParser.GetQueryParam("name") != name)
            {
                urlParser.SetQueryParam("name", name);
                UrlUtil.Navigate(urlParser.BuildUrl());
            }
        }
예제 #14
0
        public override Task TimerTickedAsync()
        {
            return(DatabaseCommands.GetTermsCount("Raven/DocumentsByEntityName", "Tag", "", 100)
                   .ContinueOnSuccess(collections =>
            {
                var collectionModels = collections.OrderByDescending(x => x.Count)
                                       .Select(col => new CollectionModel {
                    Name = col.Name, Count = col.Count
                })
                                       .ToArray();

                Collections.Match(collectionModels, AfterUpdate);
            })
                   .CatchIgnore <WebException>(() =>
            {
                var urlParser = new UrlParser(UrlUtil.Url);
                if (urlParser.RemoveQueryParam("name"))
                {
                    UrlUtil.Navigate(urlParser.BuildUrl());
                }
                ApplicationModel.Current.AddNotification(new Notification("Unable to retrieve collections from server.", NotificationLevel.Error));
            }));
        }
예제 #15
0
        private void RefreshCollectionsList()
        {
            DatabaseCommands.GetTermsCount(CollectionsIndex, "Tag", "", 100)
            .ContinueOnSuccess(collections =>
            {
                var collectionModels = collections.OrderByDescending(x => x.Count)
                                       .Where(x => x.Count > 0)
                                       .Select(col => new CollectionModel {
                    Name = col.Name, Count = col.Count
                })
                                       .ToArray();

                Collections.Match(collectionModels, () => AfterUpdate(collections));
            })
            .Catch(ex =>
            {
                var urlParser = new UrlParser(UrlUtil.Url);
                if (urlParser.RemoveQueryParam("name"))
                {
                    UrlUtil.Navigate(urlParser.BuildUrl());
                }
                ApplicationModel.Current.AddErrorNotification(ex, "Unable to retrieve collections from server.");
            });
        }
예제 #16
0
        public void CanBuildUrl_StartItem()
        {
            string url = parser.BuildUrl(startItem);

            Assert.AreEqual("/", url);
        }
        public void CanCreate_DataItemUrl_OnStartPage()
        {
            string url = parser.BuildUrl(part1);

            Assert.AreEqual("/?item=6", url);
        }