Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display indexed content fields in administration #9

Merged
merged 3 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Kentico.Xperience.Lucene/Admin/UIPages/IndexListing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@

PageConfiguration.ColumnConfigurations
.AddColumn(nameof(LuceneIndexStatisticsViewModel.Name), LocalizationService.GetString("integrations.lucene.listing.columns.name"), defaultSortDirection: SortTypeEnum.Asc, searchable: true)
.AddColumn(nameof(LuceneIndexStatisticsViewModel.Entries), LocalizationService.GetString("integrations.lucene.listing.columns.entries"))
//.AddColumn(nameof(LuceneIndexStatisticsViewModel.LastBuildTimes), LocalizationService.GetString("integrations.lucene.listing.columns.buildtime"))
.AddColumn(nameof(LuceneIndexStatisticsViewModel.UpdatedAt), LocalizationService.GetString("integrations.lucene.listing.columns.updatedat"));
.AddColumn(nameof(LuceneIndexStatisticsViewModel.Entries), LocalizationService.GetString("integrations.lucene.listing.columns.entries"));
//.AddColumn(nameof(LuceneIndexStatisticsViewModel.LastBuildTimes), LocalizationService.GetString("integrations.lucene.listing.columns.buildtime"))
//.AddColumn(nameof(LuceneIndexStatisticsViewModel.UpdatedAt), LocalizationService.GetString("integrations.lucene.listing.columns.updatedat"));

Check warning on line 74 in src/Kentico.Xperience.Lucene/Admin/UIPages/IndexListing.cs

View workflow job for this annotation

GitHub Actions / build

Remove this commented out code.
Copy link
Member

@seangwright seangwright Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this data available from Lucene? If not, can we remove this code from the repo?

(And also the LuceneIndexStatisticsViewModel.UpdatedAt property)


PageConfiguration.TableActions.AddCommand(LocalizationService.GetString("integrations.lucene.listing.commands.rebuild"), nameof(Rebuild), Icons.RotateRight);

Expand Down Expand Up @@ -209,13 +209,13 @@
Value = statistics.Entries.ToString()
},
//new StringCell
//{

Check warning on line 212 in src/Kentico.Xperience.Lucene/Admin/UIPages/IndexListing.cs

View workflow job for this annotation

GitHub Actions / build

Remove this commented out code.
// Value = statistics.LastBuildTimes.ToString()
//},
new StringCell
{
Value = statistics.UpdatedAt.ToString()
},
//new StringCell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're not using this, can it be removed? We have the git history if we need to recover it.

//{
// Value = statistics.UpdatedAt.ToString()
//},
new ActionCell
{
Actions = new List<Action>
Expand Down
57 changes: 48 additions & 9 deletions src/Kentico.Xperience.Lucene/Admin/UIPages/IndexedContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,13 @@
};


private static Row GetProperty(PropertyInfo property)
private Row GetProperty(PropertyInfo property)
{
//var isSearchable = Attribute.IsDefined(property, typeof(SearchableAttribute));
//var isRetrievable = Attribute.IsDefined(property, typeof(RetrievableAttribute));
//var isFacetable = Attribute.IsDefined(property, typeof(FacetableAttribute));

Check warning on line 116 in src/Kentico.Xperience.Lucene/Admin/UIPages/IndexedContent.cs

View workflow job for this annotation

GitHub Actions / build

Remove this commented out code.
// TODO: read from attributes
bool isSearchable = false;
bool isRetrievable = false;
var fieldAttribute = property.GetCustomAttributes<BaseFieldAttribute>(false).FirstOrDefault();
bool isSearchable = fieldAttribute != null;
string fieldType = fieldAttribute != null ? GetFieldType(fieldAttribute) : "-";
bool isStored = fieldAttribute?.Store ?? false;
bool hasSources = Attribute.IsDefined(property, typeof(SourceAttribute));
bool hasUrls = Attribute.IsDefined(property, typeof(MediaUrlsAttribute));
return new Row
Expand All @@ -142,12 +141,16 @@
Name = NamedComponentCellComponentNames.SIMPLE_STATUS_COMPONENT,
ComponentProps = new SimpleStatusNamedComponentCellProps
{
IconName = GetIconName(isRetrievable),
IconColor = GetIconColor(isRetrievable)
IconName = GetIconName(isStored),
IconColor = GetIconColor(isStored)
}
},
new StringCell
{
Value= fieldType,
},
//new NamedComponentCell
//{

