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
8ca06e11
Commit
8ca06e11
authored
May 27, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring unsavedChangesSrv and who now owns original
parent
9f548b9d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
10 deletions
+16
-10
src/app/controllers/dashLoader.js
+1
-1
src/app/services/dashboard.js
+0
-6
src/app/services/unsavedChangesSrv.js
+15
-3
No files found.
src/app/controllers/dashLoader.js
View file @
8ca06e11
...
@@ -77,7 +77,7 @@ function (angular, _, moment) {
...
@@ -77,7 +77,7 @@ function (angular, _, moment) {
$scope
.
share
=
dashboard
.
share_link
(
dashboard
.
current
.
title
,
'temp'
,
result
.
_id
);
$scope
.
share
=
dashboard
.
share_link
(
dashboard
.
current
.
title
,
'temp'
,
result
.
_id
);
}
}
$rootScope
.
$emit
(
'dashboard-saved'
);
$rootScope
.
$emit
(
'dashboard-saved'
,
dashboard
.
current
);
});
});
};
};
...
...
src/app/services/dashboard.js
View file @
8ca06e11
...
@@ -62,7 +62,6 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
...
@@ -62,7 +62,6 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
$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
=
{};
self
.
original
=
null
;
self
.
indices
=
[];
self
.
indices
=
[];
route
();
route
();
});
});
...
@@ -169,10 +168,6 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
...
@@ -169,10 +168,6 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
$rootScope
.
$emit
(
'dashboard-loaded'
,
self
.
current
);
$rootScope
.
$emit
(
'dashboard-loaded'
,
self
.
current
);
$timeout
(
function
()
{
self
.
original
=
angular
.
copy
(
self
.
current
);
},
1000
);
return
true
;
return
true
;
};
};
...
@@ -385,7 +380,6 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
...
@@ -385,7 +380,6 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
if
(
type
===
'dashboard'
)
{
if
(
type
===
'dashboard'
)
{
$location
.
path
(
'/dashboard/elasticsearch/'
+
title
);
$location
.
path
(
'/dashboard/elasticsearch/'
+
title
);
}
}
self
.
original
=
angular
.
copy
(
self
.
current
);
return
result
;
return
result
;
},
},
// Failure
// Failure
...
...
src/app/services/unsavedChangesSrv.js
View file @
8ca06e11
...
@@ -16,6 +16,18 @@ function (angular, _, config) {
...
@@ -16,6 +16,18 @@ function (angular, _, config) {
var
self
=
this
;
var
self
=
this
;
var
modalScope
=
$rootScope
.
$new
();
var
modalScope
=
$rootScope
.
$new
();
$rootScope
.
$on
(
"dashboard-loaded"
,
function
(
event
,
newDashboard
)
{
self
.
original
=
angular
.
copy
(
newDashboard
);
});
$rootScope
.
$on
(
"dashboard-saved"
,
function
(
event
,
savedDashboard
)
{
self
.
original
=
angular
.
copy
(
savedDashboard
);
});
$rootScope
.
$on
(
"$routeChangeSuccess"
,
function
()
{
self
.
original
=
null
;
});
window
.
onbeforeunload
=
function
()
{
window
.
onbeforeunload
=
function
()
{
if
(
self
.
has_unsaved_changes
())
{
if
(
self
.
has_unsaved_changes
())
{
return
"There are unsaved changes to this dashboard"
;
return
"There are unsaved changes to this dashboard"
;
...
@@ -47,12 +59,12 @@ function (angular, _, config) {
...
@@ -47,12 +59,12 @@ function (angular, _, config) {
};
};
this
.
has_unsaved_changes
=
function
()
{
this
.
has_unsaved_changes
=
function
()
{
if
(
!
dashboard
.
original
)
{
if
(
!
self
.
original
)
{
return
false
;
return
false
;
}
}
var
current
=
angular
.
copy
(
dashboard
.
current
);
var
current
=
angular
.
copy
(
dashboard
.
current
);
var
original
=
dashboard
.
original
;
var
original
=
self
.
original
;
// ignore timespan changes
// ignore timespan changes
current
.
services
.
filter
.
time
=
original
.
services
.
filter
.
time
=
{};
current
.
services
.
filter
.
time
=
original
.
services
.
filter
.
time
=
{};
...
@@ -83,7 +95,7 @@ function (angular, _, config) {
...
@@ -83,7 +95,7 @@ function (angular, _, config) {
};
};
modalScope
.
ignore
=
function
()
{
modalScope
.
ignore
=
function
()
{
dashboard
.
original
=
null
;
self
.
original
=
null
;
self
.
goto_next
();
self
.
goto_next
();
};
};
...
...
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