File: index.phtml

package info (click to toggle)
icingaweb2-module-map 2.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,032 kB
  • sloc: javascript: 11,939; php: 1,207; sh: 54; makefile: 15
file content (59 lines) | stat: -rw-r--r-- 2,843 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
?>
<script type="text/javascript">
    <?php
    echo 'var map_default_zoom = ' . (!empty($this->default_zoom) ? intval($this->default_zoom) : "null") . ";\n";
    echo 'var map_default_long = ' . (!empty($this->default_long) ? preg_replace("/[^0-9\.\,\-]/", "", $this->default_long) : "null") . ";\n";
    echo 'var map_default_lat = ' . (!empty($this->default_lat) ? preg_replace("/[^0-9\.\,\-]/", "", $this->default_lat) : "null") . ";\n";
    echo 'var map_max_zoom = ' . intval($this->max_zoom) . ";\n";
    echo 'var map_max_native_zoom = ' . intval($this->max_native_zoom) . ";\n";
    echo 'var map_min_zoom = ' . intval($this->min_zoom) . ";\n";
    echo 'var disable_cluster_at_zoom = ' . intval($this->disable_cluster_at_zoom) . ";\n";
    echo "var tile_url = '" . preg_replace("/[\'\;]/", "", $this->tile_url) . "';\n";
    echo "var cluster_problem_count = " . intval($this->cluster_problem_count) . ";\n";
    echo "var popup_mouseover = " . intval($this->popup_mouseover) . ";\n";
    echo 'var map_show_host = "' . (! empty($this->host) ? preg_replace("/[\'\;]/", "", $this->host) : "null") . "\";\n";
    ?>
    var service_status = {};
    service_status[0] = ['<?= $this->translate('OK', 'icinga.state') ?>', 'OK'];
    service_status[1] = ['<?= $this->translate('WARNING', 'icinga.state') ?>', 'WARNING'];
    service_status[2] = ['<?= $this->translate('CRITICAL', 'icinga.state') ?>', 'CRITICAL'];
    service_status[3] = ['<?= $this->translate('UNKNOWN', 'icinga.state') ?>', 'UNKNOWN'];
    service_status[99] = ['<?= $this->translate('PENDING', 'icinga.state') ?>', 'PENDING'];

    // @TODO: Is there a better way of translation in JS-Code?
    <?php
    $toTranslate = array(
        "btn-zoom-in" => "Zoom in",
        "btn-zoom-out" => "Zoom out",
        "btn-dashboard" => "Add to dashboard",
        "btn-fullscreen" => "Fullscreen",
        "btn-default" => "Show default view",
        "btn-locate" => "Show current location",
        "host-down" => "Host is down"
    );

    print("var translation = {");
    foreach ($toTranslate as $key => $value) {
        printf("'%s': '%s',", $key, $this->translate($value));
    }
    print("};\n");
    ?>

    var url_parameters = "<?=$this->url_parameters; ?>";
    var id = '<?= $this->id ?>';
    var dashlet = <?= $this->compact ? 'true' : 'false' ?>;
    var expand = <?= $this->expand ? 'true' : 'false' ?>;
    var isUsingIcingadb = <?= $this->isUsingIcingadb ? 'true' : 'false' ?>;
</script>
<div class="controls">
    <?php if (!$this->compact && !$this->fullscreen): ?>
        <?= $this->tabs ?>
    <?php endif ?>
</div>
<div class="content">
    <div <?= ($this->compact ? 'style="height:' . $this->dashletHeight . 'px;" ' : ""); ?>id="map-<?= $this->id ?>"
         class="map<?php if ($this->compact): ?>
 compact
<?php endif ?>"></div>
</div>