From 6bbfcfafeb32724fae4dbce35c1f6ece05f8a293 Mon Sep 17 00:00:00 2001 From: Christophe Moine Date: Wed, 9 Oct 2019 20:59:58 +0200 Subject: [PATCH] #135 Add other modules/blueprints --- .../home/generator/generator.component.html | 14 +++++++++ .../app/home/generator/generator.component.ts | 30 +++++++++++++++++-- .../app/home/generator/generator.service.ts | 6 ++++ .../generator/jhipster.configuration.model.ts | 1 + 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/app/home/generator/generator.component.html b/src/main/webapp/app/home/generator/generator.component.html index f3b29cc7..ac4b8b4f 100644 --- a/src/main/webapp/app/home/generator/generator.component.html +++ b/src/main/webapp/app/home/generator/generator.component.html @@ -286,6 +286,20 @@

Testing options


+

Other modules

+
+
+
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/home/generator/generator.component.ts b/src/main/webapp/app/home/generator/generator.component.ts index 257be683..376abc29 100644 --- a/src/main/webapp/app/home/generator/generator.component.ts +++ b/src/main/webapp/app/home/generator/generator.component.ts @@ -36,6 +36,7 @@ export class GeneratorComponent implements OnInit { submitted = false; languageOptions; + moduleOptions = []; selectedGitProvider: string; selectedGitCompany: string; @@ -127,6 +128,20 @@ export class GeneratorComponent implements OnInit { this.gitlabConfigured = gitConfig.gitlabConfigured; this.githubConfigured = gitConfig.githubConfigured; }); + this.generatorService.getOtherModules().subscribe( + res => { + this.moduleOptions = res.results.map(function(elt) { + return { + name: '(' + elt.package.name + '-' + elt.package.version + ') ' + elt.package.description, + value: elt.package.name + ':' + elt.package.version + }; + }); + }, + error => { + console.error('Error loading other modules.'); + console.error(error); + } + ); } updateSharedData(data: any) { @@ -174,7 +189,16 @@ export class GeneratorComponent implements OnInit { onSubmitDownload() { this.checkModelBeforeSubmit(); - this.generatorService.download(this.model).subscribe( + // Make a copy of the model to put otherModule into the right format + const copy = JSON.parse(JSON.stringify(this.model)); + copy.otherModules = copy.otherModules.map(it => { + const strs = it.split(':'); + return { + name: strs[0], + version: strs[1] + }; + }); + this.generatorService.download(copy).subscribe( data => this.downloadFile(data.body), error => console.log(error), () => { @@ -198,8 +222,8 @@ export class GeneratorComponent implements OnInit { } downloadFile(blob: Blob) { - const a = document.createElement('a'), - fileURL = URL.createObjectURL(blob); + const a = document.createElement('a'); + const fileURL = URL.createObjectURL(blob); a.href = fileURL; a.download = this.model.baseName + '.zip'; diff --git a/src/main/webapp/app/home/generator/generator.service.ts b/src/main/webapp/app/home/generator/generator.service.ts index 572b9158..d2ce7e3c 100644 --- a/src/main/webapp/app/home/generator/generator.service.ts +++ b/src/main/webapp/app/home/generator/generator.service.ts @@ -54,4 +54,10 @@ export class GeneratorService { getGenerationData(applicationId: string): Observable { return this.http.get('api/generate-application/' + applicationId, { responseType: 'text' }); } + + getOtherModules(): Observable { + return this.http.get('https://api.npms.io/v2/search?q=keywords:jhipster-module+jhipster-5&from=0&size=50', { + responseType: 'json' + }); + } } diff --git a/src/main/webapp/app/home/generator/jhipster.configuration.model.ts b/src/main/webapp/app/home/generator/jhipster.configuration.model.ts index 076b9c37..6802c930 100644 --- a/src/main/webapp/app/home/generator/jhipster.configuration.model.ts +++ b/src/main/webapp/app/home/generator/jhipster.configuration.model.ts @@ -45,4 +45,5 @@ export class JHipsterConfigurationModel { public languages = ['en']; public clientFramework = 'angularX'; public jhiPrefix = 'jhi'; + public otherModules: string[] = []; }