Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor adding React Vue Svelte and SpringBoot Generators #1484

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 8 additions & 148 deletions src/main/webapp/app/springboot/primary/Generator.component.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
import { ProjectService } from '@/springboot/domain/ProjectService';
import { defineComponent, inject, ref } from 'vue';
import { ProjectToUpdate, toProject } from '@/springboot/primary/ProjectToUpdate';
import { ReactService } from '@/springboot/domain/client/ReactService';
import { VueService } from '@/springboot/domain/client/VueService';
import { SpringBootService } from '@/springboot/domain/SpringBootService';
import { Logger } from '@/common/domain/Logger';
import { AngularGeneratorVue } from '@/springboot/primary/angular-generator';
import { ReactGeneratorVue } from '@/springboot/primary/react-generator';
import { VueGeneratorVue } from '@/springboot/primary/vue-generator';
import { SvelteGeneratorVue } from '@/springboot/primary/svelte-generator';
import { SpringBootGeneratorVue } from '@/springboot/primary/spring-boot-generator';

export default defineComponent({
name: 'GeneratorComponent',
components: {
SpringBootGeneratorVue,
AngularGeneratorVue,
ReactGeneratorVue,
SvelteGeneratorVue,
VueGeneratorVue,
},
setup() {
const logger = inject('logger') as Logger;
const projectService = inject('projectService') as ProjectService;
const reactService = inject('reactService') as ReactService;
const springBootService = inject('springBootService') as SpringBootService;
const vueService = inject('vueService') as VueService;

const selectorPrefix = 'generator';

const project = ref<ProjectToUpdate>({
folder: '',
});
const isReactWithStyle = ref<boolean>(false);
const isVueWithStyle = ref<boolean>(false);
const isSvelteWithStyle = ref<boolean>(false);
const language = ref<string>();
const buildTool = ref<string>('maven');
const server = ref<string>();
Expand Down Expand Up @@ -74,126 +73,6 @@ export default defineComponent({
}
};

const addSpringBoot = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addSpringBoot(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot to project failed', error));
}
};

const addSpringBootMvcTomcat = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addSpringBootMvcTomcat(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot MVC with Tomcat to project failed', error));
}
};

const addSpringBootWebfluxNetty = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addSpringBootWebfluxNetty(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot Webflux with Netty to project failed', error));
}
};

const addSpringBootActuator = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addSpringBootActuator(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot Actuator to project failed', error));
}
};

const addSpringBootAopLogging = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addSpringBootAopLogging(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot AOP Logging to project failed', error));
}
};

const addSpringBootLogstash = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addSpringBootLogstash(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot Logstash to project failed', error));
}
};

const addSpringBootSecurityJWT = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addJWT(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot Security JWT to project failed', error));
}
};

const addSpringBootSecurityJWTBasicAuth = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addBasicAuthJWT(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot Security JWT Basic Auth to project failed', error));
}
};

const addPostgreSQL = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addPostgres(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot Database PostgreSQL to project failed', error));
}
};

const addMySQL = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addMySQL(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot Database MySQL to project failed', error));
}
};

const addMariaDB = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addMariaDB(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot Database MariaDB to project failed', error));
}
};

const addMongoDB = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addMongoDB(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot Database MongoDB to project failed', error));
}
};

const addReact = async (): Promise<void> => {
if (project.value.folder !== '') {
if (isReactWithStyle.value) {
await reactService
.addWithStyle(toProject(project.value))
.catch(error => logger.error('Adding React with style to project failed', error));
} else {
await reactService.add(toProject(project.value)).catch(error => logger.error('Adding React to project failed', error));
}
}
};

const addVue = async (): Promise<void> => {
if (project.value.folder !== '') {
if (isVueWithStyle.value) {
await vueService
.addWithStyle(toProject(project.value))
.catch(error => logger.error('Adding Vue with style to project failed', error));
} else {
await vueService.add(toProject(project.value)).catch(error => logger.error('Adding Vue to project failed', error));
}
}
};

