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
546d489d
Commit
546d489d
authored
Jun 06, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard_history: restored unsaved changes modal to simple cancel, discard, save
parent
88da3a99
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
73 deletions
+81
-73
public/app/features/dashboard/all.js
+1
-0
public/app/features/dashboard/unsavedChangesSrv.js
+17
-19
public/app/features/dashboard/unsaved_changes_modal.ts
+63
-0
public/app/partials/unsaved-changes.html
+0
-54
No files found.
public/app/features/dashboard/all.js
View file @
546d489d
...
@@ -13,6 +13,7 @@ define([
...
@@ -13,6 +13,7 @@ define([
'./viewStateSrv'
,
'./viewStateSrv'
,
'./time_srv'
,
'./time_srv'
,
'./unsavedChangesSrv'
,
'./unsavedChangesSrv'
,
'./unsaved_changes_modal'
,
'./timepicker/timepicker'
,
'./timepicker/timepicker'
,
'./graphiteImportCtrl'
,
'./graphiteImportCtrl'
,
'./impression_store'
,
'./impression_store'
,
...
...
public/app/features/dashboard/unsavedChangesSrv.js
View file @
546d489d
...
@@ -134,34 +134,31 @@ function(angular, _) {
...
@@ -134,34 +134,31 @@ function(angular, _) {
return
currentJson
!==
originalJson
;
return
currentJson
!==
originalJson
;
};
};
p
.
open_modal
=
function
()
{
p
.
discardChanges
=
function
()
{
var
tracker
=
this
;
this
.
original
=
null
;
var
dashboard
=
this
.
current
;
this
.
gotoNext
();
};
var
modalScope
=
this
.
scope
.
$new
();
var
clone
=
dashboard
.
getSaveModelClone
();
modalScope
.
clone
=
clone
;
p
.
open_modal
=
function
()
{
modalScope
.
ignore
=
function
()
{
$rootScope
.
appEvent
(
'show-modal'
,
{
tracker
.
original
=
null
;
templateHtml
:
'<unsaved-changes-modal dismiss="dismiss()"></unsaved-changes-modal>'
,
tracker
.
goto_next
();
modalClass
:
'modal--narrow confirm-modal'
};
});
};
p
.
saveChanges
=
function
()
{
var
self
=
this
;
var
cancel
=
$rootScope
.
$on
(
'dashboard-saved'
,
function
()
{
var
cancel
=
$rootScope
.
$on
(
'dashboard-saved'
,
function
()
{
cancel
();
cancel
();
$timeout
(
function
()
{
$timeout
(
function
()
{
tracker
.
goto_n
ext
();
self
.
gotoN
ext
();
});
});
});
});
$rootScope
.
appEvent
(
'show-modal'
,
{
$rootScope
.
appEvent
(
'save-dashboard'
);
src
:
'public/app/partials/unsaved-changes.html'
,
scope
:
modalScope
,
modalClass
:
'modal--narrow'
});
};
};
p
.
goto
_n
ext
=
function
()
{
p
.
goto
N
ext
=
function
()
{
var
baseLen
=
$location
.
absUrl
().
length
-
$location
.
url
().
length
;
var
baseLen
=
$location
.
absUrl
().
length
-
$location
.
url
().
length
;
var
nextUrl
=
this
.
next
.
substring
(
baseLen
);
var
nextUrl
=
this
.
next
.
substring
(
baseLen
);
$location
.
url
(
nextUrl
);
$location
.
url
(
nextUrl
);
...
@@ -169,7 +166,8 @@ function(angular, _) {
...
@@ -169,7 +166,8 @@ function(angular, _) {
this
.
Tracker
=
Tracker
;
this
.
Tracker
=
Tracker
;
this
.
init
=
function
(
dashboard
,
scope
)
{
this
.
init
=
function
(
dashboard
,
scope
)
{
return
new
Tracker
(
dashboard
,
scope
,
1000
);
this
.
tracker
=
new
Tracker
(
dashboard
,
scope
,
1000
);
return
this
.
tracker
;
};
};
});
});
});
});
public/app/features/dashboard/unsaved_changes_modal.ts
0 → 100644
View file @
546d489d
///<reference path="../../headers/common.d.ts" />
import
coreModule
from
'app/core/core_module'
;
const
template
=
`
<div class="modal-body">
<div class="modal-header">
<h2 class="modal-header-title">
<i class="fa fa-exclamation"></i>
<span class="p-l-1">Unsaved changes</span>
</h2>
<a class="modal-header-close" ng-click="dismiss();">
<i class="fa fa-remove"></i>
</a>
</div>
<div class="modal-content text-center">
<div class="confirm-modal-text">
What do you want to do?
</div>
<div class="confirm-modal-buttons">
<button type="button" class="btn btn-inverse" ng-click="ctrl.dismiss()">Cancel</button>
<button type="button" class="btn btn-danger" ng-click="ctrl.discard()">Discard</button>
<button type="button" class="btn btn-success" ng-click="ctrl.save()">Save</button>
</div>
</div>
</div>
`
;
export
class
UnsavedChangesModalCtrl
{
clone
:
any
;
dismiss
:
()
=>
void
;
/** @ngInject */
constructor
(
private
$rootScope
,
private
unsavedChangesSrv
)
{
}
discard
()
{
this
.
dismiss
();
this
.
unsavedChangesSrv
.
tracker
.
discardChanges
();
}
save
()
{
this
.
dismiss
();
this
.
unsavedChangesSrv
.
tracker
.
saveChanges
();
}
}
export
function
unsavedChangesModalDirective
()
{
return
{
restrict
:
'E'
,
template
:
template
,
controller
:
UnsavedChangesModalCtrl
,
bindToController
:
true
,
controllerAs
:
'ctrl'
,
scope
:
{
dismiss
:
"&"
}
};
}
coreModule
.
directive
(
'unsavedChangesModal'
,
unsavedChangesModalDirective
);
public/app/partials/unsaved-changes.html
deleted
100644 → 0
View file @
88da3a99
<div
class=
"modal-body"
ng-controller=
"SaveDashboardMessageCtrl"
ng-init=
"init();"
>
<div
class=
"modal-header"
>
<h2
class=
"modal-header-title"
>
<i
class=
"fa fa-exclamation"
></i>
<span
class=
"p-l-1"
>
Unsaved changes
</span>
</h2>
<a
class=
"modal-header-close"
ng-click=
"dismiss();"
>
<i
class=
"fa fa-remove"
></i>
</a>
</div>
<form
name=
"saveMessage"
ng-submit=
"saveVersion(saveMessage.$valid)"
class=
"modal-content"
novalidate
>
<h6
class=
"text-center"
>
You're leaving without saving your changes, are you sure you want to leave? To save, add a small note to describe the changes in this version.
</h6>
<div
class=
"p-t-2"
>
<div
class=
"gf-form"
>
<label
class=
"gf-form-hint"
>
<input
type=
"text"
name=
"message"
class=
"gf-form-input"
placeholder=
"Updates to …"
give-focus=
"true"
ng-model=
"clone.message"
ng-model-options=
"{allowInvalid: true}"
ng-keydown=
"keyDown($event)"
ng-maxlength=
"clone.max"
autocomplete=
"off"
required
/>
<small
class=
"gf-form-hint-text muted"
ng-cloak
>
<span
ng-class=
"{'text-error': saveMessage.message.$invalid && saveMessage.message.$dirty }"
>
{{clone.message.length || 0}}
</span>
/ {{clone.max}} characters
</small>
</label>
</div>
</div>
<div
class=
"gf-form-button-row text-center"
>
<button
type=
"submit"
class=
"btn btn-success"
ng-disabled=
"saveMessage.$invalid"
>
Save changes
</button>
<button
type=
"button"
class=
"btn btn-danger"
ng-click=
"ignore();dismiss()"
>
Discard changes and leave
</button>
<button
class=
"btn btn-inverse"
ng-click=
"dismiss();"
>
Cancel
</button>
</div>
</form>
</div>
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