Merge branch 'release/v1.2' of github.com:ONLYOFFICE/AppServer into release/v1.2
This commit is contained in:
commit
f4d9b4dd3a
@ -96,7 +96,24 @@ namespace ASC.Core.ChunkedUploader
|
||||
|
||||
public T GetItemOrDefault<T>(string key)
|
||||
{
|
||||
return Items.ContainsKey(key) && Items[key] is T t ? t : default;
|
||||
if (Items.ContainsKey(key) && Items[key] != null)
|
||||
{
|
||||
if (Items[key] is T)
|
||||
{
|
||||
return (T)Items[key];
|
||||
}
|
||||
|
||||
if (Items[key] is JsonElement)
|
||||
{
|
||||
var jToken = (JsonElement)Items[key];
|
||||
|
||||
var item = jToken.Deserialize<T>();
|
||||
Items[key] = item;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public virtual Stream Serialize()
|
||||
@ -114,17 +131,21 @@ namespace ASC.Core.ChunkedUploader
|
||||
if (item.Value is JsonElement)
|
||||
{
|
||||
var value = (JsonElement)item.Value;
|
||||
if (value.ValueKind == JsonValueKind.String)
|
||||
|
||||
switch (value.ValueKind)
|
||||
{
|
||||
newItems.Add(item.Key, item.Value.ToString());
|
||||
}
|
||||
if (value.ValueKind == JsonValueKind.Number)
|
||||
{
|
||||
newItems.Add(item.Key, Int32.Parse(item.Value.ToString()));
|
||||
}
|
||||
if (value.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
newItems.Add(item.Key, value.EnumerateArray().Select(o => o.ToString()).ToList());
|
||||
case JsonValueKind.String:
|
||||
newItems.Add(item.Key, item.Value.ToString());
|
||||
break;
|
||||
case JsonValueKind.Number:
|
||||
newItems.Add(item.Key, Int32.Parse(item.Value.ToString()));
|
||||
break;
|
||||
case JsonValueKind.Array:
|
||||
newItems.Add(item.Key, value.EnumerateArray().Select(o => o.ToString()).ToList());
|
||||
break;
|
||||
default:
|
||||
newItems.Add(item.Key, item.Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -32,6 +32,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@ -759,14 +760,14 @@ namespace ASC.Data.Storage.GoogleCloud
|
||||
|
||||
if (chunkLength != defaultChunkSize)
|
||||
totalBytes = Convert.ToString((chunkNumber - 1) * defaultChunkSize + chunkLength);
|
||||
|
||||
var contentRangeHeader = $"bytes {bytesRangeStart}-{bytesRangeEnd}/{totalBytes}";
|
||||
|
||||
|
||||
var request = new HttpRequestMessage();
|
||||
request.RequestUri = new Uri(uploadUri);
|
||||
request.Method = HttpMethod.Put;
|
||||
request.Headers.Add("Content-Range", contentRangeHeader);
|
||||
request.Content = new StreamContent(stream);
|
||||
request.Content.Headers.ContentRange = new ContentRangeHeaderValue(Convert.ToInt64(bytesRangeStart),
|
||||
Convert.ToInt64(bytesRangeEnd),
|
||||
Convert.ToInt64(totalBytes));
|
||||
|
||||
|
||||
const int MAX_RETRIES = 100;
|
||||
|
@ -0,0 +1,10 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_26231_36088)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.3136 2.27152L10.8995 0.857399C9.72793 -0.314174 7.82844 -0.314174 6.65687 0.857399L6.06451 1.44976L0.552799 4.20561C0.265291 4.34937 0.0644141 4.62256 0.0129249 4.93986C-0.0385649 5.25715 0.0656106 5.57985 0.292905 5.80715L3.12133 8.63557L5.24265 10.7569L7.36397 12.8782L10.1924 15.7066C10.4197 15.9339 10.7424 16.0381 11.0597 15.9866C11.377 15.9351 11.6502 15.7343 11.7939 15.4467L14.5498 9.93504L15.1421 9.34268C16.3137 8.17111 16.3137 6.27161 15.1421 5.10004L13.7278 3.68573L16.7077 0.705042L15.2933 -0.708984L12.3136 2.27152ZM13.7279 7.92847C14.1185 7.53794 14.1185 6.90478 13.7279 6.51425L11.6066 4.39293L9.48529 2.27161C9.09477 1.88109 8.4616 1.88109 8.07108 2.27161L13.7279 7.92847ZM6.45941 3.48837L2.68818 5.37399L3.82844 6.51425L5.67122 4.67147L7.08543 6.08569L5.24265 7.92847L5.94976 8.63557L7.79254 6.79279L9.20675 8.20701L7.36397 10.0498L8.07108 10.7569L9.91386 8.91411L11.3281 10.3283L9.48529 12.1711L10.6256 13.3114L12.5112 9.54013L6.45941 3.48837Z" fill="#657077"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_26231_36088">
|
||||
<rect width="16" height="16" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
@ -1,4 +1,4 @@
|
||||
import React, { useEffect } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import PropTypes from "prop-types";
|
||||
import { inject, observer } from "mobx-react";
|
||||
@ -29,11 +29,12 @@ const Item = ({
|
||||
startUpload,
|
||||
uploadEmptyFolders,
|
||||
setDragging,
|
||||
showBadge,
|
||||
labelBadge,
|
||||
iconBadge,
|
||||
}) => {
|
||||
const [isDragActive, setIsDragActive] = React.useState(false);
|
||||
|
||||
const showBadge = item.newItems ? item.newItems > 0 && true : false;
|
||||
|
||||
const isDragging = dragging ? showDragItems(item) : false;
|
||||
|
||||
let value = "";
|
||||
@ -109,8 +110,9 @@ const Item = ({
|
||||
isDragActive={isDragActive && isDragging}
|
||||
value={value}
|
||||
showBadge={showBadge}
|
||||
labelBadge={showBadge ? item.newItems : null}
|
||||
labelBadge={labelBadge}
|
||||
onClickBadge={onBadgeClick}
|
||||
iconBadge={iconBadge}
|
||||
/>
|
||||
</StyledDragAndDrop>
|
||||
);
|
||||
@ -138,6 +140,9 @@ const Items = ({
|
||||
draggableItems,
|
||||
|
||||
moveDragItems,
|
||||
|
||||
setEmptyTrashDialogVisible,
|
||||
trashIsEmpty,
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
data.forEach((elem) => {
|
||||
@ -287,9 +292,26 @@ const Items = ({
|
||||
[moveDragItems, t]
|
||||
);
|
||||
|
||||
const onEmptyTrashAction = () => {
|
||||
setEmptyTrashDialogVisible(true);
|
||||
};
|
||||
|
||||
const onClickBadge = (isTrash) => {
|
||||
if (isTrash) {
|
||||
onEmptyTrashAction();
|
||||
} else {
|
||||
onBadgeClick();
|
||||
}
|
||||
};
|
||||
|
||||
const getItem = React.useCallback(
|
||||
(data) => {
|
||||
const items = data.map((item, index) => {
|
||||
const isTrash = item.rootFolderType === FolderType.TRASH;
|
||||
const showBadge = item.newItems ? item.newItems > 0 && true : false;
|
||||
const labelBadge = showBadge ? item.newItems : null;
|
||||
const iconBadge = isTrash ? "images/clear.trash.react.svg" : null;
|
||||
|
||||
return (
|
||||
<Item
|
||||
key={`${item.id}_${index}`}
|
||||
@ -305,8 +327,11 @@ const Items = ({
|
||||
showText={showText}
|
||||
onClick={onClick}
|
||||
onMoveTo={onMoveTo}
|
||||
onBadgeClick={onBadgeClick}
|
||||
onBadgeClick={() => onClickBadge(isTrash)}
|
||||
showDragItems={showDragItems}
|
||||
showBadge={showBadge || (isTrash && !trashIsEmpty)}
|
||||
labelBadge={labelBadge}
|
||||
iconBadge={iconBadge}
|
||||
/>
|
||||
);
|
||||
});
|
||||
@ -326,6 +351,7 @@ const Items = ({
|
||||
setDragging,
|
||||
startUpload,
|
||||
uploadEmptyFolders,
|
||||
trashIsEmpty,
|
||||
]
|
||||
);
|
||||
|
||||
@ -348,8 +374,15 @@ export default inject(
|
||||
filesStore,
|
||||
filesActionsStore,
|
||||
uploadDataStore,
|
||||
dialogsStore,
|
||||
}) => {
|
||||
const { selection, dragging, setDragging, setStartDrag } = filesStore;
|
||||
const {
|
||||
selection,
|
||||
dragging,
|
||||
setDragging,
|
||||
setStartDrag,
|
||||
trashIsEmpty,
|
||||
} = filesStore;
|
||||
|
||||
const { startUpload } = uploadDataStore;
|
||||
|
||||
@ -363,6 +396,8 @@ export default inject(
|
||||
|
||||
const { id } = selectedFolderStore;
|
||||
const { moveDragItems, uploadEmptyFolders } = filesActionsStore;
|
||||
const { setEmptyTrashDialogVisible } = dialogsStore;
|
||||
|
||||
return {
|
||||
isAdmin: auth.isAdmin,
|
||||
myId: myFolderId,
|
||||
@ -380,6 +415,8 @@ export default inject(
|
||||
moveDragItems,
|
||||
startUpload,
|
||||
uploadEmptyFolders,
|
||||
setEmptyTrashDialogVisible,
|
||||
trashIsEmpty,
|
||||
};
|
||||
}
|
||||
)(withTranslation(["Home", "Common", "Translations"])(observer(Items)));
|
||||
|
@ -72,6 +72,7 @@ class FilesStore {
|
||||
isLoadingFilesFind = false;
|
||||
pageItemsLength = null;
|
||||
isHidePagination = false;
|
||||
trashIsEmpty = false;
|
||||
|
||||
constructor(
|
||||
authStore,
|
||||
@ -690,6 +691,9 @@ class FilesStore {
|
||||
|
||||
this.setCreatedItem(null);
|
||||
}
|
||||
|
||||
this.getIsEmptyTrash(); //TODO:
|
||||
|
||||
return Promise.resolve(selectedFolder);
|
||||
})
|
||||
.catch((err) => {
|
||||
@ -2096,6 +2100,16 @@ class FilesStore {
|
||||
setScrollToItem = (item) => {
|
||||
this.scrollToItem = item;
|
||||
};
|
||||
|
||||
getIsEmptyTrash = async () => {
|
||||
const res = await api.files.getTrashFolderList();
|
||||
const items = [...res.files, ...res.folders];
|
||||
this.setTrashIsEmpty(items.length === 0 ? true : false);
|
||||
};
|
||||
|
||||
setTrashIsEmpty = (isEmpty) => {
|
||||
this.trashIsEmpty = isEmpty;
|
||||
};
|
||||
}
|
||||
|
||||
export default FilesStore;
|
||||
|
@ -31,6 +31,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -523,7 +524,7 @@ namespace ASC.Files.Thirdparty.GoogleDrive
|
||||
var titleData = !string.IsNullOrEmpty(driveFile.Name) ? $"\"name\":\"{driveFile.Name}\"" : "";
|
||||
var parentData = !string.IsNullOrEmpty(folderId) ? $",\"parents\":[\"{folderId}\"]" : "";
|
||||
|
||||
body = !string.IsNullOrEmpty(titleData + parentData) ? "{{" + titleData + parentData + "}}" : "";
|
||||
body = !string.IsNullOrEmpty(titleData + parentData) ? "{" + titleData + parentData + "}" : "";
|
||||
}
|
||||
|
||||
var request = new HttpRequestMessage();
|
||||
@ -562,14 +563,13 @@ namespace ASC.Files.Thirdparty.GoogleDrive
|
||||
request.RequestUri = new Uri(googleDriveSession.Location);
|
||||
request.Method = HttpMethod.Put;
|
||||
request.Headers.Add("Authorization", "Bearer " + AccessToken);
|
||||
request.Headers.Add("Content-Range", string.Format("bytes {0}-{1}/{2}",
|
||||
googleDriveSession.BytesTransfered,
|
||||
googleDriveSession.BytesTransfered + chunkLength - 1,
|
||||
googleDriveSession.BytesToTransfer));
|
||||
request.Content = new StreamContent(stream);
|
||||
request.Content.Headers.ContentRange = new ContentRangeHeaderValue(googleDriveSession.BytesTransfered,
|
||||
googleDriveSession.BytesTransfered + chunkLength - 1,
|
||||
googleDriveSession.BytesToTransfer);
|
||||
var httpClient = _clientFactory.CreateClient();
|
||||
HttpResponseMessage response;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
response = await httpClient.SendAsync(request);
|
||||
@ -598,10 +598,11 @@ namespace ASC.Files.Thirdparty.GoogleDrive
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
var locationHeader = response.Headers.Location.ToString();
|
||||
if (!string.IsNullOrEmpty(locationHeader))
|
||||
var locationHeader = response.Headers.Location;
|
||||
|
||||
if (locationHeader != null)
|
||||
{
|
||||
uplSession.Location = locationHeader;
|
||||
uplSession.Location = locationHeader.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -276,10 +276,10 @@ namespace ASC.Files.Thirdparty.OneDrive
|
||||
request.RequestUri = uploadUriBuilder.Uri;
|
||||
request.Method = HttpMethod.Post;
|
||||
request.Headers.Add("Authorization", "Bearer " + AccessToken);
|
||||
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json")
|
||||
{
|
||||
CharSet = Encoding.UTF8.WebName
|
||||
};
|
||||
//request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json")
|
||||
//{
|
||||
// CharSet = Encoding.UTF8.WebName
|
||||
//};
|
||||
|
||||
var uploadSession = new ResumableUploadSession(onedriveFile.Id, folderId, contentLength);
|
||||
|
||||
@ -318,11 +318,11 @@ namespace ASC.Files.Thirdparty.OneDrive
|
||||
request.RequestUri = new Uri(oneDriveSession.Location);
|
||||
request.Method = HttpMethod.Put;
|
||||
request.Headers.Add("Authorization", "Bearer " + AccessToken);
|
||||
request.Headers.Add("Content-Range", string.Format("bytes {0}-{1}/{2}",
|
||||
oneDriveSession.BytesTransfered,
|
||||
oneDriveSession.BytesTransfered + chunkLength - 1,
|
||||
oneDriveSession.BytesToTransfer));
|
||||
request.Content = new StreamContent(stream);
|
||||
|
||||
request.Content.Headers.ContentRange = new ContentRangeHeaderValue(oneDriveSession.BytesTransfered,
|
||||
oneDriveSession.BytesTransfered + chunkLength - 1,
|
||||
oneDriveSession.BytesToTransfer);
|
||||
|
||||
var httpClient = ClientFactory.CreateClient();
|
||||
using var response = await httpClient.SendAsync(request);
|
||||
|
Loading…
Reference in New Issue
Block a user