From 594c1a776b71e743163764564b7b55e45ee65409 Mon Sep 17 00:00:00 2001 From: Ilya Oleshko Date: Wed, 11 Mar 2020 14:15:44 +0300 Subject: [PATCH] Web: Common: Api: Files: Added file creating API requests --- web/ASC.Web.Common/src/api/files/index.js | 176 ++++++++++++++-------- 1 file changed, 110 insertions(+), 66 deletions(-) diff --git a/web/ASC.Web.Common/src/api/files/index.js b/web/ASC.Web.Common/src/api/files/index.js index 18ceee9f35..02c563ea4e 100644 --- a/web/ASC.Web.Common/src/api/files/index.js +++ b/web/ASC.Web.Common/src/api/files/index.js @@ -3,19 +3,6 @@ import { request } from "../client"; import Filter from "./filter"; import * as fakeFiles from "./fake"; -export function getFolder(folderId, filter = Filter.getDefault(), fake = false) { - if (fake) { - return fakeFiles.getFakeElements(filter, "Fake folder"); - } - - const options = { - method: "get", - url: `/files/${folderId}` - }; - - return request(options); -} - export function getFolderInfo(folderId) { const options = { method: "get", @@ -34,6 +21,19 @@ export function getFolderPath(folderId) { return request(options); } +export function getFolder(folderId, filter = Filter.getDefault(), fake = false) { + if (fake) { + return fakeFiles.getFakeElements(filter, "Fake folder"); + } + + const options = { + method: "get", + url: `/files/${folderId}` + }; + + return request(options); +} + export function getMyFolderList(filter = Filter.getDefault(), fake = false) { if (fake) { return fakeFiles.getFakeElements(filter, "My Documents"); @@ -99,59 +99,6 @@ export function getSharedFolderList(filter = Filter.getDefault(), fake = false) return request(options); } -export function createTextFileInMy(title) { - const data = { title }; - const options = { - method: "post", - url: "/files/@my/file", - data - }; - - return request(options); -} - -export function createTextFileInCommon(title) { - const data = { title }; - const options = { - method: "post", - url: "/files/@common/file", - data - }; - - return request(options); -} - -export function createTextFile(folderId, title) { - const data = { title }; - const options = { - method: "post", - url: `/files/${folderId}/file`, - data - }; - - return request(options); -} - -export function getFileInfo(fileId) { - const options = { - method: "get", - url: `/files/file/${fileId}` - }; - - return request(options); -} - -export function updateFile(fileId, title, lastVersion) { - const data = { title, lastVersion }; - const options = { - method: "put", - url: `/files/file/${fileId}`, - data - }; - - return request(options); -} - export function createFolder(parentFolderId, title) { const data = { title }; const options = { @@ -185,6 +132,103 @@ export function deleteFolder(folderId, deleteAfter, immediately) { return request(options); } +export function createFile(folderId, title) { + const data = { title }; + const options = { + method: "post", + url: `/files/${folderId}/file`, + data + }; + + return request(options); +} + +export function createTextFile(folderId, title, content) { + const data = { title, content }; + const options = { + method: "post", + url: `/files/${folderId}/text`, + data + }; + + return request(options); +} + +export function createTextFileInMy(title) { + const data = { title }; + const options = { + method: "post", + url: "/files/@my/file", + data + }; + + return request(options); +} + +export function createTextFileInCommon(title) { + const data = { title }; + const options = { + method: "post", + url: "/files/@common/file", + data + }; + + return request(options); +} + +export function createHtmlFile(folderId, title, content) { + const data = { title, content }; + const options = { + method: "post", + url: `/files/${folderId}/html`, + data + }; + + return request(options); +} + +export function createHtmlFileInMy(title, content) { + const data = { title, content }; + const options = { + method: "post", + url: "/files/@my/html", + data + }; + + return request(options); +} + +export function createHtmlFileInCommon(title, content) { + const data = { title, content }; + const options = { + method: "post", + url: "/files/@common/html", + data + }; + + return request(options); +} + +export function getFileInfo(fileId) { + const options = { + method: "get", + url: `/files/file/${fileId}` + }; + + return request(options); +} + +export function updateFile(fileId, title, lastVersion) { + const data = { title, lastVersion }; + const options = { + method: "put", + url: `/files/file/${fileId}`, + data + }; + + return request(options); +} + export function deleteFile(fileId, deleteAfter, immediately) { const data = { deleteAfter, immediately }; const options = {