Skip to content

Commit

Permalink
Add invalidate cache button to OpenWrt luci
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Jul 22, 2022
1 parent b804c5f commit 7c1c7b1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function index()
entry({ "admin", "services", "aliyundrive-webdav", "logtail" }, call("action_logtail")).leaf = true -- 日志采集
entry({ "admin", "services", "aliyundrive-webdav", "qrcode" }, call("action_generate_qrcode")).leaf = true -- 生成扫码登录二维码地址和参数
entry({ "admin", "services", "aliyundrive-webdav", "query" }, call("action_query_qrcode")).leaf = true -- 查询扫码登录结果
entry({ "admin", "services", "aliyundrive-webdav", "invalidate-cache" }, call("action_invalidate_cache")).leaf = true -- 清除缓存
end

function action_status()
Expand Down Expand Up @@ -57,3 +58,10 @@ function action_query_qrcode()
luci.http.prepare_content("application/json")
luci.http.write_json(output)
end

function action_invalidate_cache()
local e = {}
e.ok = luci.sys.call("kill -HUP `pidof aliyundrive-webdav`") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,26 @@
}
}
);

function invalidateCache(button) {
XHR.get('<%=url([[admin]], [[services]], [[aliyundrive-webdav]], [[invalidate-cache]])%>', null,
function(x, data) {
if (data.ok) {
alert("缓存已清除.");
} else {
alert("清除缓存失败!");
}
}
);
}
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="aliyundrive-webdav_status">
<p id="aliyundrive-webdav_status" style="float: left; width: 60%; margin-top: 12px;">
<em><%:Collecting data...%></em>
</p>
<p class="right" style="float: right; width: 40%;">
<button class="cbi-button" onclick="event.stopPropagation(); invalidateCache(this);"><%:Invalidate cache%></button>
</p>
</fieldset>
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ msgstr "目录缓存过期时间(单位为秒)"
msgid "Collecting data..."
msgstr "获取数据中..."

msgid "Invalidate cache"
msgstr "清除缓存"

msgid "RUNNING"
msgstr "运行中"

Expand Down

0 comments on commit 7c1c7b1

Please sign in to comment.