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
bfce3794
Commit
bfce3794
authored
Mar 02, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4222 from raintank/pluginSettingEditHooks
Add support for pre/post update hooks in the PluginEditCtrl.
parents
4872f6d2
4317e4c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
10 deletions
+47
-10
public/app/features/plugins/edit_ctrl.ts
+47
-10
No files found.
public/app/features/plugins/edit_ctrl.ts
View file @
bfce3794
...
...
@@ -9,6 +9,8 @@ export class PluginEditCtrl {
includedPanels
:
any
;
includedDatasources
:
any
;
tabIndex
:
number
;
preUpdateHook
:
()
=>
any
;
postUpdateHook
:
()
=>
any
;
/** @ngInject */
constructor
(
private
backendSrv
:
any
,
private
$routeParams
:
any
)
{
...
...
@@ -24,20 +26,55 @@ export class PluginEditCtrl {
}
update
()
{
var
updateCmd
=
_
.
extend
({
pluginId
:
this
.
model
.
pluginId
,
orgId
:
this
.
model
.
orgId
,
enabled
:
this
.
model
.
enabled
,
pinned
:
this
.
model
.
pinned
,
jsonData
:
this
.
model
.
jsonData
,
secureJsonData
:
this
.
model
.
secureJsonData
,
},
{});
this
.
backendSrv
.
post
(
`/api/org/plugins/
${
this
.
pluginId
}
/settings`
,
updateCmd
).
then
(
function
()
{
var
chain
=
Promise
.
resolve
();
var
self
=
this
;
// if set, handle the preUpdateHook. If this returns a promise,
// the next step of execution will block until the promise resolves.
// if the promise is rejected, this update will be aborted.
if
(
this
.
preUpdateHook
!=
null
)
{
chain
=
chain
.
then
(
function
()
{
return
Promise
.
resolve
(
self
.
preUpdateHook
());
});
}
// Perform the core update procedure
chain
=
chain
.
then
(
function
()
{
var
updateCmd
=
_
.
extend
({
pluginId
:
self
.
model
.
pluginId
,
orgId
:
self
.
model
.
orgId
,
enabled
:
self
.
model
.
enabled
,
pinned
:
self
.
model
.
pinned
,
jsonData
:
self
.
model
.
jsonData
,
secureJsonData
:
self
.
model
.
secureJsonData
,
},
{});
return
self
.
backendSrv
.
post
(
`/api/org/plugins/
${
self
.
pluginId
}
/settings`
,
updateCmd
);
});
// if set, performt he postUpdate hook. If a promise is returned it will block
// the final step of the update procedure (reloading the page) until the promise
// resolves. If the promise is rejected the page will not be reloaded.
if
(
this
.
postUpdateHook
!=
null
)
{
chain
=
chain
.
then
(
function
()
{
return
Promise
.
resolve
(
this
.
postUpdateHook
());
});
}
// all stesp in the update procedure are complete, so reload the page to make changes
// take effect.
chain
.
then
(
function
()
{
window
.
location
.
href
=
window
.
location
.
href
;
});
}
setPreUpdateHook
(
callback
:
()
=>
any
)
{
this
.
preUpdateHook
=
callback
;
}
setPOstUpdateHook
(
callback
:
()
=>
any
)
{
this
.
postUpdateHook
=
callback
;
}
toggleEnabled
()
{
this
.
update
();
}
...
...
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