diff --git a/package.json b/package.json index e645eed..c8021c7 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "@angular/cli": "~8.3.25", "@angular/compiler-cli": "8.1.0", "@angular/language-service": "8.1.0", + "@babel/compat-data": "~7.8.0", "@ngxs/devtools-plugin": "^3.3.4", "@ngxs/logger-plugin": "^3.3.4", "@types/antlr4-autosuggest": "0.0.0", diff --git a/src/app/modules/server-settings/pages/manage-settings/manage-settings.component.html b/src/app/modules/server-settings/pages/manage-settings/manage-settings.component.html index 8052827..8a15b92 100644 --- a/src/app/modules/server-settings/pages/manage-settings/manage-settings.component.html +++ b/src/app/modules/server-settings/pages/manage-settings/manage-settings.component.html @@ -27,8 +27,8 @@ - The URL from which Strongbox is accessed (i.e. if you're using reverse proxy - this should be the public url) + (Optional) If set it will be used when generating links across Strongbox. + If empty - will guess automatically using request headers. diff --git a/src/app/modules/server-settings/pages/manage-settings/manage-settings.component.ts b/src/app/modules/server-settings/pages/manage-settings/manage-settings.component.ts index ba2a62a..fc48cd4 100644 --- a/src/app/modules/server-settings/pages/manage-settings/manage-settings.component.ts +++ b/src/app/modules/server-settings/pages/manage-settings/manage-settings.component.ts @@ -36,7 +36,7 @@ export class ManageSettingsComponent implements OnInit, OnDestroy { ngOnInit() { this.settingsForm = new FormGroup({ instanceName: new FormControl(this.randomName(), [Validators.required, Validators.minLength(3)]), - baseUrl: new FormControl(this.guessUrl(), [Validators.required]), + baseUrl: new FormControl(null, []), port: new FormControl(48080, [ Validators.required, (control: FormControl) => { diff --git a/src/app/shared/layout/components/directory-listing/directory-listing.component.ts b/src/app/shared/layout/components/directory-listing/directory-listing.component.ts index 4c1e072..eef7373 100644 --- a/src/app/shared/layout/components/directory-listing/directory-listing.component.ts +++ b/src/app/shared/layout/components/directory-listing/directory-listing.component.ts @@ -81,28 +81,21 @@ export class DirectoryListingComponent implements OnInit, OnDestroy { } downloadFile(pathRecord: PathRecord): void { - - this.http - .get(pathRecord.url, {responseType: 'arraybuffer'}) - .subscribe((buffer: ArrayBuffer) => { - if (pathRecord.name.match(/md5|sha1$/i)) { + if (pathRecord.name.match(/md5|sha1$/i)) { + this.http + .get(pathRecord.url, {responseType: 'arraybuffer'}) + .subscribe((buffer: ArrayBuffer) => { pathRecord.description = String.fromCharCode.apply(null, new Uint8Array(buffer)); this.cdr.detectChanges(); - } else { - const blob: Blob = new Blob([buffer], {type: 'application/octet-stream'}); - const fileName = pathRecord.name; - const objectUrl: string = URL.createObjectURL(blob); - const a: HTMLAnchorElement = document.createElement('a') as HTMLAnchorElement; - - a.href = objectUrl; - a.download = fileName; - document.body.appendChild(a); - a.click(); - - document.body.removeChild(a); - URL.revokeObjectURL(objectUrl); - } - }); + }); + } else { + const a: HTMLAnchorElement = document.createElement('a') as HTMLAnchorElement; + a.href = pathRecord.url; + a.target = '_window'; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + } } confirmDelete(pathRecord: PathRecord) { @@ -124,7 +117,6 @@ export class DirectoryListingComponent implements OnInit, OnDestroy { }); } - sortPathRecord(a: PathRecord, b: PathRecord ) { return a.name.toLocaleLowerCase().localeCompare(b.name.toLocaleLowerCase()); diff --git a/tools/proxy.conf.js b/tools/proxy.conf.js index 662bd4a..7a2ec4c 100644 --- a/tools/proxy.conf.js +++ b/tools/proxy.conf.js @@ -1,21 +1,24 @@ -const filter = function(pathname, req) { - return req.method === 'GET' && pathname.match('^/(index\.html)?$') -}; - const LOCAL_IP = '127.0.0.1'; +const proxyEndpoints = [ + "/api", + "/storages" +]; + const PROXY_CONFIG = [ { - context: filter, + context: function(pathname, req) { + return req.method === 'GET' && ( + pathname.match('^/(index\.html)?$') || + !pathname.match('^' + proxyEndpoints.join("|") + '|/static') + ) + }, target: `http://${LOCAL_IP}:4200/static/assets`, secure: false, logLevel: "debug" }, { - context: [ - "/api", - "/storages" - ], + context: proxyEndpoints, target: `http://${LOCAL_IP}:48080`, secure: false, logLevel: "debug",