CheckStatistics: Show TimePeriod name if available

This commit is contained in:
Sukhwinder Dhillon 2023-06-06 13:14:50 +02:00 committed by Johannes Meyer
parent 690feba9df
commit 2e7d7b9129
6 changed files with 21 additions and 4 deletions

View file

@ -40,7 +40,7 @@ class HostController extends Controller
{
$name = $this->params->getRequired('name');
$query = Host::on($this->getDb())->with(['state', 'icon_image']);
$query = Host::on($this->getDb())->with(['state', 'icon_image', 'timeperiod']);
$query
->setResultSetClass(VolatileStateResults::class)
->filter(Filter::equal('host.name', $name));

View file

@ -41,7 +41,8 @@ class ServiceController extends Controller
'state',
'icon_image',
'host',
'host.state'
'host.state',
'timeperiod'
]);
$query
->setResultSetClass(VolatileStateResults::class)

View file

@ -199,7 +199,8 @@ class Host extends Model
$relations->belongsTo('eventcommand', Eventcommand::class);
$relations->belongsTo('checkcommand', Checkcommand::class);
$relations->belongsTo('timeperiod', Timeperiod::class)
->setCandidateKey('check_timeperiod_id');
->setCandidateKey('check_timeperiod_id')
->setJoinType('LEFT');
$relations->belongsTo('action_url', ActionUrl::class)
->setCandidateKey('action_url_id')
->setForeignKey('id');

View file

@ -188,7 +188,8 @@ class Service extends Model
$relations->belongsTo('host', Host::class)->setJoinType('LEFT');
$relations->belongsTo('checkcommand', Checkcommand::class);
$relations->belongsTo('timeperiod', Timeperiod::class)
->setCandidateKey('check_timeperiod_id');
->setCandidateKey('check_timeperiod_id')
->setJoinType('LEFT');
$relations->belongsTo('eventcommand', Eventcommand::class);
$relations->belongsTo('action_url', ActionUrl::class)
->setCandidateKey('action_url_id')

View file

@ -191,6 +191,15 @@ class CheckStatistics extends Card
t('Scheduling Source') . ':',
$this->object->state->scheduling_source ?? (new EmptyState(t('n. a.')))->setTag('span')
));
if ($this->object->timeperiod->id) {
$footer->add(new HorizontalKeyValue(
t('Timeperiod') . ':',
$this->object->timeperiod->display_name ?? $this->object->timeperiod->name
));
$footer->addAttributes(['class' => 'space-between']);
}
}
protected function assembleHeader(BaseHtmlElement $header)

View file

@ -7,6 +7,11 @@
justify-content: center;
border-top: 1px solid @gray-light;
&.space-between {
justify-content: space-between;
padding: 0 0.5em;
}
.key {
width: auto;
margin-right: .28125em; //calculated   width