Skip to content

Commit 92f4a0b

Browse files
authored
feat (#129): add auto-expand dropdowns UI option (#134)
1 parent 0ae7a16 commit 92f4a0b

File tree

13 files changed

+133
-110
lines changed

13 files changed

+133
-110
lines changed

samples/WebApi/WebApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<!-- Serilog UI packages -->
2323
<ItemGroup>
2424
<!-- comment/uncomment to directly reference Nuget release
25-
<PackageReference Include="Serilog.UI" Version="3.0.0"/>
25+
<PackageReference Include="Serilog.UI" Version="3.0.1"/>
2626
<PackageReference Include="Serilog.UI.MsSqlServerProvider" Version="3.0.0"/>
2727
<PackageReference Include="Serilog.UI.ElasticSearchProvider" Version="3.0.0"/>
2828
-->

samples/WebApp/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
app.UseSerilogUi(options => options
4040
.WithHomeUrl("/#Test")
4141
.WithAuthenticationType(AuthenticationType.Jwt)
42+
.WithExpandedDropdownsByDefault()
4243
.EnableAuthorizationOnAppRoutes()
4344
.InjectJavascript("/js/serilog-ui/custom.js")
4445
);

samples/WebApp/WebApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<!-- Serilog UI packages -->
3939
<ItemGroup>
4040
<!-- comment/uncomment to directly reference Nuget release
41-
<PackageReference Include="Serilog.UI" Version="3.0.0"/>
41+
<PackageReference Include="Serilog.UI" Version="3.0.1"/>
4242
<PackageReference Include="Serilog.UI.MongoDbProvider" Version="3.0.0"/>
4343
-->
4444

src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ private async Task<string> LoadStream(Stream stream, UiOptions options)
7777
options.HomeUrl,
7878
BlockHomeAccess,
7979
options.RoutePrefix,
80+
options.ExpandDropdownsByDefault
8081
};
8182
var encodeAuthOpts = Uri.EscapeDataString(JsonSerializer.Serialize(feOpts, JsonSerializerOptions));
8283

src/Serilog.Ui.Web/Models/UiOptions.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public class UiOptions(ProvidersOptions options)
2929
/// <value>The route prefix.</value>
3030
public string RoutePrefix { get; private set; } = "serilog-ui";
3131

32+
/// <summary>
33+
/// Get the option to auto-expand dropdowns in the log viewer.
34+
/// </summary>
35+
public bool ExpandDropdownsByDefault { get; private set; }
36+
3237
/// <summary>
3338
/// Sets the type of the authentication.
3439
/// </summary>
@@ -56,6 +61,16 @@ public UiOptions HideSerilogUiBrand()
5661
return this;
5762
}
5863

64+
/// <summary>
65+
/// Sets the expand dropdowns by default property to true.
66+
/// </summary>
67+
public UiOptions WithExpandedDropdownsByDefault()
68+
{
69+
ExpandDropdownsByDefault = true;
70+
return this;
71+
}
72+
73+
5974
/// <summary>
6075
/// Injects additional CSS stylesheets into the index.html page.
6176
/// Each call to the method adds a stylesheet entry.

src/Serilog.Ui.Web/Serilog.Ui.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<PackageId>Serilog.UI</PackageId>
55
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
66
<LangVersion>latest</LangVersion>
7-
<Version>3.0.0</Version>
7+
<Version>3.0.1</Version>
88
</PropertyGroup>
99

1010
<ItemGroup>

