Ilya Oleshko
ab472b0148
# Conflicts: # .gitignore # build/install/docker/Dockerfile.dev # build/install/docker/build.dev.yml # build/install/docker/docspace.dev.yml # build/install/win/DocSpace.aip # common/ASC.ActiveDirectory/Base/DbHelper.cs # common/ASC.Api.Core/Model/EmployeeDto.cs # common/ASC.Core.Common/Billing/ITariffService.cs # common/ASC.Core.Common/Billing/License/LicenseReader.cs # common/ASC.Core.Common/Billing/TariffService.cs # common/ASC.Core.Common/Context/Impl/CoreConfiguration.cs # common/ASC.Core.Common/Context/Impl/UserManager.cs # common/ASC.Core.Common/HostedSolution.cs # common/ASC.Core.Common/Messaging/MessagesContext.cs # common/ASC.Core.Common/Tenants/TenantCookieSettings.cs # common/ASC.Data.Storage/GoogleCloud/GoogleCloudStorage.cs # common/ASC.Data.Storage/IQuotaController.cs # common/ASC.Data.Storage/RackspaceCloud/RackspaceCloudStorage.cs # common/ASC.Data.Storage/S3/S3Storage.cs # common/Tools/ASC.Migration.Creator/ASC.Migration.Creator.csproj # common/Tools/ASC.Migration.Runner/ASC.Migration.Runner.csproj # common/Tools/ASC.Migration.Runner/GlobalUsings.cs # common/Tools/ASC.Migration.Runner/MigrationRunner.cs # common/Tools/ASC.Migration.Runner/Program.cs # common/Tools/ASC.MigrationPersonalToDocspace/MigrationRunner.cs # common/Tools/ASC.Migrations.Core/Models/ConfigurationInfo.cs # common/Tools/ASC.Migrations.Core/Utils/DbContextActivator.cs # common/services/ASC.ClearEvents/Services/ClearEventsService.cs # common/services/ASC.ElasticSearch/Core/SearchSettings.cs # common/services/ASC.ElasticSearch/Engine/FactoryIndexer.cs # config/nginx/onlyoffice.conf # migrations/mysql/ASC.Migrations.MySql.csproj # migrations/mysql/SaaS/AccountLinkContext/20221019144349_AccountLinkContextMigrate.Designer.cs # migrations/mysql/SaaS/AccountLinkContext/20221019144349_AccountLinkContextMigrate.cs # migrations/mysql/SaaS/AccountLinkContext/AccountLinkContextModelSnapshot.cs # migrations/mysql/SaaS/BackupsContext/20230130103901_BackupsContextMigrate.Designer.cs # migrations/mysql/SaaS/BackupsContext/20230130103901_BackupsContextMigrate.cs # migrations/mysql/SaaS/BackupsContext/BackupsContextModelSnapshot.cs # migrations/mysql/SaaS/CoreDbContext/20230130103905_CoreDbContextMigrate.Designer.cs # migrations/mysql/SaaS/CoreDbContext/20230130103905_CoreDbContextMigrate.cs # migrations/mysql/SaaS/CoreDbContext/CoreDbContextModelSnapshot.cs # migrations/mysql/SaaS/CustomDbContext/20221019144350_CustomDbContextMigrate.Designer.cs # migrations/mysql/SaaS/CustomDbContext/20221019144350_CustomDbContextMigrate.cs # migrations/mysql/SaaS/CustomDbContext/CustomDbContextModelSnapshot.cs # migrations/mysql/SaaS/FeedDbContext/20221019144344_FeedDbContextMigrate.Designer.cs # migrations/mysql/SaaS/FeedDbContext/20221019144344_FeedDbContextMigrate.cs # migrations/mysql/SaaS/FeedDbContext/FeedDbContextModelSnapshot.cs # migrations/mysql/SaaS/FilesDbContext/20230130103904_FilesDbContextMigrate.Designer.cs # migrations/mysql/SaaS/FilesDbContext/20230130103904_FilesDbContextMigrate.cs # migrations/mysql/SaaS/FilesDbContext/20230515174318_FilesDbContext_Upgrade1.Designer.cs # migrations/mysql/SaaS/FilesDbContext/20230515174318_FilesDbContext_Upgrade1.cs # migrations/mysql/SaaS/FilesDbContext/FilesDbContextModelSnapshot.cs # migrations/mysql/SaaS/FirebaseDbContext/20221019144351_FirebaseDbContextMigrate.Designer.cs # migrations/mysql/SaaS/FirebaseDbContext/20221019144351_FirebaseDbContextMigrate.cs # migrations/mysql/SaaS/FirebaseDbContext/FirebaseDbContextModelSnapshot.cs # migrations/mysql/SaaS/InstanceRegistrationContext/20221019144346_InstanceRegistrationContextMigrate.Designer.cs # migrations/mysql/SaaS/InstanceRegistrationContext/20221019144346_InstanceRegistrationContextMigrate.cs # migrations/mysql/SaaS/InstanceRegistrationContext/InstanceRegistrationContextModelSnapshot.cs # migrations/mysql/SaaS/IntegrationEventLogContext/20221019144342_IntegrationEventLogContextMigrate.Designer.cs # migrations/mysql/SaaS/IntegrationEventLogContext/20221019144342_IntegrationEventLogContextMigrate.cs # migrations/mysql/SaaS/IntegrationEventLogContext/IntegrationEventLogContextModelSnapshot.cs # migrations/mysql/SaaS/MessagesContext/20221019144345_MessagesContextMigrate.Designer.cs # migrations/mysql/SaaS/MessagesContext/20221019144345_MessagesContextMigrate.cs # migrations/mysql/SaaS/MessagesContext/MessagesContextModelSnapshot.cs # migrations/mysql/SaaS/NotifyDbContext/20221019144352_NotifyDbContextMigrate.Designer.cs # migrations/mysql/SaaS/NotifyDbContext/20221019144352_NotifyDbContextMigrate.cs # migrations/mysql/SaaS/NotifyDbContext/NotifyDbContextModelSnapshot.cs # migrations/mysql/SaaS/TeamlabSiteContext/20221219145514_TeamlabSiteContextMigrate.Designer.cs # migrations/mysql/SaaS/TeamlabSiteContext/20221219145514_TeamlabSiteContextMigrate.cs # migrations/mysql/SaaS/TeamlabSiteContext/20230621121634_TeamlabSiteContextMigrate.Designer.cs # migrations/mysql/SaaS/TeamlabSiteContext/20230621121634_TeamlabSiteContextMigrate.cs # migrations/mysql/SaaS/TelegramDbContext/20221019144353_TelegramDbContextMigrate.Designer.cs # migrations/mysql/SaaS/TelegramDbContext/20221019144353_TelegramDbContextMigrate.cs # migrations/mysql/SaaS/TelegramDbContext/TelegramDbContextModelSnapshot.cs # migrations/mysql/SaaS/TenantDbContext/20221019144354_TenantDbContextMigrate.Designer.cs # migrations/mysql/SaaS/TenantDbContext/20221019144354_TenantDbContextMigrate.cs # migrations/mysql/SaaS/TenantDbContext/TenantDbContextModelSnapshot.cs # migrations/mysql/SaaS/UrlShortenerFakeDbContext/20221019144355_UrlShortenerFakeDbContextMigrate.Designer.cs # migrations/mysql/SaaS/UrlShortenerFakeDbContext/20221019144355_UrlShortenerFakeDbContextMigrate.cs # migrations/mysql/SaaS/UrlShortenerFakeDbContext/UrlShortenerFakeDbContextModelSnapshot.cs # migrations/mysql/SaaS/UserDbContext/20230310195637_UserDbContextMigrate.Designer.cs # migrations/mysql/SaaS/UserDbContext/20230310195637_UserDbContextMigrate.cs # migrations/mysql/SaaS/UserDbContext/UserDbContextModelSnapshot.cs # migrations/mysql/SaaS/WebhooksDbContext/20221019144343_WebhooksDbContextMigrate.Designer.cs # migrations/mysql/SaaS/WebhooksDbContext/20221019144343_WebhooksDbContextMigrate.cs # migrations/mysql/SaaS/WebhooksDbContext/WebhooksDbContextModelSnapshot.cs # migrations/mysql/SaaS/WebstudioDbContext/20221019144356_WebstudioDbContextMigrate.Designer.cs # migrations/mysql/SaaS/WebstudioDbContext/20221019144356_WebstudioDbContextMigrate.cs # migrations/mysql/SaaS/WebstudioDbContext/WebstudioDbContextModelSnapshot.cs # migrations/mysql/TeamlabSiteContext/20221219145514_TeamlabSiteContextMigrate.Designer.cs # migrations/mysql/TeamlabSiteContext/20221219145514_TeamlabSiteContextMigrate.cs # migrations/postgre/ASC.Migrations.PostgreSql.csproj # migrations/postgre/SaaS/AccountLinkContext/20221019144350_AccountLinkContextMigrate.Designer.cs # migrations/postgre/SaaS/AccountLinkContext/20221019144350_AccountLinkContextMigrate.cs # migrations/postgre/SaaS/AccountLinkContext/AccountLinkContextModelSnapshot.cs # migrations/postgre/SaaS/BackupsContext/20230130103902_BackupsContextMigrate.Designer.cs # migrations/postgre/SaaS/BackupsContext/20230130103902_BackupsContextMigrate.cs # migrations/postgre/SaaS/BackupsContext/BackupsContextModelSnapshot.cs # migrations/postgre/SaaS/CoreDbContext/20230130103905_CoreDbContextMigrate.Designer.cs # migrations/postgre/SaaS/CoreDbContext/20230130103905_CoreDbContextMigrate.cs # migrations/postgre/SaaS/CoreDbContext/CoreDbContextModelSnapshot.cs # migrations/postgre/SaaS/CustomDbContext/20221019144351_CustomDbContextMigrate.Designer.cs # migrations/postgre/SaaS/CustomDbContext/20221019144351_CustomDbContextMigrate.cs # migrations/postgre/SaaS/CustomDbContext/CustomDbContextModelSnapshot.cs # migrations/postgre/SaaS/FeedDbContext/20221019144345_FeedDbContextMigrate.Designer.cs # migrations/postgre/SaaS/FeedDbContext/20221019144345_FeedDbContextMigrate.cs # migrations/postgre/SaaS/FeedDbContext/FeedDbContextModelSnapshot.cs # migrations/postgre/SaaS/FilesDbContext/20230130103904_FilesDbContextMigrate.Designer.cs # migrations/postgre/SaaS/FilesDbContext/20230130103904_FilesDbContextMigrate.cs # migrations/postgre/SaaS/FilesDbContext/20230515174319_FilesDbContext_Upgrade1.Designer.cs # migrations/postgre/SaaS/FilesDbContext/20230515174319_FilesDbContext_Upgrade1.cs # migrations/postgre/SaaS/FilesDbContext/FilesDbContextModelSnapshot.cs # migrations/postgre/SaaS/FirebaseDbContext/20221019144352_FirebaseDbContextMigrate.Designer.cs # migrations/postgre/SaaS/FirebaseDbContext/20221019144352_FirebaseDbContextMigrate.cs # migrations/postgre/SaaS/FirebaseDbContext/FirebaseDbContextModelSnapshot.cs # migrations/postgre/SaaS/InstanceRegistrationContext/20221019144347_InstanceRegistrationContextMigrate.Designer.cs # migrations/postgre/SaaS/InstanceRegistrationContext/20221019144347_InstanceRegistrationContextMigrate.cs # migrations/postgre/SaaS/InstanceRegistrationContext/InstanceRegistrationContextModelSnapshot.cs # migrations/postgre/SaaS/IntegrationEventLogContext/20221019144343_IntegrationEventLogContextMigrate.Designer.cs # migrations/postgre/SaaS/IntegrationEventLogContext/20221019144343_IntegrationEventLogContextMigrate.cs # migrations/postgre/SaaS/IntegrationEventLogContext/IntegrationEventLogContextModelSnapshot.cs # migrations/postgre/SaaS/MessagesContext/20221019144346_MessagesContextMigrate.Designer.cs # migrations/postgre/SaaS/MessagesContext/20221019144346_MessagesContextMigrate.cs # migrations/postgre/SaaS/MessagesContext/MessagesContextModelSnapshot.cs # migrations/postgre/SaaS/NotifyDbContext/20221019144353_NotifyDbContextMigrate.Designer.cs # migrations/postgre/SaaS/NotifyDbContext/20221019144353_NotifyDbContextMigrate.cs # migrations/postgre/SaaS/NotifyDbContext/NotifyDbContextModelSnapshot.cs # migrations/postgre/SaaS/TelegramDbContext/20221019144354_TelegramDbContextMigrate.Designer.cs # migrations/postgre/SaaS/TelegramDbContext/20221019144354_TelegramDbContextMigrate.cs # migrations/postgre/SaaS/TelegramDbContext/TelegramDbContextModelSnapshot.cs # migrations/postgre/SaaS/TenantDbContext/20221019144355_TenantDbContextMigrate.Designer.cs # migrations/postgre/SaaS/TenantDbContext/20221019144355_TenantDbContextMigrate.cs # migrations/postgre/SaaS/TenantDbContext/TenantDbContextModelSnapshot.cs # migrations/postgre/SaaS/UrlShortenerFakeDbContext/20221019144356_UrlShortenerFakeDbContextMigrate.Designer.cs # migrations/postgre/SaaS/UrlShortenerFakeDbContext/20221019144356_UrlShortenerFakeDbContextMigrate.cs # migrations/postgre/SaaS/UrlShortenerFakeDbContext/UrlShortenerFakeDbContextModelSnapshot.cs # migrations/postgre/SaaS/UserDbContext/20230310195637_UserDbContextMigrate.Designer.cs # migrations/postgre/SaaS/UserDbContext/20230310195637_UserDbContextMigrate.cs # migrations/postgre/SaaS/UserDbContext/UserDbContextModelSnapshot.cs # migrations/postgre/SaaS/WebhooksDbContext/20221019144344_WebhooksDbContextMigrate.Designer.cs # migrations/postgre/SaaS/WebhooksDbContext/20221019144344_WebhooksDbContextMigrate.cs # migrations/postgre/SaaS/WebhooksDbContext/WebhooksDbContextModelSnapshot.cs # migrations/postgre/SaaS/WebstudioDbContext/20221019144357_WebstudioDbContextMigrate.Designer.cs # migrations/postgre/SaaS/WebstudioDbContext/20221019144357_WebstudioDbContextMigrate.cs # migrations/postgre/SaaS/WebstudioDbContext/WebstudioDbContextModelSnapshot.cs # packages/client/src/Shell.jsx # packages/client/src/components/Article/Body/Items.js # packages/client/src/components/Article/Body/index.js # packages/client/src/components/EmptyContainer/RoomNoAccessContainer.js # packages/client/src/components/EmptyContainer/RootFolderContainer.js # packages/client/src/components/panels/InvitePanel/index.js # packages/client/src/components/panels/InvitePanel/sub-components/AccessSelector.js # packages/client/src/components/panels/InvitePanel/sub-components/Item.js # packages/client/src/components/panels/InvitePanel/sub-components/ItemsList.js # packages/client/src/components/panels/SelectFileDialog/AsideView.js # packages/client/src/components/panels/SelectFileDialog/index.js # packages/client/src/components/panels/SelectFolderDialog/index.js # packages/client/src/components/panels/SelectionPanel/ExceptionFoldersConstants.js # packages/client/src/components/panels/SelectionPanel/SelectionPanelBody.js # packages/client/src/components/panels/SelectionPanel/StyledSelectionPanel.js # packages/client/src/pages/Accounts.jsx # packages/client/src/pages/AccountsHome/index.js # packages/client/src/pages/Confirm/index.js # packages/client/src/pages/Confirm/sub-components/removePortal.js # packages/client/src/pages/Errors/520/index.js # packages/client/src/pages/Files.jsx # packages/client/src/pages/Home/Section/AccountsBody/TableView/TableContainer.js # packages/client/src/pages/Home/Section/AccountsBody/TableView/TableRow.js # packages/client/src/pages/Home/Section/Body/TableView/TableHeader.js # packages/client/src/pages/Home/Section/Filter/index.js # packages/client/src/pages/Home/Section/Header/index.js # packages/client/src/pages/Home/Section/SettingsBody/index.js # packages/client/src/pages/Home/index.js # packages/client/src/pages/PortalSettings/Layout/Article/Body/index.js # packages/client/src/pages/PortalSettings/Layout/Section/Header/index.js # packages/client/src/pages/PortalSettings/categories/common/Customization/dns-settings.js # packages/client/src/pages/PortalSettings/categories/common/sub-components/common-tooltips.js # packages/client/src/pages/PortalSettings/categories/data-management/backup/index.js # packages/client/src/pages/PortalSettings/categories/data-management/index.js # packages/client/src/pages/PortalSettings/categories/developer-tools/JavascriptSDK/index.js # packages/client/src/pages/PortalSettings/categories/developer-tools/index.js # packages/client/src/pages/PortalSettings/categories/integration/SingleSignOn/FieldMapping.js # packages/client/src/pages/PortalSettings/categories/integration/SingleSignOn/IdpSettings.js # packages/client/src/pages/PortalSettings/categories/integration/SingleSignOn/ProviderMetadata.js # packages/client/src/pages/PortalSettings/categories/integration/SingleSignOn/sub-components/MetadataUrlField.js # packages/client/src/pages/PortalSettings/categories/payments/index.js # packages/client/src/pages/PortalSettings/categories/security/access-portal/index.js # packages/client/src/pages/PortalSettings/categories/security/access-portal/mobileView.js # packages/client/src/pages/PortalSettings/categories/security/access-portal/sessionLifetime.js # packages/client/src/pages/PortalSettings/categories/security/sub-components/category-wrapper.js # packages/client/src/pages/PortalSettings/index.js # packages/client/src/pages/PortalSettings/utils/settingsTree.js # packages/client/src/pages/Profile/Section/Body/sub-components/interface-theme/index.js # packages/client/src/pages/Profile/Section/Body/sub-components/main-profile/index.js # packages/client/src/pages/VersionHistory/Section/Body/StyledVersionHistory.js # packages/client/src/pages/VersionHistory/Section/Body/VersionRow.js # packages/client/src/pages/Wizard/index.js # packages/client/src/store/AccountsContextOptionsStore.js # packages/client/src/store/FilesActionsStore.js # packages/client/src/store/FilesStore.js # packages/common/components/Article/index.js # packages/common/components/Article/sub-components/article-alerts.js # packages/common/components/Article/sub-components/article-header.js # packages/common/components/FilterInput/sub-components/FilterBlock.js # packages/common/components/Loaders/index.js # packages/common/components/MediaViewer/sub-components/ImageViewer/ImageViewer.props.ts # packages/common/components/MediaViewer/sub-components/ImageViewer/index.tsx # packages/common/components/PrivateRoute/index.js # packages/common/store/SettingsStore.js # packages/common/store/UserStore.js # packages/common/utils/index.ts # packages/components/file-input/index.js # packages/components/selector/StyledSelector.js # packages/components/selector/index.tsx # packages/components/selector/sub-components/Body/index.tsx # packages/components/slider/styled-slider.js # products/ASC.Files/Core/Core/Dao/TeamlabDao/FileDao.cs # products/ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs # products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs # products/ASC.Files/Core/Core/Security/FileSecurity.cs # products/ASC.Files/Core/Core/Thirdparty/Box/BoxFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/Box/BoxFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/Dropbox/DropboxFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/Dropbox/DropboxFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/GoogleDrive/GoogleDriveFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/GoogleDrive/GoogleDriveFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/OneDrive/OneDriveFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/OneDrive/OneDriveFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/SharePoint/SharePointFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/Sharpbox/SharpBoxFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/ThirdPartyProviderDao.cs # products/ASC.Files/Core/HttpHandlers/ChunkedUploaderHandler.cs # products/ASC.Files/Core/Utils/EntryManager.cs # products/ASC.Files/Core/Utils/FileConverter.cs # products/ASC.Files/Server/Api/FoldersController.cs # products/ASC.Files/Server/Api/SettingsController.cs # products/ASC.Files/Service/Cleanup/Worker.cs # products/ASC.People/Server/Api/UserController.cs # public/scripts/api.js # web/ASC.Web.Api/Api/AuthenticationController.cs # web/ASC.Web.Api/Api/PaymentsController.cs # web/ASC.Web.Api/Api/PortalController.cs # web/ASC.Web.Api/Api/Settings/LicenseController.cs # web/ASC.Web.Api/Api/Settings/MessageSettingsController.cs # web/ASC.Web.Api/Api/Settings/SettingsController.cs # web/ASC.Web.Api/Api/Settings/TfaappController.cs # web/ASC.Web.Api/Api/SmtpSettingsController.cs # web/ASC.Web.Api/Core/SmtpOperation.cs # web/ASC.Web.Core/CookiesManager.cs # yarn.lock
574 lines
15 KiB
TypeScript
574 lines
15 KiB
TypeScript
import LoginPageSvgUrl from "PUBLIC_DIR/images/logo/loginpage.svg?url";
|
|
import DarkLoginPageSvgUrl from "PUBLIC_DIR/images/logo/dark_loginpage.svg?url";
|
|
import LeftMenuSvgUrl from "PUBLIC_DIR/images/logo/leftmenu.svg?url";
|
|
import DocseditorSvgUrl from "PUBLIC_DIR/images/logo/docseditor.svg?url";
|
|
import LightSmallSvgUrl from "PUBLIC_DIR/images/logo/lightsmall.svg?url";
|
|
import DocsEditoRembedSvgUrl from "PUBLIC_DIR/images/logo/docseditorembed.svg?url";
|
|
import DarkLightSmallSvgUrl from "PUBLIC_DIR/images/logo/dark_lightsmall.svg?url";
|
|
import FaviconIco from "PUBLIC_DIR/favicon.ico";
|
|
|
|
import BackgroundPatternReactSvgUrl from "PUBLIC_DIR/images/background.pattern.react.svg?url";
|
|
import BackgroundPatternOrangeReactSvgUrl from "PUBLIC_DIR/images/background.pattern.orange.react.svg?url";
|
|
import BackgroundPatternGreenReactSvgUrl from "PUBLIC_DIR/images/background.pattern.green.react.svg?url";
|
|
import BackgroundPatternRedReactSvgUrl from "PUBLIC_DIR/images/background.pattern.red.react.svg?url";
|
|
import BackgroundPatternPurpleReactSvgUrl from "PUBLIC_DIR/images/background.pattern.purple.react.svg?url";
|
|
import BackgroundPatternLightBlueReactSvgUrl from "PUBLIC_DIR/images/background.pattern.lightBlue.react.svg?url";
|
|
import BackgroundPatternBlackReactSvgUrl from "PUBLIC_DIR/images/background.pattern.black.react.svg?url";
|
|
|
|
import moment from "moment";
|
|
|
|
import { LANGUAGE, ThemeKeys } from "../constants";
|
|
import sjcl from "sjcl";
|
|
import { isMobile } from "react-device-detect";
|
|
import TopLoaderService from "@docspace/components/top-loading-indicator";
|
|
import { Encoder } from "./encoder";
|
|
import FilesFilter from "../api/files/filter";
|
|
import combineUrlFunc from "./combineUrl";
|
|
// import { translations } from "./i18next-http-backend/lib/translations";
|
|
export const toUrlParams = (obj, skipNull) => {
|
|
let str = "";
|
|
for (var key in obj) {
|
|
if (skipNull && !obj[key]) continue;
|
|
|
|
if (str !== "") {
|
|
str += "&";
|
|
}
|
|
|
|
if (typeof obj[key] === "object") {
|
|
str += key + "=" + encodeURIComponent(JSON.stringify(obj[key]));
|
|
} else {
|
|
str += key + "=" + encodeURIComponent(obj[key]);
|
|
}
|
|
}
|
|
|
|
return str;
|
|
};
|
|
|
|
export const decodeDisplayName = (items) => {
|
|
return items.map((item) => {
|
|
if (!item) return item;
|
|
|
|
if (item.updatedBy?.displayName) {
|
|
item.updatedBy.displayName = Encoder.htmlDecode(
|
|
item.updatedBy.displayName
|
|
);
|
|
}
|
|
if (item.createdBy?.displayName) {
|
|
item.createdBy.displayName = Encoder.htmlDecode(
|
|
item.createdBy.displayName
|
|
);
|
|
}
|
|
return item;
|
|
});
|
|
};
|
|
|
|
export function getObjectByLocation(location) {
|
|
if (!location.search || !location.search.length) return null;
|
|
|
|
const searchUrl = location.search.substring(1);
|
|
const decodedString = decodeURIComponent(searchUrl)
|
|
.replace(/\["/g, '["')
|
|
.replace(/"\]/g, '"]')
|
|
.replace(/"/g, '\\"')
|
|
.replace(/&/g, '","')
|
|
.replace(/=/g, '":"')
|
|
.replace(/\\/g, "\\\\")
|
|
.replace(/\[\\\\"/g, '["')
|
|
.replace(/\\\\"\]/g, '"]')
|
|
.replace(/"\[/g, "[")
|
|
.replace(/\]"/g, "]")
|
|
.replace(/\\\\",\\\\"/g, '","');
|
|
|
|
const object = JSON.parse(`{"${decodedString}"}`);
|
|
|
|
return object;
|
|
}
|
|
|
|
export function changeLanguage(i18n, currentLng = getCookie(LANGUAGE)) {
|
|
return currentLng
|
|
? i18n.language !== currentLng
|
|
? i18n.changeLanguage(currentLng)
|
|
: Promise.resolve((...args) => i18n.t(...args))
|
|
: i18n.changeLanguage("en");
|
|
}
|
|
|
|
export function createPasswordHash(password, hashSettings) {
|
|
if (
|
|
!password ||
|
|
!hashSettings ||
|
|
typeof password !== "string" ||
|
|
typeof hashSettings !== "object" ||
|
|
!hashSettings.hasOwnProperty("salt") ||
|
|
!hashSettings.hasOwnProperty("size") ||
|
|
!hashSettings.hasOwnProperty("iterations") ||
|
|
typeof hashSettings.size !== "number" ||
|
|
typeof hashSettings.iterations !== "number" ||
|
|
typeof hashSettings.salt !== "string"
|
|
)
|
|
throw new Error("Invalid params.");
|
|
|
|
const { size, iterations, salt } = hashSettings;
|
|
|
|
let bits = sjcl.misc.pbkdf2(password, salt, iterations);
|
|
bits = bits.slice(0, size / 32);
|
|
const hash = sjcl.codec.hex.fromBits(bits);
|
|
|
|
return hash;
|
|
}
|
|
|
|
export function updateTempContent(isAuth = false) {
|
|
if (isAuth) {
|
|
const el = document.getElementById("burger-loader-svg");
|
|
if (el) {
|
|
el.style.display = "block";
|
|
}
|
|
|
|
const el1 = document.getElementById("logo-loader-svg");
|
|
if (el1) {
|
|
el1.style.display = "block";
|
|
}
|
|
|
|
const el2 = document.getElementById("avatar-loader-svg");
|
|
if (el2) {
|
|
el2.style.display = "block";
|
|
}
|
|
} else {
|
|
const tempElm = document.getElementById("temp-content");
|
|
if (tempElm) {
|
|
tempElm.outerHTML = "";
|
|
}
|
|
}
|
|
}
|
|
|
|
let timer = null;
|
|
|
|
export function hideLoader() {
|
|
if (isMobile) return;
|
|
if (timer) {
|
|
clearTimeout(timer);
|
|
timer = null;
|
|
}
|
|
TopLoaderService.end();
|
|
}
|
|
|
|
export function showLoader() {
|
|
if (isMobile) return;
|
|
|
|
hideLoader();
|
|
|
|
timer = setTimeout(() => TopLoaderService.start(), 500);
|
|
}
|
|
|
|
export { withLayoutSize } from "./withLayoutSize";
|
|
|
|
export function isMe(user, userName) {
|
|
return (
|
|
user && user.id && (userName === "@self" || user.userName === userName)
|
|
);
|
|
}
|
|
|
|
export function isAdmin(currentUser) {
|
|
return (
|
|
currentUser.isAdmin ||
|
|
currentUser.isOwner ||
|
|
currentUser?.listAdminModules?.length > 0
|
|
);
|
|
}
|
|
|
|
export const getUserRole = (user) => {
|
|
if (user.isOwner) return "owner";
|
|
else if (isAdmin(user))
|
|
//TODO: Change to People Product Id const
|
|
return "admin";
|
|
//TODO: Need refactoring
|
|
else if (user.isVisitor) return "user";
|
|
else if (user.isCollaborator) return "collaborator";
|
|
else return "manager";
|
|
};
|
|
|
|
export const combineUrl = combineUrlFunc;
|
|
|
|
export function getCookie(name) {
|
|
let matches = document.cookie.match(
|
|
new RegExp(
|
|
"(?:^|; )" +
|
|
name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") +
|
|
"=([^;]*)"
|
|
)
|
|
);
|
|
return matches ? decodeURIComponent(matches[1]) : undefined;
|
|
}
|
|
|
|
export function setCookie(name, value, options = {}) {
|
|
options = {
|
|
path: "/",
|
|
...options,
|
|
};
|
|
|
|
if (options.expires instanceof Date) {
|
|
options.expires = options.expires.toUTCString();
|
|
}
|
|
|
|
let updatedCookie =
|
|
encodeURIComponent(name) + "=" + encodeURIComponent(value);
|
|
|
|
for (let optionKey in options) {
|
|
updatedCookie += "; " + optionKey;
|
|
let optionValue = options[optionKey];
|
|
if (optionValue !== true) {
|
|
updatedCookie += "=" + optionValue;
|
|
}
|
|
}
|
|
|
|
document.cookie = updatedCookie;
|
|
}
|
|
|
|
export function deleteCookie(name) {
|
|
setCookie(name, "", {
|
|
"max-age": -1,
|
|
});
|
|
}
|
|
|
|
export function clickBackdrop() {
|
|
var elms = document.getElementsByClassName("backdrop-active");
|
|
if (elms && elms.length > 0) {
|
|
elms[0].click();
|
|
}
|
|
}
|
|
|
|
export function objectToGetParams(object) {
|
|
const params = Object.entries(object)
|
|
.filter(([, value]) => value !== undefined && value !== null)
|
|
.map(
|
|
([key, value]) =>
|
|
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
|
);
|
|
|
|
return params.length > 0 ? `?${params.join("&")}` : "";
|
|
}
|
|
|
|
export function toCommunityHostname(hostname) {
|
|
let communityHostname;
|
|
try {
|
|
communityHostname =
|
|
hostname.indexOf("m.") > -1
|
|
? hostname.substring(2, hostname.length)
|
|
: hostname;
|
|
} catch (e) {
|
|
console.error(e);
|
|
communityHostname = hostname;
|
|
}
|
|
|
|
return communityHostname;
|
|
}
|
|
|
|
export function getProviderTranslation(provider, t, linked = false) {
|
|
const capitalizeProvider =
|
|
provider.charAt(0).toUpperCase() + provider.slice(1);
|
|
if (linked) {
|
|
return `${t("Common:Disconnect")} ${capitalizeProvider}`;
|
|
}
|
|
|
|
switch (provider) {
|
|
case "google":
|
|
return t("Common:SignInWithGoogle");
|
|
case "facebook":
|
|
return t("Common:SignInWithFacebook");
|
|
case "twitter":
|
|
return t("Common:SignInWithTwitter");
|
|
case "linkedin":
|
|
return t("Common:SignInWithLinkedIn");
|
|
case "sso":
|
|
return t("Common:SignInWithSso");
|
|
}
|
|
}
|
|
|
|
export function getLanguage(lng) {
|
|
try {
|
|
if (!lng) return lng;
|
|
|
|
let language = lng == "en-US" || lng == "en-GB" ? "en" : lng;
|
|
|
|
const splitted = lng.split("-");
|
|
|
|
if (splitted.length == 2 && splitted[0] == splitted[1].toLowerCase()) {
|
|
language = splitted[0];
|
|
}
|
|
|
|
return language;
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
|
|
return lng;
|
|
}
|
|
|
|
export function loadScript(url, id, onLoad, onError) {
|
|
try {
|
|
const script = document.createElement("script");
|
|
script.setAttribute("type", "text/javascript");
|
|
script.setAttribute("id", id);
|
|
|
|
if (onLoad) script.onload = onLoad;
|
|
if (onError) script.onerror = onError;
|
|
|
|
script.src = url;
|
|
script.async = true;
|
|
|
|
document.body.appendChild(script);
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
}
|
|
|
|
export function isRetina() {
|
|
if (window.devicePixelRatio > 1) return true;
|
|
|
|
var mediaQuery =
|
|
"(-webkit-min-device-pixel-ratio: 1.5),\
|
|
(min--moz-device-pixel-ratio: 1.5),\
|
|
(-o-min-device-pixel-ratio: 3/2),\
|
|
(min-resolution: 1.5dppx),\
|
|
(min-device-pixel-ratio: 1.5)";
|
|
|
|
if (window.matchMedia && window.matchMedia(mediaQuery).matches) return true;
|
|
return false;
|
|
}
|
|
|
|
export function convertLanguage(key) {
|
|
switch (key) {
|
|
case "en":
|
|
return "en-GB";
|
|
case "ru-RU":
|
|
return "ru";
|
|
case "de-DE":
|
|
return "de";
|
|
case "it-IT":
|
|
return "it";
|
|
case "fr-FR":
|
|
return "fr";
|
|
}
|
|
|
|
return key;
|
|
}
|
|
|
|
export function sleep(ms) {
|
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
}
|
|
|
|
export function isElementInViewport(el) {
|
|
if (!el) return;
|
|
|
|
const rect = el.getBoundingClientRect();
|
|
|
|
return (
|
|
rect.top >= 0 &&
|
|
rect.left >= 0 &&
|
|
rect.bottom <=
|
|
(window.innerHeight || document.documentElement.clientHeight) &&
|
|
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
|
|
);
|
|
}
|
|
|
|
export function assign(obj, keyPath, value) {
|
|
const lastKeyIndex = keyPath.length - 1;
|
|
for (let i = 0; i < lastKeyIndex; ++i) {
|
|
const key = keyPath[i];
|
|
if (!(key in obj)) {
|
|
obj[key] = {};
|
|
}
|
|
obj = obj[key];
|
|
}
|
|
obj[keyPath[lastKeyIndex]] = value;
|
|
}
|
|
|
|
export function getOAuthToken(
|
|
tokenGetterWin: Window | string | null
|
|
): Promise<string> {
|
|
return new Promise((resolve, reject) => {
|
|
localStorage.removeItem("code");
|
|
let interval: ReturnType<typeof setInterval>;
|
|
interval = setInterval(() => {
|
|
try {
|
|
const code = localStorage.getItem("code");
|
|
if (typeof tokenGetterWin !== "string") {
|
|
if (code) {
|
|
localStorage.removeItem("code");
|
|
clearInterval(interval);
|
|
resolve(code);
|
|
} else if (tokenGetterWin && tokenGetterWin.closed) {
|
|
clearInterval(interval);
|
|
reject();
|
|
}
|
|
}
|
|
} catch (e) {
|
|
clearInterval(interval);
|
|
reject(e);
|
|
}
|
|
}, 500);
|
|
});
|
|
}
|
|
|
|
export function getLoginLink(token: string, code: string) {
|
|
return combineUrl(
|
|
window.DocSpaceConfig?.proxy?.url,
|
|
`/login.ashx?p=${token}&code=${code}`
|
|
);
|
|
}
|
|
|
|
export function checkIsSSR() {
|
|
return typeof window === "undefined";
|
|
}
|
|
|
|
export const frameCallbackData = (methodReturnData: any) => {
|
|
window.parent.postMessage(
|
|
JSON.stringify({
|
|
type: "onMethodReturn",
|
|
methodReturnData,
|
|
}),
|
|
"*"
|
|
);
|
|
};
|
|
|
|
export const frameCallEvent = (eventReturnData: any) => {
|
|
window.parent.postMessage(
|
|
JSON.stringify({
|
|
type: "onEventReturn",
|
|
eventReturnData,
|
|
}),
|
|
"*"
|
|
);
|
|
};
|
|
|
|
export const frameCallCommand = (commandName: string, commandData: any) => {
|
|
window.parent.postMessage(
|
|
JSON.stringify({
|
|
type: "onCallCommand",
|
|
commandName,
|
|
commandData,
|
|
}),
|
|
"*"
|
|
);
|
|
};
|
|
|
|
export const getConvertedSize = (t, bytes) => {
|
|
let power = 0,
|
|
resultSize = bytes;
|
|
|
|
const sizeNames = [
|
|
t("Common:Bytes"),
|
|
t("Common:Kilobyte"),
|
|
t("Common:Megabyte"),
|
|
t("Common:Gigabyte"),
|
|
t("Common:Terabyte"),
|
|
t("Common:Petabyte"),
|
|
t("Common:Exabyte"),
|
|
];
|
|
|
|
if (bytes <= 0) return `${"0" + " " + t("Common:Bytes")}`;
|
|
|
|
if (bytes >= 1024) {
|
|
power = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
power = power < sizeNames.length ? power : sizeNames.length - 1;
|
|
resultSize = parseFloat((bytes / Math.pow(1024, power)).toFixed(2));
|
|
}
|
|
|
|
return resultSize + " " + sizeNames[power];
|
|
};
|
|
|
|
export const getBgPattern = (colorSchemeId: number | undefined) => {
|
|
switch (colorSchemeId) {
|
|
case 1:
|
|
return `url('${BackgroundPatternReactSvgUrl}')`;
|
|
case 2:
|
|
return `url('${BackgroundPatternOrangeReactSvgUrl}')`;
|
|
case 3:
|
|
return `url('${BackgroundPatternGreenReactSvgUrl}')`;
|
|
case 4:
|
|
return `url('${BackgroundPatternRedReactSvgUrl}')`;
|
|
case 5:
|
|
return `url('${BackgroundPatternPurpleReactSvgUrl}')`;
|
|
case 6:
|
|
return `url('${BackgroundPatternLightBlueReactSvgUrl}')`;
|
|
case 7:
|
|
return `url('${BackgroundPatternBlackReactSvgUrl}')`;
|
|
default:
|
|
return `url('${BackgroundPatternReactSvgUrl}')`;
|
|
}
|
|
};
|
|
|
|
export const getLogoFromPath = (path) => {
|
|
if (!path || path.indexOf("images/logo/") === -1) return path;
|
|
|
|
const name = path.split("/").pop();
|
|
|
|
switch (name) {
|
|
case "aboutpage.svg":
|
|
case "loginpage.svg":
|
|
return LoginPageSvgUrl;
|
|
case "dark_loginpage.svg":
|
|
return DarkLoginPageSvgUrl;
|
|
case "leftmenu.svg":
|
|
case "dark_leftmenu.svg":
|
|
return LeftMenuSvgUrl;
|
|
case "dark_aboutpage.svg":
|
|
case "dark_lightsmall.svg":
|
|
return DarkLightSmallSvgUrl;
|
|
case "docseditor.svg":
|
|
return DocseditorSvgUrl;
|
|
case "lightsmall.svg":
|
|
return LightSmallSvgUrl;
|
|
case "docseditorembed.svg":
|
|
return DocsEditoRembedSvgUrl;
|
|
case "favicon.ico":
|
|
return FaviconIco;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return path;
|
|
};
|
|
|
|
export const getDaysLeft = (date) => {
|
|
return moment(date).startOf("day").diff(moment().startOf("day"), "days");
|
|
};
|
|
export const getDaysRemaining = (autoDelete) => {
|
|
let daysRemaining = getDaysLeft(autoDelete);
|
|
|
|
if (daysRemaining <= 0) return "<1";
|
|
return "" + daysRemaining;
|
|
};
|
|
|
|
export const checkFilterInstance = (filterObject, certainClass) => {
|
|
const isInstance =
|
|
filterObject.constructor.name === certainClass.prototype.constructor.name;
|
|
|
|
if (!isInstance)
|
|
throw new Error(
|
|
`Filter ${filterObject.constructor.name} isn't an instance of ${certainClass.prototype.constructor.name}`
|
|
);
|
|
|
|
return isInstance;
|
|
};
|
|
|
|
export const getFileExtension = (fileTitle: string) => {
|
|
if (!fileTitle) {
|
|
return "";
|
|
}
|
|
fileTitle = fileTitle.trim();
|
|
const posExt = fileTitle.lastIndexOf(".");
|
|
return 0 <= posExt ? fileTitle.substring(posExt).trim().toLowerCase() : "";
|
|
};
|
|
|
|
export const getSystemTheme = () => {
|
|
const isDesktopClient = window["AscDesktopEditor"] !== undefined;
|
|
return isDesktopClient
|
|
? window?.RendererProcessVariable?.theme?.type === "dark"
|
|
? ThemeKeys.DarkStr
|
|
: ThemeKeys.BaseStr
|
|
: window.matchMedia &&
|
|
window.matchMedia("(prefers-color-scheme: dark)").matches
|
|
? ThemeKeys.DarkStr
|
|
: ThemeKeys.BaseStr;
|
|
};
|