mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-09 20:12:00 +10:00
add env variable (#513)
This commit is contained in:
@ -40,3 +40,5 @@ SMTP_IGNORETLS=false
|
|||||||
# Postmark driver config
|
# Postmark driver config
|
||||||
POSTMARK_TOKEN=
|
POSTMARK_TOKEN=
|
||||||
|
|
||||||
|
# for custom drawio server
|
||||||
|
DRAWIO_URL=
|
||||||
@ -3,7 +3,7 @@ import { ActionIcon, Card, Image, Modal, Text, useComputedColorScheme } from '@m
|
|||||||
import { useRef, useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
import { uploadFile } from '@/features/page/services/page-service.ts';
|
import { uploadFile } from '@/features/page/services/page-service.ts';
|
||||||
import { useDisclosure } from '@mantine/hooks';
|
import { useDisclosure } from '@mantine/hooks';
|
||||||
import { getFileUrl } from '@/lib/config.ts';
|
import { getDrawioUrl, getFileUrl } from '@/lib/config.ts';
|
||||||
import {
|
import {
|
||||||
DrawIoEmbed,
|
DrawIoEmbed,
|
||||||
DrawIoEmbedRef,
|
DrawIoEmbedRef,
|
||||||
@ -87,6 +87,7 @@ export default function DrawioView(props: NodeViewProps) {
|
|||||||
<DrawIoEmbed
|
<DrawIoEmbed
|
||||||
ref={drawioRef}
|
ref={drawioRef}
|
||||||
xml={initialXML}
|
xml={initialXML}
|
||||||
|
baseUrl={getDrawioUrl()}
|
||||||
urlParameters={{
|
urlParameters={{
|
||||||
ui: computedColorScheme === 'light' ? 'kennedy' : 'dark',
|
ui: computedColorScheme === 'light' ? 'kennedy' : 'dark',
|
||||||
spin: true,
|
spin: true,
|
||||||
|
|||||||
@ -57,6 +57,14 @@ export function getFileUrl(src: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getFileUploadSizeLimit() {
|
export function getFileUploadSizeLimit() {
|
||||||
const limit = window.CONFIG?.FILE_UPLOAD_SIZE_LIMIT || process?.env.FILE_UPLOAD_SIZE_LIMIT || '50mb';
|
const limit =getConfigValue("FILE_UPLOAD_SIZE_LIMIT", "50mb");
|
||||||
return bytes(limit);
|
return bytes(limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDrawioUrl() {
|
||||||
|
return getConfigValue("DRAWIO_URL", "https://embed.diagrams.net");
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfigValue(key: string, defaultValue: string = undefined) {
|
||||||
|
return window.CONFIG?.[key] || process?.env?.[key] || defaultValue;
|
||||||
}
|
}
|
||||||
@ -74,4 +74,4 @@ export function decodeBase64ToSvgString(base64Data: string): string {
|
|||||||
|
|
||||||
export function capitalizeFirstChar(string: string) {
|
export function capitalizeFirstChar(string: string) {
|
||||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,13 +5,14 @@ import * as path from "path";
|
|||||||
export const envPath = path.resolve(process.cwd(), "..", "..");
|
export const envPath = path.resolve(process.cwd(), "..", "..");
|
||||||
|
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
const { APP_URL, FILE_UPLOAD_SIZE_LIMIT } = loadEnv(mode, envPath, "");
|
const { APP_URL, FILE_UPLOAD_SIZE_LIMIT, DRAWIO_URL } = loadEnv(mode, envPath, "");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
define: {
|
define: {
|
||||||
"process.env": {
|
"process.env": {
|
||||||
APP_URL,
|
APP_URL,
|
||||||
FILE_UPLOAD_SIZE_LIMIT
|
FILE_UPLOAD_SIZE_LIMIT,
|
||||||
|
DRAWIO_URL
|
||||||
},
|
},
|
||||||
'APP_VERSION': JSON.stringify(process.env.npm_package_version),
|
'APP_VERSION': JSON.stringify(process.env.npm_package_version),
|
||||||
},
|
},
|
||||||
|
|||||||
@ -122,6 +122,10 @@ export class EnvironmentService {
|
|||||||
return this.configService.get<string>('POSTMARK_TOKEN');
|
return this.configService.get<string>('POSTMARK_TOKEN');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDrawioUrl(): string {
|
||||||
|
return this.configService.get<string>('DRAWIO_URL');
|
||||||
|
}
|
||||||
|
|
||||||
isCloud(): boolean {
|
isCloud(): boolean {
|
||||||
const cloudConfig = this.configService
|
const cloudConfig = this.configService
|
||||||
.get<string>('CLOUD', 'false')
|
.get<string>('CLOUD', 'false')
|
||||||
|
|||||||
@ -33,7 +33,8 @@ export class StaticModule implements OnModuleInit {
|
|||||||
ENV: this.environmentService.getNodeEnv(),
|
ENV: this.environmentService.getNodeEnv(),
|
||||||
APP_URL: this.environmentService.getAppUrl(),
|
APP_URL: this.environmentService.getAppUrl(),
|
||||||
IS_CLOUD: this.environmentService.isCloud(),
|
IS_CLOUD: this.environmentService.isCloud(),
|
||||||
FILE_UPLOAD_SIZE_LIMIT: this.environmentService.getFileUploadSizeLimit()
|
FILE_UPLOAD_SIZE_LIMIT: this.environmentService.getFileUploadSizeLimit(),
|
||||||
|
DRAWIO_URL: this.environmentService.getDrawioUrl()
|
||||||
};
|
};
|
||||||
|
|
||||||
const windowScriptContent = `<script>window.CONFIG=${JSON.stringify(configString)};</script>`;
|
const windowScriptContent = `<script>window.CONFIG=${JSON.stringify(configString)};</script>`;
|
||||||
|
|||||||
Reference in New Issue
Block a user