Skip to content

Commit

Permalink
Merge pull request #1530 from Franceq34/save-commands-history
Browse files Browse the repository at this point in the history
Save commands history
  • Loading branch information
pascalgrimaud authored Apr 29, 2022
2 parents e446dfa + 08feaa5 commit c6945e5
Show file tree
Hide file tree
Showing 28 changed files with 673 additions and 402 deletions.
70 changes: 64 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"vue-router": "4.0.14"
},
"devDependencies": {
"@pinia/testing": "0.0.11",
"@prettier/plugin-xml": "2.1.0",
"@rushstack/eslint-patch": "1.1.3",
"@types/jest": "27.4.1",
Expand Down
22 changes: 19 additions & 3 deletions src/main/webapp/app/common/domain/Service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
export enum Service {
AOP_LOGGING = 'AOP_LOGGING',
ANGULAR = 'ANGULAR',
DOWNLOAD = 'DOWNLOAD',
FRONTEND_MAVEN_PLUGIN = 'FRONTEND_MAVEN_PLUGIN',
INITIALIZATION = 'INITIALIZATION',
MAVEN = 'MAVEN',
JACOCO_CHECK_MINIMAL_COVERAGE = 'JACOCO_CHECK_MINIMAL_COVERAGE',
JAVA_BASE = 'JAVA_BASE',
LOGSTASH = 'LOGSTASH',
MAVEN_JAVA = 'MAVEN_JAVA',
MARIADB = 'MARIADB',
MYSQL = 'MYSQL',
MONGODB = 'MONGODB',
POSTGRESQL = 'POSTGRESQL',
SONAR_JAVA_BACKEND = 'SONAR_JAVA_BACKEND',
SONAR_JAVA_BACKEND_AND_FRONTEND = 'SONAR_JAVA_BACKEND_AND_FRONTEND',
SPRINGBOOT = 'SPRINGBOOT',
SPRINGBOOT_ACTUATOR = 'SPRINGBOOT_ACTUATOR',
SPRINGBOOT_JWT = 'SPRINGBOOT_JWT',
SPRINGBOOT_JWT_WITH_BASIC_AUTHENTICATION = 'SPRINGBOOT_JWT_WITH_BASIC_AUTHENTICATION',
SPRINGBOOT_MVC_WITH_TOMCAT = 'SPRINGBOOT_MVC_WITH_TOMCAT',
ANGULAR = 'ANGULAR',
SPRINGBOOT_WEBFLUX_NETTY = 'SPRINGBOOT_WEBFLUX_NETTY',
REACT = 'REACT',
REACT_STYLED = 'REACT_STYLED',
VUE = 'VUE',
FRONTEND_MAVEN_PLUGIN = 'FRONTEND_MAVEN_PLUGIN',
VUE_STYLED = 'VUE_STYLED',
UNKNOWN = 'UNKNOWN',
}
24 changes: 24 additions & 0 deletions src/main/webapp/app/common/primary/HistoryStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineStore } from 'pinia';
import { History } from '@/common/domain/History';

const emptyHistory = (): History => ({
services: [],
});