src/Serilog.Ui.Web/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
},
1616
"dependencies": {
1717
"@fontsource/mononoki": "^5.0.11",
18-
"@mantine/core": "^7.12.0",
19-
"@mantine/dates": "^7.12.0",
20-
"@mantine/hooks": "^7.12.0",
21-
"@mantine/notifications": "^7.12.0",
18+
"@mantine/core": "^7.12.1",
19+
"@mantine/dates": "^7.12.1",
20+
"@mantine/hooks": "^7.12.1",
21+
"@mantine/notifications": "^7.12.1",
2222
"@tabler/icons-react": "^3.12.0",
2323
"@tanstack/react-query": "^5.51.23",
2424
"dayjs": "^1.11.12",
@@ -35,7 +35,7 @@
3535
"@testing-library/jest-dom": "^6.4.8",
3636
"@testing-library/react": "^16.0.0",
3737
"@testing-library/user-event": "^14.5.2",
38-
"@types/node": "^22.2.0",
38+
"@types/node": "^22.3.0",
3939
"@types/react": "^18.3.3",
4040
"@types/react-dom": "^18.3.0",
4141
"@vitejs/plugin-react-swc": "^3.7.0",
@@ -51,7 +51,7 @@
5151
"eslint-plugin-promise": "^7.1.0",
5252
"eslint-plugin-react": "^7.35.0",
5353
"eslint-plugin-react-hooks": "^4.6.2",
54-
"eslint-plugin-testing-library": "^6.2.2",
54+
"eslint-plugin-testing-library": "^6.3.0",
5555
"eslint-plugin-vitest": "^0.5.4",
5656
"eslint-plugin-vitest-globals": "^1.5.0",
5757
"happy-dom": "^14.12.3",
@@ -64,7 +64,7 @@
6464
"shiki": "^1.12.1",
6565
"testing-library-selector": "^0.3.1",
6666
"typescript": "^5.5.4",
67-
"typescript-eslint": "^8.0.1",
67+
"typescript-eslint": "^8.1.0",
6868
"vite": "^5.4.0",
6969
"vite-plugin-checker": "^0.7.2",
7070
"vite-plugin-mkcert": "^1.17.5",

src/Serilog.Ui.Web/src/app/components/Table/PropertiesModal.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const PropertiesModal = ({
4444
radius="sm"
4545
size="xl"
4646
closeButtonProps={{ 'aria-label': 'close-properties-modal' }}
47-
title="Additional Columns"
47+
title="Enrichment Data"
4848
overlayProps={overlayProps(colorScheme, theme.colors)}
4949
>
5050
<Box display="grid" style={boxGridProperties}>
@@ -73,16 +73,17 @@ const RenderProps = memo(
7373
prop: unknown;
7474
logPropertyType: string;
7575
}) => {
76-
const { isUtc } = useSerilogUiProps();
76+
const { expandDropdownsByDefault, isUtc } = useSerilogUiProps();
7777
const { additionalColumn, removeProperties } = useColumnsInfo(name, logPropertyType);
7878

7979
if (!additionalColumn) return null;
8080

8181
const propertyName = capitalize(name);
82+
const defaultAccordionValue = expandDropdownsByDefault ? propertyName : null;
8283

8384
if (additionalColumn.codeType && !removeProperties) {
8485
return (
85-
<Accordion style={{ order: 1 }}>
86+
<Accordion defaultValue={defaultAccordionValue} style={{ order: 1 }}>
8687
<Accordion.Item value={propertyName}>
8788
<Accordion.Control icon={<IconCodeDots />}>{propertyName}</Accordion.Control>
8889
<Accordion.Panel>

src/Serilog.Ui.Web/src/app/components/Table/SerilogResults.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const TableHead = memo(() => {
106106
{!removeException && (
107107
<TableHeader text="Exception" columnType={ColumnType.code} />
108108
)}
109-
<TableHeader text="Additional Columns" columnType={ColumnType.code} />
109+
<TableHeader text="Enrichment Data" columnType={ColumnType.code} />
110110
</Table.Tr>
111111
</Table.Thead>
112112
);

src/Serilog.Ui.Web/src/types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export interface SerilogUiConfig {
101101
routePrefix?: string;
102102
homeUrl?: string;
103103
showBrand?: boolean;
104+
expandDropdownsByDefault?: boolean;
104105
blockHomeAccess?: boolean;
105106
disabledSortOnKeys?: string[];
106107
columnsInfo?: ColumnsInfo;

0 commit comments

Comments
 (0)