ui: enable experimental tape UI if tape.cfg exists

This commit is contained in:
Dietmar Maurer 2021-03-03 08:27:54 +01:00
parent 347cde827b
commit 40bf636b47
6 changed files with 16 additions and 10 deletions

View File

@ -86,6 +86,11 @@ async fn run() -> Result<(), Error> {
let mut config = ApiConfig::new( let mut config = ApiConfig::new(
buildcfg::JS_DIR, &proxmox_backup::api2::ROUTER, RpcEnvironmentType::PUBLIC)?; buildcfg::JS_DIR, &proxmox_backup::api2::ROUTER, RpcEnvironmentType::PUBLIC)?;
// Enable experimental tape UI if tape.cfg exists
if Path::new("/etc/proxmox-backup/tape.cfg").exists() {
config.enable_tape_ui = true;
}
config.add_alias("novnc", "/usr/share/novnc-pve"); config.add_alias("novnc", "/usr/share/novnc-pve");
config.add_alias("extjs", "/usr/share/javascript/extjs"); config.add_alias("extjs", "/usr/share/javascript/extjs");
config.add_alias("qrcodejs", "/usr/share/javascript/qrcodejs"); config.add_alias("qrcodejs", "/usr/share/javascript/qrcodejs");

View File

@ -22,6 +22,7 @@ pub struct ApiConfig {
templates: RwLock<Handlebars<'static>>, templates: RwLock<Handlebars<'static>>,
template_files: RwLock<HashMap<String, (SystemTime, PathBuf)>>, template_files: RwLock<HashMap<String, (SystemTime, PathBuf)>>,
request_log: Option<Arc<Mutex<FileLogger>>>, request_log: Option<Arc<Mutex<FileLogger>>>,
pub enable_tape_ui: bool,
} }
impl ApiConfig { impl ApiConfig {
@ -35,6 +36,7 @@ impl ApiConfig {
templates: RwLock::new(Handlebars::new()), templates: RwLock::new(Handlebars::new()),
template_files: RwLock::new(HashMap::new()), template_files: RwLock::new(HashMap::new()),
request_log: None, request_log: None,
enable_tape_ui: false,
}) })
} }

View File

@ -457,6 +457,7 @@ fn get_index(
"CSRFPreventionToken": csrf_token, "CSRFPreventionToken": csrf_token,
"language": lang, "language": lang,
"debug": debug, "debug": debug,
"enableTapeUI": api.enable_tape_ui,
}); });
let (ct, index) = match api.render_template(template_file, &data) { let (ct, index) = match api.render_template(template_file, &data) {

View File

@ -5,9 +5,6 @@ IMAGES := \
images/logo-128.png \ images/logo-128.png \
images/proxmox_logo.png images/proxmox_logo.png
TAPE_UI_FILES=
ifdef TEST_TAPE_GUI
TAPE_UI_FILES= \ TAPE_UI_FILES= \
tape/form/AllocationSelector.js \ tape/form/AllocationSelector.js \
tape/form/ChangerSelector.js \ tape/form/ChangerSelector.js \
@ -34,9 +31,7 @@ TAPE_UI_FILES= \
tape/PoolConfig.js \ tape/PoolConfig.js \
tape/TapeInventory.js \ tape/TapeInventory.js \
tape/BackupJobs.js \ tape/BackupJobs.js \
tape/TapeManagement.js \ tape/TapeManagement.js
endif
JSSRC= \ JSSRC= \
Utils.js \ Utils.js \

View File

@ -118,7 +118,7 @@ Ext.define('PBS.view.main.NavigationTree', {
view.rstore.on('load', this.onLoad, this); view.rstore.on('load', this.onLoad, this);
view.on('destroy', view.rstore.stopUpdate); view.on('destroy', view.rstore.stopUpdate);
if (PBS.TapeManagement !== undefined) { if (PBS.enableTapeUI) {
view.tapestore = Ext.create('Proxmox.data.UpdateStore', { view.tapestore = Ext.create('Proxmox.data.UpdateStore', {
autoStart: true, autoStart: true,
interval: 2 * 1000, interval: 2 * 1000,
@ -266,7 +266,7 @@ Ext.define('PBS.view.main.NavigationTree', {
select: function(path, silent) { select: function(path, silent) {
var me = this; var me = this;
if (me.rstore.isLoaded() && (!PBS.TapeManagement || me.tapestore.isLoaded())) { if (me.rstore.isLoaded() && (!PBS.enableTapeUI || me.tapestore.isLoaded())) {
if (silent) { if (silent) {
me.suspendEvents(false); me.suspendEvents(false);
} }

View File

@ -31,6 +31,9 @@
UserName: "{{ UserName }}", UserName: "{{ UserName }}",
CSRFPreventionToken: "{{ CSRFPreventionToken }}", CSRFPreventionToken: "{{ CSRFPreventionToken }}",
}; };
PBS = {
enableTapeUI: {{ enableTapeUI }},
};
</script> </script>
<script type="text/javascript" src="/widgettoolkit/proxmoxlib.js"></script> <script type="text/javascript" src="/widgettoolkit/proxmoxlib.js"></script>
<script type="text/javascript" src="/extjs/locale/locale-en.js"></script> <script type="text/javascript" src="/extjs/locale/locale-en.js"></script>