fix dashboard ajax reload

This commit is contained in:
msquare 2017-12-13 16:51:38 +01:00
parent 4277906768
commit cf7eb80a92
1 changed files with 19 additions and 14 deletions

View File

@ -19,15 +19,24 @@ function public_dashboard_view($stats, $free_shifts)
]); ]);
} }
return page([ return page([
div('first container-fluid', [ div('public-dashboard', [
stats(_('Angels needed in the next 3 hrs'), $stats['needed-3-hours']), div('first container-fluid', [
stats(_('Angels needed for nightshifts'), $stats['needed-night']), stats(_('Angels needed in the next 3 hrs'), $stats['needed-3-hours']),
stats(_('Angels currently working'), $stats['angels-working'], 'default'), stats(_('Angels needed for nightshifts'), $stats['needed-night']),
stats(_('Hours to be worked'), $stats['hours-to-work'], 'default'), stats(_('Angels currently working'), $stats['angels-working'], 'default'),
'<script>$(function(){setTimeout(function(){$(\'#statistics\').load(window.location.href + \' #statistics\');}, 60000)})</script>' stats(_('Hours to be worked'), $stats['hours-to-work'], 'default'),
], 'statistics'), '<script>
$needed_angels $(function() {
]); setInterval(function() {
$(\'#public-dashboard\').parent().load(window.location.href + \' #public-dashboard\');
}, 60000);
})
</script>'
], 'statistics'),
$needed_angels
], 'public-dashboard')
]
);
} }
/** /**
@ -56,11 +65,7 @@ function public_dashborad_shift_render($shift)
foreach ($shift['NeedAngels'] as $needed_angels) { foreach ($shift['NeedAngels'] as $needed_angels) {
$need = $needed_angels['count'] - $needed_angels['taken']; $need = $needed_angels['count'] - $needed_angels['taken'];
if ($need > 0) { if ($need > 0) {
$panel_body .= $panel_body .= '<br>' . glyph('user') . '<span class="text-' . $style . '">' . $need . ' &times; ' . AngelType($needed_angels['TID'])['name'] . '</span>';
'<br>' . glyph('user') .
'<span class="text-' . $style . '">' .
$need . ' &times; ' . AngelType($needed_angels['TID'])['name'] .
'</span>';
} }
} }