Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b415d826
Commit
b415d826
authored
Nov 02, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed to template PR issues, #13938
parent
70bb81c6
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
89 additions
and
8 deletions
+89
-8
pkg/middleware/middleware_test.go
+1
-0
pkg/middleware/recovery.go
+1
-1
pkg/middleware/recovery_test.go
+4
-0
pkg/models/context.go
+1
-1
pkg/setting/setting.go
+4
-0
public/app/features/dashboard/specs/panel_model.test.ts
+72
-0
public/views/error-template.html
+0
-0
public/views/index-template.html
+0
-0
scripts/webpack/webpack.common.js
+1
-1
scripts/webpack/webpack.dev.js
+2
-2
scripts/webpack/webpack.hot.js
+1
-1
scripts/webpack/webpack.prod.js
+2
-2
No files found.
pkg/middleware/middleware_test.go
View file @
b415d826
...
...
@@ -18,6 +18,7 @@ import (
)
func
TestMiddlewareContext
(
t
*
testing
.
T
)
{
setting
.
ERR_TEMPLATE_NAME
=
"error-template"
Convey
(
"Given the grafana middleware"
,
t
,
func
()
{
middlewareScenario
(
"middleware should add context to injector"
,
func
(
sc
*
scenarioContext
)
{
...
...
pkg/middleware/recovery.go
View file @
b415d826
...
...
@@ -138,7 +138,7 @@ func Recovery() macaron.Handler {
c
.
JSON
(
500
,
resp
)
}
else
{
c
.
HTML
(
500
,
"error"
)
c
.
HTML
(
500
,
setting
.
ERR_TEMPLATE_NAME
)
}
}
}()
...
...
pkg/middleware/recovery_test.go
View file @
b415d826
...
...
@@ -8,11 +8,14 @@ import (
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/session"
"github.com/grafana/grafana/pkg/setting"
.
"github.com/smartystreets/goconvey/convey"
"gopkg.in/macaron.v1"
)
func
TestRecoveryMiddleware
(
t
*
testing
.
T
)
{
setting
.
ERR_TEMPLATE_NAME
=
"error-template"
Convey
(
"Given an api route that panics"
,
t
,
func
()
{
apiURL
:=
"/api/whatever"
recoveryScenario
(
"recovery middleware should return json"
,
apiURL
,
func
(
sc
*
scenarioContext
)
{
...
...
@@ -50,6 +53,7 @@ func recoveryScenario(desc string, url string, fn scenarioFunc) {
sc
:=
&
scenarioContext
{
url
:
url
,
}
viewsPath
,
_
:=
filepath
.
Abs
(
"../../public/views"
)
sc
.
m
=
macaron
.
New
()
...
...
pkg/models/context.go
View file @
b415d826
...
...
@@ -36,7 +36,7 @@ func (ctx *ReqContext) Handle(status int, title string, err error) {
ctx
.
Data
[
"AppSubUrl"
]
=
setting
.
AppSubUrl
ctx
.
Data
[
"Theme"
]
=
"dark"
ctx
.
HTML
(
status
,
"error"
)
ctx
.
HTML
(
status
,
setting
.
ERR_TEMPLATE_NAME
)
}
func
(
ctx
*
ReqContext
)
JsonOK
(
message
string
)
{
...
...
pkg/setting/setting.go
View file @
b415d826
...
...
@@ -39,6 +39,10 @@ const (
)
var
(
ERR_TEMPLATE_NAME
=
"error"
)
var
(
// App settings.
Env
=
DEV
AppUrl
string
...
...
public/app/features/dashboard/specs/panel_model.test.ts
0 → 100644
View file @
b415d826
import
_
from
'lodash'
;
import
{
PanelModel
}
from
'../panel_model'
;
describe
(
'PanelModel'
,
()
=>
{
describe
(
'when creating new panel model'
,
()
=>
{
let
model
;
beforeEach
(()
=>
{
model
=
new
PanelModel
({});
});
it
(
'should apply defaults'
,
()
=>
{
expect
(
model
.
gridPos
.
h
).
toBe
(
3
);
});
it
(
'getSaveModel should remove defaults'
,
()
=>
{
const
saveModel
=
model
.
getSaveModel
();
expect
(
saveModel
.
gridPos
).
toBe
(
undefined
);
});
it
(
'getSaveModel should remove nonPersistedProperties'
,
()
=>
{
const
saveModel
=
model
.
getSaveModel
();
expect
(
saveModel
.
events
).
toBe
(
undefined
);
});
describe
(
'when calling applyDefaults'
,
()
=>
{
beforeEach
(()
=>
{
const
defaults
=
{
myName
:
'My name'
,
myBool1
:
true
,
myBool2
:
false
,
myNumber
:
0
,
nestedObj
:
{
myName
:
'nested name'
,
myBool1
:
true
,
myBool2
:
false
,
myNumber
:
0
,
},
};
model
.
applyDefaults
(
defaults
);
});
it
(
'Should apply defaults'
,
()
=>
{
expect
(
model
.
myName
).
toBe
(
'My name'
);
expect
(
model
.
myBool1
).
toBe
(
true
);
expect
(
model
.
myBool2
).
toBe
(
false
);
expect
(
model
.
myNumber
).
toBe
(
0
);
expect
(
model
.
nestedObj
.
myName
).
toBe
(
'nested name'
);
expect
(
model
.
nestedObj
.
myBool1
).
toBe
(
true
);
expect
(
model
.
nestedObj
.
myBool2
).
toBe
(
false
);
expect
(
model
.
nestedObj
.
myNumber
).
toBe
(
0
);
});
it
(
'getSaveModel should remove them'
,
()
=>
{
const
saveModel
=
model
.
getSaveModel
();
expect
(
saveModel
.
myName
).
toBe
(
undefined
);
expect
(
saveModel
.
nestedObj
).
toBe
(
undefined
);
});
it
(
'getSaveModel should remove only unchanged defaults'
,
()
=>
{
model
.
myName
=
'changed'
;
model
.
nestedObj
.
myBool2
=
true
;
const
saveModel
=
model
.
getSaveModel
();
expect
(
saveModel
.
myName
).
toBe
(
'changed'
);
expect
(
saveModel
.
nestedObj
.
myBool2
).
toBe
(
true
);
expect
(
saveModel
.
nestedObj
.
myBool1
).
toBe
(
undefined
);
});
});
});
});
public/views/error
.
template.html
→
public/views/error
-
template.html
View file @
b415d826
File moved
public/views/index
.
template.html
→
public/views/index
-
template.html
View file @
b415d826
File moved
scripts/webpack/webpack.common.js
View file @
b415d826
...
...
@@ -47,7 +47,7 @@ module.exports = {
},
{
test
:
/
\.
html$/
,
exclude
:
/
(
index|error
)\
.
template
\.
html/
,
exclude
:
/
(
index|error
)\
-
template
\.
html/
,
use
:
[
{
loader
:
'ngtemplate-loader?relativeTo='
+
(
path
.
resolve
(
__dirname
,
'../../public'
))
+
'&prefix=public'
},
{
...
...
scripts/webpack/webpack.dev.js
View file @
b415d826
...
...
@@ -84,12 +84,12 @@ module.exports = merge(common, {
}),
new
HtmlWebpackPlugin
({
filename
:
path
.
resolve
(
__dirname
,
'../../public/views/error.html'
),
template
:
path
.
resolve
(
__dirname
,
'../../public/views/error
.
template.html'
),
template
:
path
.
resolve
(
__dirname
,
'../../public/views/error
-
template.html'
),
inject
:
'false'
,
}),
new
HtmlWebpackPlugin
({
filename
:
path
.
resolve
(
__dirname
,
'../../public/views/index.html'
),
template
:
path
.
resolve
(
__dirname
,
'../../public/views/index
.
template.html'
),
template
:
path
.
resolve
(
__dirname
,
'../../public/views/index
-
template.html'
),
inject
:
'body'
,
chunks
:
[
'manifest'
,
'vendor'
,
'app'
],
}),
...
...
scripts/webpack/webpack.hot.js
View file @
b415d826
...
...
@@ -87,7 +87,7 @@ module.exports = merge(common, {
new
CleanWebpackPlugin
(
'../public/build'
,
{
allowExternal
:
true
}),
new
HtmlWebpackPlugin
({
filename
:
path
.
resolve
(
__dirname
,
'../../public/views/index.html'
),
template
:
path
.
resolve
(
__dirname
,
'../../public/views/index
.
template.html'
),
template
:
path
.
resolve
(
__dirname
,
'../../public/views/index
-
template.html'
),
inject
:
'body'
,
alwaysWriteToDisk
:
true
}),
...
...
scripts/webpack/webpack.prod.js
View file @
b415d826
...
...
@@ -76,13 +76,13 @@ module.exports = merge(common, {
new
ngAnnotatePlugin
(),
new
HtmlWebpackPlugin
({
filename
:
path
.
resolve
(
__dirname
,
'../../public/views/index.html'
),
template
:
path
.
resolve
(
__dirname
,
'../../public/views/index
.
template.html'
),
template
:
path
.
resolve
(
__dirname
,
'../../public/views/index
-
template.html'
),
inject
:
'body'
,
chunks
:
[
'vendor'
,
'app'
],
}),
new
HtmlWebpackPlugin
({
filename
:
path
.
resolve
(
__dirname
,
'../../public/views/error.html'
),
template
:
path
.
resolve
(
__dirname
,
'../../public/views/error
.
template.html'
),
template
:
path
.
resolve
(
__dirname
,
'../../public/views/error
-
template.html'
),
inject
:
false
,
}),
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment