From b514e830f38fb1488d27557a88837f55e9b201db Mon Sep 17 00:00:00 2001 From: Adam Driscoll Date: Fri, 14 Jun 2019 13:54:28 -0600 Subject: [PATCH 01/19] Pagination. --- .../Components/ud-grid.jsx | 59 ++++++++++++++++--- .../Scripts/grid.ps1 | 3 +- .../Tests/grid.tests.ps1} | 29 +-------- 3 files changed, 56 insertions(+), 35 deletions(-) rename src/{UniversalDashboard.UITest/Integration/Grid.Tests.ps1 => UniversalDashboard.Materialize/Tests/grid.tests.ps1} (97%) diff --git a/src/UniversalDashboard.Materialize/Components/ud-grid.jsx b/src/UniversalDashboard.Materialize/Components/ud-grid.jsx index b11b40c6..d1d905d4 100644 --- a/src/UniversalDashboard.Materialize/Components/ud-grid.jsx +++ b/src/UniversalDashboard.Materialize/Components/ud-grid.jsx @@ -5,6 +5,8 @@ import ErrorCard from './error-card.jsx'; import UdLink from './ud-link.jsx'; import CustomCell from './custom-cell.jsx'; import {DebounceInput} from 'react-debounce-input'; +import { Dropdown, Button } from 'react-materialize'; +import UdIcon from './ud-icon.jsx'; function strMapToObj(strMap) { if (strMap == undefined) return null; @@ -182,6 +184,12 @@ export default class UdGrid extends React.Component { this.pubSubToken = UniversalDashboard.subscribe(this.props.id, this.onIncomingEvent.bind(this)); } + onPageChanged(x) { + this.setState({ + currentPage: x + }) + } + render() { if (this.state.hasError) { return [, ] @@ -225,7 +233,8 @@ export default class UdGrid extends React.Component { var gridPlugins = []; var serverSort, serverFilter, serverNext, serverPrev, serverGetPage, serverFilterControl; var components = { - SettingsToggle: () => + SettingsToggle: () => , + Pagination: () => } var serverFilterControl = @@ -235,8 +244,8 @@ export default class UdGrid extends React.Component { if (this.props.noFilter) { components = { - Filter: () => , - SettingsToggle: () => + ...components, + Filter: () => } } } else { @@ -252,8 +261,8 @@ export default class UdGrid extends React.Component { } components = { - Filter: () => , - SettingsToggle: () => + ...components, + Filter: () => } } @@ -261,11 +270,12 @@ export default class UdGrid extends React.Component {
{this.props.title} + {serverFilterControl} { this.state.loading ?
: rowDefinition ? - {rowDefinition} - :
No results found
} + , + ] + :
No results found
}
+ {actions}
); } +} + +class GridToolbar extends React.Component { + render() { + + var cursor = { + cursor: "pointer" + } + + var pagination = null; + if (!this.props.noPaging && this.props.totalPages > 1) { + var pages = []; + for(var i = 1; i <= this.props.totalPages; i++) { + pages.push(); + } + pagination = + } + + return ( +
+ ) + } +} + +class Page extends React.Component { + render() { + return
  • this.props.onPageChanged(this.props.page)}>{this.props.page}
  • + } } \ No newline at end of file diff --git a/src/UniversalDashboard.Materialize/Scripts/grid.ps1 b/src/UniversalDashboard.Materialize/Scripts/grid.ps1 index eafcf089..acd64e2c 100644 --- a/src/UniversalDashboard.Materialize/Scripts/grid.ps1 +++ b/src/UniversalDashboard.Materialize/Scripts/grid.ps1 @@ -37,8 +37,7 @@ function New-UDGrid { [Parameter()] [Switch]$AutoRefresh, [Parameter()] - [int]$RefreshInterval = 5 - + [int]$RefreshInterval = 5 ) End { diff --git a/src/UniversalDashboard.UITest/Integration/Grid.Tests.ps1 b/src/UniversalDashboard.Materialize/Tests/grid.tests.ps1 similarity index 97% rename from src/UniversalDashboard.UITest/Integration/Grid.Tests.ps1 rename to src/UniversalDashboard.Materialize/Tests/grid.tests.ps1 index 7c9d1713..50c06d37 100644 --- a/src/UniversalDashboard.UITest/Integration/Grid.Tests.ps1 +++ b/src/UniversalDashboard.Materialize/Tests/grid.tests.ps1 @@ -1,25 +1,3 @@ -param([Switch]$Release) - -$Env:Debug = -not $Release - -Import-Module "$PSScriptRoot\..\TestFramework.psm1" -Force -$ModulePath = Get-ModulePath -Release:$Release -$BrowserPort = Get-BrowserPort -Release:$Release - -Import-Module $ModulePath -Force - -Get-UDDashboard | Stop-UDDashboard - -$Server = Start-UDDashboard -Port 10001 -Dashboard $dashboard -$Driver = Start-SeFirefox - -function Set-TestDashboard { - param($Dashboard) - - $Server.DashboardService.SetDashboard($Dashboard) - Enter-SeUrl -Url "http://localhost:$BrowserPort" -Driver $Driver -} - Describe "Grid" { Context "simple grid" { @@ -365,6 +343,8 @@ Describe "Grid" { Set-TestDashboard -Dashboard $dashboard + Wait-Debugger + It "should not page when NoPaging set" { $Element = Find-SeElement -Id "NoPagingGrid" -Driver $Driver $Element = Find-SeElement -ClassName "griddle-row" -Driver $Element[0] @@ -497,7 +477,4 @@ Describe "Grid" { } -} - -Stop-SeDriver $Driver -Stop-UDDashboard -Server $Server \ No newline at end of file +} \ No newline at end of file From 3b26f3b8a58ad320185dcebee698e40327bdff7d Mon Sep 17 00:00:00 2001 From: Adam Driscoll Date: Tue, 18 Jun 2019 07:32:53 -0600 Subject: [PATCH 02/19] Formatting. --- .../Components/ud-grid.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/UniversalDashboard.Materialize/Components/ud-grid.jsx b/src/UniversalDashboard.Materialize/Components/ud-grid.jsx index d1d905d4..c2dc7f9a 100644 --- a/src/UniversalDashboard.Materialize/Components/ud-grid.jsx +++ b/src/UniversalDashboard.Materialize/Components/ud-grid.jsx @@ -5,7 +5,7 @@ import ErrorCard from './error-card.jsx'; import UdLink from './ud-link.jsx'; import CustomCell from './custom-cell.jsx'; import {DebounceInput} from 'react-debounce-input'; -import { Dropdown, Button } from 'react-materialize'; +import { Dropdown, Button, Row, Col } from 'react-materialize'; import UdIcon from './ud-icon.jsx'; function strMapToObj(strMap) { @@ -190,6 +190,10 @@ export default class UdGrid extends React.Component { }) } + onExportData() { + + } + render() { if (this.state.hasError) { return [, ] @@ -323,7 +327,7 @@ class GridToolbar extends React.Component { for(var i = 1; i <= this.props.totalPages; i++) { pages.push(); } - pagination =
      + pagination =
      • 1 ? cursor : {}}> this.props.activePage > 1 && this.props.onPageChanged(this.props.activePage - 1)}>
      • {pages}
      • this.props.activePage < this.props.totalPages && this.props.onPageChanged(this.props.activePage + 1)}>
      • @@ -331,7 +335,7 @@ class GridToolbar extends React.Component { } return ( -
        +