Skip to content
Snippets Groups Projects
Select Git revision
  • bacb9feb698833fa196afdcd6833a8d7a9dfb8e4
  • master default protected
  • devel
  • hruska-feature-clients-api
  • malostik-#5066-deduplicate-idea-ids
  • warden-postgresql-port
  • hruska-feature-#6799-filter-keys
  • hruska-feature-5066-duplicateIdeaID
  • warden-client-3.0-beta3
  • warden-server-3.0-beta3
  • warden-client-2.2-final
  • warden-server-2.2-final
  • warden-client-3.0-beta2
  • warden-server-3.0-beta2
  • warden-client-2.2
  • warden-server-2.2-patch3
  • warden-client-3.0-beta1
  • warden-server-3.0-beta1
  • warden-server-2.2-patch1
  • warden-client-3.0-beta0
  • warden-server-3.0-beta0
  • warden-server-2.2
  • warden-server-2.1-patch1
  • warden-client-2.1
  • warden-server-2.1
  • warden-server-2.1-beta6
  • warden-server-2.1-beta5
  • warden-server-2.1-beta4
28 results

warden20to21.patch

Blame
  • Forked from 713 / Warden / Warden - archive
    Source project has a limited visibility.
    config.ts 3.13 KiB
    /**
     * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author David Sehnal <david.sehnal@gmail.com>
     * @author Alexander Rose <alexander.rose@weirdbyte.de>
     */
    
    import { Structure, Model } from '../mol-model/structure';
    import { PluginContext } from './context';
    import { PdbDownloadProvider } from '../mol-plugin-state/actions/structure';
    import { EmdbDownloadProvider } from '../mol-plugin-state/actions/volume';
    import { StructureRepresentationPresetProvider } from '../mol-plugin-state/builder/structure/representation-preset';
    
    export class PluginConfigItem<T = any> {
        toString() { return this.key; }
        valueOf() { return this.key; }
        constructor(public key: string, public defaultValue?: T) { }
    }
    
    function item<T>(key: string, defaultValue?: T) { return new PluginConfigItem(key, defaultValue); }
    
    export const PluginConfig = {
        item,
        General: {
            IsBusyTimeoutMs: item('plugin-config.is-busy-timeout', 750),
            DisableAntialiasing: item('plugin-config.disable-antialiasing', false)
        },
        State: {
            DefaultServer: item('plugin-state.server', 'https://webchem.ncbr.muni.cz/molstar-state'),
            CurrentServer: item('plugin-state.server', 'https://webchem.ncbr.muni.cz/molstar-state'),
            HistoryCapacity: item('history-capacity.server', 5)
        },
        VolumeStreaming: {
            DefaultServer: item('volume-streaming.server', 'https://ds.litemol.org'),
            CanStream: item('volume-streaming.can-stream', (s: Structure, plugin: PluginContext) => {
                return s.models.length === 1 && Model.probablyHasDensityMap(s.models[0]);
            }),
            EmdbHeaderServer: item('volume-streaming.emdb-header-server', 'https://ftp.wwpdb.org/pub/emdb/structures'),
        },
        Viewport: {
            ShowExpand: item('viewer.show-expand-button', true),
            ShowControls: item('viewer.show-controls-button', true),
            ShowSettings: item('viewer.show-settings-button', true),
            ShowSelectionMode: item('viewer.show-selection-model-button', true),
            ShowAnimation: item('viewer.show-animation-button', true),
        },
        Download: {
            DefaultPdbProvider: item<PdbDownloadProvider>('download.default-pdb-provider', 'pdbe'),
            DefaultEmdbProvider: item<EmdbDownloadProvider>('download.default-emdb-provider', 'pdbe'),
        },
        Structure: {
            SizeThresholds: item('structure.size-thresholds', Structure.DefaultSizeThresholds),
            DefaultRepresentationPresetParams: item<StructureRepresentationPresetProvider.CommonParams>('structure.default-representation-preset-params', { })
        }
    };
    
    export class PluginConfigManager {
        private _config = new Map<PluginConfigItem<any>, unknown>();
    
        get<T>(key: PluginConfigItem<T>) {
            if (!this._config.has(key)) return key.defaultValue;
            return this._config.get(key) as T;
        }
    
        set<T>(key: PluginConfigItem<T>, value: T) {
            this._config.set(key, value);
        }
    
        delete<T>(key: PluginConfigItem<T>) {
            this._config.delete(key);
        }
    
        constructor(initial?: [PluginConfigItem, unknown][]) {
            if (!initial) return;
            initial.forEach(([k, v]) => this._config.set(k, v));
        }
    }