You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by an...@apache.org on 2019/09/20 10:54:31 UTC
[incubator-dlab] 04/06: [DLAB-1079]: download key parameters fixes;
util options added
This is an automated email from the ASF dual-hosted git repository.
ankovalyshyn pushed a commit to branch DLAB-1056
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit 48a04adbbf0c747c1233a18f28d612f39eda163c
Author: Andriana Kovalyshyn <An...@epam.com>
AuthorDate: Fri Sep 20 12:45:50 2019 +0300
[DLAB-1079]: download key parameters fixes; util options added
---
.../project/project-form/project-form.component.ts | 9 +++++++--
.../resources/webapp/src/app/core/util/fileUtils.ts | 21 +++++++++++----------
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts
index 8a32f00..f8d3320 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts
@@ -29,6 +29,8 @@ import { CheckUtils, FileUtils, PATTERNS } from '../../../core/util';
import { Project } from '../project.component';
import { DICTIONARY } from '../../../../dictionary/global.dictionary';
+export interface GenerateKey { privateKey: string, publicKey: string };
+
@Component({
selector: 'project-form',
templateUrl: './project-form.component.html',
@@ -124,8 +126,11 @@ export class ProjectFormComponent implements OnInit {
}
public generateUserAccessKey() {
- this.userAccessKeyService.generateAccessKey().subscribe(data => {
- FileUtils.downloadFile(data);
+ this.userAccessKeyService.generateAccessKey().subscribe((data: any) => {
+ const parsedData = JSON.parse(data.body);
+ FileUtils.downloadFile(data, parsedData.privateKey, 'private');
+
+ this.projectForm.controls.key.setValue(parsedData.publicKey);
this.keyLabel = 'Key is generated';
this.accessKeyValid = true;
});
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/util/fileUtils.ts b/services/self-service/src/main/resources/webapp/src/app/core/util/fileUtils.ts
index edd6d0a..0a3a32c 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/util/fileUtils.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/util/fileUtils.ts
@@ -18,20 +18,21 @@
*/
export class FileUtils {
- public static downloadFile(data: any) {
- const fileName = data.headers.get('content-disposition').match(/filename="(.+)"/)[1];
- const blob = new Blob([ data.body]);
+ public static downloadFile(data: any, options?: string, name?: string) {
+ const fileName = name || data.headers.get('content-disposition').match(/filename="(.+)"/)[1];
+ const body = options || data.body;
+ const blob = new Blob([body]);
const url = window.URL.createObjectURL(blob);
if (navigator.msSaveOrOpenBlob) {
- navigator.msSaveBlob(blob, fileName);
+ navigator.msSaveBlob(blob, fileName);
} else {
- const a = document.createElement('a');
- a.href = url;
- a.download = fileName;
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = fileName;
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
}
window.URL.revokeObjectURL(url);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org