Web: Files: Fixed opening file on external link

This commit is contained in:
Alexey Safronov 2020-12-10 19:15:36 +03:00
parent 0b0d7187e0
commit 2548dba9b7
6 changed files with 10 additions and 175 deletions

View File

@ -1,31 +1,24 @@
import React, { useEffect } from "react";
import React from "react";
import { withRouter } from "react-router";
import { /*RequestLoader,*/ Box } from "asc-web-components";
import { utils, api, toastr } from "asc-web-common";
import { withTranslation, I18nextProvider } from "react-i18next";
import { createI18N } from "../../../helpers/i18n";
const i18n = createI18N({
page: "DocEditor",
localesPath: "pages/DocEditor",
});
const { changeLanguage, getObjectByLocation, showLoader } = utils;
const { files } = api;
const { getObjectByLocation, showLoader } = utils;
class PureEditor extends React.Component {
async componentDidMount() {
const urlParams = getObjectByLocation(window.location);
const fileId = urlParams.fileId || null;
const doc = urlParams.doc || null;
console.log("PureEditor componentDidMount", fileId);
console.log("PureEditor componentDidMount", fileId, doc);
const vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty("--vh", `${vh}px`);
showLoader();
let docApiUrl = await files.getDocServiceUrl();
let docApiUrl = await api.files.getDocServiceUrl();
const script = document.createElement("script");
script.setAttribute("type", "text/javascript");
@ -34,8 +27,8 @@ class PureEditor extends React.Component {
script.onload = function () {
console.log("PureEditor script.onload", fileId, window.DocsAPI);
files
.openEdit(fileId)
api.files
.openEdit(fileId, doc)
.then((config) => {
if (window.innerWidth < 720) {
config.type = "mobile";
@ -67,17 +60,4 @@ class PureEditor extends React.Component {
}
}
const EditorContainer = withTranslation()(PureEditor);
const DocEditor = (props) => {
useEffect(() => {
changeLanguage(i18n);
}, []);
return (
<I18nextProvider i18n={i18n}>
<EditorContainer {...props} />
</I18nextProvider>
);
};
export default withRouter(DocEditor);
export default withRouter(PureEditor);

View File

@ -1,72 +0,0 @@
{
"NewDocument": "New document",
"NewSpreadsheet": "New spreadsheet",
"NewPresentation": "New presentation",
"NewFolder": "New folder",
"UploadToFolder": "Upload to folder",
"SharingSettings": "Sharing settings",
"LinkForPortalUsers": "Link for portal users",
"MoveTo": "Move to",
"Copy": "Copy",
"Download": "Download",
"Rename": "Rename",
"Delete": "Delete",
"Type": "Type",
"Author": "Author",
"Search": "Search",
"Folders": "Folders",
"Document": "Document",
"Documents": "Documents",
"Spreadsheet": "Spreadsheet",
"Presentation": "Presentation",
"Presentations": "Presentations",
"Spreadsheets": "Spreadsheets",
"Images": "Images",
"Media": "Media",
"Archives": "Archives",
"AllFiles": "All files",
"NoSubfolders": "No subfolders",
"LoadingProcessing": "Loading...",
"LoadingDescription": "Please wait...",
"ByLastModifiedDate": "Last modified date",
"ByCreationDate": "Creation date",
"ByTitle": "Title",
"ByType": "Type",
"BySize": "Size",
"ByAuthor": "Author",
"DirectionAscLabel": "A-Z",
"DirectionDescLabel": "Z-A",
"CountPerPage": "{{count}} per page",
"PageOfTotalPage": "{{page}} of {{totalPage}}",
"PreviousPage": "Previous",
"NextPage": "Next",
"DefaultOptionLabel": "Me",
"LblSelect": "Select",
"AuthorMe": "Me",
"TitleCreated": "Created",
"TitleUploaded": "Uploaded",
"TitleModified": "Updated",
"TitleRemoved": "Removed",
"TitleSubfolders": "Flds",
"TitleDocuments": "Dcs",
"Share": "Share",
"DownloadAs": "Download as",
"More": "More",
"CloseButton": "Close",
"All": "All",
"Files": "Files",
"EmptyRecycleBin": "Empty Recycle Bin",
"Folder": "Folder",
"ClearButton": "Reset filter",
"SubheadingEmptyText": "No files to be displayed in this section",
"MyEmptyContainerDescription": "The documents and image files you create or upload to the portal are kept here in 'My Documents' section. You can open and edit them using the ONLYOFFICE™ portal editor, share them with friends or colleagues, organize into folders. Drag-and-drop the files from your computer here to upload them to your portal even more easily.",
"SharedEmptyContainerDescription": "The 'Shared with Me' section is used to show the files which your friends or colleagues gave you access to. In case you haven't seen the latest changes in the documents they are marked 'new'. You can remove the files from the list clicking the appropriate button.",
"CommonEmptyContainerDescription": "The 'Common Documents' section shows all the documents shared by portal administrator for common access. Only portal administrator can create folders in this section, but with the access granted the portal users can also upload their files here. Drag-and-drop the files from your computer here to upload them to your portal even more easily.",
"TrashEmptyContainerDescription": "The 'Recycle Bin' section is where all the deleted files are moved. You can either restore them in case they are deleted by mistake or delete them permanently. Please note, that when you delete the files from the 'Recycle Bin' they cannot be restored any longer.",
"GoToMyButton": "Go to My Documents",
"BackToParentFolderButton": "Back to parent folder",
"EmptyFolderHeader": "No files in this folder",
"EmptyFilterSubheadingText": "No files to be displayed for this filter here",
"EmptyFilterDescriptionText": "No files or folders matching your filter can be displayed in this section. Please select other filter options or clear filter to view all the files in this section. You can also look for the file you need in other sections.",
"Filter": "Filter"
}

View File

@ -1,72 +0,0 @@
{
"NewDocument": "Новый документ",
"NewSpreadsheet": "Новая таблица",
"NewPresentation": "Новая презентация",
"NewFolder": "Новая папка",
"UploadToFolder": "Загрузить в папку",
"SharingSettings": "Настройки доступа",
"LinkForPortalUsers": "Ссылка для пользователей портала",
"MoveTo": "Переместить",
"Copy": "Копировать",
"Download": "Скачать",
"Rename": "Переименовать",
"Delete": "Удалить",
"Type": "Тип",
"Author": "Автор",
"Search": "Поиск",
"Folders": "Папки",
"Document": "Документ",
"Documents": "Документы",
"Spreadsheet": "Таблица",
"Presentation": "Презентация",
"Presentations": "Презентации",
"Spreadsheets": "Таблицы",
"Images": "Изображения",
"Media": "Медиа",
"Archives": "Архивы",
"AllFiles": "Все файлы",
"NoSubfolders": "Без подпапок",
"LoadingProcessing": "Загрузка...",
"LoadingDescription": "Пожалуйста, подождите...",
"ByLastModifiedDate": "Дата последнего изменения",
"ByCreationDate": "Дата создания",
"ByTitle": "Название",
"ByType": "Тип",
"BySize": "Размер",
"ByAuthor": "Автор",
"DirectionAscLabel": "А-Я",
"DirectionDescLabel": "Я-А",
"CountPerPage": "{{count}} на странице",
"PageOfTotalPage": "{{page}} из {{totalPage}}",
"PreviousPage": "Предыдущая",
"NextPage": "Следующая",
"DefaultOptionLabel": "Я",
"LblSelect": "Выберите",
"AuthorMe": "Я",
"TitleCreated": "Создана",
"TitleUploaded": "Загружен",
"TitleModified": "Обновлён",
"TitleRemoved": "Удалён",
"TitleSubfolders": "Flds",
"TitleDocuments": "Dcs",
"Share": "Доступ",
"DownloadAs": "Скачать как",
"More": "Больше",
"CloseButton": "Закрыть",
"All": "Все",
"Files": "Файлы",
"EmptyRecycleBin": "Очистить корзину",
"Folder": "Папка",
"ClearButton": "Сбросить фильтр",
"SubheadingEmptyText": "Нет файлов для отображения в этом разделе",
"MyEmptyContainerDescription": "Документы и файлы изображений, которые вы создаете или загружаете на портал, хранятся здесь, в разделе «Мои документы». Вы можете открывать и редактировать их с помощью редактора портала ONLYOFFICE ™, делиться ими с друзьями или коллегами, организовывать в папки. Перетащите файлы со своего компьютера сюда, чтобы загрузить их на свой портал еще проще.",
"SharedEmptyContainerDescription": "Раздел «Доступно для меня» используется для отображения файлов, к которым ваши друзья или коллеги предоставили вам доступ. Если вы не видели последние изменения в документах, они помечаются как «новые». Вы можете удалить файлы из списка, нажав соответствующую кнопку.",
"CommonEmptyContainerDescription": "В разделе «Общие документы» отображаются все документы, которыми администратор портала предоставил общий доступ. Только администраторы портала могут создавать папки в этом разделе, но с предоставленным доступом пользователи портала также могут загружать свои файлы здесь. Перетащите файлы со своего компьютера сюда, чтобы загрузить их на свой портал еще проще.",
"TrashEmptyContainerDescription": "В разделе «Корзина» находятся все удаленные файлы. Вы можете восстановить их, если они были удалены по ошибке, или удалить их навсегда. Обратите внимание, что когда вы удаляете файлы из корзины, они больше не могут быть восстановлены.",
"GoToMyButton": "Перейти к моим документам",
"BackToParentFolderButton": "Вернуться в папку на уровень выше",
"EmptyFolderHeader": "В этой папке нет файлов",
"EmptyFilterSubheadingText": "Здесь нет файлов, соответствующих этому фильтру",
"EmptyFilterDescriptionText": "В этом разделе нет файлов или папок, соответствующих фильтру. Пожалуйста, выберите другие параметры или очистите фильтр, чтобы показать все файлы в этом разделе. Вы можете также поискать нужный файл в других разделах.",
"Filter": "Фильтр"
}

View File

@ -845,7 +845,6 @@ const startSessionFunc = (indexOfFile, t, dispatch, getState) => {
if (!item) {
console.error("Empty files");
debugger;
return Promise.resolve();
}
@ -1250,7 +1249,6 @@ const startConvertFiles = async (files, t, dispatch, getState) => {
alert: true,
})
);
//debugger;
return;
}
if (progress === 100) {

View File

@ -2219,6 +2219,7 @@ namespace ASC.Api.Documents
}
/// <visible>false</visible>
[AllowAnonymous]
[Read("docservice")]
public object GetDocServiceUrl(bool version)
{

View File

@ -4,7 +4,7 @@ import FilesFilter from "./filter";
import { FolderType } from "../../constants";
import find from "lodash/find";
export function openEdit(fileId, version, doc) {
export function openEdit(fileId, doc) {
const params = doc ? `?doc=${doc}` : "";
const options = {