const addFrontendMavenPlugin = async (): Promise<void> => {
if (project.value.folder !== '') {
await projectService
Expand All @@ -219,9 +98,6 @@ export default defineComponent({

return {
project,
isReactWithStyle,
isVueWithStyle,
isSvelteWithStyle,
language,
buildTool,
server,
Expand All @@ -232,22 +108,6 @@ export default defineComponent({
addSonarBackend,
addSonarBackendFrontend,
addJavaBase,
addSpringBoot,
addSpringBootMvcTomcat,
addSpringBootWebfluxNetty,
addSpringBootActuator,

addSpringBootAopLogging,
addSpringBootLogstash,

addSpringBootSecurityJWT,
addSpringBootSecurityJWTBasicAuth,
addPostgreSQL,
addMySQL,
addMariaDB,
addMongoDB,
addReact,
addVue,
addFrontendMavenPlugin,
download,
selectorPrefix,
Expand Down
187 changes: 4 additions & 183 deletions src/main/webapp/app/springboot/primary/Generator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -558,190 +558,11 @@
Download
</button>
</div>
<div
v-if="server === 'springboot'"
id="v-pills-springboot"
class="tab-pane fade"
role="tabpanel"
aria-labelledby="v-pills-profile-tab"
>
<button
id="springboot"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-button'"
@click.prevent="addSpringBoot"
>
Spring Boot
</button>

<button
id="springbootmvctomcat"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-mvc-tomcat-button'"
@click.prevent="addSpringBootMvcTomcat"
>
Spring MVC Tomcat
</button>

<button
id="springbootwebfluxnetty"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-webflux-netty-button'"
@click.prevent="addSpringBootWebfluxNetty"
>
Spring Webflux Netty
</button>

<button
id="springboot-actuator"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-actuator-button'"
@click.prevent="addSpringBootActuator"
>
Spring Boot Actuator
</button>
<br />
<br />
<button
id="springboot-aop"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-aop-button'"
@click.prevent="addSpringBootAopLogging"
>
AOP Logging
</button>

<button
id="springboot-logstash"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-logstash-button'"
@click.prevent="addSpringBootLogstash"
>
Logstash
</button>
<br />
<br />
<button
id="springboot-jwt"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-jwt-button'"
@click.prevent="addSpringBootSecurityJWT"
>
Security JWT
</button>

<button
id="springboot-jwt-basic-auth"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-jwt-basic-auth-button'"
@click.prevent="addSpringBootSecurityJWTBasicAuth"
>
Security JWT Basic Auth
</button>
<br />
<br />
<button
id="springboot-database-postgresql"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-database-postgresql-button'"
@click.prevent="addPostgreSQL"
>
PostgreSQL
</button>

<button
id="springboot-database-mysql"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-database-mysql-button'"
@click.prevent="addMySQL"
>
MySQL
</button>

<button
id="springboot-database-mariadb"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-database-mariadb-button'"
@click.prevent="addMariaDB"
>
MariaDB
</button>

<button
id="springboot-database-mongodb"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-database-mongodb-button'"
@click.prevent="addMongoDB"
>
MongoDB
</button>
</div>
<SpringBootGeneratorVue v-if="server === 'springboot'" :project="project" />
<AngularGeneratorVue v-if="client === 'angular'" :project="project" />
<div v-if="client === 'react'" id="v-pills-react" class="tab-pane fade" role="tabpanel" aria-labelledby="v-pills-react-tab">
<div class="list-group--inline py-2">
<label for="react-with-style" class="list-group-item gap-3">
<input
id="react-with-style"
v-model="isReactWithStyle"
name="react-with-style"
class="form-check-input flex-shrink-0"
type="checkbox"
value=""
/>
<span class="form-checked-content">
<strong>Add React style</strong>
</span>
</label>
</div>
<button
id="react"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-react-button'"
@click.prevent="addReact"
>
Generate React
</button>
</div>
<div v-if="client === 'vue'" id="v-pills-vue" class="tab-pane fade" role="tabpanel" aria-labelledby="v-pills-vue-tab">
<div class="list-group--inline py-2">
<label for="react-with-style" class="list-group-item gap-3">
<input
id="vue-with-style"
v-model="isVueWithStyle"
type="checkbox"
name="vue-with-style"
class="form-check-input flex-shrink-0"
value=""
/>
<span class="form-checked-content">
<strong>Add Vue.js style</strong>
</span>
</label>
</div>
<button id="vue" class="btn btn-outline-primary" :data-selector="selectorPrefix + '.add-vue-button'" @click.prevent="addVue">
Generate Vue.js
</button>
</div>
<div v-if="client === 'svelte'" id="v-pills-svelte" class="tab-pane fade" role="tabpanel" aria-labelledby="v-pills-svelte-tab">
<div class="list-group--inline py-2">
<label for="svelte-with-style" class="list-group-item gap-3">
<input
id="svelte-with-style"
v-model="isSvelteWithStyle"
type="checkbox"
name="svelte-with-style"
class="form-check-input flex-shrink-0"
value=""
/>
<span class="form-checked-content">
<strong>Add Svelte style</strong>
</span>
</label>
</div>
<button id="svelte" class="btn btn-outline-primary" :data-selector="selectorPrefix + '.add-svelte-button'" @click.prevent="">
Generate Svelte (not implemented)
</button>
</div>
<ReactGeneratorVue v-if="client === 'react'" :project="project" />
<VueGeneratorVue v-if="client === 'vue'" :project="project" />
<SvelteGeneratorVue v-if="client === 'svelte'" :project="project" />
</div>
</div>
</div>
Expand Down
Loading