Skip to content

Commit

Permalink
feat: Add Zashboard (#4276)
Browse files Browse the repository at this point in the history
* add zashboard

* Update openclash.zh-cn.po

* Update switch_dashboard.htm
  • Loading branch information
xuanranran authored Jan 12, 2025
1 parent 3c80969 commit 9019aff
Show file tree
Hide file tree
Showing 23 changed files with 277 additions and 8 deletions.
4 changes: 4 additions & 0 deletions luci-app-openclash/luasrc/model/cbi/openclash/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,10 @@ o = s:taboption("dashboard", DummyValue, "Metacubexd", translate("Update Metacub
o.template="openclash/switch_dashboard"
o.rawhtml = true

o = s:taboption("dashboard", DummyValue, "zashboard", translate("Update zashboard Version"))
o.template="openclash/switch_dashboard"
o.rawhtml = true

---- ipv6
o = s:taboption("ipv6", Flag, "ipv6_enable", translate("Proxy IPv6 Traffic"))
o.description = font_red..bold_on..translate("The Gateway and DNS of The Connected Device Must be The Router IP, Disable IPv6 DHCP To Avoid Abnormal Connection If You Do Not Use")..bold_off..font_off
Expand Down
27 changes: 25 additions & 2 deletions luci-app-openclash/luasrc/view/openclash/status.htm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<input type="radio" id="direct" name="radios" value="direct" onclick="return switch_rule_mode(this.value)"/>
<label for="direct"><%:Direct%></label>
</span></td><td width="25%"><%:Control Panel Login Secret%></td><td width="25%" align="left" id="_dase"><%:Collecting data...%></td></tr>
<tr><td colspan="4"><div style="margin: 10px 0; text-align: center"><span id="_web" style="width: 33%; display: inline-block;"></span><span id="_webm" style="width: 33%; display: inline-block;"><%:Collecting data...%></span><span id="_webo" style="width: 33%; display: inline-block;"></span></div></td></tr>
<tr><td colspan="4"><div style="margin: 10px 0; text-align: center"><span id="_web" style="width: 25%; display: inline-block;"></span><span id="_webm" style="width: 25%; display: inline-block;"><%:Collecting data...%></span><span id="_webz" style="width: 25%; display: inline-block;"><%:Collecting data...%></span><span id="_webo" style="width: 25%; display: inline-block;"></span></div></td></tr>
<tr id="tool_label2"><td colspan="4">
<div style="margin: 10px 0; text-align: center">
<span>
Expand Down Expand Up @@ -193,6 +193,7 @@
var web = document.getElementById('_web');
var webo = document.getElementById('_webo');
var webm = document.getElementById('_webm');
var webz = document.getElementById('_webz');
var watchdog = document.getElementById('_watchdog');
var daip = document.getElementById('_daip');
var dase = document.getElementById('_dase');
Expand Down Expand Up @@ -253,6 +254,7 @@
web.innerHTML = status.web ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Yacd Control Panel%>" onclick="return ycad_dashboard(this)"/>' : '<b style=color:red><%:Not Running%></b>';
webo.innerHTML = status.web ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Dashboard Control Panel%>" onclick="return net_dashboard(this)"/>' : '<b style=color:red><%:Not Running%></b>';
webm.innerHTML = status.web ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Metacubexd Control Panel%>" onclick="return meta_dashboard(this)"/>' : '<b style=color:red><%:Not Running%></b>';
webz.innerHTML = status.web ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:zashboard Control Panel%>" onclick="return net_zashboard(this)"/>' : '<b style=color:red><%:Not Running%></b>';
close_all_connection.innerHTML = status.clash ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Close All Connections%>" onclick="return b_close_all_connection(this)"/>' : '<b style=color:red><%:Not Running%></b>';
reload_firewall.innerHTML = status.clash ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Reload Firewall Rules%>" onclick="return b_reload_firewall(this)"/>' : '<b style=color:red><%:Not Running%></b>';
flush_fakeip_cache.innerHTML = status.clash ? '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Flush Fake-IP Cache%>" onclick="return b_flush_fakeip_cache(this)"/>' : '<b style=color:red><%:Not Running%></b>';
Expand Down Expand Up @@ -850,7 +852,28 @@
return false;
});
};



