Skip to content

Commit

Permalink
Merge pull request #80 from EyeSeeTea/master
Browse files Browse the repository at this point in the history
Release 3.7.0
  • Loading branch information
adrianq authored Apr 21, 2023
2 parents 421946d + fd9e99c commit acc12e0
Show file tree
Hide file tree
Showing 45 changed files with 79,833 additions and 70,681 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/3dbio_viewer/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.14.0
1 change: 0 additions & 1 deletion app/assets/javascripts/3dbio_viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"react-dom": "^17.0.1",
"react-draggable": "4.4.3",
"react-dropzone": "^11.3.1",
"react-ga": "^3.3.0",
"react-image-fallback": "^8.0.0",
"react-markdown": "5.0.2",
"react-router-dom": "^5.2.0",
Expand Down
8 changes: 0 additions & 8 deletions app/assets/javascripts/3dbio_viewer/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import React from "react";
import ReactGA from "react-ga";
import ReactDOM from "react-dom";
import "./index.css";
import reportWebVitals from "./reportWebVitals";
import App from "./webapp/pages/app/App";

const gaAppId = "UA-93698320-1"; //UA-93698320-4 for development UA-93698320-1 for production
ReactGA.initialize(gaAppId, {
debug: true,
titleCase: false,
useExistingGa: process.env.NODE_ENV !== "development",
});

ReactDOM.render(<App />, document.getElementById("root"));

