diff --git a/.gitignore b/.gitignore index f7e73ef58..cac4e5c65 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ dist/ cache/ /frontend/datasafe-ui/package-lock.json +/datasafe-rest-impl/ROOT_BUCKET/ diff --git a/datasafe-rest-impl/1.createDockerimage.sh b/datasafe-rest-impl/1.createDockerimage.sh index ef7f3d866..539b68814 100755 --- a/datasafe-rest-impl/1.createDockerimage.sh +++ b/datasafe-rest-impl/1.createDockerimage.sh @@ -13,4 +13,4 @@ npm install ng build --deploy-url /static/ --base-href /static/ mv dist ../../datasafe-rest-impl/target/dist cd ../../datasafe-rest-impl -docker build . -t datasafe-rest-test:latest --build-arg JAR_FILE=datasafe-rest-impl-*.jar +docker build . -t datasafe-rest-test:latest --build-arg JAR_FILE=datasafe-rest-impl.jar diff --git a/datasafe-rest-impl/DEMO.md b/datasafe-rest-impl/DEMO.md index 9c6cf7dfd..e9095bf9e 100644 --- a/datasafe-rest-impl/DEMO.md +++ b/datasafe-rest-impl/DEMO.md @@ -19,7 +19,29 @@ To **run** demo: ## Building and running demo -### Building +### Run it with Docker Compose +The easiest way to run Datasafe Rest Application is using Docker Compose. By default, it works with filesystem with root +directory `datasafe-rest-impl/ROOT_BUCKET`. +Build it with: +``` bash +# build backend +mvn clean package + +# build frontend +cd frontend/datasafe-ui +npm i +ng build --deploy-url /static/ --base-href /static/ +mv dist ../../datasafe-rest-impl/target/dist + +# build image and start datasafe in docker +docker compose up datasafe +``` + +Frontend is available at http://localhost:8080/static/index.html + +### Alternatively you can use shell scripts to build and run datasafe with different types of storages + +#### Building - Build from sources @@ -34,7 +56,7 @@ cd datasafe-rest-impl docker pull adorsys/datasafe && docker tag adorsys/datasafe datasafe-rest-test:latest ``` -### Running +#### Running Run using local filesystem, all data will be stored in `target/ROOT_BUCKET` folder: ```bash diff --git a/datasafe-rest-impl/compose.yml b/datasafe-rest-impl/compose.yml index 254ce02f3..84345fe71 100644 --- a/datasafe-rest-impl/compose.yml +++ b/datasafe-rest-impl/compose.yml @@ -2,15 +2,17 @@ services: datasafe: build: args: - JAR_FILE: "datasafe-rest-impl-2.0.2-SNAPSHOT.jar" + JAR_FILE: "datasafe-rest-impl.jar" # image: adorsys/datasafe environment: EXPOSE_API_CREDS: true DEFAULT_USER: username DEFAULT_PASSWORD: password - USE_FILESYSTEM: file:///Users/max/Desktop/datasafe + USE_FILESYSTEM: file:///usr/app/ROOT_BUCKET ports: - 8080:8080 + volumes: + - "./ROOT_BUCKET:/usr/app/ROOT_BUCKET" db: image: mysql:5.7 restart: always diff --git a/datasafe-rest-impl/pom.xml b/datasafe-rest-impl/pom.xml index 6cf7062ad..33dd14c4b 100644 --- a/datasafe-rest-impl/pom.xml +++ b/datasafe-rest-impl/pom.xml @@ -163,7 +163,6 @@ true - ${project.artifactId}-${project.version} org.springframework.boot diff --git a/datasafe-rest-impl/run.sh b/datasafe-rest-impl/run.sh index d13c46e48..01eadff0c 100755 --- a/datasafe-rest-impl/run.sh +++ b/datasafe-rest-impl/run.sh @@ -7,7 +7,7 @@ if [[ -z "$API_URL" ]]; then fi # Bind API url and credentials, sed -i won't work because of OC user permissions -sed 's!${API_URL}!'"$API_URL"'!g' "$APP_HOME/frontend/env.js" > /tmp/env.js && mv /tmp/env.js "$APP_HOME/frontend/env.js" +sed 's!${API_URL}!'"$API_URL"'!g' "$APP_HOME/frontend/env.prod.js" > /tmp/env.js && mv /tmp/env.js "$APP_HOME/frontend/env.js" # do not expose sensitive data by default LOGIN="" diff --git a/frontend/datasafe-ui/src/app/app.component.ts b/frontend/datasafe-ui/src/app/app.component.ts index 852e4d829..bee20cf9a 100644 --- a/frontend/datasafe-ui/src/app/app.component.ts +++ b/frontend/datasafe-ui/src/app/app.component.ts @@ -1,6 +1,6 @@ -import {Component, OnInit} from '@angular/core'; -import {ErrorStateMatcher} from "@angular/material/core"; -import {FormControl, FormGroupDirective, NgForm} from "@angular/forms"; +import {Component} from '@angular/core'; +import {ErrorStateMatcher} from '@angular/material/core'; +import {FormControl, FormGroupDirective, NgForm} from '@angular/forms'; export class Env { @@ -8,6 +8,10 @@ export class Env { private static browserWindow = window || {}; private static browserWindowEnv = Env.browserWindow['__env'] || {}; + static apiUrl = Env.get('apiUrl'); + static apiUsername = Env.get('apiUsername'); + static apiPassword = Env.get('apiPassword'); + static get(key): string { if (this.browserWindowEnv.hasOwnProperty(key)) { return window['__env'][key]; @@ -15,10 +19,6 @@ export class Env { return null; } - - static apiUrl = Env.get('apiUrl'); - static apiUsername = Env.get('apiUsername'); - static apiPassword = Env.get('apiPassword'); } export class FieldErrorStateMatcher implements ErrorStateMatcher { @@ -30,8 +30,8 @@ export class FieldErrorStateMatcher implements ErrorStateMatcher { export class ParentOrFieldErrorStateMatcher implements ErrorStateMatcher { isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { - const invalidCtrl = !!(control && control.invalid && control.parent.dirty); - const invalidParent = !!(control && control.parent && control.parent.invalid && control.parent.dirty); + const invalidCtrl = !!(control?.invalid && control?.parent?.dirty); + const invalidParent = !!(control?.parent?.invalid && control?.parent?.dirty); return (invalidCtrl || invalidParent); } @@ -40,12 +40,12 @@ export class ParentOrFieldErrorStateMatcher implements ErrorStateMatcher { export class ErrorMessageUtil { static extract(error): string { - let errMsg = "Failed " + error.message; - if (error && error.error && error.error.message) { + let errMsg = 'Failed ' + error.message; + if (error?.error?.message) { errMsg = error.error.message; } - return errMsg.substring(0, 32) + (errMsg.length >= 32 ? "..." : ""); + return errMsg.substring(0, 32) + (errMsg.length >= 32 ? '...' : ''); } } @@ -54,10 +54,7 @@ export class ErrorMessageUtil { templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) -export class AppComponent implements OnInit { +export class AppComponent { constructor() { } - - ngOnInit() { - } } diff --git a/frontend/datasafe-ui/src/app/component/filetree/filetree.component.ts b/frontend/datasafe-ui/src/app/component/filetree/filetree.component.ts index 9269168d4..9e055c08c 100644 --- a/frontend/datasafe-ui/src/app/component/filetree/filetree.component.ts +++ b/frontend/datasafe-ui/src/app/component/filetree/filetree.component.ts @@ -3,11 +3,11 @@ import {FlatTreeControl} from '@angular/cdk/tree'; import {Component, Inject, Injectable} from '@angular/core'; import {BehaviorSubject, merge, Observable} from 'rxjs'; import {map} from 'rxjs/operators'; -import {ApiService} from "../../service/api/api.service"; -import {CredentialsService} from "../../service/credentials/credentials.service"; -import {Router} from "@angular/router"; -import {ErrorMessageUtil} from "../../app.component"; -import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from "@angular/material/dialog"; +import {ApiService} from '../../service/api/api.service'; +import {CredentialsService} from '../../service/credentials/credentials.service'; +import {Router} from '@angular/router'; +import {ErrorMessageUtil} from '../../app.component'; +import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material/dialog'; class UserFileSystem { @@ -19,43 +19,43 @@ class UserFileSystem { this.fs.clear(); // maintain consistent order - files.concat(Array.from(this.uiCreatedFolders).map(it => it + "/")) + files.concat(Array.from(this.uiCreatedFolders).map(it => it + '/')) .sort() .forEach(it => this.addEntry(it)); } - rootLevelNodes() : string[] { - let res = new Set(); + rootLevelNodes(): string[] { + const res = new Set(); this.fs.forEach((value, key) => { - let split = key.split("/", 2); - res.add(split[0] + (split.length > 1 ? "/" : "")); + const split = key.split('/', 2); + res.add(split[0] + (split.length > 1 ? '/' : '')); }); - return Array.from(res) + return Array.from(res); } private addEntry(path: string) { - var fullPath = ""; - var folder = ""; + let fullPath = ''; + let folder = ''; path = (path.startsWith('/')) ? path.substring(1) : path; - path.split("/").forEach(segment => { + path.split('/').forEach(segment => { fullPath += segment; - fullPath += (fullPath === path ? "" : "/"); + fullPath += (fullPath === path ? '' : '/'); - let name = (((fullPath === path) && (!path.endsWith("/"))) ? segment : segment + "/"); + const name = (((fullPath === path) && (!path.endsWith('/'))) ? segment : segment + '/'); this.putToFolder(folder, name); - folder = fullPath - }) + folder = fullPath; + }); } private putToFolder(folder: string, name: string) { - if ("" === name || "/" === name) { + if ('' === name || '/' === name) { name = null; } - if (folder === "") { + if (folder === '') { folder = name; name = null; } @@ -76,15 +76,15 @@ export class DynamicFlatNode { isLoading: boolean; constructor(path: string) { - let level = path.split("/").length - 1; - if (path.endsWith("/")) { + let level = path.split('/').length - 1; + if (path.endsWith('/')) { level = level - 1; } - this.name = path.replace(/\/$/, "").match(/(.+\/)*([^\/]+)$/)[2]; + this.name = path.replace(/\/$/, '').match(/(.+\/)*([^\/]+)$/)[2]; this.path = path; this.level = level; - this.expandable = path.endsWith("/"); + this.expandable = path.endsWith('/'); } } @@ -93,7 +93,7 @@ export class DynamicDatabase { storageTree = new UserFileSystem(); loadData(api: ApiService, creds: CredentialsService, filetreeComponent: FiletreeComponent, router: Router) { - api.listDocuments("", creds.getCredentialsForApi()) + api.listDocuments('', creds.getCredentialsForApi()) .then(res => { this.storageTree.buildFs(> res); @@ -111,7 +111,7 @@ export class DynamicDatabase { } rebuildView(filetreeComponent: FiletreeComponent) { - let paths = this.memoizedFs(); + const paths = this.memoizedFs(); this.storageTree.buildFs(Array.from(paths)); filetreeComponent.dataSource.data = this.storageTree.rootLevelNodes() @@ -119,14 +119,14 @@ export class DynamicDatabase { } private memoizedFs() { - let paths = new Set(); + const paths = new Set(); this.storageTree.fs.forEach((values, key) => { paths.add(key); values.forEach(file => { if (null != file) { paths.add(key + file); } - }) + }); }); return paths; } @@ -158,7 +158,7 @@ export class DynamicDataSource { } private keepExpandedNodesState() { - let toExpand = new Set(this.expandedMemoize); + const toExpand = new Set(this.expandedMemoize); let expanded = false; do { expanded = false; @@ -169,7 +169,7 @@ export class DynamicDataSource { expanded = true; toExpand.delete(node.path); }); - } while (toExpand.size != 0 && expanded); + } while (toExpand.size !== 0 && expanded); } constructor(private treeControl: FlatTreeControl, @@ -254,10 +254,10 @@ export class FiletreeComponent { treeControl: FlatTreeControl; dataSource: DynamicDataSource; + error: any; getLevel = (node: DynamicFlatNode) => node.level; isExpandable = (node: DynamicFlatNode) => node.expandable; hasChild = (_: number, _nodeData: DynamicFlatNode) => _nodeData.expandable; - error: any; constructor(private database: DynamicDatabase, private api: ApiService, private creds: CredentialsService, private router: Router, public dialog: MatDialog) { @@ -270,19 +270,19 @@ export class FiletreeComponent { addUiFolderWithPath(path: string) { const dialogRef = this.dialog.open(AddFolderDialog, { width: '250px', - data: {folderPath: ""} + data: {folderPath: ''} }); dialogRef.afterClosed().subscribe(result => { if (result !== undefined) { - this.database.storageTree.uiCreatedFolders.add("" !== path ? path + result : result); + this.database.storageTree.uiCreatedFolders.add('' !== path ? path + result : result); this.database.rebuildView(this); } }); } addUiFolder() { - this.addUiFolderWithPath(""); + this.addUiFolderWithPath(''); } addUiFolderWithpathFromName(event) { @@ -308,8 +308,8 @@ export class FiletreeComponent { } private removePathFromUiCreatedFolders(path: string) { - let pathPrefix = path.replace(/\/$/, ""); - let toRemove = Array.from(this.database.storageTree.uiCreatedFolders) + const pathPrefix = path.replace(/\/$/, ''); + const toRemove = Array.from(this.database.storageTree.uiCreatedFolders) .filter(it => it.startsWith(pathPrefix)); toRemove.forEach(remove => this.database.storageTree.uiCreatedFolders.delete(remove)); } diff --git a/frontend/datasafe-ui/src/app/component/register/register.component.ts b/frontend/datasafe-ui/src/app/component/register/register.component.ts index 4c5542fe3..38edd7acc 100644 --- a/frontend/datasafe-ui/src/app/component/register/register.component.ts +++ b/frontend/datasafe-ui/src/app/component/register/register.component.ts @@ -1,5 +1,5 @@ -import {Component, OnInit} from '@angular/core'; -import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms'; +import {Component} from '@angular/core'; +import {FormBuilder, FormControl, FormGroup, ValidationErrors, ValidatorFn, Validators} from '@angular/forms'; import {Router} from '@angular/router'; import {ApiService} from '../../service/api/api.service'; import {CredentialsService} from '../../service/credentials/credentials.service'; @@ -29,7 +29,7 @@ class PasswordsMatchControl extends FormControl { templateUrl: './register.component.html', styleUrls: ['./register.component.css'] }) -export class RegisterComponent implements OnInit { +export class RegisterComponent { constructor(public router: Router, private api: ApiService, private fb: FormBuilder, private creds: CredentialsService) { @@ -51,21 +51,21 @@ export class RegisterComponent implements OnInit { username: this.userNameControl, passwords: this.passwordControl, matchPasswords: this.passwordMatchControl - }, {validator: RegisterComponent.checkPasswords}); - + }, { + validators: [RegisterComponent.checkPasswords] + }); fieldMatcher = new FieldErrorStateMatcher(); parentOrFieldMatcher = new ParentOrFieldErrorStateMatcher(); - private static checkPasswords(group: FormGroup) { // here we have the 'passwords' group - const matchControl = group.controls.matchPasswords; - const pass = group.controls.passwords.value; - const confirmPass = matchControl.value; - - return (matchControl.Hidden || pass === confirmPass) ? null : {notSame: true} - } + private static checkPasswords(): ValidatorFn { // here we have the 'passwords' group + return (group: FormGroup): ValidationErrors | null => { + const matchControl = group.controls.matchPasswords; + const pass = group.controls.passwords.value; + const confirmPass = matchControl.value; - ngOnInit() { + return (matchControl.Hidden || pass === confirmPass) ? null : {notSame: true}; + }; } public handleCreateUserClick() { @@ -74,7 +74,7 @@ export class RegisterComponent implements OnInit { } this.api.createUser(this.userNameControl.value, this.passwordControl.value) - .then(res => { + .then(() => { this.creds.setCredentials(this.userNameControl.value, this.passwordControl.value); this.router.navigate(['/user']); }) diff --git a/frontend/datasafe-ui/src/app/component/user/user.component.ts b/frontend/datasafe-ui/src/app/component/user/user.component.ts index e9f0191ff..4a976da5a 100644 --- a/frontend/datasafe-ui/src/app/component/user/user.component.ts +++ b/frontend/datasafe-ui/src/app/component/user/user.component.ts @@ -1,7 +1,7 @@ import {Component, OnInit} from '@angular/core'; -import {Router} from "@angular/router"; -import {CredentialsService} from "../../service/credentials/credentials.service"; -import {ApiService} from "../../service/api/api.service"; +import {Router} from '@angular/router'; +import {CredentialsService} from '../../service/credentials/credentials.service'; +import {ApiService} from '../../service/api/api.service'; @Component({ selector: 'app-user', @@ -19,11 +19,11 @@ export class UserComponent implements OnInit { ngOnInit() { if (null == this.creds.getCredentialsForApi()) { - this.router.navigate(['']) + this.router.navigate(['']); } } doLogout() { - this.router.navigate(['']) + this.router.navigate(['']); } } diff --git a/frontend/datasafe-ui/src/app/polyfills.ts b/frontend/datasafe-ui/src/app/polyfills.ts index d9a70a1ca..d42447b83 100755 --- a/frontend/datasafe-ui/src/app/polyfills.ts +++ b/frontend/datasafe-ui/src/app/polyfills.ts @@ -1,4 +1,4 @@ import 'core-js/features/reflect'; import 'zone.js'; import 'hammerjs'; -import 'web-animations-js'; \ No newline at end of file +import 'web-animations-js'; diff --git a/frontend/datasafe-ui/src/app/service/api/api.service.ts b/frontend/datasafe-ui/src/app/service/api/api.service.ts index 14db1ed7d..7b78662d5 100644 --- a/frontend/datasafe-ui/src/app/service/api/api.service.ts +++ b/frontend/datasafe-ui/src/app/service/api/api.service.ts @@ -1,137 +1,126 @@ import {Injectable} from '@angular/core'; -import {HttpClient, HttpResponse} from "@angular/common/http"; -import {Observable, of} from "rxjs"; -import {flatMap, map} from "rxjs/operators"; -import {Credentials} from "../credentials/credentials.service"; -import {Env} from "../../app.component"; +import {HttpClient, HttpResponse} from '@angular/common/http'; +import {lastValueFrom, Observable, of} from 'rxjs'; +import {mergeMap, map} from 'rxjs/operators'; +import {Credentials} from '../credentials/credentials.service'; +import {Env} from '../../app.component'; @Injectable({providedIn: 'root'}) export class ApiService { - private static TOKEN_HEADER = "token"; + private static TOKEN_HEADER = 'token'; apiUserName = Env.apiUsername; apiPassword = Env.apiPassword; private uri = Env.apiUrl; - private authorizeUri = this.uri + "/api/authenticate"; - private createUserUri = this.uri + "/user"; - private listDocumentUri = this.uri + "/documents/"; - private putDocumentUri = this.uri + "/document/"; - private getDocumentUri = this.uri + "/document/"; - private deleteDocumentUri = this.uri + "/document/"; + private authorizeUri = this.uri + '/api/authenticate'; + private createUserUri = this.uri + '/user'; + private listDocumentUri = this.uri + '/documents/'; + private putDocumentUri = this.uri + '/document/'; + private getDocumentUri = this.uri + '/document/'; + private deleteDocumentUri = this.uri + '/document/'; private token: string; + private static headers(token: string) { + return {'headers': {[ApiService.TOKEN_HEADER]: token}}; + } + + private static headersWithAuth(token: string, creds: Credentials) { + return {'headers': { + [ApiService.TOKEN_HEADER]: token, + 'user': creds.username, + 'password': creds.password} + }; + } + + private static extractToken(response: HttpResponse<{}>): string { + return response.headers.get(ApiService.TOKEN_HEADER); + } + constructor(private httpClient: HttpClient) { } authorize() { - let result = this.httpClient.post( + const result = this.httpClient.post( this.authorizeUri, - {"userName": this.apiUserName, "password": this.apiPassword}, + {'userName': this.apiUserName, 'password': this.apiPassword}, {observe: 'response'} ); result.subscribe(res => { - this.token = ApiService.extractToken(res) + this.token = ApiService.extractToken(res); }); return result; } - createUser(username: string, password: string) { + async createUser(username: string, password: string) { + // tslint:disable-next-line:no-console console.info(`Creating user using api URL '${this.uri}'`); - return this.withAuthorization() - .pipe(flatMap(token => - this.httpClient.put( - this.createUserUri, - {"userName": username, "password": password}, - ApiService.headers(token) - ))).toPromise(); + return await lastValueFrom(this.withAuthorization() + .pipe(mergeMap(token => + this.httpClient.put(this.createUserUri, {'userName': username, 'password': password}, ApiService.headers(token)) + ))); } - listDocuments(path: string, creds: Credentials) { - return this.withAuthorization() - .pipe(flatMap(token => - this.httpClient.get( - this.listDocumentUri + path, - ApiService.headersWithAuth(token, creds) - ))).toPromise(); + async listDocuments(path: string, creds: Credentials) { + return await lastValueFrom(this.withAuthorization() + .pipe(mergeMap(token => + this.httpClient.get(this.listDocumentUri + path, ApiService.headersWithAuth(token, creds)) + ))); } - uploadDocument(document, path: string, creds: Credentials) { - let formData: FormData = new FormData(); + async uploadDocument(document: string | Blob, path: string, creds: Credentials) { + const formData: FormData = new FormData(); formData.append('file', document); - return this.withAuthorization() - .pipe(flatMap(token => + return await lastValueFrom(this.withAuthorization() + .pipe(mergeMap(token => this.httpClient.put( this.putDocumentUri + path, formData, - { - "headers": ApiService.headersWithAuth(token, creds)["headers"], - responseType: 'blob' as 'json' - }) - )).toPromise(); + {'headers': ApiService.headersWithAuth(token, creds)['headers'], responseType: 'blob' as 'json'} + ) + ))); } downloadDocument(path: string, creds: Credentials) { this.withAuthorization() - .pipe(flatMap(token => + .pipe(mergeMap(token => this.httpClient.get( this.getDocumentUri + path, - { - "headers": ApiService.headersWithAuth(token, creds)["headers"], - responseType: 'blob' as 'json' - } + {'headers': ApiService.headersWithAuth(token, creds)['headers'], responseType: 'blob' as 'json'} ) )).subscribe( (response: any) => { - let dataType = response.type; - let binaryData = []; + const dataType = response.type; + const binaryData = []; binaryData.push(response); - let downloadLink = document.createElement('a'); + const downloadLink = document.createElement('a'); downloadLink.href = window.URL.createObjectURL(new Blob(binaryData, {type: dataType})); - downloadLink.setAttribute('download', path.match(/(.+\/)*([^/]+)$/)[2]); + downloadLink.setAttribute('download', RegExp(/(.+\/)*([^/]+)$/).exec(path)[2]); document.body.appendChild(downloadLink); downloadLink.click(); } - ) + ); } - deleteDocument(path: string, creds: Credentials) { - return this.withAuthorization() - .pipe(flatMap(token => - this.httpClient.delete( - this.deleteDocumentUri + path, - ApiService.headersWithAuth(token, creds) - ))).toPromise(); + async deleteDocument(path: string, creds: Credentials) { + return await lastValueFrom(this.withAuthorization() + .pipe(mergeMap(token => + this.httpClient.delete(this.deleteDocumentUri + path, ApiService.headersWithAuth(token, creds)) + ))); } - private withAuthorization() : Observable { + private withAuthorization(): Observable { if (!this.token) { return this.authorize() - .pipe(map((res) => ApiService.extractToken(res))) + .pipe(map((res) => ApiService.extractToken(res))); } - return of(this.token) - } - - private static headers(token: string) { - return {"headers": {[ApiService.TOKEN_HEADER]: token}}; - } - - private static headersWithAuth(token: string, creds: Credentials) { - return {"headers": { - [ApiService.TOKEN_HEADER]: token, - "user": creds.username, - "password": creds.password} - }; - } - - private static extractToken(response: HttpResponse<{}>) : string { - return response.headers.get(ApiService.TOKEN_HEADER) + return of(this.token); } } diff --git a/frontend/datasafe-ui/src/app/service/credentials/credentials.service.ts b/frontend/datasafe-ui/src/app/service/credentials/credentials.service.ts index b98faf8c5..545b9e60c 100644 --- a/frontend/datasafe-ui/src/app/service/credentials/credentials.service.ts +++ b/frontend/datasafe-ui/src/app/service/credentials/credentials.service.ts @@ -20,10 +20,10 @@ export class CredentialsService { constructor() { } setCredentials(username: string, password: string) { - this.credentials = new Credentials(username, password) + this.credentials = new Credentials(username, password); } - getCredentialsForApi() : Credentials { - return this.credentials + getCredentialsForApi(): Credentials { + return this.credentials; } } diff --git a/frontend/datasafe-ui/src/env.js b/frontend/datasafe-ui/src/env.js index 05b2e4a5b..5526ce23a 100644 --- a/frontend/datasafe-ui/src/env.js +++ b/frontend/datasafe-ui/src/env.js @@ -1,9 +1,9 @@ (function (window) { window.__env = window.__env || {}; - window.__env.apiUrl = '${API_URL:http://localhost:8080}'; + window.__env.apiUrl = 'http://localhost:8080'; // ideally these are not necessary, but API is protected, so supplying it for docker-local deployment - window.__env.apiUsername = '${API_USERNAME:username}'; - window.__env.apiPassword = '${API_PASSWORD:password}'; + window.__env.apiUsername = 'username'; + window.__env.apiPassword = 'password'; }(this)); \ No newline at end of file diff --git a/frontend/datasafe-ui/src/env.prod.js b/frontend/datasafe-ui/src/env.prod.js new file mode 100644 index 000000000..fc7e7a057 --- /dev/null +++ b/frontend/datasafe-ui/src/env.prod.js @@ -0,0 +1,9 @@ +(function (window) { + window.__env = window.__env || {}; + + window.__env.apiUrl = `${API_URL}`; + // ideally these are not necessary, but API is protected, so supplying it for docker-local deployment + window.__env.apiUsername = '${API_USERNAME}'; + window.__env.apiPassword = '${API_PASSWORD}'; + +}(this)); \ No newline at end of file