fix public view link remove hash
This commit is contained in:
parent
bafe0942ee
commit
266dc8ba4a
|
@ -88,6 +88,7 @@ final class Container extends Model
|
|||
'height' => (int) $data['height'],
|
||||
'backgroundURL' => static::extractBackgroundUrl($data),
|
||||
'relationLineWidth' => (int) $data['relationLineWidth'],
|
||||
'hash' => static::extractHash($data),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -198,6 +199,22 @@ final class Container extends Model
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a hash.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return mixed String representing hash (not empty) or null.
|
||||
*/
|
||||
private static function extractHash(array $data)
|
||||
{
|
||||
return static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['hash']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a background color value.
|
||||
*
|
||||
|
@ -279,6 +296,10 @@ final class Container extends Model
|
|||
);
|
||||
}
|
||||
|
||||
$row['hash'] = md5(
|
||||
$config['dbpass'].$row['id'].$config['id_user']
|
||||
);
|
||||
|
||||
return \io_safe_output($row);
|
||||
}
|
||||
|
||||
|
|
|
@ -177,6 +177,22 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
|
|||
var handleUpdate = function (prevProps, newProps) {
|
||||
if (!newProps) return;
|
||||
|
||||
//Remove spinner change VC.
|
||||
document
|
||||
.getElementById("visual-console-container")
|
||||
.classList.remove("is-updating");
|
||||
|
||||
var div = document
|
||||
.getElementById("visual-console-container")
|
||||
.querySelector(".div-visual-console-spinner");
|
||||
|
||||
if (div !== null) {
|
||||
var parent = div.parentElement;
|
||||
if (parent !== null) {
|
||||
parent.removeChild(div);
|
||||
}
|
||||
}
|
||||
|
||||
// Change the background color when the fullscreen mode is enabled.
|
||||
if (prevProps
|
||||
&& prevProps.backgroundColor != newProps.backgroundColor
|
||||
|
@ -200,17 +216,24 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
|
|||
var regex = /(id=|id_visual_console=|id_layout=|id_visualmap=)\d+(&?)/gi;
|
||||
var replacement = '$1' + newProps.id + '$2';
|
||||
|
||||
var regex_hash = /(hash=)[^&]+(&?)/gi;
|
||||
var replacement_hash = '$1' + newProps.hash + '$2';
|
||||
// Tab links.
|
||||
var menuLinks = document.querySelectorAll("div#menu_tab a");
|
||||
if (menuLinks !== null) {
|
||||
menuLinks.forEach(function (menuLink) {
|
||||
menuLink.href = menuLink.href.replace(regex, replacement);
|
||||
menuLink.href = menuLink.href.replace(
|
||||
regex_hash,
|
||||
replacement_hash
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Change the URL (if the browser has support).
|
||||
if ("history" in window) {
|
||||
var href = window.location.href.replace(regex, replacement);
|
||||
href = href.replace(regex_hash, replacement_hash);
|
||||
window.history.replaceState({}, document.title, href);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -470,11 +470,17 @@ ui_require_css_file('form');
|
|||
var regex = /(id=|id_visual_console=|id_layout=|id_visualmap=)\d+(&?)/gi;
|
||||
var replacement = '$1' + newProps.id + '$2';
|
||||
|
||||
var regex_hash = /(hash=)[^&]+(&?)/gi;
|
||||
var replacement_hash = '$1' + newProps.hash + '$2';
|
||||
// Tab links.
|
||||
var menuLinks = document.querySelectorAll("div#menu_tab a");
|
||||
if (menuLinks !== null) {
|
||||
menuLinks.forEach(function (menuLink) {
|
||||
menuLink.href = menuLink.href.replace(regex, replacement);
|
||||
menuLink.href = menuLink.href.replace(
|
||||
regex_hash,
|
||||
replacement_hash
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -487,6 +493,7 @@ ui_require_css_file('form');
|
|||
// Change the URL (if the browser has support).
|
||||
if ("history" in window) {
|
||||
var href = window.location.href.replace(regex, replacement);
|
||||
href = href.replace(regex_hash, replacement_hash);
|
||||
window.history.replaceState({}, document.title, href);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue