[Wopi] Show error if BaseFileName is empty

This commit is contained in:
Julia Radzhabova 2021-05-13 21:51:49 +03:00
parent cb6998eac6
commit 7d060fe6c9

View file

@ -51,6 +51,39 @@ div {
margin: 0;
padding: 0;
}
.app-error-panel {
position: absolute;
width: 100%;
height: 100%;
top: 0;
background-color: #f4f4f4;
z-index: 10;
}
.message-block {
display: inline-block;
vertical-align: middle;
width: 100%;
}
.message-inner {
width: 550px;
margin: auto;
padding: 30px;
background-color: #e3e3e3;
text-align: center;
}
.title {
font-size: 24px;
margin: 0 0 14px;
}
.text {
font-size: 16px;
}
</style>
</head>
<body>
@ -207,6 +240,11 @@ div {
var token = "<%- token %>";
var queryParams = <%- JSON.stringify(queryParams) %>;
if (!fileInfo.BaseFileName) {
showError();
return;
}
var fileType = fileInfo.BaseFileName ? fileInfo.BaseFileName.substr(fileInfo.BaseFileName.lastIndexOf('.') + 1) : "";
var config = {
"width": "100%",
@ -291,6 +329,20 @@ div {
}
};
var showError = function(msg, title) {
msg = msg || 'Sorry, editor could not be loaded. Please contact your administrator.';
var newDiv = document.createElement("div");
newDiv.className = "app-error-panel";
newDiv.innerHTML = '<div class="message-block">' +
'<div class="message-inner">' +
(title ? '<div class="title">' + title + '</div>' : '') +
'<div class="text">' + msg + '</div>' +
'</div>' +
'</div>';
document.body.appendChild(newDiv);
};
if (window.addEventListener) {
window.addEventListener("load", connectEditor);
window.addEventListener("resize", fixSize);