File size: 3,695 Bytes
71174bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { getUrlParam } from "@/Core/UrlParams";

export enum Tag {
    All = "all",
    Docking = "docking",
    Visualization = "visualization",
    Modeling = "modeling",
    Cheminformatics = "cheminformatics",
    LeadOptimization = "lead-optimization",
}

const tagShortDescriptions: { [key in Tag]: string } = {
    [Tag.All]: "Access all available tools and features.",
    [Tag.Docking]: "Focus on computational prediction of protein-ligand interactions.",
    [Tag.Visualization]: "Focus on visual exploration of molecular structures.",
    [Tag.Modeling]: "Focus on building and modifying molecular structures.",
    [Tag.Cheminformatics]: "Focus on chemical structures and their properties.",
    [Tag.LeadOptimization]: "Focus on the iterative process of improving the binding affinities of compounds (ligands).."
};

const tagLongDescriptions: { [key in Tag]: string } = {
    [Tag.All]: "Recommended for users who need the full range of capabilities or who are performing multiple types of tasks.",
    [Tag.Docking]: "Ideal for researchers studying how small molecules bind to protein targets.",
    [Tag.Visualization]: "Perfect for examining structural details and creating high-quality molecular visualizations for publications or presentations.",
    [Tag.Modeling]: "Suitable for researchers who need to prepare molecules for computational analysis or modify existing structures.",
    [Tag.Cheminformatics]: "Designed for analyzing molecular features and managing chemical information systematically.",
    [Tag.LeadOptimization]: "Ideal for researchers working to optimize candidate molecules."
};

const appTags: Tag[] = [];

/**
 * Setup the tags for the app.
 */
export function setupTags() {
    // Get "tags" from the url parameter
    const tags = getUrlParam("focus");
    if (tags) {
        // Split the tags by comma
        const tagArray = tags.split(",");
        // Iterate through the tags
        for (const tag of tagArray) {
            // If the tag is in the Tag enum, add it to the tags array
            if (Object.values(Tag).includes(tag as Tag)) {
                appTags.push(tag as Tag);
            }
        }
    }

    if (appTags.length === 0) {
        appTags.push(Tag.All);
    }

    console.log(appTags);
}

/**
 * Check if the plugin matches the tags.
 * 
 * @param {Tag[]} pluginTags  The tags of the plugin.
 * @returns {boolean}  True if the plugin matches the tags, false otherwise.
 */
export function matchesTag(pluginTags: Tag[]): boolean {
    // If Tag.All is in pluginTags, always return true.
    if (pluginTags.includes(Tag.All)) {
        return true;
    }

    // If Tag.All is in appTags, also return true;
    if (appTags.includes(Tag.All)) {
        return true;
    }

    // If there are tags, check if the plugin has any of the tags
    for (const tag of appTags) {
        if (pluginTags.includes(tag)) {
            return true;
        }
    }

    return false;
}

/**
 * Get the activity focus mode.
 * 
 * @returns {string}  The activity focus mode.
 */
export function getActivityFocusMode(): string {
    // Set the initial mode based on URL
    let mode = getUrlParam("focus");
    if (mode === null) {
        mode = "all";
    }
    return mode;
}

/**
 * Get the activity focus mode description.
 * 
 * @param {string} mode  The activity focus mode.
 * @returns {string}  The activity focus mode description.
 */
export function getActvityFocusModeDescription(mode: string): string[] {
    return [tagShortDescriptions[mode as Tag], tagLongDescriptions[mode as Tag]];
}


// export const appTitles: { [key in Tag]: string } = {
//     [Tag.All]: "All Title",
//     [Tag.Docking]: "Docking Title"
// };