summaryrefslogtreecommitdiffstats
path: root/modules/setup/application/views/scripts/index/index.phtml
blob: 32952e7d319dfbdc70dacee18ce1885a67ac1e36 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php

use Icinga\Util\Csp;
use Icinga\Web\Notification;
use ipl\Web\Style;

$pages = $wizard->getPages();
$finished = isset($success);
$configPages = array_slice($pages, 3, count($pages) - 4, true);
$currentPos = array_search($wizard->getCurrentPage(), $pages, true);
list($configPagesLeft, $configPagesRight) = array_chunk($configPages, (int)(count($configPages) / 2), true);
$setupStyle = (new Style())
    ->setSelector('.setup-header > .progress-bar')
    ->setNonce(Csp::getStyleNonce());

$visitedPages = array_keys($wizard->getPageData());
$maxProgress = max(array_merge([0], array_keys(array_filter(
    $pages,
    function ($page) use ($visitedPages) { return in_array($page->getName(), $visitedPages); }
))));

$setupStyle->add(
    '.width-percent-10',
    ['width' => '10%']
)->add(
    '.width-percent-60',
    ['width' => '60%']
);
?>
<div id="setup-content-wrapper" data-base-target="layout">
  <div class="setup-header">
    <?= $this->img('img/icinga-logo-big.png'); ?>
    <div class="progress-bar">
      <div class="step width-percent-10">
        <h1><?= $this->translate('Welcome', 'setup.progress'); ?></h1>
        <?php $stateClass = $finished || $currentPos > 0 ? 'complete' : (
          $maxProgress > 0 ? 'visited' : 'active'
        ); ?>
        <table><tbody><tr>
          <td class="left"></td>
          <td class="middle"><div class="bubble <?= $stateClass; ?>"></div></td>
          <td class="right"><div class="line right <?= $stateClass; ?>"></div></td>
        </tr></tbody></table>
      </div>
      <div class="step width-percent-10">
        <h1><?= $this->translate('Modules', 'setup.progress'); ?></h1>
        <?php $stateClass = $finished || $currentPos > 1 ? ' complete' : (
          $maxProgress > 1 ? ' visited' : (
            $currentPos === 1 ? ' active' : ''
          )
        ); ?>
        <table><tbody><tr>
          <td class="left"><div class="line left<?= $stateClass; ?>"></div></td>
          <td class="middle"><div class="bubble <?= $stateClass; ?>"></div></td>
          <td class="right"><div class="line right <?= $stateClass; ?>"></div></td>
        </tr></tbody></table>
        <?php if (($maxProgress < $currentPos && $currentPos === 1) || ($maxProgress >= $currentPos && $maxProgress === 1)): ?>
          <?= $this->restartForm ?>
        <?php endif ?>
      </div>
      <div class="step width-percent-10">
        <h1><?= $this->translate('Requirements', 'setup.progress'); ?></h1>
        <?php $stateClass = $finished || $currentPos > 2 ? ' complete' : (
          $maxProgress > 2 ? ' visited' : (
            $currentPos === 2 ? ' active' : ''
          )
        ); ?>
        <table><tbody><tr>
          <td class="left"><div class="line left<?= $stateClass; ?>"></div></td>
          <td class="middle"><div class="bubble<?= $stateClass; ?>"></div></td>
          <td class="right"><div class="line right<?= $stateClass; ?>"></div></td>
        </tr></tbody></table>
        <?php if (($maxProgress < $currentPos && $currentPos === 2) || ($maxProgress >= $currentPos && $maxProgress === 2)): ?>
          <?= $this->restartForm ?>
        <?php endif ?>
      </div>
      <div class="step width-percent-60">
        <h1><?= $this->translate('Configuration', 'setup.progress'); ?></h1>
        <table><tbody><tr>
          <td class="left">
          <?php
            $firstPage = current($configPagesLeft);
            $lastPage = end($configPagesLeft);
            $lineWidth = sprintf('%.2F', round(100 / count($configPagesLeft), 2, PHP_ROUND_HALF_DOWN));
          ?>
          <?php foreach ($configPagesLeft as $pos => $page): ?>
            <?php $stateClass = $finished || $pos < $currentPos ? ' complete' : (
              $pos < $maxProgress ? ' visited' : ($currentPos > 2 ? ' active' : '')
            ); ?>
            <?php if ($page === $firstPage): ?>
            <?php
                $setupStyle->add(
                    '.step .left-line-' . $pos,
                    [
                        'float'         => 'left',
                        'width'         => sprintf(
                            '%.2F%%',
                            100 - (count($configPagesLeft) - 1) * $lineWidth
                        ),
                        'margin-right'  => 0
                    ]
                );
            ?>
            <div class="line left<?= $stateClass; ?> left-line-<?= $pos; ?>"></div>
            <?php elseif ($page === $lastPage): ?>
                <?php
                  $setupStyle->add(
                      '.step .left-line-' . $pos,
                      [
                          'float'         => 'left',
                          'width'         => $lineWidth . '%',
                          'margin-right'  => '-0.1em'
                      ]
                  );
                ?>
                <div class="line<?= $stateClass; ?> left-line-<?= $pos; ?>"></div>
            <?php else: ?>
                <?php
                    $setupStyle->add(
                        '.step .left-line-' . $pos,
                        [
                            'float' => 'left',
                            'width' => $lineWidth . '%'
                        ]
                    );
                ?>
                <div class="line<?= $stateClass; ?> left-line-<?= $pos; ?>"></div>
            <?php endif ?>
          <?php endforeach ?>
          </td>
          <td class="middle">
            <div class="bubble<?= array_key_exists($currentPos, $configPagesLeft) ? (
              key($configPagesRight) <= $maxProgress ? ' visited' : ' active') : (
              $finished || $currentPos > 2 ? ' complete' : (
                key($configPagesRight) < $maxProgress ? ' visited' : ''
              )
            ); ?>"></div>
          </td>
          <td class="right">
          <?php
            $firstPage = current($configPagesRight);
            $lastPage = end($configPagesRight);
            $lineWidth = sprintf('%.2F', round(100 / count($configPagesRight), 2, PHP_ROUND_HALF_DOWN));
          ?>
          <?php foreach ($configPagesRight as $pos => $page): ?>
            <?php $stateClass = $finished || $pos < $currentPos ? ' complete' : (
              $pos < $maxProgress ? ' visited' : ($currentPos > 2 ? ' active' : '')
            ); ?>
            <?php if ($page === $firstPage): ?>
              <?php
                  $setupStyle->add(
                      '.step .right-line-' . $pos,
                      [
                          'float'         => 'left',
                          'width'         => $lineWidth . '%',
                          'margin-right'  => '-0.1em'
                      ]
                  );
              ?>
              <div class="line<?= $stateClass; ?> right-line-<?= $pos; ?>"></div>
            <?php elseif ($page === $lastPage): ?>
              <?php
                  $setupStyle->add(
                      '.step .right-line-' . $pos,
                      [
                          'float'         => 'left',
                          'width'         => sprintf(
                              '%.2F%%',
                              100 - (count($configPagesRight) - 1) * $lineWidth
                          ),
                          'margin-right'  => 0
                      ]
                  );
              ?>
            <div class="line right<?= $stateClass; ?> right-line-<?= $pos; ?>"></div>
            <?php else: ?>
              <?php
                  $setupStyle->add(
                      '.step .right-line-' . $pos,
                      [
                          'float' => 'left',
                          'width' => $lineWidth . '%'
                      ]
                  );
              ?>
            <div class="line<?= $stateClass; ?> right-line-<?= $pos; ?>"></div>
            <?php endif ?>
          <?php endforeach ?>
          </td>
        </tr></tbody></table>
        <?php if ($maxProgress > 2 || $currentPos > 2): ?>
          <?= $this->restartForm ?>
        <?php endif ?>
      </div>
      <div class="step width-percent-10">
        <h1><?= $this->translate('Finish', 'setup.progress'); ?></h1>
        <?php $stateClass = $finished ? ' complete' : ($pages[$currentPos] === end($pages) ? ' active' : ''); ?>
        <table><tbody><tr>
          <td class="left"><div class="line left<?= $stateClass; ?>"></div></td>
          <td class="middle"><div class="bubble<?= $stateClass; ?>"></div></td>
          <td class="right"></td>
        </tr></tbody></table>
      </div>
    </div>
  </div>
  <div class="setup-content">
<?php if ($finished): ?>
    <?= $this->render('index/parts/finish.phtml'); ?>
<?php else: ?>
    <?= $this->render('index/parts/wizard.phtml'); ?>
<?php endif ?>
  </div>
</div>
<div id="footer">
    <ul role="alert" id="notifications"><?php
        $notifications = Notification::getInstance();
        if ($notifications->hasMessages()) {
            foreach ($notifications->popMessages() as $m) {
                echo '<li class="' . $m->type . '">' . $this->escape($m->message) . '</li>';
            }
        }
    ?></ul>
</div>
<?= $setupStyle; ?>