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
c2692614
Commit
c2692614
authored
Apr 23, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
began work on unsaved changes warning when changing dashboard, Issue #324
parent
827e1846
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
src/app/services/dashboard.js
+23
-0
No files found.
src/app/services/dashboard.js
View file @
c2692614
...
@@ -60,6 +60,12 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
...
@@ -60,6 +60,12 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
this
.
last
=
{};
this
.
last
=
{};
this
.
availablePanels
=
[];
this
.
availablePanels
=
[];
$rootScope
.
$on
(
"$locationChangeStart"
,
function
(
event
,
next
,
current
)
{
if
(
!
self
.
confirm_dash_change
())
{
event
.
preventDefault
();
}
});
$rootScope
.
$on
(
'$routeChangeSuccess'
,
function
(){
$rootScope
.
$on
(
'$routeChangeSuccess'
,
function
(){
// Clear the current dashboard to prevent reloading
// Clear the current dashboard to prevent reloading
self
.
current
=
{};
self
.
current
=
{};
...
@@ -156,6 +162,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
...
@@ -156,6 +162,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
// Set the current dashboard
// Set the current dashboard
self
.
current
=
angular
.
copy
(
dashboard
);
self
.
current
=
angular
.
copy
(
dashboard
);
self
.
original
=
angular
.
copy
(
dashboard
);
// Delay this until we're sure that querySrv and filterSrv are ready
// Delay this until we're sure that querySrv and filterSrv are ready
$timeout
(
function
()
{
$timeout
(
function
()
{
...
@@ -184,6 +191,22 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
...
@@ -184,6 +191,22 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
return
true
;
return
true
;
};
};
this
.
confirm_dash_change
=
function
()
{
if
(
!
self
.
original
)
{
return
true
;
}
var
current
=
angular
.
copy
(
self
.
current
);
var
currentJson
=
angular
.
toJson
(
current
);
var
originalJson
=
angular
.
toJson
(
self
.
original
);
if
(
currentJson
!==
originalJson
)
{
return
confirm
(
'There are unsaved changes, are you sure you want to change dashboard?'
);
}
return
true
;
};
this
.
gist_id
=
function
(
string
)
{
this
.
gist_id
=
function
(
string
)
{
if
(
self
.
is_gist
(
string
))
{
if
(
self
.
is_gist
(
string
))
{
return
string
.
match
(
gist_pattern
)[
0
].
replace
(
/.*
\/
/
,
''
);
return
string
.
match
(
gist_pattern
)[
0
].
replace
(
/.*
\/
/
,
''
);
...
...
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