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
154 lines (139 loc) · 5.73 KB
/
Copy pathupdate.phtml
File metadata and controls
154 lines (139 loc) · 5.73 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
151
152
153
154
<?php
use PHPCensor\Helper\Lang;
use PHPCensor\Model\Build;
/**
* @var Build[] $builds
*/
foreach($builds as $projectId => $projectEnvs):
if (!isset($projects[$projectId])) {
echo '<!-- project '.$projectId.' not set -->';
continue;
}
$project = $projects[$projectId];
foreach($projectEnvs as $environment => $projectEnv):
$statuses = [];
$failures = 0;
$backgroundClass = 'gray';
$cls = '';
$success = null;
$failure = null;
// Get the most recent build status to determine the main block colour.
$last_build = $projectEnv['latest'][0];
$status = $last_build->getStatus();
switch($status) {
case Build::STATUS_PENDING:
$backgroundClass = 'blue';
break;
case Build::STATUS_RUNNING:
$backgroundClass = 'yellow';
break;
case Build::STATUS_SUCCESS:
$backgroundClass = 'green';
break;
case Build::STATUS_FAILED:
$backgroundClass = 'red';
break;
}
// Use the last 5 builds to determine project health:
$failures = 0;
foreach ($projectEnv['latest'] as $build) {
switch ($build->getStatus()) {
case Build::STATUS_PENDING:
$statuses[] = 'pending';
break;
case Build::STATUS_RUNNING:
$statuses[] = 'running';
break;
case Build::STATUS_SUCCESS:
$statuses[] = 'ok';
$success = is_null($success) && !is_null($build->getFinishDate()) ? $build->getFinishDate()->format('Y-m-d H:i:s') : $success;
break;
case Build::STATUS_FAILED:
$failures++;
$statuses[] = 'failed';
$failure = is_null($failure) && !is_null($build->getFinishDate()) ? $build->getFinishDate()->format('Y-m-d H:i:s') : $failure;
break;
}
}
$buildCount = count($projectEnv['latest']);
$lastSuccess = $projectEnv['success'];
$lastFailure = $projectEnv['failed'];
$message = Lang::get('no_builds_yet');
if ($buildCount > 0) {
if ($failures > 0) {
$message = Lang::get('x_of_x_failed', $failures, $buildCount);
if (!is_null($lastSuccess) && !is_null($lastSuccess->getFinishDate())) {
$message .= Lang::get('last_successful_build', $lastSuccess->getFinishDate()->format('Y-m-d H:i:s'));
} else {
$message .= Lang::get('never_built_successfully');
}
} else {
$message = Lang::get('all_builds_passed', $buildCount);
if (!is_null($lastFailure) && !is_null($lastFailure->getFinishDate())) {
$message .= Lang::get('last_failed_build', $lastFailure->getFinishDate()->format('Y-m-d H:i:s'));
} else {
$message .= Lang::get('never_failed_build');
}
}
}
?>
<div class="project-box">
<div class="small-box small-box-full bg-<?= $backgroundClass; ?>">
<div class="inner">
<h3>
<a href="<?= APP_URL; ?>project/view/<?= $project->getId(); ?>">
<?= $project->getTitle(); ?>
</a>
<?php if (!empty($environment)) { ?>
<sup title="<?= Lang::get('environment'); ?>"><?= $environment ?></sup>
<?php } ?>
</h3>
<p>
<?= $message; ?>
</p>
</div>
<div class="icon">
<i class="fa fa-<?= $project->getIcon(); ?>"></i>
</div>
<a href="<?= APP_URL; ?>project/view/<?= $project->getId(); ?>" class="small-box-footer small-box-footer-project">
<div class="pull-left" style="margin-left: 10px">
<?php if ($project->getAllowPublicStatus()): ?>
<i class="fa fa-unlock"></i>
<?php else: ?>
<i class="fa fa-lock"></i>
<?php endif; ?>
</div>
<?= Lang::get('view_project'); ?> <i class="fa fa-arrow-circle-right"></i>
</a>
<?php for ($idx=0; $idx < 5; $idx++) {
if (empty($projectEnv['latest'][$idx])) {
echo '<span class="small-box-footer-build small-box-footer bg-gray"><i class="fa fa-minus"></i></span>';
} else {
$build = $projectEnv['latest'][$idx];
$link = APP_URL . 'build/view/' . $build->getId();
switch ($build->getStatus()) {
case Build::STATUS_PENDING:
$class = 'bg-blue';
$icon = 'fa-clock-o';
break;
case Build::STATUS_RUNNING:
$class = 'bg-yellow';
$icon = 'fa-cogs';
break;
case Build::STATUS_SUCCESS:
$class = 'bg-green';
$icon = 'fa-check';
break;
case Build::STATUS_FAILED:
$class = 'bg-red';
$icon = 'fa-times';
break;
}
echo '<a href="' . $link .'" class="small-box-footer-build small-box-footer ' . $class . '"><i class="fa ' . $icon . '"></i></a>';
}
} ?>
<div style="clear: both;"></div>
</div>
</div>
<?php endforeach; ?>
<?php endforeach; ?>