diff --git a/src/UniversalDashboard.UITest/Integration/Page.Tests.ps1 b/src/UniversalDashboard.UITest/Integration/Page.Tests.ps1
index 1bd8d1b0..83294e58 100644
--- a/src/UniversalDashboard.UITest/Integration/Page.Tests.ps1
+++ b/src/UniversalDashboard.UITest/Integration/Page.Tests.ps1
@@ -6,9 +6,18 @@ $BrowserPort = Get-BrowserPort -Release:$Release
Import-Module $ModulePath -Force
-
Get-UDDashboard | Stop-UDDashboard
+$Driver = Start-SeFirefox
+$Server = Start-UDDashboard -Port 10001
+
+function Set-TestDashboard {
+ param($Dashboard)
+
+ $Server.DashboardService.SetDashboard($Dashboard)
+ Enter-SeUrl -Url "http://localhost:10000" -Driver $Driver
+}
+
Describe "New-UDPage" {
Context "cycling" {
@@ -22,19 +31,14 @@ Describe "New-UDPage" {
}
$dashboard = New-UDDashboard -Title "Test" -Pages @($Page1, $Page2) -CyclePages -CyclePagesInterval 2
- $Server = Start-UDDashboard -Port 10001 -Dashboard $dashboard
- $Driver = Start-SeFirefox
- Enter-SeUrl -Driver $Driver -Url "http://localhost:$BrowserPort"
- Start-Sleep 2
+
+ Set-TestDashboard -Dashboard $dashboard
It "should cycle dynamic pages" {
Find-SeElement -Id "Home" -Driver $Driver | Should not be $null
Start-Sleep 2
Find-SeElement -Id "Page" -Driver $Driver | Should not be $null
}
-
- Stop-SeDriver $Driver
- Stop-UDDashboard -Server $Server
}
Context "AutoReload" {
@@ -49,21 +53,45 @@ Describe "New-UDPage" {
$dashboard = New-UDDashboard -Title "Test" -Pages @($Page1, $Page2)
- $Server = Start-UDDashboard -Port 10001 -Dashboard $dashboard
- $Driver = Start-SeFirefox
- Enter-SeUrl -Driver $Driver -Url "http://localhost:$BrowserPort/mypage"
- Start-Sleep 2
+ Set-TestDashboard -Dashboard $dashboard
+
+ It "should autoreload" {
+
+ Enter-SeUrl -Driver $Driver -Url http://localhost:$BrowserPort/mypage
- It "should navigate to page with spaces" {
$ElementText = (Find-SeElement -Id "page-with-spaces" -Driver $Driver).Text
Start-Sleep 3
(Find-SeElement -Id "page-with-spaces" -Driver $Driver).Text | Should not be $ElementText
}
+ }
- Stop-SeDriver $Driver
- Stop-UDDashboard -Server $Server
+ Context "Titles" {
+
+ $Page1 = New-UDPage -Name "Home" -Content {
+ New-UDCard -Text "Home"
+ } -Title "My First Page"
+
+ $Page2 = New-UDPage -Url "/mypage" -Endpoint {
+ New-UDCard -Text (Get-Date) -Id "page-with-spaces"
+ }
+
+ $dashboard = New-UDDashboard -Title "Test" -Pages @($Page1, $Page2)
+
+ Set-TestDashboard -Dashboard $dashboard
+
+ Enter-SeUrl -Driver $Driver -Url "http://localhost:$BrowserPort/Home"
+ Start-Sleep 2
+
+ It "should have home page title" {
+ (Find-SeElement -Id "udtitle" -Driver $Driver).Text | should be "My First Page"
+
+ Enter-SeUrl -Driver $Driver -Url "http://localhost:$BrowserPort/mypage"
+ Start-Sleep 2
+
+ (Find-SeElement -Id "udtitle" -Driver $Driver).Text | should be "Test"
+ }
}
Context "multi-page" {
@@ -107,10 +135,7 @@ Describe "New-UDPage" {
}
$dashboard = New-UDDashboard -Title "Test" -Pages @($Page1, $Page2, $Page3, $Page5, $Page4, $Page7, $Page6, $Page8, $Page9)
- $Server = Start-UDDashboard -Port 10001 -Dashboard $dashboard
- $Driver = Start-SeFirefox
- Enter-SeUrl -Driver $Driver -Url "http://localhost:$BrowserPort"
- Start-Sleep 2
+ Set-TestDashboard -Dashboard $dashboard
It "should navigate to page with spaces" {
$Element = Find-SeElement -ClassName "menu-button" -Driver $Driver
@@ -182,9 +207,6 @@ Describe "New-UDPage" {
Enter-SeUrl -Driver $Driver -Url "http://localhost:$BrowserPort/somerandompage"
Find-SeElement -Id 'notfound' -Driver $Driver | Should not be $null
}
-
- Stop-SeDriver $Driver
- Stop-UDDashboard -Server $Server
}
Context "Page with DefaultHomePage parameter" {
@@ -198,10 +220,7 @@ Describe "New-UDPage" {
}
$dashboard = New-UDDashboard -Title "Test" -Pages @($Page1, $Page2)
- $Server = Start-UDDashboard -Port 10001 -Dashboard $dashboard
- $Driver = Start-SeFirefox
- Enter-SeUrl -Driver $Driver -Url "http://localhost:$BrowserPort"
- Start-Sleep 2
+ Set-TestDashboard -Dashboard $dashboard
it "First page should be the one with DefualtHomePage parameter set to true" {
Enter-SeUrl -Driver $Driver -Url "http://localhost:$BrowserPort"
@@ -220,9 +239,6 @@ Describe "New-UDPage" {
Start-Sleep 3
(Find-SeElement -Id 'Test-Page' -Driver $Driver).text | Should not be $HomePageText
}
-
- Stop-SeDriver $Driver
- Stop-UDDashboard -Server $Server
}
@@ -237,11 +253,7 @@ Describe "New-UDPage" {
}
$dashboard = New-UDDashboard -Title "Test" -Pages @($Page1, $Page2)
-
- $Server = Start-UDDashboard -Port 10001 -Dashboard $dashboard
- $Driver = Start-SeFirefox
- Enter-SeUrl -Driver $Driver -Url "http://localhost:$BrowserPort"
- Start-Sleep 2
+ Set-TestDashboard -Dashboard $dashboard
It "should navigate to page with hyphens" {
$Element = Find-SeElement -ClassName "menu-button" -Driver $Driver
@@ -262,8 +274,8 @@ Describe "New-UDPage" {
Start-Sleep 3
Find-SeElement -Id "page-with-hyphens" -Driver $Driver | Should not be $null
}
-
- Stop-SeDriver $Driver
- Stop-UDDashboard -Server $Server
}
}
+
+Stop-SeDriver $Driver
+Stop-UDDashboard -Server $Server
\ No newline at end of file
diff --git a/src/UniversalDashboard/Cmdlets/NewPageCommand.cs b/src/UniversalDashboard/Cmdlets/NewPageCommand.cs
index 0cdb2f1a..e478cd9f 100644
--- a/src/UniversalDashboard/Cmdlets/NewPageCommand.cs
+++ b/src/UniversalDashboard/Cmdlets/NewPageCommand.cs
@@ -26,6 +26,9 @@ public class NewPageCommand : CallbackCmdlet
[Parameter(Position = 3)]
public SwitchParameter DefaultHomePage { get; set; }
+ [Parameter(Position = 4)]
+ public string Title { get; set; }
+
protected override void EndProcessing()
{
var page = new Page();
@@ -36,6 +39,7 @@ protected override void EndProcessing()
page.DefaultHomePage = DefaultHomePage;
page.AutoRefresh = AutoRefresh;
page.RefreshInterval = RefreshInterval;
+ page.Title = Title;
if (Content != null && Endpoint != null) {
throw new Exception("Content and Endpoint cannot both be specified.");
diff --git a/src/UniversalDashboard/Models/Page.cs b/src/UniversalDashboard/Models/Page.cs
index 21189adb..3a1bbe8f 100644
--- a/src/UniversalDashboard/Models/Page.cs
+++ b/src/UniversalDashboard/Models/Page.cs
@@ -25,5 +25,8 @@ public class Page : Component
[JsonProperty("dynamic")]
public bool Dynamic { get; set; }
+
+ [JsonProperty("title")]
+ public string Title { get; set; }
}
}
diff --git a/src/client/src/app/ud-dashboard.jsx b/src/client/src/app/ud-dashboard.jsx
index 978fe6ef..1844c405 100644
--- a/src/client/src/app/ud-dashboard.jsx
+++ b/src/client/src/app/ud-dashboard.jsx
@@ -36,7 +36,8 @@ export default class UdDashboard extends React.Component {
location: null,
authenticated: false,
sessionId: '',
- design: false
+ design: false,
+ title: ''
}
}
@@ -218,7 +219,8 @@ export default class UdDashboard extends React.Component {
loading: false,
sessionId: json.sessionId,
authenticated: json.authenticated,
- design: dashboard.design
+ design: dashboard.design,
+ title: dashboard.title
});
}.bind(this), this.props.history);
@@ -282,6 +284,12 @@ export default class UdDashboard extends React.Component {
return
}
}
+
+ onTitleChanged(title) {
+ this.setState({
+ title
+ })
+ }
render() {
if (this.state.hasError) {
@@ -296,6 +304,7 @@ export default class UdDashboard extends React.Component {
}
+ var _this = this;
var dynamicPages = this.state.dashboard.pages.map(function(x) {
if (!x.dynamic) return null;
@@ -303,16 +312,16 @@ export default class UdDashboard extends React.Component {
x.url = "/" + x.url;
}
- return (
-
+ return (
+
)} />
})
var staticPages = this.state.dashboard.pages.map(function(x) {
if (x.dynamic) return null;
- return (
-
+ return (
+
)} />
})
@@ -320,7 +329,7 @@ export default class UdDashboard extends React.Component {
- {logo} {this.props.text}
+ {logo} {this.props.text}
{
this.props.authenticated ?
diff --git a/src/client/src/app/ud-page.jsx b/src/client/src/app/ud-page.jsx
index 7b96097a..5ffd6877 100644
--- a/src/client/src/app/ud-page.jsx
+++ b/src/client/src/app/ud-page.jsx
@@ -24,6 +24,13 @@ export default class UdPage extends React.Component {
this.loadData();
}
+ componentDidMount() {
+ if (this.props.title) {
+ document.title = this.props.title;
+ this.props.onTitleChanged(this.props.title);
+ }
+ }
+
loadData() {
if (this.props.dynamic) {
this.loadDynamicPage();