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
8fd3015e
Unverified
Commit
8fd3015e
authored
Jun 06, 2018
by
Alexander Zobnin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: improve import UX for non-editor users
validate folderId, import only into available folders
parent
9460063a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
14 deletions
+26
-14
public/app/features/dashboard/dashboard_import_ctrl.ts
+8
-1
public/app/features/dashboard/folder_picker/folder_picker.ts
+14
-11
public/app/features/dashboard/partials/dashboard_import.html
+4
-2
No files found.
public/app/features/dashboard/dashboard_import_ctrl.ts
View file @
8fd3015e
...
...
@@ -22,6 +22,7 @@ export class DashboardImportCtrl {
autoGenerateUid
:
boolean
;
autoGenerateUidValue
:
string
;
folderId
:
number
;
initialFolderTitle
:
string
;
isValidFolderSelection
:
boolean
;
/** @ngInject */
...
...
@@ -33,7 +34,8 @@ export class DashboardImportCtrl {
this
.
uidExists
=
false
;
this
.
autoGenerateUid
=
true
;
this
.
autoGenerateUidValue
=
'auto-generated'
;
this
.
folderId
=
Number
(
$routeParams
.
folderId
)
||
0
;
this
.
folderId
=
$routeParams
.
folderId
?
Number
(
$routeParams
.
folderId
)
||
0
:
null
;
this
.
initialFolderTitle
=
'Select a folder'
;
// check gnetId in url
if
(
$routeParams
.
gnetId
)
{
...
...
@@ -107,6 +109,7 @@ export class DashboardImportCtrl {
this
.
validationSrv
.
validateNewDashboardName
(
this
.
folderId
,
this
.
dash
.
title
)
.
then
(()
=>
{
this
.
nameExists
=
false
;
this
.
hasNameValidationError
=
false
;
})
.
catch
(
err
=>
{
...
...
@@ -154,6 +157,10 @@ export class DashboardImportCtrl {
this
.
inputsValid
=
true
;
}
isValid
()
{
return
this
.
inputsValid
&&
!
this
.
hasNameValidationError
&&
this
.
folderId
!==
null
;
}
saveDashboard
()
{
var
inputs
=
this
.
inputs
.
map
(
input
=>
{
return
{
...
...
public/app/features/dashboard/folder_picker/folder_picker.ts
View file @
8fd3015e
...
...
@@ -132,23 +132,26 @@ export class FolderPickerCtrl {
}
private
loadInitialValue
()
{
if
(
this
.
initialFolderId
&&
this
.
initialFolderId
>
0
)
{
this
.
getOptions
(
''
).
then
(
result
=>
{
this
.
getOptions
(
''
).
then
(
result
=>
{
if
(
!
_
.
isNil
(
this
.
initialFolderId
))
{
// If initialFolderId is set, try to find it in result or return null
this
.
folder
=
_
.
find
(
result
,
{
value
:
this
.
initialFolderId
});
if
(
!
this
.
folder
)
{
this
.
folder
=
{
text
:
this
.
initialTitle
,
value
:
this
.
initialFolderId
};
this
.
folder
=
{
text
:
this
.
initialTitle
,
value
:
null
};
}
this
.
onFolderLoad
();
});
}
else
{
if
(
this
.
initialTitle
&&
this
.
initialFolderId
===
null
)
{
this
.
folder
=
{
text
:
this
.
initialTitle
,
value
:
null
};
}
else
{
this
.
folder
=
{
text
:
this
.
rootName
,
value
:
0
};
// If initialFolderId isn't set, return General folder for Editor
// or first available for user, otherwise return null
if
(
this
.
isEditor
)
{
this
.
folder
=
{
text
:
this
.
rootName
,
value
:
0
};
}
else
if
(
result
.
length
>
0
)
{
this
.
folder
=
result
[
0
];
}
else
{
this
.
folder
=
{
text
:
this
.
initialTitle
,
value
:
null
};
}
}
this
.
onFolderLoad
();
}
}
);
}
private
onFolderLoad
()
{
...
...
public/app/features/dashboard/partials/dashboard_import.html
View file @
8fd3015e
...
...
@@ -83,7 +83,9 @@
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form gf-form--grow"
>
<folder-picker
initial-folder-id=
"ctrl.folderId"
initial-title=
"ctrl.initialFolderTitle"
on-change=
"ctrl.onFolderChange($folder)"
on-load=
"ctrl.onFolderChange($folder)"
enter-folder-creation=
"ctrl.onEnterFolderCreation()"
exit-folder-creation=
"ctrl.onExitFolderCreation()"
enable-create-new=
"true"
...
...
@@ -144,10 +146,10 @@
</div>
<div
class=
"gf-form-button-row"
>
<button
type=
"button"
class=
"btn btn-success width-12"
ng-click=
"ctrl.saveDashboard()"
ng-hide=
"ctrl.nameExists || ctrl.uidExists"
ng-disabled=
"!ctrl.i
nputsValid
"
>
<button
type=
"button"
class=
"btn btn-success width-12"
ng-click=
"ctrl.saveDashboard()"
ng-hide=
"ctrl.nameExists || ctrl.uidExists"
ng-disabled=
"!ctrl.i
sValid()
"
>
<i
class=
"fa fa-save"
></i>
Import
</button>
<button
type=
"button"
class=
"btn btn-danger width-12"
ng-click=
"ctrl.saveDashboard()"
ng-show=
"ctrl.nameExists || ctrl.uidExists"
ng-disabled=
"!ctrl.i
nputsValid
"
>
<button
type=
"button"
class=
"btn btn-danger width-12"
ng-click=
"ctrl.saveDashboard()"
ng-show=
"ctrl.nameExists || ctrl.uidExists"
ng-disabled=
"!ctrl.i
sValid()
"
>
<i
class=
"fa fa-save"
></i>
Import (Overwrite)
</button>
<a
class=
"btn btn-link"
ng-click=
"ctrl.back()"
>
Cancel
</a>
...
...
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