sse_url_prefix: String,
links: Html,
player_info_pane: Html,
+ bundles_info_pane: Html,
fake_rng: bool,
}
nick,
sse_url_prefix,
player_info_pane,
+ bundles_info_pane: ig.bundle_list.info_pane()?,
ptoken: form.ptoken.clone(),
links: (&*ig.links).into(),
fake_rng: config().game_rng.is_fake(),
--- /dev/null
+{# -*- HTML -*- -#}
+<!-- Copyright 2020-2021 Ian Jackson and contributors to Otter
+ SPDX-License-Identifier: AGPL-3.0-or-later
+ There is NO WARRANTY. -->
+{% for b in bundles %}
+<div class="bundle">
+<a href=""><code class="b_id">#{{ b.id }}</code></a>
+<span class="b_title">{{ b.title }}</span>
+</div>
+{% endfor %}
#[throws(Self::Err)]
fn from_str(s: &str) -> Index { Index(u16::from_str(s)?) }
}
+hformat_as_display!{Id}
const BUNDLES_MAX: Index = Index(64);
fn updated(&self, ig: &mut Instance) {
ig.bundle_list = self.iter().map(|(id, state)| {
(id, state.clone())
- }).collect()
+ }).collect();
+
+ let new_info_pane = ig.bundle_list.info_pane().unwrap_or_else(|e|{
+ let m = "error rendering bundle list";
+ error!("{}: {}", m, e);
+ Html::from_txt(m)
+ });
+ let new_info_pane = Arc::new(new_info_pane);
+ let mut prepub = PrepareUpdatesBuffer::new(ig, Some(1));
+ prepub.raw_updates(vec![
+ PUE::UpdateBundles { new_info_pane }
+ ]);
}
#[throws(IE)]
}
}
+#[ext(pub)]
+impl MgmtBundleList {
+ #[throws(IE)]
+ fn info_pane(&self) -> Html {
+ #[derive(Serialize,Debug)]
+ struct RenderPane {
+ bundles: Vec<RenderBundle>,
+ }
+ #[derive(Serialize,Debug)]
+ struct RenderBundle {
+ id: Html,
+ title: Html,
+ }
+ let bundles = self.iter().filter_map(|(&id, state)| {
+ if_let!{ State::Loaded(Loaded { meta }) = state; else return None; }
+ let BundleMeta { title } = meta;
+ let id = hformat!("{}", id);
+ let title = Html::from_txt(title);
+ Some(RenderBundle { id, title })
+ }).collect();
+
+ Html::from_html_string(
+ nwtemplates::render("bundles-info-pane.tera", &RenderPane { bundles })?
+ )
+ }
+}
+
impl InstanceBundles {
#[throws(MgmtError)]
pub fn finish_upload(&mut self, ig: &mut Instance,
pub use crate::accounts::*;
pub use crate::authproofs::{self, Authorisation, Unauthorised};
pub use crate::authproofs::AuthorisationSuperuser;
-pub use crate::bundles::{self, InstanceBundles};
+pub use crate::bundles::{self, InstanceBundles, MgmtBundleListExt};
pub use crate::commands::{AccessTokenInfo, AccessTokenReport, MgmtError};
pub use crate::commands::{MgmtCommand, MgmtResponse};
pub use crate::commands::{MgmtGameInstruction, MgmtGameResponse};
player: PlayerId,
new_info_pane: Arc<Html>,
},
+ UpdateBundles {
+ new_info_pane: Arc<Html>,
+ },
Log(Arc<CommittedLogEntry>),
Error(ErrorSignaledViaUpdate<PUE_P>),
}
player: PlayerId,
new_info_pane: &'u Html,
},
+ UpdateBundles {
+ new_info_pane: &'u Arc<Html>,
+ },
SetLinks(Html),
#[serde(serialize_with="serialize_logentry")]
Log(TransmitUpdateLogEntry<'u>),
RemovePlayer { player:_, new_info_pane } => {
new_info_pane.json_len() + 100
}
+ UpdateBundles { new_info_pane } => {
+ new_info_pane.json_len() + 100
+ }
SetTableColour(colour) => {
colour.json_len() + 50
}
&PUE::RemovePlayer { player, ref new_info_pane } => {
TUE::RemovePlayer { player, new_info_pane }
}
+ &PUE::UpdateBundles { ref new_info_pane } => {
+ TUE::UpdateBundles { new_info_pane }
+ }
PUE::Error(e) => {
match *e {
ESVU::InternalError => TUE::Error(ESVU::InternalError),
<div class="uokey">Show
<strong>H</strong> this help
<strong>U</strong> players
+ <strong>B</strong> bundles
</div>
</div>
</div>
</div>
</div>
+ <div id="pane_bundles" class="somepane" style="display:none">
+ <div id="bundle_list_columns">
+<div><strong>Bundles</strong> (<strong>H</strong>/<strong>B</strong>: return to help)</div>
+ <div id="bundle_list">
+{{ bundles_info_pane }}
+ </div>
+ </div>
+ </div>
+
</div id="infopane">
{% endmacro infopane %}
const pane_keys : { [key: string]: PaneName } = {
"H" : "help",
"U" : "players",
+ "B" : "bundles",
};
const uo_kind_prec : { [kind: string]: number } = {
.innerHTML = j.new_info_pane;
}
+messages.UpdateBundles = <MessageHandler>function
+(j: { new_info_pane: string }) {
+ document.getElementById('bundle_list')!
+ .innerHTML = j.new_info_pane;
+}
+
messages.SetTableSize = <MessageHandler>function
([x, y]: [number, number]) {
function set_attrs(elem: Element, l: [string,string][]) {