update config when json changed. fixes #25

This commit is contained in:
Evstifeev Roman 2016-09-21 21:37:51 +03:00
parent aced96819b
commit 569a9b083e
2 changed files with 3 additions and 12 deletions

View File

@ -151,10 +151,6 @@
onclick="loadMonkeyConfig()" style="margin-top:-4px"> onclick="loadMonkeyConfig()" style="margin-top:-4px">
Refresh Refresh
</button> </button>
<button id="btnConfigUpdate" style="display: none;" class="btn btn-default" type="button"
onclick="updateMonkeyConfig()" style="margin-top:-4px">
Update
</button>
</span> </span>
</div> </div>
<div style="display: none;" id="monkey-config"> <div style="display: none;" id="monkey-config">
@ -173,12 +169,6 @@
<a href="#config" data-toggle="collapse">General Config</a> <a href="#config" data-toggle="collapse">General Config</a>
</div> </div>
<div id="config" style="overflow: visible" class="panel-body panel-collapse collapse in" aria-expanded="true"> <div id="config" style="overflow: visible" class="panel-body panel-collapse collapse in" aria-expanded="true">
<span class="input-group-btn">
<button id="btnNewConfigUpdate" class="btn btn-default" type="button"
onclick="updateNewMonkeysConfig()" style="margin-top:-4px">
Update
</button>
</span>
<div id="new-config"> <div id="new-config">
</div> </div>
</div> </div>

View File

@ -659,14 +659,12 @@ function killMonkey() {
var curr_config = monkeyCfg.getValue(); var curr_config = monkeyCfg.getValue();
curr_config.alive = false; curr_config.alive = false;
monkeyCfg.setValue(curr_config); monkeyCfg.setValue(curr_config);
updateMonkeyConfig();
} }
function reviveMonkey() { function reviveMonkey() {
var curr_config = monkeyCfg.getValue(); var curr_config = monkeyCfg.getValue();
curr_config.alive = true; curr_config.alive = true;
monkeyCfg.setValue(curr_config); monkeyCfg.setValue(curr_config);
updateMonkeyConfig();
} }
function toggleFocusOnNode() { function toggleFocusOnNode() {
@ -694,6 +692,7 @@ function loadNewMonkeysConfig() {
delete json.id; delete json.id;
newCfg.setValue(json); newCfg.setValue(json);
} }
newCfg.watch('root', updateNewMonkeysConfig);
}); });
} }
@ -738,7 +737,9 @@ function loadMonkeyConfig() {
var monkey = getMonkey(node[0]); var monkey = getMonkey(node[0]);
monkeyCfg.unwatch('root', updateMonkeyConfig);
monkeyCfg.setValue(monkey.config); monkeyCfg.setValue(monkey.config);
monkeyCfg.watch('root', updateMonkeyConfig);
} }
function updateMonkeyConfig() { function updateMonkeyConfig() {