Skip to content

Commit

Permalink
fix: fix designer UI embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn committed Jan 7, 2025
1 parent 575e6f5 commit 47bd3cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 42 deletions.
24 changes: 3 additions & 21 deletions core/src/ten_manager/src/cmd/cmd_designer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use console::Emoji;

use crate::{
config::TmanConfig,
designer::{configure_routes, DesignerState},
designer::{configure_routes, frontend::get_frontend_asset, DesignerState},
fs::{check_is_app_folder, get_cwd},
log::tman_verbose_println,
};
Expand All @@ -28,7 +28,6 @@ pub struct DesignerCommand {
pub ip_address: String,
pub port: u16,
pub base_dir: Option<String>,
pub external_frontend_asset_path: Option<String>,
}

pub fn create_sub_cmd(_args_cfg: &crate::cmd_line::ArgsCfg) -> Command {
Expand Down Expand Up @@ -66,17 +65,6 @@ pub fn create_sub_cmd(_args_cfg: &crate::cmd_line::ArgsCfg) -> Command {
.help("The base directory")
.required(false),
)
// This is a hidden feature that allows the use of frontend asset
// resources from the file system instead of the frontend resources
// originally bundled into the tman executable, providing a bit more
// flexibility.
.arg(
Arg::new("EXTERNAL_FRONTEND_ASSET_PATH")
.long("external-frontend-asset-path")
.help("Sets the external frontend asset path")
.required(false)
.hide(true),
)
}

pub fn parse_sub_cmd(
Expand All @@ -89,9 +77,6 @@ pub fn parse_sub_cmd(
.to_string(),
port: *sub_cmd_args.get_one::<u16>("PORT").unwrap(),
base_dir: sub_cmd_args.get_one::<String>("BASE_DIR").cloned(),
external_frontend_asset_path: sub_cmd_args
.get_one::<String>("EXTERNAL_FRONTEND_ASSET_PATH")
.cloned(),
};

Ok(cmd)
Expand Down Expand Up @@ -144,8 +129,6 @@ pub async fn execute_cmd(
tman_config: TmanConfig::default(),
}));

let command_data_cloned = command_data.clone();

let server = HttpServer::new(move || {
let state = web::Data::new(state.clone());

Expand All @@ -159,9 +142,8 @@ pub async fn execute_cmd(
App::new()
.app_data(state.clone())
.wrap(cors)
.configure(|cfg| {
configure_routes(cfg, &command_data_cloned, state.clone())
})
.configure(|cfg| configure_routes(cfg, state.clone()))
.default_service(web::to(get_frontend_asset))
});

let bind_address =
Expand Down
21 changes: 0 additions & 21 deletions core/src/ten_manager/src/designer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ mod version;

use std::sync::{Arc, RwLock};

use actix_files::Files;
use actix_web::web;

use frontend::get_frontend_asset;
use ten_rust::pkg_info::PkgInfo;

use super::config::TmanConfig;
use crate::cmd::cmd_designer::DesignerCommand;
use terminal::ws_terminal;
use version::get_version;

Expand All @@ -42,7 +39,6 @@ pub struct DesignerState {

pub fn configure_routes(
cfg: &mut web::ServiceConfig,
command_data: &DesignerCommand,
state: web::Data<Arc<RwLock<DesignerState>>>,
) {
cfg.service(
Expand Down Expand Up @@ -100,21 +96,4 @@ pub fn configure_routes(
.route("/dir-list/{path}", web::get().to(dir_list::list_dir))
.route("/ws/terminal", web::get().to(ws_terminal)),
);

if let Some(external_frontend_asset_path) =
&command_data.external_frontend_asset_path
{
cfg.service(
Files::new("/", external_frontend_asset_path)
.index_file("index.html")
.use_last_modified(true)
.use_etag(true),
);
} else {
cfg.service(
web::scope("/")
.app_data(state.clone())
.default_service(web::route().to(get_frontend_asset)),
);
}
}

0 comments on commit 47bd3cc

Please sign in to comment.