add mode maintenance VC pandora_enterprise#4822

This commit is contained in:
Daniel Barbero 2022-10-13 17:45:44 +02:00
parent 3099ffa7cb
commit 19cfc84a39
11 changed files with 46 additions and 39 deletions

View File

@ -3708,6 +3708,8 @@ function visual_map_print_visual_map(
// End function // End function
// Start function // Start function
/** /**
* Get a list with the layouts for a user. * Get a list with the layouts for a user.
* *
@ -3719,8 +3721,6 @@ function visual_map_print_visual_map(
* *
* @return array A list of layouts the user can see. * @return array A list of layouts the user can see.
*/ */
function visual_map_get_user_layouts( function visual_map_get_user_layouts(
$id_user=0, $id_user=0,
$only_names=false, $only_names=false,
@ -3729,6 +3729,7 @@ function visual_map_get_user_layouts(
$favourite=false, $favourite=false,
$check_user_groups=true $check_user_groups=true
) { ) {
$where = '';
if (! is_array($filter)) { if (! is_array($filter)) {
$filter = []; $filter = [];
} else { } else {
@ -3814,12 +3815,12 @@ function visual_map_get_user_layouts(
$retval = []; $retval = [];
foreach ($layouts as $layout) { foreach ($layouts as $layout) {
if ($only_names) { if ($only_names) {
$retval[$layout['id']] = $layout['name']; $retval[$layout['id']]['name'] = $layout['name'];
} else { } else {
$retval[$layout['id']] = $layout; $retval[$layout['id']] = $layout;
} }
// add_perms // Aad_perms.
if (isset($groups[$layout['id_group']]['vconsole_view'])) { if (isset($groups[$layout['id_group']]['vconsole_view'])) {
$retval[$layout['id']]['vr'] = $groups[$layout['id_group']]['vconsole_view']; $retval[$layout['id']]['vr'] = $groups[$layout['id_group']]['vconsole_view'];
} }

View File

@ -1386,6 +1386,12 @@ function dashboardLoadVC(settings) {
: "dashboard" : "dashboard"
); );
if (settings.props.maintenanceMode != null) {
if (settings.props.maintenanceMode.user !== settings.id_user) {
visualConsoleManager.visualConsole.enableMaintenanceMode();
}
}
if (settings.mobile_view_orientation_vc === true) { if (settings.mobile_view_orientation_vc === true) {
$(window).on("orientationchange", function() { $(window).on("orientationchange", function() {
$(container).width($(window).height()); $(container).width($(window).height());

View File

@ -248,6 +248,7 @@ final class Container extends Model
*/ */
private static function extractMaintenanceMode(array $data) private static function extractMaintenanceMode(array $data)
{ {
global $config;
$maintenance_mode = static::notEmptyStringOr( $maintenance_mode = static::notEmptyStringOr(
static::issetInArray( static::issetInArray(
$data, $data,
@ -262,6 +263,12 @@ final class Container extends Model
$result = null; $result = null;
if ($maintenance_mode !== null) { if ($maintenance_mode !== null) {
$result = json_decode($maintenance_mode, true); $result = json_decode($maintenance_mode, true);
$result['date'] = date(
$config['date_format'],
$result['timestamp']
);
$result['timestamp'] = human_time_description_raw( $result['timestamp'] = human_time_description_raw(
(time() - $result['timestamp']) (time() - $result['timestamp'])
); );

View File

@ -7,13 +7,11 @@
margin-top: 5px; margin-top: 5px;
} }
#visual-console-container.is-maintenance { .is-maintenance {
border: 2px solid green;
background-image: url(maintenanceMode.png) !important; background-image: url(maintenanceMode.png) !important;
} }
#visual-console-container.is-maintenance :nth-child(1) { .is-maintenance :nth-child(1) {
display: none; display: none;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -358,6 +358,7 @@ class Visualmap
'uniq' => $uniq, 'uniq' => $uniq,
'mobile' => true, 'mobile' => true,
'vcId' => $visualConsoleId, 'vcId' => $visualConsoleId,
'id_user' => $config['id_user'],
'mobile_view_orientation_vc' => (bool) !$config['mobile_view_orientation_vc'], 'mobile_view_orientation_vc' => (bool) !$config['mobile_view_orientation_vc'],
] ]
); );

View File

@ -281,6 +281,12 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
"<?php echo get_parameter('hash', ''); ?>" "<?php echo get_parameter('hash', ''); ?>"
); );
if(props.maintenanceMode != null) {
if(props.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
visualConsoleManager.visualConsole.enableMaintenanceMode();
}
}
var controls = document.getElementById('vc-controls'); var controls = document.getElementById('vc-controls');
autoHideElement(controls, 1000); autoHideElement(controls, 1000);

View File

@ -417,22 +417,20 @@ if ($pure === false) {
echo '</div>'; echo '</div>';
} }
$style_edit_mode = ''; $disabled_edit_mode = false;
if ($aclManage === true) { if ($aclManage === true) {
$style = '';
$value_maintenance_mode = true; $value_maintenance_mode = true;
if ($maintenanceMode === null) { if ($maintenanceMode === null) {
$style = ' style="visibility:hidden"';
$value_maintenance_mode = false; $value_maintenance_mode = false;
} else { } else {
if ($maintenanceMode['user'] !== $config['id_user']) { if ($maintenanceMode['user'] !== $config['id_user']) {
$style_edit_mode = ' style="visibility:hidden"'; $disabled_edit_mode = true;
} }
} }
echo '<div id="maintenance-mode-control" class="flex-column" '.$style.'>'; echo '<div id="maintenance-mode-control" class="flex-column">';
echo html_print_label( echo html_print_label(
__('Maintenance Mode'), __('Maintenance'),
'maintenance-mode', 'maintenance-mode',
true true
); );
@ -445,9 +443,9 @@ if ($pure === false) {
echo '</div>'; echo '</div>';
} }
echo '<div id="edit-mode-control" class="flex-column" '.$style_edit_mode.'>'; echo '<div id="edit-mode-control" class="flex-column">';
echo html_print_label(__('Edit Mode'), 'edit-mode', true); echo html_print_label(__('Edit'), 'edit-mode', true);
echo html_print_checkbox_switch('edit-mode', 1, false, true); echo html_print_checkbox_switch('edit-mode', 1, false, true, $disabled_edit_mode);
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';
} }
@ -705,15 +703,13 @@ ui_require_css_file('form');
if(newProps.maintenanceMode != null) { if(newProps.maintenanceMode != null) {
$('input[name=maintenance-mode]').prop('checked', true); $('input[name=maintenance-mode]').prop('checked', true);
if(newProps.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') { if(newProps.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
$('#edit-mode-control').css('visibility', 'hidden'); $('input[name=edit-mode]').prop('disabled', true);
$('#maintenance-mode-control').css('visibility', '');
} else { } else {
$('#edit-mode-control').css('visibility', ''); $('input[name=edit-mode]').prop('disabled', false);
} }
} else { } else {
$('input[name=maintenance-mode]').prop('checked', false); $('input[name=maintenance-mode]').prop('checked', false);
$('#edit-mode-control').css('visibility', ''); $('input[name=edit-mode]').prop('disabled', false);
$('#maintenance-mode-control').css('visibility', '');
} }
} }
@ -751,18 +747,12 @@ if ($edit_capable === true) {
if ($(this).prop('checked')) { if ($(this).prop('checked')) {
visualConsoleManager.visualConsole.enableEditMode(); visualConsoleManager.visualConsole.enableEditMode();
visualConsoleManager.changeUpdateInterval(0); visualConsoleManager.changeUpdateInterval(0);
$('#force_check_control').hide();
$('#edit-controls').css('visibility', ''); $('#edit-controls').css('visibility', '');
$('#maintenance-mode-control').css('visibility', '');
} else { } else {
visualConsoleManager.visualConsole.disableEditMode(); visualConsoleManager.visualConsole.disableEditMode();
visualConsoleManager.visualConsole.unSelectItems(); visualConsoleManager.visualConsole.unSelectItems();
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms. visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms.
$('#force_check_control').show();
$('#edit-controls').css('visibility', 'hidden'); $('#edit-controls').css('visibility', 'hidden');
if(maintenanceMode != null && maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
$('#maintenance-mode-control').css('visibility', 'hidden');
}
} }
resetInterval(); resetInterval();
@ -783,9 +773,9 @@ if ($edit_capable === true) {
msg += '<?php echo __('Are you sure you wish to disable maintenance mode'); ?>'; msg += '<?php echo __('Are you sure you wish to disable maintenance mode'); ?>';
msg += '?'; msg += '?';
} else { } else {
msg = '<?php echo __('The visual console has been in maintenance mode since'); ?>'; msg = '<?php echo __('The visual console was set to maintenance mode'); ?>';
msg += ' ' + maintenanceMode.timestamp; msg += ' ' + '<span title="'+maintenanceMode.date+'">' + maintenanceMode.timestamp + '</span>';
msg += ' ' + '<?php echo __('by user'); ?>'; msg += ' ' + '<?php echo __('ago by user'); ?>';
msg += ' ' + maintenanceMode.user; msg += ' ' + maintenanceMode.user;
msg += '. ' + '<?php echo __('Are you sure you wish to disable maintenance mode'); ?>'; msg += '. ' + '<?php echo __('Are you sure you wish to disable maintenance mode'); ?>';
msg += '?'; msg += '?';

View File

@ -159,10 +159,10 @@ export interface VisualConsoleProps extends Size {
backgroundColor: string | null; backgroundColor: string | null;
isFavorite: boolean; isFavorite: boolean;
relationLineWidth: number; relationLineWidth: number;
maintenanceMode: maintenanceModeInterface | null; maintenanceMode: MaintenanceModeInterface | null;
} }
export interface maintenanceModeInterface { export interface MaintenanceModeInterface {
user: string; user: string;
timestamp: number; timestamp: number;
} }

View File

@ -7,13 +7,11 @@
margin-top: 5px; margin-top: 5px;
} }
#visual-console-container.is-maintenance { .is-maintenance {
border: 2px solid green;
background-image: url(./lib/maintenanceMode.png) !important; background-image: url(./lib/maintenanceMode.png) !important;
} }
#visual-console-container.is-maintenance :nth-child(1) { .is-maintenance :nth-child(1) {
display: none; display: none;
} }