some cleanup
This commit is contained in:
@@ -5,11 +5,11 @@ COMPONENT(Request& context)
|
||||
starter_register_js("components/gauges/common.js", context);
|
||||
starter_register_css("themes/common/css/gauges.css", context);
|
||||
|
||||
String gauge_id = first(context.call["id"].to_string(), "arcgauge-" + std::to_string((u64)time()));
|
||||
String title = context.call["title"].to_string();
|
||||
String subtitle = context.call["subtitle"].to_string();
|
||||
String style = context.call["style"].to_string();
|
||||
DTree scale = context.call["scale"];
|
||||
String gauge_id = first(context.props["id"].to_string(), "arcgauge-" + std::to_string((u64)time()));
|
||||
String title = context.props["title"].to_string();
|
||||
String subtitle = context.props["subtitle"].to_string();
|
||||
String style = context.props["style"].to_string();
|
||||
DTree scale = context.props["scale"];
|
||||
|
||||
<>
|
||||
<div class="arcgauge-set" id="<?= gauge_attr_id(gauge_id) ?>" style="<?= style ?>">
|
||||
@@ -20,7 +20,7 @@ COMPONENT(Request& context)
|
||||
</div>
|
||||
<? } ?>
|
||||
<div class="arcgauge-grid">
|
||||
<? context.call["items"].each([&](DTree item, String item_id_raw) {
|
||||
<? context.props["items"].each([&](DTree item, String item_id_raw) {
|
||||
DTree merged = scale;
|
||||
item.each([&](DTree value, String key) { merged[key] = value; });
|
||||
String item_id = gauge_attr_id(item_id_raw);
|
||||
@@ -62,7 +62,7 @@ COMPONENT(Request& context)
|
||||
}); ?>
|
||||
</div>
|
||||
</div>
|
||||
<? if(context.call["listen"].to_string() != "") { ?>
|
||||
<? if(context.props["listen"].to_string() != "") { ?>
|
||||
<script>
|
||||
window.ArcgaugeComponents = window.ArcgaugeComponents || {
|
||||
start_listen : function(prop) {
|
||||
@@ -84,7 +84,7 @@ COMPONENT(Request& context)
|
||||
});
|
||||
}
|
||||
};
|
||||
ArcgaugeComponents.start_listen(<?: json_encode(context.call, '\'') ?>);
|
||||
ArcgaugeComponents.start_listen(<?: json_encode(context.props, '\'') ?>);
|
||||
</script>
|
||||
<? } ?>
|
||||
</>
|
||||
|
||||
@@ -5,15 +5,15 @@ COMPONENT(Request& context)
|
||||
starter_register_js("components/gauges/common.js", context);
|
||||
starter_register_css("themes/common/css/gauges.css", context);
|
||||
|
||||
String gauge_id = first(context.call["id"].to_string(), "needlegauge-" + std::to_string((u64)time()));
|
||||
String style = context.call["style"].to_string();
|
||||
String title = context.call["title"].to_string();
|
||||
String subtitle = context.call["subtitle"].to_string();
|
||||
f64 size = float_val(first(context.call["size"].to_string(), "200"));
|
||||
DTree scale = context.call["scale"];
|
||||
String gauge_id = first(context.props["id"].to_string(), "needlegauge-" + std::to_string((u64)time()));
|
||||
String style = context.props["style"].to_string();
|
||||
String title = context.props["title"].to_string();
|
||||
String subtitle = context.props["subtitle"].to_string();
|
||||
f64 size = float_val(first(context.props["size"].to_string(), "200"));
|
||||
DTree scale = context.props["scale"];
|
||||
f64 scale_angle_start = float_val(first(scale["angle_start"].to_string(), std::to_string(-gauge_pi())));
|
||||
f64 scale_angle_end = float_val(first(scale["angle_end"].to_string(), "0"));
|
||||
f64 img_height = float_val(first(context.call["img_height"].to_string(), std::to_string(size * std::max(cos(scale_angle_start), cos(scale_angle_end)))));
|
||||
f64 img_height = float_val(first(context.props["img_height"].to_string(), std::to_string(size * std::max(cos(scale_angle_start), cos(scale_angle_end)))));
|
||||
|
||||
<>
|
||||
<section class="gauge-set needlegauge-set" id="<?= gauge_attr_id(gauge_id) ?>" style="<?= style ?>">
|
||||
@@ -24,7 +24,7 @@ COMPONENT(Request& context)
|
||||
</div>
|
||||
<? } ?>
|
||||
<div class="needlegauge-grid">
|
||||
<? context.call["items"].each([&](DTree item, String item_id_raw) {
|
||||
<? context.props["items"].each([&](DTree item, String item_id_raw) {
|
||||
DTree merged = scale;
|
||||
item.each([&](DTree value, String key) { merged[key] = value; });
|
||||
String item_id = gauge_attr_id(item_id_raw);
|
||||
@@ -117,7 +117,7 @@ COMPONENT(Request& context)
|
||||
}); ?>
|
||||
</div>
|
||||
</section>
|
||||
<? if(context.call["listen"].to_string() != "") { ?>
|
||||
<? if(context.props["listen"].to_string() != "") { ?>
|
||||
<script>
|
||||
window.NeedlegaugeComponents = window.NeedlegaugeComponents || {
|
||||
start_listen : function(prop) {
|
||||
@@ -137,7 +137,7 @@ COMPONENT(Request& context)
|
||||
});
|
||||
}
|
||||
};
|
||||
NeedlegaugeComponents.start_listen(<?: json_encode(context.call, '\'') ?>);
|
||||
NeedlegaugeComponents.start_listen(<?: json_encode(context.props, '\'') ?>);
|
||||
</script>
|
||||
<? } ?>
|
||||
</>
|
||||
|
||||
@@ -5,18 +5,18 @@ COMPONENT(Request& context)
|
||||
starter_register_js("components/gauges/common.js", context);
|
||||
starter_register_css("themes/common/css/gauges.css", context);
|
||||
|
||||
String gauge_id = first(context.call["id"].to_string(), "progressbar-" + std::to_string((u64)time()));
|
||||
String style = context.call["style"].to_string();
|
||||
String item_style = context.call["item-style"].to_string();
|
||||
String label_style = context.call["label-style"].to_string();
|
||||
String value_style = context.call["value-style"].to_string();
|
||||
String bar_style = context.call["bar-style"].to_string();
|
||||
String title = context.call["title"].to_string();
|
||||
String subtitle = context.call["subtitle"].to_string();
|
||||
String layout = first(context.call["layout"].to_string(), "horizontal");
|
||||
String bar_color_default = context.call["bar-color"].to_string();
|
||||
DTree scale = context.call["scale"];
|
||||
DTree markers = context.call["markers"];
|
||||
String gauge_id = first(context.props["id"].to_string(), "progressbar-" + std::to_string((u64)time()));
|
||||
String style = context.props["style"].to_string();
|
||||
String item_style = context.props["item-style"].to_string();
|
||||
String label_style = context.props["label-style"].to_string();
|
||||
String value_style = context.props["value-style"].to_string();
|
||||
String bar_style = context.props["bar-style"].to_string();
|
||||
String title = context.props["title"].to_string();
|
||||
String subtitle = context.props["subtitle"].to_string();
|
||||
String layout = first(context.props["layout"].to_string(), "horizontal");
|
||||
String bar_color_default = context.props["bar-color"].to_string();
|
||||
DTree scale = context.props["scale"];
|
||||
DTree markers = context.props["markers"];
|
||||
|
||||
StringList default_palette;
|
||||
default_palette.push_back("var(--success, #10b981)");
|
||||
@@ -35,7 +35,7 @@ COMPONENT(Request& context)
|
||||
<? } ?>
|
||||
<? if(layout == "horizontal") { ?>
|
||||
<div class="progressbar-grid progressbar-grid-horizontal">
|
||||
<? context.call["items"].each([&](DTree bar, String bar_id) {
|
||||
<? context.props["items"].each([&](DTree bar, String bar_id) {
|
||||
DTree merged = scale;
|
||||
bar.each([&](DTree item, String key) { merged[key] = item; });
|
||||
String item_id = gauge_attr_id(bar_id);
|
||||
@@ -86,8 +86,8 @@ COMPONENT(Request& context)
|
||||
}); ?>
|
||||
</div>
|
||||
<? } else { ?>
|
||||
<div class="progressbar-grid progressbar-grid-vertical" style="--progressbar-height: <?= first(context.call["height"].to_string(), "240") ?>px;">
|
||||
<? context.call["items"].each([&](DTree bar, String bar_id) {
|
||||
<div class="progressbar-grid progressbar-grid-vertical" style="--progressbar-height: <?= first(context.props["height"].to_string(), "240") ?>px;">
|
||||
<? context.props["items"].each([&](DTree bar, String bar_id) {
|
||||
DTree merged = scale;
|
||||
bar.each([&](DTree item, String key) { merged[key] = item; });
|
||||
String item_id = gauge_attr_id(bar_id);
|
||||
@@ -137,7 +137,7 @@ COMPONENT(Request& context)
|
||||
</div>
|
||||
<? } ?>
|
||||
</section>
|
||||
<? if(context.call["listen"].to_string() != "") { ?>
|
||||
<? if(context.props["listen"].to_string() != "") { ?>
|
||||
<script>
|
||||
window.ProgressbarComponents = window.ProgressbarComponents || {
|
||||
start_listen : function(prop) {
|
||||
@@ -161,7 +161,7 @@ COMPONENT(Request& context)
|
||||
});
|
||||
}
|
||||
};
|
||||
ProgressbarComponents.start_listen(<?: json_encode(context.call, '\'') ?>);
|
||||
ProgressbarComponents.start_listen(<?: json_encode(context.props, '\'') ?>);
|
||||
</script>
|
||||
<? } ?>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user