Fix CSS replace code.

This commit is contained in:
Adam Ierymenko
2021-06-04 12:20:14 -04:00
parent dc80fdd5d7
commit ff9f74e83b
6 changed files with 33183 additions and 9 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
mac:
cd tray ; make clean ; make
cd tray ; make clean
cd tray ; make zt_lib
cd ui ; yarn build
cargo build --release
cp -f ui/dist/index.html mac-app-template/ZeroTier.app/Contents/Resources/ui.html
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+5 -4
View File
@@ -38,20 +38,21 @@ fn open_window_subprocess(mut w: MutexGuard<Option<Child>>, ui_mode: &str) {
}
}
const CSS_PLACEHOLDER: &'static str = "/* XXXthis_is_replaced_by_css_in_the_rust_codeXXX */";
const CSS_PLACEHOLDER: &'static str = ".XXXthis_is_replaced_by_css_in_the_rust_codeXXX{border:0}";
#[cfg(target_os = "macos")]
#[inline(always)]
fn get_web_ui_blob() -> String {
let resources_path = std::env::current_exe().unwrap().parent().unwrap().parent().unwrap().join("Resources");
let ui = std::fs::read_to_string(resources_path.join("ui.html")).map_or_else(|_| {
std::fs::read_to_string(resources_path.join("ui.html")).map_or_else(|_| {
"<html><body>Error: unable to load ui.html from application bundle Resources.<script>window.zt_ui_render = function(window_type) {}; setTimeout(function() { external.invoke('{ \"cmd\": \"ready\" }'); }, 1);</script></body></html>".into()
}, |ui| {
ui.replace(CSS_PLACEHOLDER, std::fs::read_to_string(resources_path.join("dark.css")).unwrap_or(String::new()).into())
});
ui.replace(CSS_PLACEHOLDER, std::fs::read_to_string(resources_path.join("dark.css")).unwrap_or(String::new()).as_str())
})
}
#[cfg(all(unix, not(target_os = "macos")))]
#[inline(always)]
fn get_web_ui_blob() -> String {
include_str!("../ui/dist/index.html").replace(CSS_PLACEHOLDER, include_str!("../ui/node_modules/@elastic/eui/dist/eui_theme_amsterdam_dark.css"))
}
+3 -3
View File
@@ -63,19 +63,19 @@ impl ServiceClient {
pub fn refresh(&self) {
// Yuck, but okay for now...
let timeout = Duration::from_secs(SERVICE_TIMEOUT_SECONDS);
let res = ureq::get(format!("{}status", self.base_url).into()).timeout(timeout).set("X-ZT1-Auth", self.auth_token.into()).call();
let res = ureq::get(format!("{}status", self.base_url).as_str()).timeout(timeout).set("X-ZT1-Auth", self.auth_token.as_str()).call();
if res.is_ok() {
let res = res.unwrap();
if res.status() == 200 {
let status = res.into_string();
if status.is_ok() {
let res = ureq::get(format!("{}network", self.base_url).into()).timeout(timeout).set("X-ZT1-Auth", self.auth_token.into()).call();
let res = ureq::get(format!("{}network", self.base_url).as_str()).timeout(timeout).set("X-ZT1-Auth", self.auth_token.as_str()).call();
if res.is_ok() {
let res = res.unwrap();
if res.status() == 200 {
let networks = res.into_string();
if networks.is_ok() {
let res = ureq::get(format!("{}peer", self.base_url).into()).timeout(timeout).set("X-ZT1-Auth", self.auth_token.into()).call();
let res = ureq::get(format!("{}peer", self.base_url).as_str()).timeout(timeout).set("X-ZT1-Auth", self.auth_token.as_str()).call();
if res.is_ok() {
let res = res.unwrap();
if res.status() == 200 {
+1 -1
View File
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>ZeroTier</title>
<style>
/* XXXthis_is_replaced_by_css_in_the_rust_codeXXX */
.XXXthis_is_replaced_by_css_in_the_rust_codeXXX{border:0}
</style>
</head>
<body style="width: 100vw; height: 100vh; border: 0; margin: 0; padding: 0; max-width: 100vw; max-height: 100vh;">