public void TestMainMethods()
        {
            _client.WithPaging(5);
            string gridState = _client.Grid.GetState();
            var    query     = StringExtensions.GetQuery(gridState);

            foreach (var element in query)
            {
                Assert.IsTrue(_client.Grid.Query.ContainsKey(element.Key));
                Assert.AreEqual(_client.Grid.Query[element.Key], element.Value);
            }

            query = new QueryDictionary <StringValues>();
            query.Add("grid-search", "TEST");
            query.Add("grid-page", "2");
            _client = new GridClient <TestModel>((q) => _repo.GetAllService(_columns, q, true, true),
                                                 query, false, "testGrid", _columns);
            _client.Searchable();
            gridState = _client.Grid.GetState();
            query     = StringExtensions.GetQuery(gridState);
            foreach (var element in query)
            {
                Assert.IsTrue(_client.Grid.Query.ContainsKey(element.Key));
                Assert.AreEqual(_client.Grid.Query[element.Key], element.Value);
            }
        }
        protected override async Task OnParametersSetAsync()
        {
            _renderFragments  = new QueryDictionary <RenderFragment>();
            _isTooltipVisible = new QueryDictionary <bool>();
            foreach (var column in GridComponent.Grid.Columns)
            {
                // Name must have a non empty value
                if (string.IsNullOrWhiteSpace(column.Name))
                {
                    column.Name = Guid.NewGuid().ToString();
                }

                if (((ICGridColumn)column).SubGrids != null)
                {
                    var values = ((ICGridColumn)column).GetSubGridKeyValues(Item).Values.ToArray();
                    var grid   = await((ICGridColumn)column).SubGrids(values, false, true, false, true) as ICGrid;
                    _renderFragments.Add(column.Name, CreateSubGridComponent(grid));
                }
                else if (column.DeleteComponentType != null)
                {
                    _renderFragments.Add(column.Name, GridCellComponent <T> .CreateComponent(_sequence,
                                                                                             column.DeleteComponentType, column, Item, null, true));
                }

                _isTooltipVisible.AddParameter(column.Name, false);
            }
            _tabGroups = GridComponent.Grid.Columns
                         .Where(r => !string.IsNullOrWhiteSpace(r.TabGroup) && _renderFragments.Keys.Any(s => s.Equals(r.Name)))
                         .Select(r => r.TabGroup).Distinct();

            _shouldRender = true;
        }
        public IQueryDictionary <StringValues> ToQuery()
        {
            QueryDictionary <StringValues> query = new QueryDictionary <StringValues>();

            if (!string.IsNullOrWhiteSpace(_sortSettings.ColumnName))
            {
                query.Add(_sortSettings.ColumnQueryParameterName, _sortSettings.ColumnName);
                query.Add(_sortSettings.DirectionQueryParameterName, _sortSettings.Direction.ToString("d"));
            }

            List <string> stringValues = new List <string>();

            foreach (var column in _filterSettings.FilteredColumns)
            {
                stringValues.Add(column.ColumnName + QueryStringFilterSettings.FilterDataDelimeter +
                                 column.FilterType + QueryStringFilterSettings.FilterDataDelimeter +
                                 column.FilterValue);
            }
            if (stringValues.Count > 0)
            {
                query.Add(QueryStringFilterSettings.DefaultTypeQueryParameter,
                          new StringValues(stringValues.ToArray()));
            }

            query.Add(QueryStringSearchSettings.DefaultSearchQueryParameter, _searchSettings.SearchValue);

            return(query);
        }
        public void TestAllColumnsSearch()
        {
            QueryDictionary <StringValues> query = new QueryDictionary <StringValues>();

            query.Add("grid-search", "3");

            _gridClient = new GridClient <TestModel>((q) => _repo.GetAllService(Columns, q, true, false), query, false, "testGrid",
                                                     Columns);
            _gridClient.Searchable(true, false);

            _gridClient.UpdateGrid().Wait();

            var searched = _gridClient.Grid.Items;

            var original = _repo.GetAll().AsQueryable().Where(t => t.Id.ToString().ToUpper().Contains("3") ||
                                                              t.Title.ToUpper().Contains("3") ||
                                                              t.Created.ToString().ToUpper().Contains("3") ||
                                                              t.Int16Field.ToString().ToUpper().Contains("3") ||
                                                              t.UInt16Field.ToString().ToUpper().Contains("3") ||
                                                              t.UInt32Field.ToString().ToUpper().Contains("3") ||
                                                              t.UInt64Field.ToString().ToUpper().Contains("3"));

            for (int i = 0; i < searched.Count(); i++)
            {
                if (searched.ElementAt(i).Id != original.ElementAt(i).Id)
                {
                    Assert.Fail("Searching not works");
                }
            }
            Assert.AreEqual(_gridClient.Grid.ItemsCount, 8);
        }
        protected override void OnParametersSet()
        {
            _renderFragments  = new QueryDictionary <RenderFragment>();
            _isTooltipVisible = new QueryDictionary <bool>();
            foreach (var column in GridComponent.Grid.Columns)
            {
                // Name must have a non empty value
                if (string.IsNullOrWhiteSpace(column.Name))
                {
                    column.Name = Guid.NewGuid().ToString();
                }

                if (column.CreateComponentType != null)
                {
                    _renderFragments.Add(column.Name, GridCellComponent <T> .CreateComponent(_sequence,
                                                                                             column.CreateComponentType, column, Item, null, true));
                }

                _isTooltipVisible.AddParameter(column.Name, false);
            }
            _tabGroups = GridComponent.Grid.Columns
                         .Where(r => !string.IsNullOrWhiteSpace(r.TabGroup) && _renderFragments.Keys.Any(s => s.Equals(r.Name)))
                         .Select(r => r.TabGroup).Distinct();

            _shouldRender = true;
        }
