Skip to content

Commit

Permalink
merged development_3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Newatia authored and Newatia committed Aug 20, 2024
2 parents 9bd3982 + 29ec708 commit 07e0276
Show file tree
Hide file tree
Showing 32 changed files with 466 additions and 123 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: "CodeQL-Advanced"

on:
push:
branches: [ "development_3.0" ]
pull_request:
branches: [ "development_3.0" ]

jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on:
group: ncats-onprem-internal-runners
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: javascript-typescript
build-mode: none # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too.
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"

- name: Generate Security Report
uses: rsdmike/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: reports
path: ./*.pdf
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dist: trusty

language: node_js
node_js:
- 14.17.0
- 17.9.1


install:
Expand All @@ -21,6 +21,9 @@ install:
- npm install webpack
- npm i --save webpack-sources --legacy-peer-deps
- npm install -f @types/[email protected]
- npm install -g yarn
- npm uninstall undici
- npm install [email protected]
- export NODE_OPTIONS="--max-old-space-size=8192"
script:
- npm run build:fda:prod
Expand Down
4 changes: 2 additions & 2 deletions package.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"zone.js": "0.11.4",
"z-schema": "5.0.4",
"jexl": "2.3.0",
"xlsx": "^0.18.5"
"xlsx": "0.18.5"
},
"devDependencies": {
"@angular-devkit/build-angular": "13.2.1",
Expand All @@ -89,7 +89,7 @@
"@types/node": "17.0.16",
"@typescript-eslint/eslint-plugin": "5.11.0",
"@typescript-eslint/parser": "5.11.0",
"cheerio": "^1.0.0-rc.2",
"cheerio": "1.0.0-rc.2",
"codelyzer": "6.0.2",
"cpx-fixed": "1.6.0",
"eslint": "8.8.0",
Expand Down
4 changes: 2 additions & 2 deletions package.real.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"z-schema": "4.2.2",
"jexl": "2.3.0",
"ngx-schema-form": "2.7.0",
"xlsx": "^0.18.5"
"xlsx": "0.18.5"
},
"devDependencies": {
"@angular-devkit/build-angular": "13.2.1",
Expand All @@ -97,7 +97,7 @@
"@types/node": "17.0.16",
"@typescript-eslint/eslint-plugin": "5.11.0",
"@typescript-eslint/parser": "5.11.0",
"cheerio": "^1.0.0-rc.2",
"cheerio": "1.0.0-rc.2",
"codelyzer": "6.0.2",
"cpx-fixed": "1.6.0",
"eslint": "8.8.0",
Expand Down
39 changes: 35 additions & 4 deletions projects/ketcher-wrapper/src/lib/ketcher-wrapper.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Ketcher } from './ketcher.model';
export class KetcherWrapperComponent implements OnInit, AfterViewInit {
@ViewChild('ketcherFrame', { static: true }) ketcherFrame: { nativeElement: HTMLIFrameElement };
@Output() ketcherOnLoad = new EventEmitter<any>();
randomId: string;
safeKetcherFilePath: SafeUrl;
@ViewChild('ketcherBody') kBod: ElementRef;
@ViewChild('ketcherFrame') iframe: ElementRef;
Expand All @@ -18,11 +19,10 @@ export class KetcherWrapperComponent implements OnInit, AfterViewInit {
private sanitizer: DomSanitizer,
private renderer: Renderer2
) {

this.randomId = Math.random().toString(36).replace('0.', '');
}

ngOnInit() {


}

Expand All @@ -35,8 +35,8 @@ export class KetcherWrapperComponent implements OnInit, AfterViewInit {
});
// let doc = this.iframe.nativeElement.contentDocument || this.iframe.nativeElement.contentWindow;
};
// this.renderer.listen(window, 'blur', () => this.onWindowBlur());*/
};*/
this.renderer.listen(window, 'blur', () => this.onWindowBlur());
}


Expand All @@ -49,5 +49,36 @@ export class KetcherWrapperComponent implements OnInit, AfterViewInit {
}
}, interval);
}
@HostListener('mouseover')
private onIframeMouseOver() {
this.iframeMouseOver = true;
this.resetFocusOnWindow();
}

@HostListener('mouseout')
private onIframeMouseOut() {
this.iframeMouseOver = false;
this.resetFocusOnWindow();
}

@HostListener('click')
private onClick() {
// this.iframeMouseOver = false;
setTimeout(() => {
this.resetFocusOnWindow();
}, 100);
}

private onWindowBlur() {
if (this.iframeMouseOver) {
this.resetFocusOnWindow();
}
}

