Skip to content

Commit

Permalink
Add paginator addon into table widget (#701)
Browse files Browse the repository at this point in the history
* Add paginator addon into table widget

* Refactor

* Add unit tests

* Adjust ITableWidgetConfig + add some tests

* Paginator configuration prototype

* Add pageSize and pageSizeSet into configuration

* Add unit tests + minor changes

* Final fixes + small refactor

* Add documentation

* Fix failing build

* Minor fix

* Fix bad import

* PR review requests + better error handling

* Lint error + bad datasource

* Update imports
  • Loading branch information
erzik987 authored Jul 30, 2024
1 parent 887b136 commit e4efe53
Show file tree
Hide file tree
Showing 37 changed files with 1,742 additions and 65 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [15.0.8] 📅 2024-06-03

### Added

- `@nova-ui/dashboards` | Paginator added for table widget.

### Bugfix

- `@nova-ui/dashboards` | Added missing empty image for _nuiListWidgetComponent_ with no data.
Expand Down
11 changes: 8 additions & 3 deletions packages/dashboards/examples/src/components/docs/demo.files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export const DEMO_PATHS = [
"overview/overview-docs.component.html",
"overview/overview-docs.component.ts",
"overview/overview.module.ts",
"tutorials/customization/configurator-section/custom-configurator-section/custom-configurator-section.example.component.html",
"tutorials/customization/configurator-section/custom-configurator-section/custom-configurator-section.example.component.less",
"tutorials/customization/configurator-section/custom-configurator-section/custom-configurator-section.example.component.ts",
"tutorials/customization/configurator-section/custom-configurator-section-docs.component.html",
"tutorials/customization/configurator-section/custom-configurator-section-docs.component.ts",
"tutorials/customization/configurator-section/custom-configurator-section.example.component.html",
"tutorials/customization/configurator-section/custom-configurator-section.example.component.less",
"tutorials/customization/configurator-section/custom-configurator-section.example.component.ts",
"tutorials/customization/configurator-section/custom-configurator-section.module.ts",
"tutorials/customization/customization.module.ts",
"tutorials/customization/data-source-configurator/custom-data-source-configurator-docs.component.html",
Expand Down Expand Up @@ -164,6 +164,11 @@ export const DEMO_PATHS = [
"widget-types/table/table-widget-interactive/table-widget-interactive-example.component.html",
"widget-types/table/table-widget-interactive/table-widget-interactive-example.component.less",
"widget-types/table/table-widget-interactive/table-widget-interactive-example.component.ts",
"widget-types/table/table-widget-paginator/docs/table-paginator-docs.component.html",
"widget-types/table/table-widget-paginator/docs/table-paginator-docs.component.ts",
"widget-types/table/table-widget-paginator/example/table-widget-paginator-example.component.html",
"widget-types/table/table-widget-paginator/example/table-widget-paginator-example.component.less",
"widget-types/table/table-widget-paginator/example/table-widget-paginator-example.component.ts",
"widget-types/table/table-widget-search-example/docs/table-search-docs.component.html",
"widget-types/table/table-widget-search-example/docs/table-search-docs.component.ts",
"widget-types/table/table-widget-search-example/example/table-widget-search.example.component.html",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import { TableWidgetInteractiveExampleComponent } from "./table-widget-interacti
import { TableSearchDocsComponent } from "./table-widget-search-example/docs/table-search-docs.component";
import { TableWidgetSearchExampleComponent } from "./table-widget-search-example/example/table-widget-search.example.component";
import { TableWidgetExampleComponent } from "./table-widget/table-widget-example.component";
import { TablePaginatorDocsComponent } from "./table-widget-paginator/docs/table-paginator-docs.component";
import { TableWidgetPaginatorExampleComponent } from "./table-widget-paginator/example/table-widget-paginator-example.component";

const routes: Routes = [
{
Expand Down Expand Up @@ -71,6 +73,16 @@ const routes: Routes = [
showThemeSwitcher: true,
},
},
{
path: "table-paginator",
component: TablePaginatorDocsComponent,
data: {
srlc: {
hideIndicator: true,
},
showThemeSwitcher: true,
},
},
];

@NgModule({
Expand All @@ -85,9 +97,11 @@ const routes: Routes = [
declarations: [
TableDocsComponent,
TableSearchDocsComponent,
TablePaginatorDocsComponent,
TableWidgetInteractiveExampleComponent,
TableWidgetExampleComponent,
TableWidgetSearchExampleComponent,
TableWidgetPaginatorExampleComponent,
],
providers: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<h1>Table Widget with paginator</h1>

<p>
Table Widget can have pagination functionality. This page contains
information only about setting up the pagination, so before proceeding get
familiar with the following:
</p>
<ul>
<li>
<a
href="../additional-documentation/anatomy/data-sources.html"
target="_blank"
><code>Data Sources</code></a
>
- for information about Data Sources and their Features.
</li>
<li>
<a
href="../additional-documentation/widget-types/table.html"
target="_blank"
><code>Table Widget</code></a
>
- for configuring a table widget itself.
</li>
</ul>

<nui-example-wrapper
filenamePrefix="table-widget-paginator-example"
exampleTitle="Table widget with Paginator"
>
<table-widget-paginator-example></table-widget-paginator-example>
</nui-example-wrapper>

<h2>Configuring the Widget</h2>
<p>
To configure the widget you have to enable paginator in the widget
configuration:
</p>
<nui-example-code language="typescript">
{{ tableConfigurationText }}
</nui-example-code>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// © 2022 SolarWinds Worldwide, LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component } from "@angular/core";

@Component({
selector: "nui-table-paginator-docs",
templateUrl: "./table-paginator-docs.component.html",
})
export class TablePaginatorDocsComponent {
public tableConfigurationText = `
"table": {
...
properties: {
configuration: {
// define paginator configuration here
scrollType: ScrollType.paginator,
paginatorConfiguration: {
pageSize: 10, // Value have to be one of pageSizeSet values
pageSizeSet: [10, 20, 30],
},
// If not specified, default is set to
// pageSize: 10,
// pageSizeSet: [10, 20, 50],
hasVirtualScroll: false, // Has to be speciefied because of backward compatibility
} as ITableWidgetConfig,
},
},
`;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div class="mb-2 d-flex align-items-center">
<nui-switch class="ml-3 py-2" [(value)]="editMode" i18n>
Edit Mode
</nui-switch>
<button
*ngIf="!dashboard?.widgets['tableWidgetId']"
type="button"
displayStyle="action"
(click)="reInitializeDashboard()"
nui-button
>
Restore Widget
</button>
</div>

<div class="w-100 dashboard">
<!--
Note: The dashboard and gridsterConfig input assignments must use banana-in-a-box notation to keep
the dashboard state updated with changes to the pizzagna.
-->
<nui-dashboard
*ngIf="dashboard"
[(dashboard)]="dashboard"
[editMode]="editMode"
[(gridsterConfig)]="gridsterConfig"
nuiWidgetEditor
>
</nui-dashboard>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.dashboard {
height: 400px;
}
Loading

0 comments on commit e4efe53

Please sign in to comment.