Example #6
0
        protected override async Task OnInitializedAsync()
        {
            Action <IGridColumnCollection <InvitationViewModel> > columns = c =>
            {
                c.Add(o => o.Id).Titled("Id").Sortable(true);
                c.Add(o => o.To).Titled("To").Sortable(true);
                c.Add(o => o.SentBy).Titled("By").Sortable(true);
                c.Add(o => o.SentAt).Titled("Sent").Sortable(true);
                c.Add(o => o.Error).Titled("Error").Sortable(true);
                c.Add(o => o.AcceptedAt).Titled("Accepted").Sortable(true);
                c.Add().Titled("Expired").RenderValueAs(i => i.Expired.ToString()).Sortable(true);
            };

            var query = new QueryDictionary <StringValues>();

            query.Add("grid-page", "1");

            var client = new GridClient <InvitationViewModel>(q => GridService.GetRows(columns, q), query, false, "grid", columns);

            Grid = client.Grid;

            // Set new items to grid
            Task = client.UpdateGrid();
            await Task;
        }
        protected override async Task OnParametersSetAsync()
        {
            _renderFragments = new QueryDictionary <RenderFragment>();
            foreach (var column in GridComponent.Grid.Columns)
            {
                // Name must have a non empty value
                if (string.IsNullOrWhiteSpace(column.Name))
                {
                    column.Name = Guid.NewGuid().ToString();
                }

                if (column.CreateComponentType != null)
                {
                    VariableReference reference = new VariableReference();
                    Children.Add(column.Name, reference);
                    _renderFragments.Add(column.Name, GridCellComponent <T> .CreateComponent(_sequence,
                                                                                             GridComponent, column.CreateComponentType, column, Item, null, true, reference));
                }
            }
            _tabGroups = GridComponent.Grid.Columns
                         .Where(r => !string.IsNullOrWhiteSpace(r.TabGroup) && _renderFragments.Keys.Any(s => s.Equals(r.Name)))
                         .Select(r => r.TabGroup).Distinct();

            foreach (var column in GridComponent.Grid.Columns)
            {
                if (((IGridColumn <T>)column).IsSelectColumn.IsSelectKey)
                {
                    var selectItem = await((IGridColumn <T>)column).SelectItemExpr(Item);
                    SelectItems.Add(column.Name, selectItem);
                }
            }

            _shouldRender = true;
        }