private resetFocusOnWindow() {
setTimeout(() => {

window.focus();
}, 100);
}
}
2 changes: 1 addition & 1 deletion projects/ketcher-wrapper/src/lib/ketcher.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface Ketcher {
editor?: any;
getSmiles: () => string;
saveSmiles: () => Promise<any>;
getMolfile: () => string;
getMolfile: () => any;
setMolecule: (molString: any) => void;
addFragment: (molString: any) => void;
showMolfile: (clientArea: any, molString: any, options: any) => any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ private overlayContainer: HTMLElement;


getPossibleSmiles(smi) {
console.log(smi);
function getMarkers(smi) {
let temp = smi.replace(/@H/g, '').replace(/[^A-Z*]/g, '');
var alias: any = {
Expand Down
6 changes: 5 additions & 1 deletion src/app/core/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ const childRoutes: Routes = [
{
path: 'user-downloads/:id',
component: UserDownloadsComponent
}
},
{
path: 'structure-features',
component: SubstanceFormComponent
},
];

const routes: Routes = [
Expand Down
19 changes: 16 additions & 3 deletions src/app/core/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, PLATFORM_ID, Inject } from '@angular/core';
import { ConfigService } from '../config/config.service';
import { Auth, Role, UserGroup } from './auth.model';
import { Observable, Subject } from 'rxjs';
import { Observable, Subject, of } from 'rxjs';
import { map, take, catchError } from 'rxjs/operators';
import { HttpClient, HttpParams } from '@angular/common/http';
import { isPlatformBrowser } from '@angular/common';
Expand Down Expand Up @@ -57,7 +57,11 @@ export class AuthService {

public checkAuth(): Observable<Auth> {
const url = `${(this.configService.configData && this.configService.configData.apiBaseUrl) || '/'}api/v1/`;
return this.http.get<any>(`${url}whoami`);
if (this.configService.configData && this.configService.configData.dummyWhoami) {
return of(this.configService.configData.dummyWhoami);
} else {
return this.http.get<any>(`${url}whoami`);
}
}

login(username: string, password: string): Observable<Auth> {
Expand All @@ -70,7 +74,12 @@ export class AuthService {
};

const url = `${(this.configService.configData && this.configService.configData.apiBaseUrl) || '/'}api/v1/`;
return this.http.get<Auth>(`${url}whoami`, options).pipe(

let obs = this.http.get<Auth>(`${url}whoami`, options);
if (this.configService.configData && this.configService.configData.dummyWhoami) {
obs = of(this.configService.configData.dummyWhoami);
}
return obs.pipe(
map(auth => {
if (auth && auth.computedToken) {
this._auth = auth;
Expand Down Expand Up @@ -295,6 +304,9 @@ export class AuthService {
return new Observable(observer => {
this.configService.afterLoad().then(cd => {
const url = `${(this.configService.configData && this.configService.configData.apiBaseUrl) || '/'}api/v1/`;
if (this.configService.configData && this.configService.configData.dummyWhoami) {
observer.next(this.configService.configData.dummyWhoami);
} else {
this.http.get<Auth>(`${url}whoami`)
.subscribe(
auth => {
Expand All @@ -309,6 +321,7 @@ export class AuthService {
},
() => observer.complete()
);
}
});
});
}
Expand Down
5 changes: 5 additions & 0 deletions src/app/core/config/config.model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Auth } from "@gsrs-core/auth";

export interface Config {
apiBaseUrl?: string;
gsrsHomeBaseUrl?: string;
Expand Down Expand Up @@ -78,6 +80,9 @@ export interface Config {
jsdrawLicense?: boolean;
disableKetcher?: boolean;
useApprovalAPI?: boolean;
dummyWhoami?: Auth;
enableStructureFeatures?: boolean;
structureEditSearch?: boolean;
}

export interface StagingAreaSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class EditorImplementation implements Editor {
getMolfile(): Observable<any> {
return new Observable<any>(observer => {
if (this.ketcher && this.ketcher != null) {
from(this.ketcher.getMolfile()).pipe(take(1)).subscribe(result => {
this.ketcher.getMolfile().then(result => {
let mfile = result;

observer.next(mfile);
Expand Down Expand Up @@ -96,8 +96,7 @@ export class EditorImplementation implements Editor {

getSmiles(): Observable<string> {
if (this.ketcher != null) {
return from(this.ketcher.getSmiles()).pipe(switchMap(data => {
return data;}));
return from(this.ketcher.getSmiles());
} else if (this.jsdraw != null) {
return new Observable<string>(observer => {
observer.next(this.jsdraw.getSmiles());
Expand Down Expand Up @@ -144,6 +143,7 @@ export class EditorImplementation implements Editor {
setMolecule(molfile: string): void {
if (this.ketcher && this.ketcher != null) {
this.ketcher.setMolecule(molfile);
this.ketcher.setMolecule(molfile);
} else if (this.jsdraw && this.jsdraw != null) {
// from simple tests, this should push the current molecule down
// on the undo stack.
Expand All @@ -164,18 +164,17 @@ export class EditorImplementation implements Editor {
} else if (this.ketcher != null) {
this.ketcher.editor.subscribe('change', operations => {
if(!(operations.length == 1 && operations[0].operation == 'Load canvas')){
from(this.ketcher.getMolfile()).pipe(take(1)).subscribe(result => {
this.ketcher.getMolfile().then(result => {
observer.next(result);
});
} else {
this.getMolfile().pipe(take(1)).subscribe(result => {
observer.next(result);
});
// observer.next(this.tempMol);
}


});//*/
});

}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ncats-jsdraw-wrapper id = "jsdrawwrap" oncontextmenu="return false" (jsDrawOnLoad)="jsDrawOnLoad($event)" [hidden]="structureEditor === 'ketcher' && !firstload" style = "width:990px"></ncats-jsdraw-wrapper>
</div>
<div style = "width: 100%">
<ncats-ketcher-wrapper (ketcherOnLoad)="ketcherOnLoad($event)" [hidden]="structureEditor === 'jsdraw'">
<ncats-ketcher-wrapper id="ketcherwrapper" (ketcherOnLoad)="ketcherOnLoad($event)" [hidden]="structureEditor === 'jsdraw'">
</ncats-ketcher-wrapper>
</div>

Expand Down
Loading

0 comments on commit 07e0276

Please sign in to comment.