Skip to content

Commit

Permalink
fix: issue#110 missing rules change when updating selector detail for…
Browse files Browse the repository at this point in the history
… no local js cache was updated after rules changed
  • Loading branch information
sumory committed May 16, 2017
1 parent f4900f8 commit 8888525
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions dashboard/static/js/orange.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@
if (result.success) {
//重新渲染规则
_this.loadRules(op_type, context, selector_id);
_this.refreshConfigs(op_type, context);
return true;
} else {
L.Common.showErrorTip("提示", result.msg || "添加规则发生错误");
Expand Down Expand Up @@ -913,6 +914,7 @@
if (result.success) {
//重新渲染规则
_this.loadRules(op_type, context, selector_id);
_this.refreshConfigs(op_type, context);//刷新本地缓存
return true;
} else {
L.Common.showErrorTip("提示", result.msg || "删除规则发生错误");
Expand Down Expand Up @@ -1352,6 +1354,34 @@
});
},

refreshConfigs: function (type, context) {//刷新本地缓存,fix issue #110 (https://github.com/sumory/orange/issues/110)
var op_type = type;
$.ajax({
url: '/' + op_type + '/selectors',
type: 'get',
cache: false,
data: {},
dataType: 'json',
success: function (result) {
if (result.success) {
var enable = result.data.enable;
var meta = result.data.meta;
var selectors = result.data.selectors;

//重新设置数据
context.data.enable = enable;
context.data.meta = meta;
context.data.selectors = selectors;
} else {
_this.showErrorTip("错误提示", "刷新" + op_type + "配置的本地缓存发生错误, 请刷新页面!");
}
},
error: function () {
_this.showErrorTip("提示", "查询" + op_type + "配置的本地缓存发生异常, 请刷新页面!");
}
});
},

loadRules: function (type, context, selector_id) {
var op_type = type;
$.ajax({
Expand Down
2 changes: 1 addition & 1 deletion dashboard/views/common/common_js.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
}
});
</script>
<script src="/static/js/orange.js"></script>
<script src="/static/js/orange.js?v=0.6"></script>
<script type="text/javascript">
APP.Common.init();
</script>

0 comments on commit 8888525

Please sign in to comment.