Skip to content

Commit

Permalink
merged with master
Browse files Browse the repository at this point in the history
  • Loading branch information
oyurekten committed Nov 20, 2023
1 parent 190dd09 commit 0059dd7
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
nginx.conf
e2e
src/assets/configs/*.config.json
src/assets/configs/*config.json
dist
.github
node_modules
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ WORKDIR /app-root
COPY . .
RUN npm install --save --legacy-peer-deps
ARG CONFIGURATION=production
ARG BASE_HREF=/metabolights/editor
ENV NODE_OPTIONS=--openssl-legacy-provider
RUN npm run build -- --configuration $CONFIGURATION
RUN npm run build -- --configuration $CONFIGURATION --base-href="$BASE_HREF/"

# Stage 2, use the compiled app, ready for production with Nginx
FROM nginx:stable
LABEL maintainer="MetaboLights (metabolights-help @ ebi.ac.uk)"
COPY --from=build /app-root/dist/metabolights-editor /editor

COPY --from=build /app-root/dist /editor
ARG EXPOSED_PORT=8008
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/auth/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<mat-icon>public</mat-icon> Back to MetaboLights</a
>
<br />
<span *ngIf="environmentName != null && !environmentName.toLowerCase().startsWith('prod')" style="margin-top: -25px; margin-left: 10px; color: red"
> (Environment: {{ environmentName }}, URL: {{ endpoint }})</span
<span *ngIf="environmentName != null && environmentName.length > 0" style="margin-top: -25px; margin-left: 10px; color: red"
> (Environment: {{ environmentName }} hosted on {{ endpoint }})</span
>
<br />
<nav class="panel bg-white vw40">
Expand Down
10 changes: 7 additions & 3 deletions src/app/components/auth/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ConfigurationService } from "src/app/configuration.service";
import { MtblsJwtPayload } from "src/app/services/headers";
import jwtDecode from "jwt-decode";
import * as toastr from "toastr";
import {PlatformLocation} from '@angular/common';
import { stringify } from "querystring";
@Component({
selector: "app-login",
Expand All @@ -29,10 +30,14 @@ export class LoginComponent implements OnInit {
private ngRedux: NgRedux<IAppState>,
public router: Router,
private editorService: EditorService,
private configService: ConfigurationService
private configService: ConfigurationService,
private platformLocation: PlatformLocation
) {
this.baseHref = this.configService.baseHref;
this.environmentName = environment.context;
this.environmentName = this.platformLocation.getBaseHrefFromDOM();
this.environmentName = this.environmentName.replace("/metabolights/", "");
this.environmentName = this.environmentName.replace("/", "");

}

ngOnInit() {
Expand All @@ -43,7 +48,6 @@ export class LoginComponent implements OnInit {
email: ["", [Validators.required, Validators.email]],
secret: ["", Validators.required],
});
this.domain = this.configService.config.metabolightsWSURL.domain;
this.endpoint = this.configService.config.endpoint;
if (this.endpoint.endsWith("/") === false){
this.endpoint = this.endpoint + "/";
Expand Down
14 changes: 5 additions & 9 deletions src/app/components/public/guides/guides.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ export class GuidesComponent implements OnInit {
if (!environment.isTesting) {
this.setUpSubscriptions();
}
this.domain = this.configService.config.metabolightsWSURL.domain;
this.repo = this.configService.config.metabolightsWSURL.guides;
if(this.repo.endsWith("/")){
this.repo = this.repo.slice(0, -1);
}
}

setUpSubscriptions() {
Expand Down Expand Up @@ -98,7 +100,7 @@ export class GuidesComponent implements OnInit {
if (img.indexOf("ftp://") > -1) {
return img;
}
return this.repo + "media/images/" + img;
return this.repo + "/media/images/" + img;
}
}

Expand Down Expand Up @@ -143,15 +145,9 @@ export class GuidesComponent implements OnInit {
}

getURLBase(url) {
// const domain = window.location.host.split(".")[0];
// if (domain === "www" || domain === "wwwdev") {
// return "/metabolights" + url;
// } else {
// return url;
// }
const base = this.platformLocation.getBaseHrefFromDOM();
if(base.endsWith("/")){
return window.location.origin + base.slice(0, base.length-1) + url;
return window.location.origin + base.slice(0, -1) + url;
}
return window.location.origin + this.platformLocation.getBaseHrefFromDOM() + url;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/public/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class HeaderComponent {
this.setUpSubscription();
const url = this.configService.config.endpoint;
if(url.endsWith("/")){
this.metabolightsWebsiteUrl = url.slice(0, url.length - 1);
this.metabolightsWebsiteUrl = url.slice(0, -1);
} else {
this.metabolightsWebsiteUrl = url;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/public/study/study.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<p>
<a
class="button is-small custom-button"
[href]="'/metabolights/editor/study/' + requestedStudy"
[href]="baseHref + 'study/' + requestedStudy"
><mat-icon
class="mat-icon notranslate material-icons mat-icon-no-color"
role="img"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { Pipe, PipeTransform } from "@angular/core";
export class AsyncStatusTransformPipe implements PipeTransform {
register = {
PENDING: '-',
INITIATED: 'In Queue ...',
STARTED: 'Started ...',
SUCCESS: 'Done',
INITIATED: 'Task is in queue ...',
STARTED: 'Task has started ...',
SUCCESS: 'Task has completed.',
RETRY: 'Retrying ... ',
FAILURE: "Failed",
REVOKED: "Canceled"
FAILURE: "Task has failed.",
REVOKED: "Task has canceled."
};

transform(value: string): string {
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/shared/nav-bar/nav-bar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
class="navbar-item"
>
<span class="material-icons"> keyboard_backspace </span>&nbsp;Back to MetaboLights
<span *ngIf="environmentName != null && !environmentName.toLowerCase().startsWith('prod')" style="margin-left: 16px; color: orange"
> &nbsp;(Environment: {{ environmentName }}, URL: {{ endpoint }})</span
<span *ngIf="environmentName != null || environmentName.length > 0" style="margin-left: 16px; color: orange"
> &nbsp;(Environment: {{ environmentName }} hosted on {{ endpoint }})</span
>
</a>
<ng-template #studyStatus>
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/shared/nav-bar/nav-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export class NavBarComponent implements OnInit {
private platformLocation: PlatformLocation
) {
this.baseHref = this.platformLocation.getBaseHrefFromDOM();

this.environmentName = environment.context;
this.environmentName = this.baseHref.replace("/metabolights/", "");
this.environmentName = this.environmentName.replace("/", "");
}

ngOnInit() {
Expand Down
23 changes: 17 additions & 6 deletions src/app/components/shared/ontology/ontology.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class OntologyComponent implements OnInit, OnChanges {
@ViewChild("input", { read: MatAutocompleteTrigger })
valueInput: MatAutocompleteTrigger;

wsDomain = "";
baseURL = "";
loading = false;
termsLoading = false;
isforcedOntology = false;
Expand Down Expand Up @@ -81,9 +81,21 @@ export class OntologyComponent implements OnInit, OnChanges {

}

join(path1: string, path2: string){

if (path2.startsWith("/")){
path2 = path2.slice(1);
}
if (path1.endsWith("/")){
path1 = path1.slice(0,-1);
}
return path1 + "/" + path2;

}

ngOnInit() {
this.baseHref = this.configService.baseHref;
this.wsDomain = this.configService.config.endpoint;
this.baseURL = this.configService.config.metabolightsWSURL.baseURL;
if (this.values === null || this.values[0] === null) {
this.values = [];
}
Expand All @@ -99,7 +111,7 @@ export class OntologyComponent implements OnInit, OnChanges {
this.endPoints = this.validations["recommended-ontologies"].ontology;
if (this.url !== "") {
this.editorService
.getOntologyTerms(this.wsDomain + "/" + this.url)
.getOntologyTerms( this.join(this.baseURL, this.url))
.subscribe((terms) => {
this.allvalues = [];
const jsonConvert: JsonConvert = new JsonConvert();
Expand Down Expand Up @@ -144,7 +156,7 @@ export class OntologyComponent implements OnInit, OnChanges {
this.searchedMore = false;
this.loading = true;
this.editorService
.getOntologyTerms(this.wsDomain + "/" + this.url + term)
.getOntologyTerms(this.join(this.join(this.baseURL, this.url), term))
.subscribe((terms) => {
this.allvalues = [];
this.loading = false;
Expand Down Expand Up @@ -256,8 +268,7 @@ export class OntologyComponent implements OnInit, OnChanges {
this.loading = true;
this.editorService
.getOntologyTerms(
this.wsDomain + "/" +
this.url +
this.join(this.baseURL, this.url) +
term +
"&queryFields=MTBLS,MTBLS_Zooma,Zooma,OLS,Bioportal}"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ export class RsyncStatusTransformPipe implements PipeTransform {
register = {
NO_TASK: '-',
UNKNOWN: 'Unknown',
SYNC_NEEDED: 'Done. Sync Needed',
SYNC_NOT_NEEDED: 'Done. Sync not Needed',
SYNC_NEEDED: 'Task completed. Sync Needed',
SYNC_NOT_NEEDED: 'Task completed. Sync not Needed',
CALCULATING: 'Processing ...',
CALCULATION_FAILURE: 'Check failure',
NOT_FOUND: "Not Found",
PENDING: 'In Queue ...',
RUNNING: 'Running ...',
COMPLETED_SUCCESS: "Done. Sync Completed",
NOT_FOUND: "No Task Found",
PENDING: 'Task is in Queue ...',
RUNNING: 'TAsk is running ...',
COMPLETED_SUCCESS: "Task completed. Sync Completed",
SYNC_FAILURE: "Sync failure",
START_FAILURE: "Start failure",
JOB_SUBMITTED: "Submitted ...",
JOB_SUBMITTED: "Task has been submitted ...",
JOB_SUBMISSION_FAILED: "Start failure"
};

Expand Down
7 changes: 3 additions & 4 deletions src/app/configuration.mock.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ export class MockConfigurationService {
javaLogoutURL: "http://localhost:8080/metabolights/logout",
redirectURL: "console",
metabolightsWSURL: {
domain: "https://www.ebi.ac.uk/metabolights/",
baseURL: "https://www.ebi.ac.uk/metabolights/ws",
guides:
"https://raw.githubusercontent.com/EBI-Metabolights/guides/test/",
ontologyDetails: "https://www.ebi.ac.uk/ols/api/ontologies/",
"https://raw.githubusercontent.com/EBI-Metabolights/guides/test",
ontologyDetails: "https://www.ebi.ac.uk/ols/api/ontologies",
},
doiWSURL: {
article: "https://api.crossref.org/works/",
article: "https://api.crossref.org/works",
},
europePMCURL: {
article:
Expand Down
9 changes: 9 additions & 0 deletions src/app/services/metabolights/metabolights.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ export class MetabolightsService extends DataService {
) {
super("", http);
this.url = this.configService.config.metabolightsWSURL;
if(this.url.ontologyDetails.endsWith("/")){
this.url.ontologyDetails= this.url.ontologyDetails.slice(0, -1);
}
if(this.url.baseURL.endsWith("/")){
this.url.baseURL= this.url.baseURL.slice(0, -1);
}
if(this.url.guides.endsWith("/")){
this.url.guides= this.url.guides.slice(0, -1);
}
this.studyIdentifier.subscribe((value) => (this.id = value));
this.stateStudy.subscribe((value) => (this.study = value));
}
Expand Down
7 changes: 5 additions & 2 deletions src/app/services/publications/doi.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ export class DOIService extends DataService {
constructor(http: HttpClient, private configService: ConfigurationService) {
super("", http);
this.url = this.configService.config.doiWSURL;
if(this.url.article.endsWith("/")){
this.url.article = this.url.article.slice(0, -1);
}
}

getArticleInfo(doi): Observable<ICrossRefDOI> {
return this.http.get<ICrossRefDOI>(this.url.article + doi).pipe(
return this.http.get<ICrossRefDOI>(this.url.article + "/" + doi).pipe(
map((res) => this.extractArticleDetails(res)),
catchError(this.handleError)
);
}

getArticleKeyWords(doi): Observable<ICrossRefDOI> {
return this.http
.get<ICrossRefDOI>(this.url.article + doi)
.get<ICrossRefDOI>(this.url.article + "/" + doi)
.pipe(catchError(this.handleError));
}

Expand Down
Loading

0 comments on commit 0059dd7

Please sign in to comment.