fixed bad merge
This commit is contained in:
parent
2fc16bc9ec
commit
887ed64df0
@ -0,0 +1,102 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
import config from "PACKAGE_FILE";
|
||||||
|
import { combineUrl } from "@docspace/common/utils";
|
||||||
|
|
||||||
|
export const generateLogo = (
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
text,
|
||||||
|
fontSize = 18,
|
||||||
|
fontColor = "#000",
|
||||||
|
alignCenter
|
||||||
|
) => {
|
||||||
|
const canvas = document.createElement("canvas");
|
||||||
|
canvas.width = width;
|
||||||
|
canvas.height = height;
|
||||||
|
|
||||||
|
const ctx = canvas.getContext("2d");
|
||||||
|
const x = alignCenter ? width / 2 : 0;
|
||||||
|
|
||||||
|
ctx.fillStyle = "transparent";
|
||||||
|
ctx.clearRect(0, 0, width, height);
|
||||||
|
ctx.fillStyle = fontColor;
|
||||||
|
ctx.textAlign = alignCenter ? "center" : "start";
|
||||||
|
ctx.textBaseline = "middle";
|
||||||
|
ctx.font = `${fontSize}px Arial`;
|
||||||
|
ctx.fillText(text, x, height - fontSize / 2);
|
||||||
|
|
||||||
|
return canvas.toDataURL();
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getLogoOptions = (index, text) => {
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
return { fontSize: 18, text: text, width: 211, height: 24 };
|
||||||
|
case 1:
|
||||||
|
return { fontSize: 32, text: text, width: 384, height: 42 };
|
||||||
|
case 2:
|
||||||
|
return {
|
||||||
|
fontSize: 26,
|
||||||
|
text: text.trim().charAt(0),
|
||||||
|
width: 30,
|
||||||
|
height: 30,
|
||||||
|
alignCenter: true,
|
||||||
|
};
|
||||||
|
case 3:
|
||||||
|
return { fontSize: 22, text: text, width: 154, height: 27 };
|
||||||
|
case 4:
|
||||||
|
return { fontSize: 22, text: text, width: 154, height: 27 };
|
||||||
|
case 5:
|
||||||
|
return {
|
||||||
|
fontSize: 24,
|
||||||
|
text: text.trim().charAt(0),
|
||||||
|
width: 28,
|
||||||
|
height: 28,
|
||||||
|
alignCenter: true,
|
||||||
|
};
|
||||||
|
case 6:
|
||||||
|
return { fontSize: 18, text: text, width: 211, height: 24 };
|
||||||
|
default:
|
||||||
|
return { fontSize: 18, text: text, width: 211, height: 24 };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const uploadLogo = async (file) => {
|
||||||
|
try {
|
||||||
|
const { width, height } = await getUploadedFileDimensions(file);
|
||||||
|
let data = new FormData();
|
||||||
|
data.append("file", file);
|
||||||
|
data.append("width", width);
|
||||||
|
data.append("height", height);
|
||||||
|
|
||||||
|
return await axios.post(
|
||||||
|
`${combineUrl(
|
||||||
|
window.DocSpaceConfig?.proxy?.url,
|
||||||
|
config.homepage
|
||||||
|
)}/logoUploader.ashx`,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getUploadedFileDimensions = (file) =>
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
let img = new Image();
|
||||||
|
|
||||||
|
img.onload = () => {
|
||||||
|
const width = img.naturalWidth,
|
||||||
|
height = img.naturalHeight;
|
||||||
|
|
||||||
|
window.URL.revokeObjectURL(img.src);
|
||||||
|
|
||||||
|
return resolve({ width, height });
|
||||||
|
};
|
||||||
|
|
||||||
|
img.src = window.URL.createObjectURL(file);
|
||||||
|
} catch (exception) {
|
||||||
|
return reject(exception);
|
||||||
|
}
|
||||||
|
});
|
@ -10,17 +10,11 @@ import BookTrainingReactSvgUrl from "PUBLIC_DIR/images/book.training.react.svg?u
|
|||||||
import InfoOutlineReactSvgUrl from "PUBLIC_DIR/images/info.outline.react.svg?url";
|
import InfoOutlineReactSvgUrl from "PUBLIC_DIR/images/info.outline.react.svg?url";
|
||||||
import LogoutReactSvgUrl from "PUBLIC_DIR/images/logout.react.svg?url";
|
import LogoutReactSvgUrl from "PUBLIC_DIR/images/logout.react.svg?url";
|
||||||
import SpacesReactSvgUrl from "PUBLIC_DIR/images/spaces.react.svg?url";
|
import SpacesReactSvgUrl from "PUBLIC_DIR/images/spaces.react.svg?url";
|
||||||
|
|
||||||
import { makeAutoObservable } from "mobx";
|
import { makeAutoObservable } from "mobx";
|
||||||
import { combineUrl } from "@docspace/common/utils";
|
import { combineUrl } from "@docspace/common/utils";
|
||||||
|
|
||||||
import {
|
import { isDesktop, isTablet, isMobile } from "react-device-detect";
|
||||||
isDesktop,
|
|
||||||
isTablet,
|
|
||||||
isMobile,
|
|
||||||
isMobileOnly,
|
|
||||||
} from "react-device-detect";
|
|
||||||
import { getProfileMenuItems } from "SRC_DIR/helpers/plugins";
|
|
||||||
import { ZendeskAPI } from "@docspace/common/components/Zendesk";
|
import { ZendeskAPI } from "@docspace/common/components/Zendesk";
|
||||||
import { LIVE_CHAT_LOCAL_STORAGE_KEY } from "@docspace/common/constants";
|
import { LIVE_CHAT_LOCAL_STORAGE_KEY } from "@docspace/common/constants";
|
||||||
import toastr from "@docspace/components/toast/toastr";
|
import toastr from "@docspace/components/toast/toastr";
|
||||||
@ -37,13 +31,13 @@ const PAYMENTS_URL = combineUrl(
|
|||||||
//const VIDEO_GUIDES_URL = "https://onlyoffice.com/";
|
//const VIDEO_GUIDES_URL = "https://onlyoffice.com/";
|
||||||
|
|
||||||
const SPACES_URL = combineUrl(PROXY_HOMEPAGE_URL, "/management");
|
const SPACES_URL = combineUrl(PROXY_HOMEPAGE_URL, "/management");
|
||||||
|
|
||||||
class ProfileActionsStore {
|
class ProfileActionsStore {
|
||||||
authStore = null;
|
authStore = null;
|
||||||
filesStore = null;
|
filesStore = null;
|
||||||
peopleStore = null;
|
peopleStore = null;
|
||||||
treeFoldersStore = null;
|
treeFoldersStore = null;
|
||||||
selectedFolderStore = null;
|
selectedFolderStore = null;
|
||||||
|
pluginStore = null;
|
||||||
isAboutDialogVisible = false;
|
isAboutDialogVisible = false;
|
||||||
isDebugDialogVisible = false;
|
isDebugDialogVisible = false;
|
||||||
isShowLiveChat = false;
|
isShowLiveChat = false;
|
||||||
@ -54,13 +48,15 @@ class ProfileActionsStore {
|
|||||||
filesStore,
|
filesStore,
|
||||||
peopleStore,
|
peopleStore,
|
||||||
treeFoldersStore,
|
treeFoldersStore,
|
||||||
selectedFolderStore
|
selectedFolderStore,
|
||||||
|
pluginStore
|
||||||
) {
|
) {
|
||||||
this.authStore = authStore;
|
this.authStore = authStore;
|
||||||
this.filesStore = filesStore;
|
this.filesStore = filesStore;
|
||||||
this.peopleStore = peopleStore;
|
this.peopleStore = peopleStore;
|
||||||
this.treeFoldersStore = treeFoldersStore;
|
this.treeFoldersStore = treeFoldersStore;
|
||||||
this.selectedFolderStore = selectedFolderStore;
|
this.selectedFolderStore = selectedFolderStore;
|
||||||
|
this.pluginStore = pluginStore;
|
||||||
|
|
||||||
this.isShowLiveChat = this.getStateLiveChat();
|
this.isShowLiveChat = this.getStateLiveChat();
|
||||||
|
|
||||||
@ -224,7 +220,7 @@ class ProfileActionsStore {
|
|||||||
? {
|
? {
|
||||||
key: "user-menu-settings",
|
key: "user-menu-settings",
|
||||||
icon: CatalogSettingsReactSvgUrl,
|
icon: CatalogSettingsReactSvgUrl,
|
||||||
label: t("Common:SettingsDocSpace"),
|
label: t("Common:Settings"),
|
||||||
onClick: () => this.onSettingsClick(settingsUrl),
|
onClick: () => this.onSettingsClick(settingsUrl),
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
@ -341,7 +337,7 @@ class ProfileActionsStore {
|
|||||||
// onClick: this.onVideoGuidesClick,
|
// onClick: this.onVideoGuidesClick,
|
||||||
// },
|
// },
|
||||||
hotkeys,
|
hotkeys,
|
||||||
{
|
!isMobile && {
|
||||||
isSeparator: true,
|
isSeparator: true,
|
||||||
key: "separator2",
|
key: "separator2",
|
||||||
},
|
},
|
||||||
@ -359,18 +355,20 @@ class ProfileActionsStore {
|
|||||||
label: t("Common:AboutCompanyTitle"),
|
label: t("Common:AboutCompanyTitle"),
|
||||||
onClick: this.onAboutClick,
|
onClick: this.onAboutClick,
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
isSeparator: true,
|
|
||||||
key: "separator3",
|
if (
|
||||||
},
|
!window.navigator.userAgent.includes("ZoomWebKit") &&
|
||||||
{
|
!window.navigator.userAgent.includes("ZoomApps")
|
||||||
|
) {
|
||||||
|
actions.push({
|
||||||
key: "user-menu-logout",
|
key: "user-menu-logout",
|
||||||
icon: LogoutReactSvgUrl,
|
icon: LogoutReactSvgUrl,
|
||||||
label: t("Common:LogoutButton"),
|
label: t("Common:LogoutButton"),
|
||||||
onClick: this.onLogoutClick,
|
onClick: this.onLogoutClick,
|
||||||
isButton: true,
|
isButton: true,
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
if (debugInfo) {
|
if (debugInfo) {
|
||||||
actions.splice(4, 0, {
|
actions.splice(4, 0, {
|
||||||
@ -381,18 +379,14 @@ class ProfileActionsStore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enablePlugins) {
|
if (this.pluginStore.profileMenuItemsList && enablePlugins) {
|
||||||
const pluginActions = getProfileMenuItems();
|
this.pluginStore.profileMenuItemsList.forEach((option) => {
|
||||||
|
|
||||||
if (pluginActions) {
|
|
||||||
pluginActions.forEach((option) => {
|
|
||||||
actions.splice(option.value.position, 0, {
|
actions.splice(option.value.position, 0, {
|
||||||
key: option.key,
|
key: option.key,
|
||||||
...option.value,
|
...option.value,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return this.checkEnabledActions(actions);
|
return this.checkEnabledActions(actions);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user