export const useHistoryStore = defineStore('HistoryStore', {
state: () => {
return {
history: emptyHistory(),
};
},

getters: {
getHistory: state => state.history,
},

actions: {
async setHistory(history: History) {
this.history = history;
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { ProjectHistoryService } from '@/common/domain/ProjectHistoryService';
import { AxiosHttp } from '@/http/AxiosHttp';

export default class ProjectHistoryRepository implements ProjectHistoryService {
constructor(private axiosHttp: AxiosHttp) {}
constructor(private axiosHttp: AxiosHttp, private historyStore: any) {}

async get(folder: Folder): Promise<History> {
return this.axiosHttp.get<RestHistory>('api/project-histories', { params: { folder } }).then(response => toHistory(response.data));
return this.axiosHttp
.get<RestHistory>('api/project-histories', { params: { folder } })
.then(response => this.historyStore.setHistory(toHistory(response.data)));
}
}
44 changes: 38 additions & 6 deletions src/main/webapp/app/common/secondary/RestServiceId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,56 @@ export type RestServiceId = string;

export const toService = (restServiceId: RestServiceId): Service => {
switch (restServiceId) {
case 'aop-logging':
return Service.AOP_LOGGING;
case 'angular':
return Service.ANGULAR;
case 'download':
return Service.DOWNLOAD;
case 'frontend-maven-plugin':
return Service.FRONTEND_MAVEN_PLUGIN;
case 'init':
return Service.INITIALIZATION;
case 'maven':
return Service.MAVEN;
case 'jacoco-check-min-coverage':
return Service.JACOCO_CHECK_MINIMAL_COVERAGE;
case 'java-base':
return Service.JAVA_BASE;
case 'logstash':
return Service.LOGSTASH;
case 'mariadb':
return Service.MARIADB;
case 'maven-java':
return Service.MAVEN_JAVA;
case 'mongodb':
return Service.MONGODB;
case 'mysql':
return Service.MYSQL;
case 'postgresql':
return Service.POSTGRESQL;
case 'sonar-java-backend':
return Service.SONAR_JAVA_BACKEND;
case 'sonar-java-backend-and-frontend':
return Service.SONAR_JAVA_BACKEND_AND_FRONTEND;
case 'springboot':
return Service.SPRINGBOOT;
case 'springboot-jwt':
return Service.SPRINGBOOT_JWT;
case 'springboot-jwt-basic-auth':
return Service.SPRINGBOOT_JWT_WITH_BASIC_AUTHENTICATION;
case 'springboot-actuator':
return Service.SPRINGBOOT_ACTUATOR;
case 'springboot-tomcat':
return Service.SPRINGBOOT_MVC_WITH_TOMCAT;
case 'angular':
return Service.ANGULAR;
case 'springboot-webflux-netty':
return Service.SPRINGBOOT_WEBFLUX_NETTY;
case 'react':
return Service.REACT;
case 'react-styled':
return Service.REACT_STYLED;
case 'vue':
return Service.VUE;
case 'frontend-maven-plugin':
return Service.FRONTEND_MAVEN_PLUGIN;
case 'vue-styled':
return Service.VUE_STYLED;
default:
return Service.UNKNOWN;
}
Expand Down
24 changes: 15 additions & 9 deletions src/main/webapp/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import AngularRepository from '@/springboot/secondary/client/AngularRepository';
import ReactRepository from '@/springboot/secondary/client/ReactRepository';
import VueRepository from '@/springboot/secondary/client/VueRepository';
import SpringBootRepository from './springboot/secondary/SpringBootRepository';
import ProjectHistoryRepository from '@/common/secondary/ProjectHistoryRepository';
import ConsoleLogger from '@/common/secondary/ConsoleLogger';
import { FileDownloader } from '@/common/primary/FileDownloader';
import { useHistoryStore } from '@/common/primary/HistoryStore';
import { createPinia } from 'pinia';
import piniaPersist from 'pinia-plugin-persist';

Expand All @@ -18,26 +20,30 @@ import 'bootstrap-icons/font/bootstrap-icons.css';
import 'bootstrap';
import '../content/css/custom.css';

const app = createApp(App);
const pinia = createPinia();
pinia.use(piniaPersist);
app.use(pinia);

const axiosHttp = new AxiosHttp(axios.create({ baseURL: '' }));
const fileDownloader = new FileDownloader(window);
const consoleLogger = new ConsoleLogger(console);
const projectRepository = new ProjectRepository(axiosHttp);
const angularRepository = new AngularRepository(axiosHttp);
const reactRepository = new ReactRepository(axiosHttp);
const vueRepository = new VueRepository(axiosHttp);
const springBootRepository = new SpringBootRepository(axiosHttp);
const historyStore = useHistoryStore();
const projectHistoryRepository = new ProjectHistoryRepository(axiosHttp, historyStore);
const projectRepository = new ProjectRepository(axiosHttp, projectHistoryRepository);
const angularRepository = new AngularRepository(axiosHttp, projectHistoryRepository);
const reactRepository = new ReactRepository(axiosHttp, projectHistoryRepository);
const vueRepository = new VueRepository(axiosHttp, projectHistoryRepository);
const springBootRepository = new SpringBootRepository(axiosHttp, projectHistoryRepository);

const app = createApp(App);
const pinia = createPinia();
pinia.use(piniaPersist);
app.provide('angularService', angularRepository);
app.provide('fileDownloader', fileDownloader);
app.provide('historyStore', historyStore);
app.provide('logger', consoleLogger);
app.provide('projectService', projectRepository);
app.provide('reactService', reactRepository);
app.provide('springBootService', springBootRepository);
app.provide('vueService', vueRepository);
app.use(router);
app.use(pinia);

app.mount('#app');
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ import { Project } from '@/springboot/domain/Project';

export interface AngularService {
add(project: Project): Promise<void>;
addWithStyle(project: Project): Promise<void>;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, inject, ref } from 'vue';
import { defineComponent, inject } from 'vue';
import { AngularService } from '@/springboot/domain/client/AngularService';
import { ProjectToUpdate, toProject } from '@/springboot/primary/ProjectToUpdate';
import { Logger } from '@/common/domain/Logger';
Expand All @@ -23,25 +23,17 @@ export default defineComponent({
const angularService = inject('angularService') as AngularService;

const selectorPrefix = 'angular-generator';
const isAngularWithStyle = ref<boolean>(false);

const addAngular = async (): Promise<void> => {
if (props.project.folder !== '') {
if (isAngularWithStyle.value) {
await angularService
.addWithStyle(toProject(props.project as ProjectToUpdate))
.catch(error => logger.error('Adding Angular with style to project failed', error));
} else {
await angularService
.add(toProject(props.project as ProjectToUpdate))
.catch(error => logger.error('Adding Angular to project failed', error));
}
await angularService
.add(toProject(props.project as ProjectToUpdate))
.catch(error => logger.error('Adding Angular to project failed', error));
}
};

return {
selectorPrefix,
isAngularWithStyle,
addAngular,
props,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
<template>
<div id="v-pills-angular" class="tab-pane fade" role="tabpanel" aria-labelledby="v-pills-settings-tab">
<div class="list-group--inline py-2">
<label for="angular-with-style" class="list-group-item gap-3">
<input
id="angular-with-style"
v-model="isAngularWithStyle"
type="checkbox"
name="angular-with-style"
class="form-check-input flex-shrink-0"
/>
<span class="form-checked-content">
<strong>Add Angular style</strong>
</span>
</label>
</div>
<DefaultButtonVue
id="angular"
:label="'Generate Angular'"
Expand Down
Loading

0 comments on commit c6945e5

Please sign in to comment.