mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
feat(product): product configuration
CB-99
This commit is contained in:
@@ -96,6 +96,11 @@ module.exports = (env, argv) => {
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.json5$/i,
|
||||
loader: 'json5-loader',
|
||||
type: 'javascript/auto',
|
||||
},
|
||||
{
|
||||
test: /\.(ts|js)x?$/,
|
||||
exclude: /node_modules/,
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
"eslint-plugin-react": "^7.16.0",
|
||||
"eslint-plugin-react-hooks": "^1.7.0",
|
||||
"html-webpack-plugin": "^4.3.0",
|
||||
"json5-loader": "^4.0.0",
|
||||
"lerna": "^3.20.2",
|
||||
"mini-css-extract-plugin": "^0.9.0",
|
||||
"mobx": "^5.15.4",
|
||||
|
||||
@@ -10,8 +10,9 @@ import { injectable } from '@cloudbeaver/core-di';
|
||||
import { PluginManagerService } from '@cloudbeaver/core-plugin';
|
||||
|
||||
const defaultSettings = {
|
||||
'app.logViewer.refreshInterval': 3000,
|
||||
'app.logViewer.maxLogEntries': 1000,
|
||||
'app.logViewer.refreshTimeout': 3000,
|
||||
'app.logViewer.maxLogRecords': 1000,
|
||||
'app.logViewer.logBatchSize': 2000,
|
||||
'app.logViewer.maxFailedRequests': 3,
|
||||
};
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ export class LogViewerService {
|
||||
}
|
||||
this._isActive = true;
|
||||
await this.updateLog();
|
||||
const refreshInterval = this.coreSettingsService.settings.getValue('app.logViewer.refreshInterval');
|
||||
const refreshInterval = this.coreSettingsService.settings.getValue('app.logViewer.refreshTimeout');
|
||||
this.maxFailedRequests = this.coreSettingsService.settings.getValue('app.logViewer.maxFailedRequests');
|
||||
this.interval = setInterval(() => {
|
||||
this.updateLog();
|
||||
@@ -82,7 +82,7 @@ export class LogViewerService {
|
||||
}
|
||||
|
||||
async loadLog(): Promise<ILogEntry[]> {
|
||||
const maxLogEntries = this.coreSettingsService.settings.getValue('app.logViewer.maxLogEntries');
|
||||
const maxLogEntries = this.coreSettingsService.settings.getValue('app.logViewer.logBatchSize');
|
||||
const { log } = await this.graphQLService.gql.readSessionLog({
|
||||
maxEntries: maxLogEntries,
|
||||
clearEntries: true,
|
||||
@@ -97,7 +97,7 @@ export class LogViewerService {
|
||||
@action
|
||||
private addNewEntries(entries: ILogEntry[]) {
|
||||
this.log.unshift(...entries.reverse());
|
||||
const maxLogEntries = this.coreSettingsService.settings.getValue('app.logViewer.maxLogEntries');
|
||||
const maxLogEntries = this.coreSettingsService.settings.getValue('app.logViewer.maxLogRecords');
|
||||
if (this.log.length > maxLogEntries) {
|
||||
this.log.splice(maxLogEntries, this.log.length - maxLogEntries);
|
||||
}
|
||||
|
||||
@@ -14,13 +14,11 @@ import { ProductSettingsService } from './ProductSettingsService';
|
||||
|
||||
@injectable()
|
||||
export class ProductManagerService {
|
||||
|
||||
readonly settings = new ProductSettingsService(this.serverService.settings)
|
||||
|
||||
constructor(private serverService: ServerService) { }
|
||||
|
||||
setSettings(object: any) {
|
||||
|
||||
parseJSONFlat(
|
||||
object,
|
||||
this.settings.setSelfValue.bind(this.settings),
|
||||
|
||||
@@ -14,17 +14,16 @@ export class SettingsSource implements ISettingsSource {
|
||||
constructor(protected fallback?: ISettingsSource) {}
|
||||
|
||||
has(key: string): boolean {
|
||||
if (this.store.has(key)) {
|
||||
return true;
|
||||
}
|
||||
return !!this.fallback?.has(key);
|
||||
return this.store.has(key) || !!this.fallback?.has(key);
|
||||
}
|
||||
|
||||
getValue(key: string): any | undefined {
|
||||
if (this.fallback?.has(key)) {
|
||||
return this.fallback.getValue(key);
|
||||
}
|
||||
return this.store.get(key);
|
||||
}
|
||||
|
||||
setValue(key: string, value: any) {
|
||||
this.store.set(key, value);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@cloudbeaver/core-bootstrap": "0.1.0",
|
||||
"@cloudbeaver/core-di": "0.1.0",
|
||||
"@cloudbeaver/core-product": "0.1.0",
|
||||
"@cloudbeaver/plugin-administration": "0.1.0",
|
||||
"@cloudbeaver/plugin-ag-grid": "0.1.0",
|
||||
"@cloudbeaver/plugin-authentication": "0.1.0",
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* cloudbeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { injectable, Bootstrap } from '@cloudbeaver/core-di';
|
||||
import { ProductManagerService } from '@cloudbeaver/core-product';
|
||||
|
||||
import productConfig from './config.json5';
|
||||
|
||||
@injectable()
|
||||
export class ProductConfigService extends Bootstrap {
|
||||
constructor(private productManager: ProductManagerService) {
|
||||
super();
|
||||
}
|
||||
|
||||
register(): void | Promise<void> {
|
||||
this.productManager.setSettings(productConfig);
|
||||
}
|
||||
|
||||
load(): void | Promise<void> { }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Product configuration. Customized web application behavior
|
||||
// It is in JSON5 format
|
||||
{
|
||||
// Global properties
|
||||
core: {
|
||||
// User defaults
|
||||
user: {
|
||||
defaultTheme: "light",
|
||||
defaultLanguage: "en"
|
||||
},
|
||||
app: {
|
||||
// Log viewer config
|
||||
logViewer: {
|
||||
refreshTimeout: 3000,
|
||||
logBatchSize: 1000,
|
||||
maxLogRecords: 2000,
|
||||
maxFailedRequests: 3
|
||||
}
|
||||
}
|
||||
},
|
||||
// Notifications config
|
||||
core_events: {
|
||||
notificationsPool: 5
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import objectViewer from '@cloudbeaver/plugin-object-viewer';
|
||||
import sqlEditor from '@cloudbeaver/plugin-sql-editor';
|
||||
import connectionCustom from '@cloudbeaver/plugin-connection-custom';
|
||||
import connectionPreconfigured from '@cloudbeaver/plugin-connection-preconfigured';
|
||||
import { defaultProductManifest } from './manifest';
|
||||
|
||||
const PLUGINS = [
|
||||
core,
|
||||
@@ -26,6 +27,7 @@ const PLUGINS = [
|
||||
ddlViewer,
|
||||
objectViewer,
|
||||
sqlEditor,
|
||||
defaultProductManifest,
|
||||
];
|
||||
|
||||
bootstrap(PLUGINS);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* cloudbeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { PluginManifest } from '@cloudbeaver/core-di';
|
||||
|
||||
import { ProductConfigService } from './ProductConfigService';
|
||||
|
||||
export const defaultProductManifest: PluginManifest = {
|
||||
info: {
|
||||
name: 'Default Product',
|
||||
},
|
||||
|
||||
providers: [
|
||||
ProductConfigService,
|
||||
],
|
||||
};
|
||||
Vendored
+5
@@ -6,6 +6,11 @@ declare module '*.scss?raw' {
|
||||
export default classes
|
||||
}
|
||||
|
||||
declare module '*.json5' {
|
||||
const json: any
|
||||
export default json
|
||||
}
|
||||
|
||||
declare module '*.scss' {
|
||||
const classes: { readonly [key: string]: string }
|
||||
export default classes
|
||||
|
||||
+10
-1
@@ -7920,6 +7920,15 @@ json3@^3.3.2:
|
||||
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.3.tgz#7fc10e375fc5ae42c4705a5cc0aa6f62be305b81"
|
||||
integrity sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA==
|
||||
|
||||
json5-loader@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/json5-loader/-/json5-loader-4.0.0.tgz#4b6ea337c76fdf4107158491fae2408500fb6cb0"
|
||||
integrity sha512-v+wc6+u/k0qxOLhmfsk3aE0q7Kl8YwppfRuaUYASJ3zInbWZr50sI4b5WGLzNjerN3OVDSIMPxGClJ0GfUh9lg==
|
||||
dependencies:
|
||||
json5 "^2.1.3"
|
||||
loader-utils "^2.0.0"
|
||||
schema-utils "^2.6.5"
|
||||
|
||||
json5@^0.5.1:
|
||||
version "0.5.1"
|
||||
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
|
||||
@@ -7932,7 +7941,7 @@ json5@^1.0.1:
|
||||
dependencies:
|
||||
minimist "^1.2.0"
|
||||
|
||||
json5@^2.1.2:
|
||||
json5@^2.1.2, json5@^2.1.3:
|
||||
version "2.1.3"
|
||||
resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.3.tgz#c9b0f7fa9233bfe5807fe66fcf3a5617ed597d43"
|
||||
integrity sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==
|
||||
|
||||
Reference in New Issue
Block a user