reportWebVitals();
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ export const ModelSearch: React.FC<ModelSearchProps> = React.memo(props => {

const openUploadWithAnalytics = React.useCallback(() => {
openUpload();
sendAnalytics({
type: "event",
category: "dialog",
action: "open",
sendAnalytics("open_dialog", {
label: "Upload Model",
});
}, [openUpload]);
Expand Down Expand Up @@ -152,11 +149,9 @@ function useDbModelSearch(modelType: ModelSearchType) {
const search = React.useCallback(
(query: string) => {
setSearchState({ type: "searching" });
sendAnalytics({
type: "event",
category: "viewer_search_menu",
action: "search",
label: query,
sendAnalytics("search", {
on: "viewer",
query: query,
});

const searchType = modelType === "all" ? undefined : modelType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const NetworkForm: React.FC<NetworkFormProps> = React.memo(props => {
annotationsFile,
};

sendAnalytics({ type: "event", category: "viewer", action: "upload" });
sendAnalytics("upload", { type: "network", on: "viewer" });

return compositionRoot.buildNetwork
.execute({ network, onProgress })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ export const JumpToButton: React.FC<JumpToButtonProps> = React.memo(props => {
export function goToElement(DOMElementId: string) {
// Use document.getElementById for simplicity. The orthodox approach would be to use refs,
// but we'd need to pass them to all components that have an anchor.
sendAnalytics({
type: "event",
action: "jump_to",
category: "viewer",
sendAnalytics("jump_to", {
on: "viewer",
label: DOMElementId,
});
const el = document.getElementById(DOMElementId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ export const ProfilesButton: React.FC<ProfilesButtonProps> = React.memo(props =>

const setProfile = React.useCallback(
(profileId: ProfileId) => {
sendAnalytics({
type: "event",
action: "set_profile",
category: "viewer",
sendAnalytics("set_profile", {
on: "viewer",
label: profileId,
});
onChange(profiles[profileId]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ export const ToolsButton: React.FC<ToolsButtonProps> = props => {

const openNetworkWithAnalytics = React.useCallback(() => {
openNetwork();
sendAnalytics({
type: "event",
category: "dialog",
action: "open",
sendAnalytics("open_dialog", {
label: "Network",
});
}, [openNetwork]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ViewerSelector: React.FC<ViewerSelectorProps> = props => {
const runModelSearchAction = React.useCallback<ModelSearchProps["onSelect"]>(
(action, item) => {
const newSelection = runAction(selection, action, item);
sendAnalytics({ type: "event", category: "viewer_search_menu", action: action });
sendAnalytics(action, { type: "viewer_search_menu", item: item.id });
onSelectionChange(newSelection);
closeSearch();
},
Expand All @@ -56,10 +56,7 @@ export const ViewerSelector: React.FC<ViewerSelectorProps> = props => {

const openSearchWithAnalytics = React.useCallback(() => {
openSearch();
sendAnalytics({
type: "event",
category: "dialog",
action: "open",
sendAnalytics("open_dialog", {
label: "Search",
});
}, [openSearch]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ function App() {
}

const RouterTracking: React.FC = props => {
const location = useLocation();
React.useEffect(() => {
sendAnalytics({ type: "pageView", path: `/viewer${location.pathname}` });
}, [location.pathname]);
return <>{props.children}</>;
};

Expand Down
57 changes: 17 additions & 40 deletions app/assets/javascripts/3dbio_viewer/src/webapp/utils/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,21 @@
import ReactGA from "react-ga";
import _ from "lodash";

/* Non-redux GA analytics helpers. For Redux, check for example the <Citation> component. Steps:
- Import action.
- Create mapDispatchToProps.
- Add dispatch props to Props type.
- Use redux connect with mapDispatchToProps.
- Call dispatcher from props.
*/

type AnalyticsData = Event | PageView | OutboundLink;

interface Event {
type: "event";
category: string;
action: string;
label?: string;
}

interface PageView {
type: "pageView";
path: string;
declare global {
interface Window {
gtag?: (...args: []) => void;
}
}

interface OutboundLink {
type: "outboundLink";
label: string;
}
declare function gtag(type: "event", name: string, data?: object): void;

export function sendAnalytics(data: AnalyticsData) {
switch (data.type) {
case "event":
ReactGA.event({ category: data.category, action: data.action, label: data.label });
break;
case "pageView":
ReactGA.set({ page: data.path });
ReactGA.pageview(data.path);
break;
case "outboundLink":
ReactGA.outboundLink({ label: data.label }, () => {});
break;
}
export function sendAnalytics(name: string, data?: object) {
if (window.gtag !== undefined)
gtag(
"event",
name,
data && {
...data,
location_hash: window.location.hash,
location_pathname: window.location.pathname,
location_href: window.location.href,
}
);
}
5 changes: 0 additions & 5 deletions app/assets/javascripts/3dbio_viewer/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10585,11 +10585,6 @@ react-event-listener@^0.6.2:
prop-types "^15.6.0"
warning "^4.0.1"

react-ga@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.3.0.tgz#c91f407198adcb3b49e2bc5c12b3fe460039b3ca"
integrity sha512-o8RScHj6Lb8cwy3GMrVH6NJvL+y0zpJvKtc0+wmH7Bt23rszJmnqEQxRbyrqUzk9DTJIHoP42bfO5rswC9SWBQ==

react-image-fallback@^8.0.0:
version "8.0.0"
resolved "https://registry.npmjs.org/react-image-fallback/-/react-image-fallback-8.0.0.tgz#18a88c3e011ee683f35fab1dd6e88eb5152b18ec"
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/covid19/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.14.0
28 changes: 23 additions & 5 deletions app/assets/javascripts/covid19/i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2022-11-23T13:00:39.368Z\n"
"PO-Revision-Date: 2022-11-23T13:00:39.368Z\n"
"POT-Creation-Date: 2023-04-03T01:34:38.763Z\n"
"PO-Revision-Date: 2023-04-03T01:34:38.763Z\n"

msgid "No ontologies found."
msgstr ""

msgid "No ontology terms found."
msgstr ""

msgid "No organisms found."
msgstr ""

msgid "Antibodies"
msgstr ""
Expand Down Expand Up @@ -107,6 +116,18 @@ msgstr ""
msgid "Compound"
msgstr ""

msgid "ID"
msgstr ""

msgid "Term"
msgstr ""

msgid "Description"
msgstr ""

msgid "Ontology"
msgstr ""

msgid "Search protein/organism/PDB ID/EMDB ID/UniProt ID"
msgstr ""

Expand Down Expand Up @@ -216,9 +237,6 @@ msgstr ""
msgid "Publication"
msgstr ""

msgid "ID"
msgstr ""

msgid "Authors"
msgstr ""

Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/covid19/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"purify-ts": "^1.1.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-ga": "^3.3.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"styled-components": "^5.3.0",
Expand Down
10 changes: 9 additions & 1 deletion app/assets/javascripts/covid19/src/compositionRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import { AddDynamicInfoToCovid19InfoUseCase } from "./domain/usecases/AddDynamic
import { LocalStorageCacheRepository } from "./data/repositories/LocalStorageCacheRepository";
import { LigandsApiRepository } from "./data/repositories/LigandsApiRepository";
import { GetLigandImageDataResourcesUseCase } from "./domain/usecases/GetLigandImageDataResourcesUseCase";
import { BionotesOntologyRepository } from "./data/repositories/BioOntologyRepository";
import { BionotesOrganismRepository } from "./data/repositories/BionotesOrganismRepository";

export function getCompositionRoot() {
const covid19InfoRepository = new Covid19InfoFromJsonRepository();
const dataGridRepository = new BrowserDataGridRepository();
const cacheRepository = new LocalStorageCacheRepository();
const ligandsRepository = new LigandsApiRepository();
const ontologyRepository = new BionotesOntologyRepository();
const organismRepository = new BionotesOrganismRepository();

return {
getCovid19Info: new GetCovid19InfoUseCase(covid19InfoRepository),
Expand All @@ -25,7 +29,11 @@ export function getCompositionRoot() {
cacheRepository
),
ligands: {
getIDR: new GetLigandImageDataResourcesUseCase(ligandsRepository),
getIDR: new GetLigandImageDataResourcesUseCase(
ligandsRepository,
ontologyRepository,
organismRepository
),
},
};
}
Expand Down
Loading

0 comments on commit acc12e0

Please sign in to comment.