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
cef910dd
Commit
cef910dd
authored
Feb 01, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '7883_new_url_structure' of github.com:grafana/grafana into 7883_new_url_structure
parents
3db328f5
3b4e4876
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
76 additions
and
32 deletions
+76
-32
pkg/api/alerting.go
+2
-1
pkg/models/dashboards.go
+21
-1
pkg/services/alerting/eval_context.go
+25
-22
pkg/services/alerting/notifier.go
+2
-2
pkg/services/sqlstore/dashboard.go
+22
-2
public/app/containers/AlertRuleList/AlertRuleList.jest.tsx
+1
-1
public/app/containers/AlertRuleList/AlertRuleList.tsx
+1
-1
public/app/containers/AlertRuleList/__snapshots__/AlertRuleList.jest.tsx.snap
+2
-2
No files found.
pkg/api/alerting.go
View file @
cef910dd
...
...
@@ -105,7 +105,8 @@ func transformToDTOs(alerts []*models.Alert, c *middleware.Context) ([]*dtos.Ale
for
_
,
alert
:=
range
alertDTOs
{
for
_
,
dash
:=
range
dashboardsQuery
.
Result
{
if
alert
.
DashboardId
==
dash
.
Id
{
alert
.
DashbboardUri
=
"db/"
+
dash
.
Slug
alert
.
DashbboardUri
=
dash
.
GenerateUrl
()
break
}
}
}
...
...
pkg/models/dashboards.go
View file @
cef910dd
...
...
@@ -162,6 +162,11 @@ func (dash *Dashboard) GetUrl() string {
return
GetDashboardFolderUrl
(
dash
.
IsFolder
,
dash
.
Uid
,
dash
.
Slug
)
}
// Return the html url for a dashboard
func
(
dash
*
Dashboard
)
GenerateUrl
()
string
{
return
GetDashboardUrl
(
dash
.
Uid
,
dash
.
Slug
)
}
// GetDashboardFolderUrl return the html url for a folder if it's folder, otherwise for a dashboard
func
GetDashboardFolderUrl
(
isFolder
bool
,
uid
string
,
slug
string
)
string
{
if
isFolder
{
...
...
@@ -171,11 +176,16 @@ func GetDashboardFolderUrl(isFolder bool, uid string, slug string) string {
return
GetDashboardUrl
(
uid
,
slug
)
}
//
GetDashboardUrl r
eturn the html url for a dashboard
//
R
eturn the html url for a dashboard
func
GetDashboardUrl
(
uid
string
,
slug
string
)
string
{
return
fmt
.
Sprintf
(
"%s/d/%s/%s"
,
setting
.
AppSubUrl
,
uid
,
slug
)
}
// Return the full url for a dashboard
func
GetFullDashboardUrl
(
uid
string
,
slug
string
)
string
{
return
fmt
.
Sprintf
(
"%s%s"
,
setting
.
AppUrl
,
GetDashboardUrl
(
uid
,
slug
))
}
// GetFolderUrl return the html url for a folder
func
GetFolderUrl
(
folderUid
string
,
slug
string
)
string
{
return
fmt
.
Sprintf
(
"%s/dashboards/f/%s/%s"
,
setting
.
AppSubUrl
,
folderUid
,
slug
)
...
...
@@ -277,3 +287,13 @@ type DashboardPermissionForUser struct {
Permission
PermissionType
`json:"permission"`
PermissionName
string
`json:"permissionName"`
}
type
DashboardRef
struct
{
Uid
string
Slug
string
}
type
GetDashboardUIDByIdQuery
struct
{
Id
int64
Result
*
DashboardRef
}
pkg/services/alerting/eval_context.go
View file @
cef910dd
...
...
@@ -12,17 +12,19 @@ import (
)
type
EvalContext
struct
{
Firing
bool
IsTestRun
bool
EvalMatches
[]
*
EvalMatch
Logs
[]
*
ResultLogEntry
Error
error
ConditionEvals
string
StartTime
time
.
Time
EndTime
time
.
Time
Rule
*
Rule
log
log
.
Logger
dashboardSlug
string
Firing
bool
IsTestRun
bool
EvalMatches
[]
*
EvalMatch
Logs
[]
*
ResultLogEntry
Error
error
ConditionEvals
string
StartTime
time
.
Time
EndTime
time
.
Time
Rule
*
Rule
log
log
.
Logger
dashboardRef
*
m
.
DashboardRef
ImagePublicUrl
string
ImageOnDiskPath
string
NoDataFound
bool
...
...
@@ -83,29 +85,30 @@ func (c *EvalContext) GetNotificationTitle() string {
return
"["
+
c
.
GetStateModel
()
.
Text
+
"] "
+
c
.
Rule
.
Name
}
func
(
c
*
EvalContext
)
GetDashboard
Slug
()
(
string
,
error
)
{
if
c
.
dashboard
Slug
!=
""
{
return
c
.
dashboard
Slug
,
nil
func
(
c
*
EvalContext
)
GetDashboard
UID
()
(
*
m
.
DashboardRef
,
error
)
{
if
c
.
dashboard
Ref
!=
nil
{
return
c
.
dashboard
Ref
,
nil
}
slugQuery
:=
&
m
.
GetDashboardSlug
ByIdQuery
{
Id
:
c
.
Rule
.
DashboardId
}
if
err
:=
bus
.
Dispatch
(
slug
Query
);
err
!=
nil
{
return
""
,
err
uidQuery
:=
&
m
.
GetDashboardUID
ByIdQuery
{
Id
:
c
.
Rule
.
DashboardId
}
if
err
:=
bus
.
Dispatch
(
uid
Query
);
err
!=
nil
{
return
nil
,
err
}
c
.
dashboard
Slug
=
slug
Query
.
Result
return
c
.
dashboard
Slug
,
nil
c
.
dashboard
Ref
=
uid
Query
.
Result
return
c
.
dashboard
Ref
,
nil
}
const
urlFormat
=
"%s?fullscreen=true&edit=true&tab=alert&panelId=%d&orgId=%d"
func
(
c
*
EvalContext
)
GetRuleUrl
()
(
string
,
error
)
{
if
c
.
IsTestRun
{
return
setting
.
AppUrl
,
nil
}
if
slug
,
err
:=
c
.
GetDashboardSlug
();
err
!=
nil
{
if
ref
,
err
:=
c
.
GetDashboardUID
();
err
!=
nil
{
return
""
,
err
}
else
{
ruleUrl
:=
fmt
.
Sprintf
(
"%sdashboard/db/%s?fullscreen&edit&tab=alert&panelId=%d&orgId=%d"
,
setting
.
AppUrl
,
slug
,
c
.
Rule
.
PanelId
,
c
.
Rule
.
OrgId
)
return
ruleUrl
,
nil
return
fmt
.
Sprintf
(
urlFormat
,
m
.
GetFullDashboardUrl
(
ref
.
Uid
,
ref
.
Slug
),
c
.
Rule
.
PanelId
,
c
.
Rule
.
OrgId
),
nil
}
}
pkg/services/alerting/notifier.go
View file @
cef910dd
...
...
@@ -87,10 +87,10 @@ func (n *notificationService) uploadImage(context *EvalContext) (err error) {
IsAlertContext
:
true
,
}
if
slug
,
err
:=
context
.
GetDashboardSlug
();
err
!=
nil
{
if
ref
,
err
:=
context
.
GetDashboardUID
();
err
!=
nil
{
return
err
}
else
{
renderOpts
.
Path
=
fmt
.
Sprintf
(
"d
ashboard-solo/db/%s?&panelId=%d"
,
s
lug
,
context
.
Rule
.
PanelId
)
renderOpts
.
Path
=
fmt
.
Sprintf
(
"d
-solo/%s/%s?panelId=%d"
,
ref
.
Uid
,
ref
.
S
lug
,
context
.
Rule
.
PanelId
)
}
if
imagePath
,
err
:=
renderer
.
RenderToPng
(
renderOpts
);
err
!=
nil
{
...
...
pkg/services/sqlstore/dashboard.go
View file @
cef910dd
...
...
@@ -19,9 +19,11 @@ func init() {
bus
.
AddHandler
(
"sql"
,
SearchDashboards
)
bus
.
AddHandler
(
"sql"
,
GetDashboardTags
)
bus
.
AddHandler
(
"sql"
,
GetDashboardSlugById
)
bus
.
AddHandler
(
"sql"
,
GetDashboardUIDById
)
bus
.
AddHandler
(
"sql"
,
GetDashboardsByPluginId
)
bus
.
AddHandler
(
"sql"
,
GetFoldersForSignedInUser
)
bus
.
AddHandler
(
"sql"
,
GetDashboardPermissionsForUser
)
bus
.
AddHandler
(
"sql"
,
GetDashboardsBySlug
)
}
var
generateNewUid
func
()
string
=
util
.
GenerateShortUid
...
...
@@ -159,6 +161,7 @@ func SaveDashboard(cmd *m.SaveDashboardCommand) error {
return
err
})
}
func
generateNewDashboardUid
(
sess
*
DBSession
,
orgId
int64
)
(
string
,
error
)
{
for
i
:=
0
;
i
<
3
;
i
++
{
uid
:=
generateNewUid
()
...
...
@@ -539,7 +542,7 @@ func GetDashboardSlugById(query *m.GetDashboardSlugByIdQuery) error {
var
rawSql
=
`SELECT slug from dashboard WHERE Id=?`
var
slug
=
DashboardSlugDTO
{}
exists
,
err
:=
x
.
S
ql
(
rawSql
,
query
.
Id
)
.
Get
(
&
slug
)
exists
,
err
:=
x
.
S
QL
(
rawSql
,
query
.
Id
)
.
Get
(
&
slug
)
if
err
!=
nil
{
return
err
...
...
@@ -552,7 +555,7 @@ func GetDashboardSlugById(query *m.GetDashboardSlugByIdQuery) error {
}
func
GetDashboardsBySlug
(
query
*
m
.
GetDashboardsBySlugQuery
)
error
{
var
dashboards
=
make
([]
*
m
.
Dashboard
,
0
)
var
dashboards
[]
*
m
.
Dashboard
if
err
:=
x
.
Where
(
"org_id=? AND slug=?"
,
query
.
OrgId
,
query
.
Slug
)
.
Find
(
&
dashboards
);
err
!=
nil
{
return
err
...
...
@@ -561,3 +564,20 @@ func GetDashboardsBySlug(query *m.GetDashboardsBySlugQuery) error {
query
.
Result
=
dashboards
return
nil
}
func
GetDashboardUIDById
(
query
*
m
.
GetDashboardUIDByIdQuery
)
error
{
var
rawSql
=
`SELECT uid, slug from dashboard WHERE Id=?`
us
:=
&
m
.
DashboardRef
{}
exists
,
err
:=
x
.
SQL
(
rawSql
,
query
.
Id
)
.
Get
(
us
)
if
err
!=
nil
{
return
err
}
else
if
exists
==
false
{
return
m
.
ErrDashboardNotFound
}
query
.
Result
=
us
return
nil
}
public/app/containers/AlertRuleList/AlertRuleList.jest.tsx
View file @
cef910dd
...
...
@@ -23,7 +23,7 @@ describe('AlertRuleList', () => {
.
format
(),
evalData
:
{},
executionError
:
''
,
dashboardUri
:
'd
b/mygoo
l'
,
dashboardUri
:
'd
/ufkcofof/my-goa
l'
,
canEdit
:
true
,
},
])
...
...
public/app/containers/AlertRuleList/AlertRuleList.tsx
View file @
cef910dd
...
...
@@ -137,7 +137,7 @@ export class AlertRuleItem extends React.Component<AlertRuleItemProps, any> {
'fa-pause'
:
!
rule
.
isPaused
,
});
let
ruleUrl
=
`
dashboard/
${
rule
.
dashboardUri
}
?panelId=
${
rule
.
panelId
}
&fullscreen&edit
&tab=alert`
;
let
ruleUrl
=
`
${
rule
.
dashboardUri
}
?panelId=
${
rule
.
panelId
}
&fullscreen=true&edit=true
&tab=alert`
;
return
(
<
li
className=
"alert-rule-item"
>
...
...
public/app/containers/AlertRuleList/__snapshots__/AlertRuleList.jest.tsx.snap
View file @
cef910dd
...
...
@@ -21,7 +21,7 @@ exports[`AlertRuleList should render 1 rule 1`] = `
className="alert-rule-item__name"
>
<a
href="d
ashboard/db/mygool?panelId=3&fullscreen&edit
&tab=alert"
href="d
/ufkcofof/my-goal?panelId=3&fullscreen=true&edit=true
&tab=alert"
>
<Highlighter
highlightClassName="highlight-search-match"
...
...
@@ -92,7 +92,7 @@ exports[`AlertRuleList should render 1 rule 1`] = `
</button>
<a
className="btn btn-small btn-inverse alert-list__btn width-2"
href="d
ashboard/db/mygool?panelId=3&fullscreen&edit
&tab=alert"
href="d
/ufkcofof/my-goal?panelId=3&fullscreen=true&edit=true
&tab=alert"
title="Edit alert rule"
>
<i
...
...
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