Skip to content

Commit

Permalink
jhipster#135 Add other modules/blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoine committed Oct 9, 2019
1 parent 917c1bf commit 6bbfcfa
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/main/webapp/app/home/generator/generator.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,20 @@ <h4>Testing options</h4>
</div>
</div>
<hr />
<h4>Other modules</h4>
<hr />
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="modules">Which other modules would you like to use?</label>
<select id="modules" [(ngModel)]="model.otherModules" name="modules" class="form-control"
#languages="ngModel" multiple>
<option *ngFor="let option of moduleOptions" [value]="option.value">{{option.name}}</option>
</select>
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-12">
<div class="text-center">
Expand Down
30 changes: 27 additions & 3 deletions src/main/webapp/app/home/generator/generator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class GeneratorComponent implements OnInit {
submitted = false;

languageOptions;
moduleOptions = [];

selectedGitProvider: string;
selectedGitCompany: string;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
() => {
Expand All @@ -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';
Expand Down
6 changes: 6 additions & 0 deletions src/main/webapp/app/home/generator/generator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,10 @@ export class GeneratorService {
getGenerationData(applicationId: string): Observable<string> {
return this.http.get('api/generate-application/' + applicationId, { responseType: 'text' });
}

getOtherModules(): Observable<any> {
return this.http.get('https://api.npms.io/v2/search?q=keywords:jhipster-module+jhipster-5&from=0&size=50', {

This comment has been minimized.

Copy link
@santeriv

santeriv Oct 9, 2019

👍 good idea.

responseType: 'json'
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ export class JHipsterConfigurationModel {
public languages = ['en'];
public clientFramework = 'angularX';
public jhiPrefix = 'jhi';
public otherModules: string[] = [];
}

0 comments on commit 6bbfcfa

Please sign in to comment.