Example #8
0
        protected override async Task OnParametersSetAsync()
        {
            guests = await GuestRepo.GetAll().ToListAsync();

            Action <IGridColumnCollection <GuestEntity> > columns = c =>
            {
                c.Add(g => g.Username).Titled(Loc["Username"]);
                c.Add(g => g.AccessExpiration).Titled(Loc["AccessExpiration"]).SetFilterWidgetType("DateTimeLocal").Format("{0:dd/MM/yyyy HH:mm}");
                c.Add(g => g.AllowedAddresses).Titled(Loc["AllowedAddresses"]);
            };

            var query = new QueryDictionary <StringValues>();

            query.Add("grid-page", "1");

            var client = new GridClient <GuestEntity>(q => GetGridRows(columns, q), query, false, "guestsGrid", columns, CultureInfo.CurrentCulture)
                         .Sortable()
                         .Filterable()
                         .WithMultipleFilters()
                         .SetKeyboard(true)
                         .Selectable(true, false, false);

            grid = client.Grid;

            // Try to set a previous filter
            if (VolatileSettings.GridQueries.ContainsKey((0, "guestsGrid")))
            {
                grid.Query = VolatileSettings.GridQueries[(0, "guestsGrid")];
        public void TestWithParameter()
        {
            QueryDictionary <StringValues> query = new QueryDictionary <StringValues>();

            query.Add("key1", "value1");
            query.Add("key2", "value2");
            query.Add("key3", "value3");

            _builder = new CustomQueryStringBuilder(query);

            var str1 = _builder.GetQueryStringWithParameter("key4", "value4");

            Assert.AreEqual(str1, "?key1=value1&key2=value2&key3=value3&key4=value4");

            str1 = _builder.GetQueryStringWithParameter("key4", "value4new");
            Assert.AreEqual(str1, "?key1=value1&key2=value2&key3=value3&key4=value4new");
        }
        public void TestExcept()
        {
            QueryDictionary <StringValues> query = new QueryDictionary <StringValues>();

            query.Add("key1", "value1");
            query.Add("key2", "value2");

            _builder = new CustomQueryStringBuilder(query);

            var str1 = _builder.GetQueryStringExcept(new[] { "key1" });

            Assert.AreEqual(str1, "?key2=value2");

            str1 = _builder.GetQueryStringExcept(new[] { "key2" });
            Assert.AreEqual(str1, "?key1=value1");

            str1 = _builder.GetQueryStringExcept(new[] { "key1", "key2" });
            Assert.AreEqual(str1, string.Empty);
        }
 protected override async Task OnParametersSetAsync()
 {
     _grids = new QueryDictionary <RenderFragment>();
     foreach (var column in GridComponent.Grid.Columns)
     {
         if (((ICGridColumn)column).SubGrids != null)
         {
             var values = ((ICGridColumn)column).GetSubGridKeyValues(Item).Values.ToArray();
             var grid   = await((ICGridColumn)column).SubGrids(values, false, true, false, true) as ICGrid;
             _grids.Add(column.Name, CreateSubGridComponent(grid));
         }
     }
 }
        /// <summary>
        /// Adds the specified query.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="query">The query to consider.</param>
        /// <returns></returns>
        public IBdoDbModelBuilder AddQuery(string name, IDbQuery query)
        {
            if (query != null)
            {
                if (string.IsNullOrEmpty(name))
                {
                    name = query.GetName();
                }

                QueryDictionary.Remove(name);
                QueryDictionary.Add(name, DbFluent.StoredQuery(name, query));
            }
            return(this);
        }
Example #13
0
        protected override async Task OnParametersSetAsync()
        {
            AddEventHandlers();

            configs        = ConfigService.Configs.OrderByDescending(c => c.Metadata.LastModified).ToList();
            selectedConfig = ConfigService.SelectedConfig;

            Action <IGridColumnCollection <Config> > columns = c =>
            {
                c.Add(x => x.Metadata.Name).Titled(Loc["Name"]).Encoded(false).Sanitized(false)
                .RenderValueAs(x => $"<div class=\"grid-element-with-icon\"><img src=\"data:image/png;base64,{x.Metadata.Base64Image}\"/><span>{x.Metadata.Name}</span></div>");
                c.Add(x => x.Metadata.Author).Titled(Loc["Author"]);
                c.Add(x => x.Metadata.Category).Titled(Loc["Category"]);
                c.Add(x => x.IsRemote).Titled(Loc["Remote"]);
                c.Add(x => x.Settings.ProxySettings.UseProxies).Titled(Loc["Proxies"]);
                c.Add(x => x.Settings.DataSettings.AllowedWordlistTypesString).Titled(Loc["Wordlists"]);
                c.Add(x => x.Metadata.CreationDate).Titled(Loc["CreationDate"]);
                c.Add(x => x.Metadata.LastModified).Titled(Loc["LastModified"])
                .Sortable(true).SortInitialDirection(GridShared.Sorting.GridSortDirection.Descending);
            };

            var query = new QueryDictionary <StringValues>();

            query.Add("grid-page", "1");

            var client = new GridClient <Config>(q => GetGridRows(columns, q), query, false, "configsGrid", columns, CultureInfo.CurrentCulture)
                         .Sortable()
                         .ExtSortable()
                         .Filterable()
                         .WithMultipleFilters()
                         .SetKeyboard(true)
                         .ChangePageSize(true)
                         .WithGridItemsCount()
                         .Selectable(true, false, false);

            grid = client.Grid;

            // Try to set a previous filter
            if (VolatileSettings.GridQueries.ContainsKey("configsGrid"))
            {
                grid.Query = VolatileSettings.GridQueries["configsGrid"];
            }

            // Set new items to grid
            gridLoad = client.UpdateGrid();
            await gridLoad;
        }
Example #14
0
        protected override void OnParametersSet()
        {
            if (Grid.Settings.SortSettings.SortValues.Count > Values.Count)
            {
                _columnName   = Grid.Settings.SortSettings.SortValues.OrderBy(r => r.Id).ElementAt(Values.Count).ColumnName;
                _column       = Grid.Columns.SingleOrDefault(r => r.Name == _columnName);
                _columnValues = Grid.GetValuesToDisplay(_columnName, ItemsToDisplay).Distinct();

                Children = new QueryDictionary <GridGroupRowsComponent <T> >();
                foreach (object columnValue in _columnValues)
                {
                    var child = new GridGroupRowsComponent <T>();
                    child.IsVisible = true;
                    Children.Add(columnValue != null ? columnValue.ToString(): "", child);
                }
            }
        }
Example #15
0
        protected override async Task OnInitializedAsync()
        {
            Action <IGridColumnCollection <CircleViewModel> > columns = c =>
            {
                c.Add(o => o.Id).Titled("Id").Sortable(true);
                c.Add(o => o.Name).Titled("Name").Sortable(true);
                c.Add(o => o.NumberOfUsers).Sortable(true);
                c.Add(o => o.NumberOfMessages).Sortable(true);
            };

            var query = new QueryDictionary <StringValues>();

            query.Add("grid-page", "1");

            var client = new GridClient <CircleViewModel>(q => CirclesGridService.GetRows(columns, q), query, false, "ordersGrid", columns);

            Grid = client.Grid;

            // Set new items to grid
            Task = client.UpdateGrid();
            await Task;
        }
Example #16
0
        protected override async Task OnInitializedAsync()
        {
            Action <IGridColumnCollection <UserViewModel> > columns = c =>
            {
                c.Add(o => o.Id).Titled("Id").Sortable(true);
                c.Add(o => o.UserName).Titled("Name").Sortable(true);
                c.Add(o => o.Email).Titled("Email").Sortable(true);
                c.Add().Titled("Ambassador").Encoded(false).Sanitized(false).SetWidth(30).RenderComponentAs(typeof(AmbassadorCell));
            };

            var query = new QueryDictionary <StringValues>();

            query.Add("grid-page", "1");

            var client = new GridClient <UserViewModel>(q => UsersGridService.GetRows(columns, q), query, false, "usersGrid", columns);

            Grid = client.Grid;

            // Set new items to grid
            Task = client.UpdateGrid();
            await Task;
        }
Example #17
0
        protected override async Task OnParametersSetAsync()
        {
            _renderFragments = new QueryDictionary <RenderFragment>();
            foreach (var column in GridComponent.Grid.Columns)
            {
                // Name must have a non empty value
                if (string.IsNullOrWhiteSpace(column.Name))
                {
                    column.Name = Guid.NewGuid().ToString();
                }

                if (((ICGridColumn)column).SubGrids != null)
                {
                    var values = ((ICGridColumn)column).GetSubGridKeyValues(Item);
                    var grid   = await((ICGridColumn)column).SubGrids(values.Values.ToArray(), false, true, false, true) as ICGrid;
                    grid.Direction   = GridComponent.Grid.Direction;
                    grid.FixedValues = values;
                    VariableReference reference = new VariableReference();
                    if (Children.ContainsKey(column.Name))
                    {
                        Children[column.Name] = reference;
                    }
                    else
                    {
                        Children.Add(column.Name, reference);
                    }
                    if (_renderFragments.ContainsKey(column.Name))
                    {
                        _renderFragments[column.Name] = CreateSubGridComponent(grid, reference);
                    }
                    else
                    {
                        _renderFragments.Add(column.Name, CreateSubGridComponent(grid, reference));
                    }
                }
                else if (column.DeleteComponentType != null)
                {
                    VariableReference reference = new VariableReference();
                    if (Children.ContainsKey(column.Name))
                    {
                        Children[column.Name] = reference;
                    }
                    else
                    {
                        Children.Add(column.Name, reference);
                    }
                    if (_renderFragments.ContainsKey(column.Name))
                    {
                        _renderFragments[column.Name] = GridCellComponent <T> .CreateComponent(_sequence,
                                                                                               GridComponent, column.DeleteComponentType, column, Item, null, true, reference);
                    }
                    else
                    {
                        _renderFragments.Add(column.Name, GridCellComponent <T> .CreateComponent(_sequence,
                                                                                                 GridComponent, column.DeleteComponentType, column, Item, null, true, reference));
                    }
                }
            }
            _tabGroups = GridComponent.Grid.Columns
                         .Where(r => !string.IsNullOrWhiteSpace(r.TabGroup) && _renderFragments.Keys.Any(s => s.Equals(r.Name)))
                         .Select(r => r.TabGroup).Distinct();

            if (((CGrid <T>)GridComponent.Grid).ButtonCrudComponents != null && ((CGrid <T>)GridComponent.Grid).ButtonCrudComponents.Count() > 0)
            {
                foreach (var key in ((CGrid <T>)GridComponent.Grid).ButtonCrudComponents.Keys)
                {
                    var buttonCrudComponent = ((CGrid <T>)GridComponent.Grid).ButtonCrudComponents.Get(key);
                    if ((buttonCrudComponent.DeleteMode != null && buttonCrudComponent.DeleteMode(Item)) ||
                        (buttonCrudComponent.DeleteModeAsync != null && await buttonCrudComponent.DeleteModeAsync(Item)) ||
                        (buttonCrudComponent.GridMode.HasFlag(GridMode.Delete)))
                    {
                        _buttonCrudComponentVisibility.Add(key, true);
                    }
                    else
                    {
                        _buttonCrudComponentVisibility.Add(key, false);
                    }
                }
            }

            _shouldRender = true;
        }
Example #18
0
        protected override async Task OnParametersSetAsync()
        {
            _renderFragments = new QueryDictionary <RenderFragment>();
            foreach (var column in GridComponent.Grid.Columns)
            {
                // Name must have a non empty value
                if (string.IsNullOrWhiteSpace(column.Name))
                {
                    column.Name = Guid.NewGuid().ToString();
                }

                if (((ICGridColumn)column).SubGrids != null)
                {
                    var values = ((ICGridColumn)column).GetSubGridKeyValues(Item).Values.ToArray();
                    var grid   = await((ICGridColumn)column).SubGrids(values, false, true, false, false) as ICGrid;
                    grid.Direction = GridComponent.Grid.Direction;
                    VariableReference reference = new VariableReference();
                    if (Children.ContainsKey(column.Name))
                    {
                        Children[column.Name] = reference;
                    }
                    else
                    {
                        Children.Add(column.Name, reference);
                    }
                    if (_renderFragments.ContainsKey(column.Name))
                    {
                        _renderFragments[column.Name] = CreateSubGridComponent(grid, reference);
                    }
                    else
                    {
                        _renderFragments.Add(column.Name, CreateSubGridComponent(grid, reference));
                    }
                }
                else if (column.ReadComponentType != null)
                {
                    VariableReference reference = new VariableReference();
                    if (Children.ContainsKey(column.Name))
                    {
                        Children[column.Name] = reference;
                    }
                    else
                    {
                        Children.Add(column.Name, reference);
                    }
                    if (_renderFragments.ContainsKey(column.Name))
                    {
                        _renderFragments[column.Name] = GridCellComponent <T> .CreateComponent(_sequence,
                                                                                               GridComponent, column.ReadComponentType, column, Item, null, true, reference);
                    }
                    else
                    {
                        _renderFragments.Add(column.Name, GridCellComponent <T> .CreateComponent(_sequence,
                                                                                                 GridComponent, column.ReadComponentType, column, Item, null, true, reference));
                    }
                }
            }
            _tabGroups = GridComponent.Grid.Columns
                         .Where(r => !string.IsNullOrWhiteSpace(r.TabGroup) && _renderFragments.Keys.Any(s => s.Equals(r.Name)))
                         .Select(r => r.TabGroup).Distinct();

            _shouldRender = true;
        }