forked from php-censor/php-censor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.phtml
More file actions
150 lines (133 loc) · 5.51 KB
/
Copy pathupdate.phtml
File metadata and controls
150 lines (133 loc) · 5.51 KB
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
<?php
use PHPCensor\Helper\Lang;
use PHPCensor\Model\Build;
use PHPCensor\Helper\Template;
/**
* @var Build[] $builds
*/
?>
<ul class="timeline">
<?php $last = new \DateTime('-1 Year'); ?>
<?php
foreach ($builds as $build):
$environment = $build->getEnvironment();
$branches = $build->getExtra('branches');
switch ($build->getStatus()) {
case Build::STATUS_PENDING:
$updated = $build->getCreateDate();
$label = Lang::get('pending');
$color = 'blue';
break;
case Build::STATUS_RUNNING:
$updated = $build->getStartDate();
$label = Lang::get('running');
$color = 'yellow';
break;
case Build::STATUS_SUCCESS:
$updated = $build->getFinishDate();
$label = Lang::get('success');
$color = 'green';
break;
case Build::STATUS_FAILED:
$updated = $build->getFinishDate();
$label = Lang::get('failed');
$color = 'red';
break;
}
if (!$updated) {
$updated = $build->getCreateDate();
}
if ($updated->format('Y-m-d') != $last->format('Y-m-d')): $last = $updated;
?>
<li class="time-label">
<span class="bg-gray">
<?= $last->format('Y-m-d'); ?>
</span>
</li>
<?php endif; ?>
<!-- /.timeline-label -->
<!-- timeline item -->
<li>
<i class="fa fa-<?= $build->getProject()->getIcon(); ?> bg-<?= $color; ?>"></i>
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i>
<?php
echo $updated->format('H:i:s');
if ($build->getStatus() != Build::STATUS_PENDING) {
echo ' — ' . $build->getDuration(); ?> <?= Lang::get('seconds');
}
?>
</span>
<h3 class="timeline-header">
<a href="<?= APP_URL; ?>project/view/<?= $build->getProjectId(); ?>">
<?= $build->getProject()->getTitle(); ?>
</a>
<span><?= $environment; ?></span>
—
<a href="<?= APP_URL; ?>build/view/<?= $build->getId(); ?>">
<?= Lang::get('build'); ?> #<?= $build->getId(); ?>
</a>
—
<?= $build->getSourceHumanize(); ?>
—
<?= Lang::get('total_errors'); ?>:
<?= (int)$build->getErrorsTotal(); ?>
<?php if(!in_array($build->getStatus(),[Build::STATUS_PENDING, Build::STATUS_RUNNING], true)): ?>
<?php $trend = $build->getErrorsTrend(); ?>
<?php if (1 === $trend): ?>
<i class="fa fa-arrow-down arrow_trend_positive"></i>
<?php elseif (-1 === $trend): ?>
<i class="fa fa-arrow-up arrow_trend_negative"></i>
<?php endif; ?>
<?php endif; ?>
<?php if ($newErrorsCount = $build->getErrorsNew()): ?>
/
<?= Lang::get('new_errors'); ?>:
<?= $newErrorsCount; ?>
<?php endif; ?>
</h3>
<div class="timeline-body">
<p>
<?php if (in_array($build->getSource(), Build::$pullRequestSources, true)): ?>
<a href="<?= $build->getRemoteBranchLink(); ?>">
<i class="fa fa-code-fork"></i>
<?= $build->getRemoteBranch(); ?> :
</a>
<?php endif; ?>
<a href="<?= $build->getBranchLink(); ?>">
<i class="fa fa-code-fork"></i>
<?= $build->getBranch(); ?>
</a>
<?= $branches ? ' + '.implode(', ', $branches) : ''; ?>
<?php if ($tag = $build->getTag()): ?> /
<a href="<?= $build->getTagLink(); ?>">
<i class="fa fa-tag"></i>
<?= $tag; ?>
</a>
<?php endif; ?>
<?php
if (!empty($build->getCommitId())) {
echo ' — ';
echo sprintf(
'<a href="%s">%s %s</a>',
$build->getCommitLink(),
substr($build->getCommitId(), 0, 7),
$build->getCommitterEmail() ? ('(' . $build->getCommitterEmail() . ')') : ''
);
$buildCommitMessage = Template::clean($build->getCommitMessage());
if ($buildCommitMessage) {
echo '</p><p>';
echo $buildCommitMessage;
}
}
?>
</p>
</div>
</div>
</li>
<!-- END timeline item -->
<?php endforeach; ?>
<li>
<i class="fa fa-clock-o"></i>
</li>
</ul>