Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Working towards compatibility with updated file-loading system.
  • Loading branch information
jdurrant committed Mar 13, 2022
1 parent 1ff8d3d commit 123afe6
Show file tree
Hide file tree
Showing 56 changed files with 13,401 additions and 11,293 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
@@ -1,5 +1,9 @@
# Changes

## 2.2

1. Updated file loader system.

## 2.1

1. Web-browser app: changes to how interactions are displayed.
Expand Down
20,873 changes: 10,478 additions & 10,395 deletions web_app/package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion web_app/package.json
Expand Up @@ -15,6 +15,7 @@
"devDependencies": {
"@types/file-saver": "^2.0.1",
"@types/jquery": "^3.5.4",
"@types/jszip": "^3.4.1",
"clean-webpack-plugin": "^3.0.0",
"closure-webpack-plugin": "^2.3.0",
"copy-webpack-plugin": "^5.1.2",
Expand Down Expand Up @@ -44,7 +45,8 @@
"bootstrap-vue": "^2.21.2",
"file-saver": "^2.0.5",
"google-closure-compiler": "^20210601.0.0",
"jszip": "^3.5.0",
"jszip": "^3.7.1",
"localforage": "^1.10.0",
"markdown-it": "^12.2.0",
"neo-blessed": "^0.2.0",
"popper.js": "^1.16.1",
Expand Down
2 changes: 2 additions & 0 deletions web_app/src/BINANA.worker.ts
Expand Up @@ -29,6 +29,8 @@ self.onmessage = function(e) {
params.push(paramVal);
}

debugger;

binana["run"](params);

// Get the output.
Expand Down
76 changes: 76 additions & 0 deletions web_app/src/UI/FileLoaderSystem/Common/CommonProps.VueFuncs.ts
@@ -0,0 +1,76 @@
// Released under the Apache 2.0 License. See LICENSE.md or go to
// https://opensource.org/licenses/Apache-2.0 for full details. Copyright 2022
// Jacob D. Durrant.

// A place to put properties that are common to multiple components.

// Common to mol-loader, and file loaders.
export var commonMultipleFilesProps = {
"multipleFiles": {
"type": Boolean,
"default": false
},
"saveMultipleFilesToDatabase": {
// Saves copies of files to database for use elsewhere (even after page
// reload). But I can imagine scenarios when you'd want to load multiple
// files without realoading the page, so false by default.
"type": Boolean,
"default": false
},
}

// Properties common to file load, from PDB, from URL, etc.
export var commonFileLoaderProps = {
"id": {
"type": String,
"required": false
},
"required": {
"type": Boolean,
"default": true,
},
"accept": {
"type": String,
"default": "", // e.g., ".pdbqt, .out, .pdb"
},
"convert": {
"type": String,
"default": "", // e.g., ".sdf, .mol2"
},
"valid": {
"type": Boolean,
"default": true
}
}

export var commonProteinEditingProps = {
"allowAtomExtract": {
"type": Boolean,
"default": false
},
"allowAtomDelete": {
"type": Boolean,
"default": true
}
}

// Used in both queue-catcher and queue-controller.
export var commonQueueProps = {
"trigger": {
"type": Boolean,
"default": false,
"required": true
},
"countDownSeconds": {
"type": Number,
"default": 5
},
"molLoaderIds": {
"type": Array,
"required": true
},
"outputZipFilename": {
"type": String,
"default": "output.zip"
}
}
@@ -1,5 +1,5 @@
// This file is released under the Apache 2.0 License. See
// https://opensource.org/licenses/Apache-2.0 for full details. Copyright 2021
// https://opensource.org/licenses/Apache-2.0 for full details. Copyright 2022
// Jacob D. Durrant.

import { addCSS } from "../Utils";
Expand Down Expand Up @@ -54,9 +54,9 @@ export function setupFileLoaderFormGroup(): void {
:label="label"
:label-for="id"
:id="'input-group-' + id"
:style="styl"
label-cols="0"
label-cols-xl="1"
:style="styl + ';max-width:none !important;'"
:label-cols="label ? 12 : 0"
:label-cols-sm="label ? 2 : 0"
>
<slot></slot>
<small
Expand All @@ -75,7 +75,10 @@ export function setupFileLoaderFormGroup(): void {
</span>
`,
"props": {
"label": String,
"label": {
"type": String,
"default": undefined
},
"id": String,
"styl": String,
"description": String,
Expand All @@ -91,7 +94,6 @@ export function setupFileLoaderFormGroup(): void {
"methods": {},
"mounted"() {
addCSS(`.file-loader-form-group .col-form-label { hyphens: auto; }`);
// max-width: 100px !important;
}
})
}
21 changes: 17 additions & 4 deletions web_app/src/UI/FileLoaderSystem/Common/FileLoaderTextInput.ts
@@ -1,5 +1,5 @@
// This file is released under the Apache 2.0 License. See
// https://opensource.org/licenses/Apache-2.0 for full details. Copyright 2021
// https://opensource.org/licenses/Apache-2.0 for full details. Copyright 2022
// Jacob D. Durrant.

declare var Vue;
Expand All @@ -20,20 +20,33 @@ export function setupFileLoaderTextInput(): void {
};
},
"methods": {
/**
* Runs when the file is loaded.
* @returns void
*/
"onLoad"(): void {
this.$emit("onLoad", this["value"]);
},

/**
* Detect keypress to submit on enter.
* @param {KeyboardEvent} e
* @returns void
*/
"keydown"(e: KeyboardEvent): void {
if (e.key === "Enter") {
this["onLoad"]();
}
},

/**
* Detect keyup for v-bind.
* @param {KeyboardEvent} e
* @returns void
*/
"keyup"(e: KeyboardEvent) : void {
this.$emit("input", this["localValue"]);
}
// "clearText"(): void {
// this["val"] = "";
// }
},
"template": /*html*/ `
<b-input-group>
Expand Down
48 changes: 29 additions & 19 deletions web_app/src/UI/FileLoaderSystem/Common/Interfaces.ts
@@ -1,45 +1,55 @@
// This file is released under the Apache 2.0 License. See
// https://opensource.org/licenses/Apache-2.0 for full details. Copyright 2021
// https://opensource.org/licenses/Apache-2.0 for full details. Copyright 2022
// Jacob D. Durrant.

import { ISelection, ParentMol } from "../Mols/ParentMol";

export interface IVueXVar {
name: string;
val: any;
}

export interface IConvert extends IFileInfo{
onConvertDone: Function;
export interface IConvert extends IFileInfo {
onConvertDone: Function; // Must return IFileInfo
onConvertCancel: Function;
}

export interface IFileInfo {
filename: string;
fileContents: string;
// onConvertDone: IConvert;
// convertedResolveFunc?: Function;
// convertedRejectFunc?: Function;
// id?: string; // associated component id
mol: ParentMol;
}

export interface IFileLoadError {
title: string;
body: string;
}

// export interface IFileFromTextField {
// placeholder: string;
// tabName: string;
// loadFunc: Function
// onSuccess: Function;
// onError: Function;
// }

export interface IAllFiles {
selectedFilename: string;
allFiles: {[key: string]: string}; // filename => contents
}

export interface IResidueInfo {
residueId: string[],
residuePdbLines: string
export interface IExtractInfo {
selection: ISelection[],
pdbLines: string,
origFilename: string,
suggestedNewFilename: string
}

/**
* Converts ISelection to a string for labelling.
* @param {ISelection} sel
* @returns string
*/
export function iSelectionToStr(sel: ISelection): string {
if (sel["chains"] && !sel["resnames"] && !sel["resids"]) {
// Only has chain.
return "Chain: " + sel["chains"];
}

let prts = [];
if (sel["resnames"]) { prts.push(sel["resnames"]); }
if (sel["resids"]) { prts.push(sel["resids"]); }
if (sel["chains"]) { prts.push(sel["chains"]); }
return prts.join(":");
}
@@ -0,0 +1,2 @@
You can omit this if this component is registered globally (lots of other
components you use might already be using this one).
53 changes: 53 additions & 0 deletions web_app/src/UI/FileLoaderSystem/Common/SmallPillBtn.Vue/index.ts
@@ -0,0 +1,53 @@
// This file is released under the Apache 2.0 License. See
// https://opensource.org/licenses/Apache-2.0 for full details. Copyright 2022
// Jacob D. Durrant.

declare var Vue;

/** An object containing the vue-component computed functions. */
let computedFunctions = {}

/**
* Setup the small-pill-btn Vue commponent.
* @returns void
*/
export function setupSmallPillBtn(): void {
Vue.component('small-pill-btn', {
/**
* Get the data associated with this component.
* @returns any The data.
*/
"data": function() {
return {}
},
"computed": computedFunctions,
"template": /* html */ `
<b-button
pill :variant="actionStyling === 'delete' ? 'secondary' : 'outline-secondary'" size="sm"
class="py-0 px-1"
style="line-height:14px; font-size:90%; margin-right:2px;"
@click="onClick"
>
<span
v-if="actionStyling === 'extract'"
style="display:inline-block; transform: scaleX(-1);">&#10138;
</span>
<span v-else>&#10006;</span>
<slot></slot>
</b-button>
<!-- style="line-height:14px; font-size:80%;" -->
`,
"props": {
"actionStyling": {
"type": String,
"default": "delete" // Can also be "extract"
}
},
"methods": {
"onClick"(): void {
this.$emit("click");
}
},
"mounted"() {}
})
}

0 comments on commit 123afe6

Please sign in to comment.