function net_zashboard(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "status")%>', null, function(x, status) {
btn.disabled = true;
btn.value = '<%:zashboard Control Panel%>';
if (status.daip && window.location.hostname == status.daip) {
url9='<%="http://'+window.location.hostname+':'+status.cn_port+'/ui/zashboard/#/setup?hostname='+ window.location.hostname + '&port=' + status.cn_port + '&secret=' + status.dase +'"%>';
}
else if (status.daip && window.location.hostname != status.daip && status.db_foward_domain && status.db_foward_port) {
var ui_proto = status.db_forward_ssl == 0 ? 'http://' : 'https://';
url9='<%="'+ui_proto+status.db_foward_domain+':'+status.db_foward_port+'/ui/zashboard/#/setup?hostname='+ status.db_foward_domain + '&port=' + status.db_foward_port + '&secret=' + status.dase +'"%>';
}
else {
url9='<%="http://'+window.location.hostname+':'+status.cn_port+'/ui/zashboard/#/"%>';
}
winOpen(url9);
return false;
});
};

function meta_dashboard(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "status")%>', null, function(x, status) {
Expand Down
11 changes: 8 additions & 3 deletions luci-app-openclash/luasrc/view/openclash/switch_dashboard.htm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
if ( btn_type_<%=self.option%> == "Metacubexd" ) {
switch_dashboard_<%=self.option%>.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Update Metacubexd Version%>" onclick="return switch_dashboard(this, btn_type_<%=self.option%>, \'Official\')"/>';
}
if ( btn_type_<%=self.option%> == "zashboard" ) {
switch_dashboard_<%=self.option%>.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Update zashboard Version%>" onclick="return switch_dashboard(this, btn_type_<%=self.option%>, \'Official\')"/>';
}
}
});

Expand Down Expand Up @@ -54,16 +57,18 @@
{
document.getElementById("switch_dashboard_"+name).innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Switch Successful%> - <%:Switch To Meta Version%>" onclick="return switch_dashboard(this, \'Yacd\', \'Meta\')"/>';
}
else{
else if ( name == "Metacubexd" ) {
document.getElementById("switch_dashboard_"+name).innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Update Successful%> - <%:Update Metacubexd Version%>" onclick="return switch_dashboard(this, \'Metacubexd\', \'Official\')"/>';
}
} else {
document.getElementById("switch_dashboard_"+name).innerHTML = '<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Update Successful%> - <%:Update zashboard Version%>" onclick="return switch_dashboard(this, \'zashboard\', \'Official\')"/>';
}
}
}
else if ( status.download_state == "2" ) {
btn.value = '<%:Unzip Error%>';
}
else {
if ( name == "Metacubexd" ) {
if ( name == "Metacubexd" || name == "zashboard" ) {
btn.value = '<%:Update Failed%>';
}
else {
Expand Down
12 changes: 9 additions & 3 deletions luci-app-openclash/po/zh-cn/openclash.zh-cn.po
Original file line number Diff line number Diff line change
Expand Up @@ -1189,13 +1189,16 @@ msgid "Running Mode"
msgstr "运行模式"

msgid "Yacd Control Panel"
msgstr "Yacd 控制面板"
msgstr "Yacd 面板"

msgid "Dashboard Control Panel"
msgstr "Dashboard 控制面板"
msgstr "Dashboard 面板"

msgid "Metacubexd Control Panel"
msgstr "Metacubexd 控制面板"
msgstr "Metacubexd 面板"

msgid "zashboard Control Panel"
msgstr "zashboard 面板"

msgid "Control Panel Login IP"
msgstr "控制面板登录 IP"
Expand Down Expand Up @@ -2958,6 +2961,9 @@ msgstr "切换(更新) Yacd 版本"
msgid "Update Metacubexd Version"
msgstr "更新 Metacubexd 版本"

msgid "Update zashboard Version"
msgstr "更新 zashboard 版本"

msgid "Downloading File..."
msgstr "文件下载中..."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
DOWNLOAD_PATH="https://codeload.github.com/MetaCubeX/Yacd-meta/zip/refs/heads/gh-pages"
FILE_PATH_INCLUDE="Yacd-meta-gh-pages"
fi
elif [ "$DASH_NAME" == "zashboard" ]; then
UNPACK_FILE_DIR="/usr/share/openclash/ui/zashboard/"
BACKUP_FILE_DIR="/usr/share/openclash/ui/zashboard_backup/"
DOWNLOAD_PATH="https://codeload.github.com/Zephyruso/zashboard/zip/refs/heads/gh-pages"
FILE_PATH_INCLUDE="zashboard-gh-pages"
else
UNPACK_FILE_DIR="/usr/share/openclash/ui/metacubexd/"
BACKUP_FILE_DIR="/usr/share/openclash/ui/metacubexd_backup/"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
board.zash.run.place
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading

0 comments on commit 9019aff

Please sign in to comment.