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
bfb2376a
Commit
bfb2376a
authored
Apr 25, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working on unsaved changes warning
parent
c2692614
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
23 deletions
+78
-23
src/app/controllers/dash.js
+2
-1
src/app/partials/unsaved-changes.html
+13
-0
src/app/services/all.js
+2
-0
src/app/services/dashboard.js
+1
-22
src/app/services/unsavedChangesSrv.js
+60
-0
No files found.
src/app/controllers/dash.js
View file @
bfb2376a
...
...
@@ -30,7 +30,8 @@ function (angular, $, config, _) {
var
module
=
angular
.
module
(
'kibana.controllers'
);
module
.
controller
(
'DashCtrl'
,
function
(
$scope
,
$rootScope
,
$route
,
ejsResource
,
dashboard
,
alertSrv
,
panelMove
,
keyboardManager
,
grafanaVersion
)
{
$scope
,
$rootScope
,
ejsResource
,
dashboard
,
alertSrv
,
panelMove
,
keyboardManager
,
grafanaVersion
,
unsavedChangesSrv
)
{
$scope
.
requiredElasticSearchVersion
=
">=0.90.3"
;
...
...
src/app/partials/unsaved-changes.html
0 → 100644
View file @
bfb2376a
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h3>
{{modal.title}}
</h3>
</div>
<div
class=
"modal-body"
>
<div
ng-bind-html=
'modal.body'
></div>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-danger"
ng-click=
"dismiss()"
>
Close
</button>
</div>
\ No newline at end of file
src/app/services/all.js
View file @
bfb2376a
...
...
@@ -8,5 +8,6 @@ define([
'./keyboardManager'
,
'./annotationsSrv'
,
'./playlistSrv'
,
'./unsavedChangesSrv'
,
],
function
()
{});
\ No newline at end of file
src/app/services/dashboard.js
View file @
bfb2376a
...
...
@@ -60,12 +60,6 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
this
.
last
=
{};
this
.
availablePanels
=
[];
$rootScope
.
$on
(
"$locationChangeStart"
,
function
(
event
,
next
,
current
)
{
if
(
!
self
.
confirm_dash_change
())
{
event
.
preventDefault
();
}
});
$rootScope
.
$on
(
'$routeChangeSuccess'
,
function
(){
// Clear the current dashboard to prevent reloading
self
.
current
=
{};
...
...
@@ -191,22 +185,6 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
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
)
{
if
(
self
.
is_gist
(
string
))
{
return
string
.
match
(
gist_pattern
)[
0
].
replace
(
/.*
\/
/
,
''
);
...
...
@@ -416,6 +394,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
if
(
type
===
'dashboard'
)
{
$location
.
path
(
'/dashboard/elasticsearch/'
+
title
);
}
self
.
original
=
angular
.
copy
(
self
.
current
);
return
result
;
},
// Failure
...
...
src/app/services/unsavedChangesSrv.js
0 → 100644
View file @
bfb2376a
define
([
'angular'
,
'underscore'
],
function
(
angular
,
_
)
{
'use strict'
;
var
module
=
angular
.
module
(
'kibana.services'
);
module
.
service
(
'unsavedChangesSrv'
,
function
(
$rootScope
,
$modal
,
dashboard
,
$q
,
$location
)
{
var
self
=
this
;
var
modalScope
=
$rootScope
.
$new
();
$rootScope
.
$on
(
"$locationChangeStart"
,
function
(
event
,
next
,
current
)
{
if
(
self
.
has_unsaved_changes
())
{
event
.
preventDefault
();
self
.
next
=
next
;
self
.
open_modal
();
}
});
this
.
open_modal
=
function
()
{
var
confirmModal
=
$modal
({
template
:
'./app/partials/unsaved-changes.html'
,
persist
:
true
,
show
:
false
,
scope
:
modalScope
,
keyboard
:
false
});
$q
.
when
(
confirmModal
).
then
(
function
(
modalEl
)
{
modalEl
.
modal
(
'show'
);
});
};
this
.
has_unsaved_changes
=
function
()
{
if
(
!
dashboard
.
original
)
{
return
false
;
}
var
current
=
angular
.
copy
(
dashboard
.
current
);
var
currentJson
=
angular
.
toJson
(
current
);
var
originalJson
=
angular
.
toJson
(
dashboard
.
original
);
if
(
currentJson
!==
originalJson
)
{
return
true
;
//confirm('There are unsaved changes, are you sure you want to change dashboard?');
}
return
false
;
};
modalScope
.
ignore
=
function
()
{
dashboard
.
original
=
null
;
$location
.
path
(
self
.
next
)
};
});
});
\ No newline at end of file
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