Check warning on line 153 in src/Kentico.Xperience.Lucene/Admin/UIPages/IndexedContent.cs

View workflow job for this annotation

GitHub Actions / build

Remove this commented out code.
// Name = NamedComponentCellComponentNames.SIMPLE_STATUS_COMPONENT,
// ComponentProps = new SimpleStatusNamedComponentCellProps
// {
Expand Down Expand Up @@ -177,6 +180,37 @@
};
}

private string GetFieldType(BaseFieldAttribute attribute)
{
if (attribute is TextFieldAttribute)
{
return LocalizationService.GetString("integrations.lucene.content.fieldType.text");
}
else if (attribute is StringFieldAttribute)
{
return LocalizationService.GetString("integrations.lucene.content.fieldType.string");
}
else if (attribute is Int32FieldAttribute)
{
return LocalizationService.GetString("integrations.lucene.content.fieldType.int32");
}
else if (attribute is Int64FieldAttribute)
{
return LocalizationService.GetString("integrations.lucene.content.fieldType.int64");
}
else if (attribute is SingleFieldAttribute)
{
return LocalizationService.GetString("integrations.lucene.content.fieldType.single");
}
else if (attribute is DoubleFieldAttribute)
{
return LocalizationService.GetString("integrations.lucene.content.fieldType.double");
}
else
{
return "-";
}
}

private Column[] GetPropertyColumns() => new Column[] {
new Column
Expand All @@ -191,11 +225,16 @@
},
new Column
{
Caption = LocalizationService.GetString("integrations.lucene.content.columns.retrievable"),
Caption = LocalizationService.GetString("integrations.lucene.content.columns.stored"),
ContentType = ColumnContentType.Component
},
new Column
{
Caption = LocalizationService.GetString("integrations.lucene.content.columns.fieldType"),
ContentType = ColumnContentType.Component
},
//new Column
//{

Check warning on line 237 in src/Kentico.Xperience.Lucene/Admin/UIPages/IndexedContent.cs

View workflow job for this annotation

GitHub Actions / build

Remove this commented out code.
// Caption = LocalizationService.GetString("integrations.lucene.content.columns.facetable"),
// ContentType = ColumnContentType.Component
//},
Expand Down
24 changes: 24 additions & 0 deletions src/Kentico.Xperience.Lucene/Resources/LuceneResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
<data name="integrations.lucene.content.columns.facetable" xml:space="preserve">
<value>Facetable</value>
</data>
<data name="integrations.lucene.content.columns.fieldType" xml:space="preserve">
<value>Field type</value>
</data>
<data name="integrations.lucene.content.columns.pagetypes" xml:space="preserve">
<value>Content types</value>
</data>
Expand All @@ -147,9 +150,30 @@
<data name="integrations.lucene.content.columns.source" xml:space="preserve">
<value>Source</value>
</data>
<data name="integrations.lucene.content.columns.stored" xml:space="preserve">
<value>Stored</value>
</data>
<data name="integrations.lucene.content.columns.url" xml:space="preserve">
<value>URL</value>
</data>
<data name="integrations.lucene.content.fieldType.double" xml:space="preserve">
<value>Double</value>
</data>
<data name="integrations.lucene.content.fieldType.int32" xml:space="preserve">
<value>Int32</value>
</data>
<data name="integrations.lucene.content.fieldType.int64" xml:space="preserve">
<value>Int64</value>
</data>
<data name="integrations.lucene.content.fieldType.single" xml:space="preserve">
<value>Single</value>
</data>
<data name="integrations.lucene.content.fieldType.string" xml:space="preserve">
<value>String</value>
</data>
<data name="integrations.lucene.content.fieldType.text" xml:space="preserve">
<value>Text (tokenized string)</value>
</data>
<data name="integrations.lucene.content.multipletypes" xml:space="preserve">
<value>{0} content types</value>
</data>
Expand Down
Loading