diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..2cc99ccb24900d50303a4c892b1cac627bb1a9fd --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +JVM= java +EXEC= mvn exec:$(JVM) +PACKAGE= mvn package +DIR_COMP= compilation/ +DIR_GATE= gateway/ +DIR_CLIE= client/ +ANGC= ng serve --open + +COMP_PORT= 6999 +GATE_PORT= 7000 + +all: package + +run: + cd $(DIR_GATE) ; $(PACKAGE) ; $(EXEC) & + cd $(DIR_COMP) ; $(PACKAGE) ; $(EXEC) & + cd $(DIR_CLIE) ; $(ANGC) + +clean: SHELL:=/bin/bash + @echo "kill $(lsof -t -i :6999)" +# kill $(lsof -t -i :$(GATE_PORT)) + \ No newline at end of file diff --git a/README.md b/README.md index 911fcd10b3c80a2df301b0c43bd00498c2c7e39b..39071b8300c35a86ed4e0330e0d561319f72b652 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,113 @@ # Dojo Hepia +## RUN ME - DojoHepia + +### prerequisites + +<p>MAVEN</p> +<p>DOCKER</p> +<p>DOCKER-COMPOSE</p> +<p>ANGULAR CLI</p> + +### Temporary users ids : + +| Username | Password | Privileges | +|----------|----------|------------| +| shodai | shodai | shodai | +| sensei | sensei | sensei | +| monji | monji | monji | + +<b>Users privileges hierarchy</b> +<p>shodai>sensei>monji</p> + +#### Client + +>./client/ +``` +npm install +ng serve --open +``` + +#### Gateway +>./gateway/ +``` +mvn package +mvn exec:java +``` + +#### Compilateur +>./compilation/ +``` +mvn package +mvn exec:java +``` + +##### Create java container + +>./compilation/docker/java +``` +docker build . -t java:1.0 +``` + +##### Create python container + +>./compilation/docker/python +``` +docker build . -t python:1.0 +``` + +#### MongoDB + +##### Create container + +>./mongodb/ +``` +docker-compose up -d +``` + +##### Create user + +>./mongodb/ +``` +docker-compose exec mongo mongo admin -u root +password : example +``` + +insert the following command : + +``` +db.createUser( + { + user: "shodai", + pwd: "shodai", + roles: [ + { role: "readWrite", db: "DojoHepia" } + ] + } +) +``` + +##### Importing data +<p>If you want to popularize the database with programs and katas, you can insert the following files in the mongo db database</p> + +>./mongodb/data/programs + +>./mongodb/data/programssubscriptions + +<p>to import the datas, copy past them and to the following steps :</p> + +>./mongodb/ +``` +docker-compose exec mongo mongo admin -u root +password : example +``` +``` +use DojoHepia +db.Programs.insertMany(<programs-copied-data>); +db.ProgramsSubscription.insertMany(<programsSubscription-copied-data>); +``` + + ## Vocabulaire | Art - Martial | Dojo Hepia | |---------------|------------------| diff --git a/client/angular.json b/client/angular.json index 55ea3fc0665159fedf4866ce0fe0de61d729dc91..1a4878afa5ffb48d166e546ecd18d7655205e56b 100644 --- a/client/angular.json +++ b/client/angular.json @@ -23,7 +23,9 @@ "src/assets" ], "styles": [ - "src/styles.css" + "./node_modules/@angular/material/prebuilt-themes/pink-bluegrey.css", + "./node_modules/bootstrap/dist/css/bootstrap.css", + "src/styles.scss" ], "scripts": [], "es5BrowserSupport": true @@ -80,6 +82,7 @@ "tsConfig": "src/tsconfig.spec.json", "karmaConfig": "src/karma.conf.js", "styles": [ + "./node_modules/@angular/material/prebuilt-themes/pink-bluegrey.css", "src/styles.css" ], "scripts": [], @@ -133,4 +136,4 @@ } }, "defaultProject": "client" -} \ No newline at end of file +} diff --git a/client/package-lock.json b/client/package-lock.json index f92c5aecc76db2d6c08de8bf343a84cde497b346..5c029f943acac6d35ffac0491300c7f57a3d5554 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -1,5 +1,5 @@ { - "name": "client", + "name": "front-end-compilation", "version": "0.0.0", "lockfileVersion": 1, "requires": true, @@ -129,6 +129,23 @@ "tslib": "^1.9.0" } }, + "@angular/cdk": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/@angular/cdk/-/cdk-7.3.7.tgz", + "integrity": "sha512-xbXxhHHKGkVuW6K7pzPmvpJXIwpl0ykBnvA2g+/7Sgy5Pd35wCC+UtHD9RYczDM/mkygNxMQtagyCErwFnDtQA==", + "requires": { + "parse5": "^5.0.0", + "tslib": "^1.7.1" + }, + "dependencies": { + "parse5": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz", + "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==", + "optional": true + } + } + }, "@angular/cli": { "version": "7.3.8", "resolved": "https://registry.npmjs.org/@angular/cli/-/cli-7.3.8.tgz", @@ -426,6 +443,14 @@ "integrity": "sha512-YTU4ePAKikbIxNae9Qta8qaDArPgek7nhLEW9QfvrUAnpF7BkVboEI+7yLX5+NTfGf9cQ9cUfQ0TEreV+tMs7A==", "dev": true }, + "@angular/material": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/@angular/material/-/material-7.3.7.tgz", + "integrity": "sha512-Eq+7frkeNGkLOfEtmkmJgR+AgoWajOipXZWWfCSamNfpCcPof82DwvGOpAmgGni9FuN2XFQdqP5MoaffQzIvUA==", + "requires": { + "tslib": "^1.7.1" + } + }, "@angular/platform-browser": { "version": "7.2.14", "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-7.2.14.tgz", @@ -925,6 +950,11 @@ "negotiator": "0.6.2" } }, + "ace-builds": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/ace-builds/-/ace-builds-1.4.4.tgz", + "integrity": "sha512-EQArUYup9c3lBv8meKBjisff/qhhQmU/6LnLhVDfxe+Bnjr0Lz7qhL4Mp8HpwNQzmCqLunjdPFuBtCELVVG6zw==" + }, "acorn": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", @@ -1595,6 +1625,16 @@ "multicast-dns-service-types": "^1.1.0" } }, + "bootstrap": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.3.1.tgz", + "integrity": "sha512-rXqOmH1VilAt2DyPzluTi2blhk17bO7ef+zLLPlWvG494pDxcM234pJ8wTc/6R40UWizAIIMgxjvxZg5kmsbag==" + }, + "brace": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/brace/-/brace-0.11.1.tgz", + "integrity": "sha1-SJb8ydVE7vRfS7dmDbMg07N5/lg=" + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1914,6 +1954,39 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, + "chart.js": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-2.5.0.tgz", + "integrity": "sha1-/m51Gok3afVucr7lrZEgfhxZKVc=", + "requires": { + "chartjs-color": "^2.0.0", + "moment": "^2.10.6" + } + }, + "chartjs-color": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chartjs-color/-/chartjs-color-2.3.0.tgz", + "integrity": "sha512-hEvVheqczsoHD+fZ+tfPUE+1+RbV6b+eksp2LwAhwRTVXEjCSEavvk+Hg3H6SZfGlPh/UfmWKGIvZbtobOEm3g==", + "requires": { + "chartjs-color-string": "^0.6.0", + "color-convert": "^0.5.3" + }, + "dependencies": { + "color-convert": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-0.5.3.tgz", + "integrity": "sha1-vbbGnOZg+t/+CwAHzER+G59ygr0=" + } + } + }, + "chartjs-color-string": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/chartjs-color-string/-/chartjs-color-string-0.6.0.tgz", + "integrity": "sha512-TIB5OKn1hPJvO7JcteW4WY/63v6KwEdt6udfnDE9iCAZgy+V4SrbSxoIbTw/xkUIapjEI4ExGtD0+6D3KyFd7A==", + "requires": { + "color-name": "^1.0.0" + } + }, "chokidar": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz", @@ -2112,8 +2185,7 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "colors": { "version": "1.1.2", @@ -3474,6 +3546,11 @@ } } }, + "font-awesome": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/font-awesome/-/font-awesome-4.7.0.tgz", + "integrity": "sha1-j6jPBBGhoxr9B7BtKQK7n8gVoTM=" + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -4285,6 +4362,11 @@ "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", "dev": true }, + "hammerjs": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/hammerjs/-/hammerjs-2.0.8.tgz", + "integrity": "sha1-BO93hiz/K7edMPdpIJWTAiK/YPE=" + }, "handle-thing": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-2.0.0.tgz", @@ -5431,6 +5513,11 @@ "integrity": "sha1-43zwsX8ZnM4jvqcbIDk5Uka07E4=", "dev": true }, + "jquery": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz", + "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==" + }, "js-base64": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.5.1.tgz", @@ -6287,6 +6374,11 @@ } } }, + "moment": { + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", + "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" + }, "move-concurrently": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", @@ -6367,6 +6459,36 @@ "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", "dev": true }, + "ng2-ace-editor": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/ng2-ace-editor/-/ng2-ace-editor-0.3.9.tgz", + "integrity": "sha512-e8Q4YCirlL/OEiekewmzupG+zV3prYsiYmQnRzQzd0wNgsPjOLOdb0it7cCbzFfIXKGyIIHKTW5584WxPr2LnQ==", + "requires": { + "ace-builds": "^1.4.2", + "brace": "^0.11.1" + } + }, + "ngx-alerts": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/ngx-alerts/-/ngx-alerts-3.4.3.tgz", + "integrity": "sha512-8XFfNcNE3ofUP1YFeZUVOTwv6YdSR4dGgYrklEmkhAIjp56PDgoQ9yKjIVIG5LYbyU3KPjRIorp7jpezczvJWQ==", + "requires": { + "tslib": "^1.9.0" + } + }, + "ngx-bootstrap": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ngx-bootstrap/-/ngx-bootstrap-4.1.1.tgz", + "integrity": "sha512-2vbjMXxzFX6hz929474It6yI3LyFLm9V4vkLGlCGuhyPWi4G5kuLl3j5Wrj1CsBG9+Cz9xQM9JT6gZnkXBgaTw==" + }, + "ngx-ui-loader": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/ngx-ui-loader/-/ngx-ui-loader-7.2.2.tgz", + "integrity": "sha512-zmwKSypGuzwyOrGpRS/p5FO5avmbCmDWcBJM11JgJyykB50/W+KbuoOm7dFP9kYMccr2JbUAkWosztNMhY3t1Q==", + "requires": { + "tslib": "^1.9.0" + } + }, "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", @@ -9760,8 +9882,7 @@ "uuid": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", - "dev": true + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, "validate-npm-package-license": { "version": "3.0.4", diff --git a/client/package.json b/client/package.json index 70a33f488ad5e5252dcf8719747ec27f36bad877..eafca2b6b32d808f6bf804535eada417e1eaf981 100644 --- a/client/package.json +++ b/client/package.json @@ -1,5 +1,5 @@ { - "name": "client", + "name": "front-end-compilation", "version": "0.0.0", "scripts": { "ng": "ng", @@ -12,16 +12,29 @@ "private": true, "dependencies": { "@angular/animations": "~7.2.0", + "@angular/cdk": "~7.3.7", "@angular/common": "~7.2.0", "@angular/compiler": "~7.2.0", "@angular/core": "~7.2.0", "@angular/forms": "~7.2.0", + "@angular/material": "^7.3.7", "@angular/platform-browser": "~7.2.0", "@angular/platform-browser-dynamic": "~7.2.0", "@angular/router": "~7.2.0", + "bootstrap": "^4.3.1", + "brace": "^0.11.1", + "chart.js": "^2.5.0", "core-js": "^2.5.4", + "font-awesome": "^4.7.0", + "hammerjs": "^2.0.8", + "jquery": "^3.4.0", + "ng2-ace-editor": "^0.3.9", + "ngx-alerts": "^3.4.3", + "ngx-bootstrap": "^4.1.1", + "ngx-ui-loader": "^7.2.2", "rxjs": "~6.3.3", "tslib": "^1.9.0", + "uuid": "^3.3.2", "zone.js": "~0.8.26" }, "devDependencies": { diff --git a/client/src/app/_guard/auth.guard.spec.ts b/client/src/app/_guard/auth.guard.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ed05ee8111b45cec3834ee041fda1ec5a79d210 --- /dev/null +++ b/client/src/app/_guard/auth.guard.spec.ts @@ -0,0 +1,15 @@ +import { TestBed, async, inject } from '@angular/core/testing'; + +import { AuthGuard } from './auth.guard'; + +describe('AuthGuard', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [AuthGuard] + }); + }); + + it('should ...', inject([AuthGuard], (guard: AuthGuard) => { + expect(guard).toBeTruthy(); + })); +}); diff --git a/client/src/app/_guard/auth.guard.ts b/client/src/app/_guard/auth.guard.ts new file mode 100644 index 0000000000000000000000000000000000000000..852405a8cb1912e49f384503325dea872f3d84e6 --- /dev/null +++ b/client/src/app/_guard/auth.guard.ts @@ -0,0 +1,30 @@ +import {Injectable} from '@angular/core'; +import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router'; +import {AuthenticationService} from '../services/auth/authentication.service'; + +@Injectable({providedIn: 'root'}) +export class AuthGuard implements CanActivate { + + constructor(private router: Router, private authenticationService: AuthenticationService) { + } + + canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + + const currentUser = this.authenticationService.currentUserValue; + if (currentUser) { + // check if route is restricted by role + if (route.data.roles && route.data.roles.indexOf(currentUser.role) === -1) { + // role not authorised so redirect to home page + this.router.navigate(['/']); + return false; + } + + // authorised so return true + return true; + } + + // not logged in so redirect to login page with the return url + this.router.navigate(['/user/login'], {queryParams: {returnUrl: state.url}}); + return false; + } +} diff --git a/client/src/app/_helper/_models/roles.ts b/client/src/app/_helper/_models/roles.ts new file mode 100644 index 0000000000000000000000000000000000000000..85b6beaa524523ab44000e28955c113f851bc764 --- /dev/null +++ b/client/src/app/_helper/_models/roles.ts @@ -0,0 +1,7 @@ +export enum Role { + + shodai = 'shodai', + sensei = 'sensei', + monji = 'monji', + +} diff --git a/client/src/app/_helper/_models/user.ts b/client/src/app/_helper/_models/user.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e00240282712a7c3c3670c2b9acc6dab4e2082e --- /dev/null +++ b/client/src/app/_helper/_models/user.ts @@ -0,0 +1,6 @@ +export class User { + id: string; + username: string; + role: string; + token?: string; +} diff --git a/client/src/app/_helper/error.interceptor.ts b/client/src/app/_helper/error.interceptor.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f5ae055edf389823c51ab517c2cffcb2752bc4e --- /dev/null +++ b/client/src/app/_helper/error.interceptor.ts @@ -0,0 +1,25 @@ +import {Injectable} from '@angular/core'; +import {HttpRequest, HttpHandler, HttpEvent, HttpInterceptor} from '@angular/common/http'; +import {Observable, throwError} from 'rxjs'; +import {catchError} from 'rxjs/operators'; + +import {AuthenticationService} from '../services/auth/authentication.service'; + +@Injectable() +export class ErrorInterceptor implements HttpInterceptor { + constructor(private authenticationService: AuthenticationService) { + } + + intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { + return next.handle(request).pipe(catchError(err => { + if ([401, 403].indexOf(err.status) !== -1) { + // auto logout if 401 Unauthorized or 403 Forbidden response returned from api + this.authenticationService.logout(); + location.reload(); + } + + const error = err; + return throwError(error); + })); + } +} diff --git a/client/src/app/_helper/jwt.interceptor.ts b/client/src/app/_helper/jwt.interceptor.ts new file mode 100644 index 0000000000000000000000000000000000000000..a0d236c06dd10c7fb73df1feac0b918a712f5a2b --- /dev/null +++ b/client/src/app/_helper/jwt.interceptor.ts @@ -0,0 +1,25 @@ +import {Injectable} from '@angular/core'; +import {HttpRequest, HttpHandler, HttpEvent, HttpInterceptor} from '@angular/common/http'; +import {Observable} from 'rxjs'; +import {AuthenticationService} from '../services/auth/authentication.service'; + +@Injectable() +export class JwtInterceptor implements HttpInterceptor { + + constructor(private authenticationService: AuthenticationService) { + } + + intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { + // add authorization header with jwt token if available + + const currentUser = this.authenticationService.currentUserValue; + if (currentUser && currentUser.token) { + request = request.clone({ + setHeaders: { + Authorization: `Bearer ${currentUser.token}` + } + }); + } + return next.handle(request); + } +} diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..84db7391ef7c0ff6fc16415822822b5a00df71f2 --- /dev/null +++ b/client/src/app/app-routing.module.ts @@ -0,0 +1,38 @@ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from '@angular/router'; +import {ProgramDisplayerComponent} from './component/program-displayer/program-displayer.component'; +import {KataDisplayerComponent} from './component/kata-displayer/kata-displayer.component'; +import {KataComponent} from './component/kata/kata.component'; +import {ProgramCreateComponent} from './component/program-create/program-create.component'; +import {KataCreateComponent} from './component/kata-create/kata-create.component'; +import {LoginComponent} from './component/login/login.component'; +import {AuthGuard} from './_guard/auth.guard'; +import {SearchbyComponent} from './component/searchby/searchby.component'; +import {Role} from './_helper/_models/roles'; +import {SubscriptionComponent} from './component/subscription/subscription.component'; +import {MineComponent} from './component/mine/mine.component'; + +const routes: Routes = [ + {path: '', component: ProgramDisplayerComponent, canActivate: [AuthGuard]}, + + {path: 'user/login', component: LoginComponent}, + {path: 'program', component: ProgramDisplayerComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.monji, Role.sensei]}}, + {path: 'program/subscriptions', component: SubscriptionComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.monji, Role.sensei]}}, + {path: 'program/mine', component: MineComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.sensei]}}, + {path: 'program/search', component: SearchbyComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.monji, Role.sensei]}}, + {path: 'kata-displayer/:id', component: KataDisplayerComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.monji, Role.sensei]}}, + {path: 'kata/:prid/:id', component: KataComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.monji, Role.sensei]}}, + {path: 'program/create', component: ProgramCreateComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.sensei]}}, + {path: 'kata_create/:id/:language', component: KataCreateComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.sensei]}}, + {path: '**', redirectTo: ''} +]; + +@NgModule({ + declarations: [], + + exports: [RouterModule], + imports: [RouterModule.forRoot(routes)], + +}) +export class AppRoutingModule { +} diff --git a/client/src/app/app.component.html b/client/src/app/app.component.html index 5226d57f58c4c5f493660d8e328aea558586e3cc..04cc8a8d64fb0304ce3fbdbf366a17bf3e4ec718 100644 --- a/client/src/app/app.component.html +++ b/client/src/app/app.component.html @@ -1,20 +1 @@ -<!--The content below is only a placeholder and can be replaced.--> -<div style="text-align:center"> - <h1> - Welcome to {{ title }}! - </h1> - <img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="> -</div> -<h2>Here are some links to help you start: </h2> -<ul> - <li> - <h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2> - </li> - <li> - <h2><a target="_blank" rel="noopener" href="https://angular.io/cli">CLI Documentation</a></h2> - </li> - <li> - <h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2> - </li> -</ul> - +<app-main-left-side-nav></app-main-left-side-nav> diff --git a/client/src/app/app.component.scss b/client/src/app/app.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..aa5cce1e7a0284e9aa9b6cf8697998884213c00b --- /dev/null +++ b/client/src/app/app.component.scss @@ -0,0 +1,2 @@ +body{display:inline-block} + diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 87aaf530b0d5e47c6bde2268c9a3cac2d28e26da..de2adaf57449d2c9a4c0ae95c083e35c8013ae07 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -1,10 +1,21 @@ -import { Component } from '@angular/core'; +import {Component} from '@angular/core'; +import {User} from './_helper/_models/user'; +import {AuthenticationService} from './services/auth/authentication.service'; +import {Router} from '@angular/router'; @Component({ selector: 'app-root', templateUrl: './app.component.html', - styleUrls: ['./app.component.css'] + styleUrls: ['./app.component.scss'] }) export class AppComponent { - title = 'client'; + title = 'Dojo Hepia'; + currentUser: User; + + constructor( + private router: Router, + private authenticationService: AuthenticationService + ) { + this.authenticationService.currentUser.subscribe(x => this.currentUser = x); + } } diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index f65716351aa5930fea545e1e3f016e2980c1f483..7049df27d20f0612eb19adb8a57669e890ab7c55 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -1,16 +1,98 @@ -import { BrowserModule } from '@angular/platform-browser'; -import { NgModule } from '@angular/core'; +import {BrowserModule} from '@angular/platform-browser'; +import {NgModule} from '@angular/core'; -import { AppComponent } from './app.component'; +import {AppComponent} from './app.component'; +import {TerminalCodeComponent} from './component/terminal-code/terminal-code.component'; +import {TerminalAssertComponent} from './component/terminal-assert/terminal-assert.component'; +import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; +import {MainLeftSideNavComponent} from './component/main-left-side-nav/main-left-side-nav.component'; +import {LayoutModule} from '@angular/cdk/layout'; +import { + MatToolbarModule, + MatButtonModule, + MatSidenavModule, + MatIconModule, + MatListModule, + MatCardModule, + MatInputModule, MatFormFieldModule, MatExpansionModule, MatGridListModule, MatSnackBarModule +} from '@angular/material'; +import {AppRoutingModule} from './app-routing.module'; +import {RouterModule} from '@angular/router'; +import {KataDisplayerComponent} from './component/kata-displayer/kata-displayer.component'; +import {ProgramDisplayerComponent} from './component/program-displayer/program-displayer.component'; +import {KataComponent} from './component/kata/kata.component'; +import {AceEditorModule} from 'ng2-ace-editor'; +import {KataCreateComponent} from './component/kata-create/kata-create.component'; +import {ProgramCreateComponent} from './component/program-create/program-create.component'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {HttpClientModule, HTTP_INTERCEPTORS} from '@angular/common/http'; +import {RNotFoundComponent} from './component/rnot-found/rnot-found.component'; +import {NgxUiLoaderModule} from 'ngx-ui-loader'; +import {AlertModule} from 'ngx-alerts'; +import {LoginComponent} from './component/login/login.component'; +import {JwtInterceptor} from './_helper/jwt.interceptor'; +import {ErrorInterceptor} from './_helper/error.interceptor'; +import { ProfilCardComponent } from './component/user/profil-card/profil-card.component'; +import { CardDisplayerComponent } from './component/program-displayer/card-displayer/card-displayer.component'; +import { SearchbyComponent } from './component/searchby/searchby.component'; +import { SubscriptionComponent } from './component/subscription/subscription.component'; +import { MineComponent } from './component/mine/mine.component'; +import { CardNoneallDisplayerComponent } from './component/program-displayer/card-noneall-displayer/card-noneall-displayer.component'; @NgModule({ declarations: [ - AppComponent + AppComponent, + TerminalCodeComponent, + TerminalAssertComponent, + MainLeftSideNavComponent, + KataDisplayerComponent, + ProgramDisplayerComponent, + KataComponent, + KataCreateComponent, + ProgramCreateComponent, + RNotFoundComponent, + LoginComponent, + ProfilCardComponent, + CardDisplayerComponent, + SearchbyComponent, + SubscriptionComponent, + MineComponent, + CardNoneallDisplayerComponent ], imports: [ - BrowserModule + + BrowserModule, + BrowserAnimationsModule, + LayoutModule, + MatToolbarModule, + MatButtonModule, + MatSidenavModule, + MatIconModule, + MatInputModule, + MatFormFieldModule, + MatExpansionModule, + MatGridListModule, + MatSnackBarModule, + MatListModule, + AppRoutingModule, + RouterModule, + AceEditorModule, + FormsModule, + HttpClientModule, + NgxUiLoaderModule, + AlertModule.forRoot({maxMessages: 5, timeout: 5000, position: 'right'}), + ReactiveFormsModule, + MatCardModule + ], - providers: [], + providers: [{provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, { + provide: HTTP_INTERCEPTORS, + useClass: ErrorInterceptor, + multi: true + }], + bootstrap: [AppComponent] + }) -export class AppModule { } +export class AppModule { +} diff --git a/client/src/app/component/kata-create/kata-create.component.html b/client/src/app/component/kata-create/kata-create.component.html new file mode 100644 index 0000000000000000000000000000000000000000..925f3d0a040acacb8bf46821f8fb0d6340b1d416 --- /dev/null +++ b/client/src/app/component/kata-create/kata-create.component.html @@ -0,0 +1,97 @@ +<div class="d-flex justify-content-center" style="margin-top:2%"> + <div class="d-flex flex-column"> + <form [formGroup]="CreateForm"> + + <mat-accordion> + <mat-expansion-panel expanded="true"> + <mat-expansion-panel-header> + <mat-panel-title> + Kata's informations + </mat-panel-title> + </mat-expansion-panel-header> + + <div class="form-group"> + <label for="title">Title</label> + <input type="text" formControlName="title" class="form-control" + [ngClass]="{ 'is-invalid': submitted && f.title.errors }"/> + <div *ngIf="submitted && f.title.errors" class="invalid-feedback"> + <div *ngIf="f.title.errors.required">Kata needs a title</div> + </div> + </div> + <div class="form-group"> + <label for="assert">Display assert box</label> + <select class="form-control" formControlName="assert" + [ngClass]="{ 'is-invalid': submitted && f.assert.errors}"> + <option value="true">yes</option> + <option value="false">no</option> + </select> + <div *ngIf="submitted && f.assert.errors" class="invalid-feedback"> + <div *ngIf="f.assert.errors.required">Please choose an option</div> + </div> + </div> + <div class="form-group"> + <label for="number">Unlock solution at (> -1)</label> + <input type="number" formControlName="number" value="1" class="form-control" + [ngClass]="{ 'is-invalid': submitted && f.assert.errors}"/> + <div *ngIf="submitted && f.number.errors" class="invalid-feedback"> + <div *ngIf="f.number.errors.required">Please choose the number of tries before unlocking the "surrender + option" + </div> + </div> + </div> + + </mat-expansion-panel> + <mat-expansion-panel> + <mat-expansion-panel-header> + <mat-panel-title> + Kata's instruction + </mat-panel-title> + </mat-expansion-panel-header> + <div class="form-group"> + <textarea class="form-control" style="width:100%" formControlName="instruction" + [ngClass]="{ 'is-invalid': submitted && f.instruction.errors }"></textarea> + <div *ngIf="submitted && f.instruction.errors" class="invalid-feedback"> + <div *ngIf="f.instruction.errors.required">Kata needs instructions</div> + </div> + </div> + </mat-expansion-panel> + + <mat-expansion-panel> + <mat-expansion-panel-header> + <mat-panel-title> + Kata + </mat-panel-title> + </mat-expansion-panel-header> + + <mat-grid-list cols="2" rowHeight="310px"> + <mat-grid-tile> + <app-terminal-code [code]="solution" [type]="language" + (new)="OnNewEventSolution($event)"></app-terminal-code> + </mat-grid-tile> + <mat-grid-tile> + <app-terminal-code [code]="assert" [type]="language" + (new)="OnNewEventAssert($event)"></app-terminal-code> + </mat-grid-tile> + + <mat-grid-tile> + <app-terminal-code [code]="canva" [type]="language" (new)="OnNewEventCanva($event)"></app-terminal-code> + </mat-grid-tile> + <mat-grid-tile> + <textarea [ngClass]="{'success':status === 0,'error':status === 1,'':status === 2}" + style="white-space: pre-wrap;" disabled>{{result}}</textarea> + </mat-grid-tile> + </mat-grid-list> + + <br/> + + <button mat-button [disabled]="compiling" (click)="try()">Try my solution</button> + <button mat-button [disabled]="compiling" (click)="publish()" style="float:right">Create kata</button> + + </mat-expansion-panel> + </mat-accordion> + + </form> + </div> +</div> + + diff --git a/client/src/app/component/kata-create/kata-create.component.scss b/client/src/app/component/kata-create/kata-create.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..75191bec9cb26e4fcedf46eed20e01dbfd2e8c1e --- /dev/null +++ b/client/src/app/component/kata-create/kata-create.component.scss @@ -0,0 +1,88 @@ +.error { + border: 3px rgba(192, 57, 43, 0.8) solid; + background-color: rgba(192, 57, 43, 0.2); +} + +.success { + border: 3px rgba(39, 174, 96, 1.0) solid; + background-color: rgba(39, 174, 96, 0.2); +} + +* { + font-family: "Helvetica Neue"; +} +mat-expansion-panel { + width: 1100px; + background-color: var(--color-dark-blue); + color:var(--color-cloud); +} + +mat-panel-title{ + color:var(--color-cloud); +} +textarea { + background-color: var(--color-soft-light-blue); + border: 2px solid rgba(44, 62, 80, 1.0); + color: var(--color-cloud); + font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; + border-radius: 6px; + resize: none; + outline: none; + + height: 300px; + padding: 10px; + width: 500px; +} + +input{ + + background-color: var(--color-soft-light-blue); + border: 1px solid rgba(63, 67, 77, 1); + border-radius: 7px; + color: rgba(236, 240, 241, 1.0); + padding: .6em 1.4em .5em .8em; +} + +select { + color: var(--color-cloud); + background-color: var(--color-soft-light-blue); + max-width: 100%; + margin: 0; + border: 1px solid rgba(63, 67, 77, 1); + border-radius: 7px; + -moz-appearance: none; + -webkit-appearance: none; + appearance: none; +} + +label{ + color:var(--color-cloud); +} +.header{ + width: 100%; + height: 20px; + background-color: rgba(43, 47, 57, 1); + font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; + padding:3px 3px 3px 10px; + border-radius: 6px; +} + + +.animated{ + transition: all .3s; +} + +select:focus{ + color:var(--color-cloud); + background-color: var(--color-soft-light-blue); +} + +input:focus{ + color:var(--color-cloud); + background-color: var(--color-soft-light-blue); +} + +textarea:focus{ + color:var(--color-cloud); + background-color: var(--color-soft-light-blue); +} diff --git a/client/src/app/component/kata-create/kata-create.component.spec.ts b/client/src/app/component/kata-create/kata-create.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..212e732a24bdd18058da3a32ceb76110ce9aab81 --- /dev/null +++ b/client/src/app/component/kata-create/kata-create.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { KataCreateComponent } from './kata-create.component'; + +describe('KataCreateComponent', () => { + let component: KataCreateComponent; + let fixture: ComponentFixture<KataCreateComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ KataCreateComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(KataCreateComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/kata-create/kata-create.component.ts b/client/src/app/component/kata-create/kata-create.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..2cd98ee987db4864d130fd51f46d4f73456337d1 --- /dev/null +++ b/client/src/app/component/kata-create/kata-create.component.ts @@ -0,0 +1,135 @@ +import {Component, OnInit} from '@angular/core'; +import {Canva} from '../../languages_canvas'; +import {LANGService} from '../../services/LANG/lang.service'; +import {ActivatedRoute, Router} from '@angular/router'; +import {Location} from '@angular/common'; +import {CompilationService} from '../../services/compilation/compilation.service'; +import {v4 as uuid} from 'uuid'; +import {KataService} from '../../services/kata/kata.service'; +import {FormBuilder, FormGroup, Validators} from '@angular/forms'; + +@Component({ + selector: 'app-kata-create', + templateUrl: './kata-create.component.html', + styleUrls: ['./kata-create.component.scss'] +}) +export class KataCreateComponent implements OnInit { + + constructor(private langservice: LANGService, + private route: ActivatedRoute, + private location: Location, + private kataService: KataService, + public router: Router, + private compilationService: CompilationService, + private formBuilder: FormBuilder, + ) { + } + + language = ''; + assert = ''; + + status = 2; + title = ''; + + result = ''; + canva = ''; + solution = ''; + + programId = ''; + + LANG: Canva; + + CreateForm: FormGroup; + submitted = false; + + compiling = false; + + + get f() { + return this.CreateForm.controls; + } + + getLANG(id: string): void { + this.LANG = this.langservice.getLANG(id)[0]; + this.assert = this.LANG.assertCanva; + this.solution = this.LANG.codeCanva; + this.canva = this.LANG.codeCanva; + } + + OnNewEventAssert(event: any): void { + this.assert = event.toString(); + } + + OnNewEventCanva(event: any): void { + this.canva = event.toString(); + } + + OnNewEventSolution(event: any): void { + this.solution = event.toString(); + } + + + publish(): void { + + this.submitted = true; + + if (this.CreateForm.invalid) { + return; + } + + if (this.f.number.value < 0) { + return; + } + + this.kataService.publish(JSON.stringify({ + id: uuid(), + title: this.f.title.value, + language: this.language, + canva: this.canva, + cassert: this.assert, + solution: this.solution, + rules: this.f.instruction.value, + keepAssert: this.f.assert.value, + nbAttempt: this.f.number.value, + programID: this.programId, + difficulty: 'Ceinture blanche' + })).subscribe(data => this.router.navigate(['/kata-displayer/' + this.programId + ''])); + } + + try(): void { + this.compiling = true; + let response; + + this.compilationService.compilationServer(JSON.stringify({ + language: this.language, + stream: this.solution, + assert: this.assert + })).subscribe((data: string) => { + response = data; + if (response.exit === 0) { + this.status = 0; + this.result = response.output + '\nTests passed'; + } else { + this.status = 1; + this.result = response.error; + } + this.compiling = false; + this.result += '\nExecuted in : ' + response.time + 'ms'; + }); + } + + ngOnInit() { + this.programId = this.route.snapshot.paramMap.get('id'); + this.language = this.route.snapshot.paramMap.get('language'); + this.getLANG(this.language); + + this.CreateForm = this.formBuilder.group({ + title: ['', Validators.required], + assert: ['', Validators.required], + number: ['', Validators.required], + instruction: ['', Validators.required], + }); + + } + +} diff --git a/client/src/app/component/kata-displayer/kata-displayer.component.html b/client/src/app/component/kata-displayer/kata-displayer.component.html new file mode 100644 index 0000000000000000000000000000000000000000..2d9d8b227624d7f9a2a2d27e7df32f626d6ca607 --- /dev/null +++ b/client/src/app/component/kata-displayer/kata-displayer.component.html @@ -0,0 +1,46 @@ +<div class="container" *ngIf="!error"> + <div *ngIf="inforreceived"> + <h1 class="title" style="margin:2rem 0 0 2rem;">{{programTitle}} + <br/> + <span class="subtitle">{{programSensei}} <span class="language"> {{programLanguage}}</span> + </span> + + <button mat-button style="margin:0 3rem 0 0;float:right" *ngIf="isOwner" + routerLink="/kata_create/{{idProgram}}/{{programLanguage}}">Create a new kata + </button> + <button mat-button style="margin:0 3rem 0 0;float:right" *ngIf="isOwner" (click)="delete(idProgram)">Delete this program + </button> + <button mat-button style="margin:0 3rem 0 0;float:right" *ngIf="!isOwner" (click)="subscribe()">{{subvalue}}</button> + </h1> + + </div> + <br/> + + <div *ngIf="katas" disabled [ngClass]="isSubscribed ? '' : 'notsub'"> + + <div class="d-flex flex-wrap justify-content-start"> + <span *ngFor="let kata of katas"> + <div class="card" routerLink="/kata/{{idProgram}}/{{kata.id}}"> + <div class="card-body"> + <h5 class="card-title"><a class="title" + routerLink="/kata/{{idProgram}}/{{kata.id}}">{{kata.title}}</a> + <span style="float:right;" + [ngClass]="{'TODO':kata.status==='TODO','ON-GOING':kata.status==='ON-GOING','RESOLVED':kata.status==='RESOLVED','FAILED': kata.status==='FAILED'}">{{kata.status}}</span></h5> + <br/> + <h6 class="card-subtitle mb-2 text-muted">{{kata.difficulty}}</h6> + <br/> + <br/> + <!--<p class="card-text">{{kata.description}}</p>--> + </div> + </div> + </span> + </div> + </div> +</div> + +<span *ngIf="!katas || !inforreceived"><ngx-ui-loader></ngx-ui-loader></span> + +<div *ngIf="error"> + <app-rnot-found></app-rnot-found> +</div> + diff --git a/client/src/app/component/kata-displayer/kata-displayer.component.scss b/client/src/app/component/kata-displayer/kata-displayer.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..0292df1218afb6cc8be9eb78c87e1b0bec8fb408 --- /dev/null +++ b/client/src/app/component/kata-displayer/kata-displayer.component.scss @@ -0,0 +1,55 @@ + +.language { + color: var(--color-language); +} + +.title { + font-size: 20px; + color:var(--color-cloud); +} +.subtitle{ + + font-size:15px; + color:var(--color-dark-grey) !important; +} +.notsub{ + pointer-events: none; + + /* for "disabled" effect */ + opacity: 0.5; + background: var(--color-dark-blue); +} +* { + font-family: "Helvetica Neue"; + +} +.card { + width: 18rem; + margin: 2rem; + background-color: var(--color-dark-blue); +} +a { + text-decoration: none; +} + +.card:hover{ + background-color: var(--color-electro); + border:1px solid var(--color-electro); + cursor: pointer; +} + +.TODO { + color: var(--color-sunflower); +} + +.RESOLVED { + color: rgba(46, 204, 113, 1.0); +} + +.ON-GOING { + color: rgba(230, 126, 34, 1.0); +} + +.FAILED{ + color:rgba(231, 76, 60,1.0); +} diff --git a/client/src/app/component/kata-displayer/kata-displayer.component.spec.ts b/client/src/app/component/kata-displayer/kata-displayer.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8e484f0d6b99930cf3fa96e0da1935fdc7707f6 --- /dev/null +++ b/client/src/app/component/kata-displayer/kata-displayer.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { KataDisplayerComponent } from './kata-displayer.component'; + +describe('KataDisplayerComponent', () => { + let component: KataDisplayerComponent; + let fixture: ComponentFixture<KataDisplayerComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ KataDisplayerComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(KataDisplayerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/kata-displayer/kata-displayer.component.ts b/client/src/app/component/kata-displayer/kata-displayer.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e23a1328b7bc1081bf4d98fe0b95b2b67825487 --- /dev/null +++ b/client/src/app/component/kata-displayer/kata-displayer.component.ts @@ -0,0 +1,156 @@ +import {Component, OnInit} from '@angular/core'; +import {KataShowCase} from './kataShowCase'; +import {ActivatedRoute, Router} from '@angular/router'; +import {Location} from '@angular/common'; +import {NgxUiLoaderService} from 'ngx-ui-loader'; +import {AuthenticationService} from '../../services/auth/authentication.service'; +import {User} from '../../_helper/_models/user'; +import {ProgramSubscription} from '../../interfaces/subscriptions/ProgramSubscription'; +import {v4 as uuid} from 'uuid'; +import {ProgramSubscriptionService} from '../../services/program/subs/program-subscription.service'; +import {ProgramService} from '../../services/program/program.service'; +import {KataService} from '../../services/kata/kata.service'; +import {MatSnackBar} from '@angular/material'; + + +@Component({ + selector: 'app-kata-displayer', + templateUrl: './kata-displayer.component.html', + styleUrls: ['./kata-displayer.component.scss'] +}) +export class KataDisplayerComponent implements OnInit { + + katas: KataShowCase[]; + idProgram: string; + programTitle: string; + programLanguage: string; + programSensei: string; + programSenseiID: string; + error = false; + isSubscribed = false; + currentUser: User; + inforreceived = false; + subscription: ProgramSubscription; + subvalue = 'Unsubscribe'; + + // Tells if the users has already a registered subscription + // The subscription could exist even if the user is un subscribed (it keeps the programs data + // if once the user has been subscribe) + nullsubs: boolean; + + isOwner = false; + + constructor( + private route: ActivatedRoute, + private location: Location, + private kataService: KataService, + private programService: ProgramService, + private ngxLoader: NgxUiLoaderService, + private auth: AuthenticationService, + private programSubscription: ProgramSubscriptionService, + private router: Router, + private snackBar: MatSnackBar + ) { + } + + getIsOwner() { + if (this.currentUser.id === this.programSenseiID) { + this.isOwner = true; + this.isSubscribed = true; + } + } + + subscribe() { + + if (this.nullsubs) { + this.programSubscription.createSubscription(JSON.stringify({ + id: uuid(), + iduser: this.currentUser.id, + idprogram: this.idProgram, + status: true, + nbKataDone: 0, + katas: [] + })).subscribe(() => { + this.isSubscribed = true; + this.nullsubs = false; + this.subvalue = 'Unsubscribe'; + this.programSubscription.getSubs(this.idProgram, this.currentUser.id).subscribe((data: ProgramSubscription) => this.subscription = data); + }); + } else { + this.isSubscribed = !this.isSubscribed; + this.programSubscription.toggle(JSON.stringify({programid: this.idProgram, userid: this.currentUser.id})).subscribe(() => { + if (this.isSubscribed) { + this.subvalue = 'Unsubscribe'; + this.snackBar.open('Subscribed to ' + this.programTitle,'', { + duration: 2000 + }); + } else { + this.subvalue = 'Subscribe'; + this.snackBar.open('Unsubscribed from ' + this.programTitle,'', { + duration: 2000 + }); + } + }); + } + } + + getSubs() { + this.programSubscription.getSubs(this.idProgram, this.currentUser.id).subscribe((data: ProgramSubscription) => { + this.subscription = data; + console.log(data); + this.isSubscribed = this.subscription.status; + if (!this.isSubscribed) { + this.subvalue = 'Subscribe'; + } + this.nullsubs = false; + }, error1 => { + if (error1.status === 404) { + this.isSubscribed = false; + this.subvalue = 'Subscribe'; + this.nullsubs = true; + } + + }); + } + + delete(id: string) { + if (confirm('Are you sure you want to delete this program ? all katas and users datas regarding this katas will be deleted as well.')) { + this.programService.deleteProgram(id).subscribe(() => { + this.router.navigate(['program/mine']); + }); + } + } + + getKatas() { + + this.ngxLoader.start(); + this.programService.getDetails(this.idProgram).subscribe((data: string[]) => { + this.programTitle = data[0]; + this.programLanguage = data[1]; + this.programSensei = data[2]; + console.log(data[3]); + this.programSenseiID = data[3]; + + this.getIsOwner(); + this.getSubs(); + + this.inforreceived = true; + this.kataService.getKatasDetails(this.idProgram, this.auth.currentUserValue.id).subscribe((datas: KataShowCase[]) => { + this.katas = datas; + this.ngxLoader.stop(); + }); + }, (error1 => { + if (error1.status === 404) { + this.error = true; + this.ngxLoader.stop(); + } + })); + } + + ngOnInit() { + this.idProgram = this.route.snapshot.paramMap.get('id'); + this.currentUser = this.auth.currentUserValue; + this.getKatas(); + } + +} diff --git a/client/src/app/component/kata-displayer/kataShowCase.ts b/client/src/app/component/kata-displayer/kataShowCase.ts new file mode 100644 index 0000000000000000000000000000000000000000..01043af95ebb554d40b1be61bfd3d439d5db1c98 --- /dev/null +++ b/client/src/app/component/kata-displayer/kataShowCase.ts @@ -0,0 +1,8 @@ +export interface KataShowCase { + title: string; + difficulty: string; + id: string; + status: string; +} + + diff --git a/client/src/app/component/kata-displayer/kataShowCaseMock.ts b/client/src/app/component/kata-displayer/kataShowCaseMock.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9827e49f72cd5d6414b1558dd6f45310bc4e6af --- /dev/null +++ b/client/src/app/component/kata-displayer/kataShowCaseMock.ts @@ -0,0 +1,15 @@ +/*import {KataShowCase} from './kataShowCase'; + +export const KATAS: KataShowCase[] = [ + { + id: 0, + title: 'Multiplication par 2', + difficulty: 'Ceinture Blanche', + idProgram: 0, + description: 'Multiplier tous les chiffres d\'un tableau par 2', + status: 'TODO' + }, + {id: 1, title: 'Fopen', difficulty: 'Ceinture Jaune', idProgram: 1, description: 'TOFILL', status: 'FAILED'}, + {id: 2, title: 'Fwrite', difficulty: 'Ceinture Verte', idProgram: 1, description: 'TOFILL', status: 'RESOLVED'} +]; +*/ diff --git a/client/src/app/component/kata/kata.component.html b/client/src/app/component/kata/kata.component.html new file mode 100644 index 0000000000000000000000000000000000000000..4476726f3612b645b53ac1234e580350b0b8a1d6 --- /dev/null +++ b/client/src/app/component/kata/kata.component.html @@ -0,0 +1,50 @@ +<div *ngIf="!error" class="d-flex justify-content-center" style="margin-top:2%"> + <span *ngIf="katareceived"> + <div class="d-flex flex-column"> + <div class="p-2 title"> + {{kata.title}} <a routerLink="/kata-displayer/{{programID}}">- {{programTitle}}</a> + <br><span class="subtitle">{{programSensei}} <span class="language"> {{kata.language}}</span></span> + <span style="float:right"><span + [ngClass]="{'TODO':kataStatus==='TODO','ON-GOING':kataStatus==='ON-GOING','RESOLVED':kataStatus==='RESOLVED','FAILED': kataStatus==='FAILED'}">{{kataStatus}}</span> | ATTEMPTS : {{nbAttempt}}</span> + </div> + + + <div class="p-2 "><label class="header">rules :</label><label style="margin-left: 20px;" + class="header">{{this.filename}}</label></div> + <div class="p-2 "> + <textarea disabled style="text-align: justify">{{kata.rules}}</textarea> + <app-terminal-code style="margin-left: 20px;" [code]="kata.canva" [type]="kata.language" + (new)="OnNewEvent($event)"></app-terminal-code> + </div> +<div class="p-2 "><label [hidden]="assert" style="margin-right: 20px;" class="header">{{assertname}}</label><label + [ngClass]="{'header':true,'no-assert':assert===true}">output :</label></div> + <div class="p-2"> + <app-terminal-assert [hidden]="assert" [code]="kata.cassert" [type]="kata.language"></app-terminal-assert> + <textarea [ngClass]="{'success':status === 0,'error':status === 1,'':status === 2,'no-assert':assert===true}" + style="white-space: pre-wrap;" + disabled>{{result}}</textarea> + </div> + + <div class="p-2"> + + <button mat-button [hidden]="!isResolved" [disabled]="newTry" (click)="newtry()" style="margin-right: 10px">Try again</button> + <button mat-button [disabled]="compiling || (isResolved && !newTry )" + (click)="compile(kata.language,kata.canva,kata.cassert)" + style="float:right">Run</button> + <img style="float:right" *ngIf="compiling" + src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA=="/> + <button mat-button [disabled]="compiling || isResolved" (click)="Surrender()" + style="margin-right: 10px">Surrender</button> + </div> + </div> + </span> + <span *ngIf="!katareceived"><ngx-ui-loader></ngx-ui-loader></span> +</div> + + +<div *ngIf="error"> + <app-rnot-found></app-rnot-found> +</div> + + +<ngx-alerts></ngx-alerts> diff --git a/client/src/app/component/kata/kata.component.scss b/client/src/app/component/kata/kata.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..db0786b4e2234402aaa720b431b189f8f9169d8d --- /dev/null +++ b/client/src/app/component/kata/kata.component.scss @@ -0,0 +1,90 @@ +textarea { + background-color: rgba(43, 47, 57, 1); + border: 2px solid rgba(44, 62, 80, 1.0); + color: white; + font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; + + border-radius: 6px; + + resize: none; + outline: none; + height: 300px; + width: 500px; + padding: 10px; +} + +.language { + color: rgba(230, 126, 34, 1); +} + +.title { + font-size: 20px; + color: rgba(236, 240, 241, 1); +} + +.subtitle { + + font-size: 15px; + color: #6c757d !important; +} + +.title a { + text-decoration: none; + color: #6c757d !important; + font-size: 20px; +} + +.title a:hover { + color: rgba(67, 81, 86, 1.0); +} + +.container { + width: 70%; + background: blue; + height: 200px; +} + +* { + font-family: "Helvetica Neue"; + display: inline-block +} + +.error { + border: 3px rgba(192, 57, 43, 0.8) solid; + background-color: rgba(192, 57, 43, 0.2); +} + +.success { + border: 3px rgba(39, 174, 96, 1.0) solid; + background-color: rgba(39, 174, 96, 0.2); +} + +.header { + width: 500px; + height: 20px; + background-color: rgba(43, 47, 57, 1); + font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; + padding: 3px 3px 3px 10px; + border-radius: 6px; +} + + +.TODO { + color: var(--color-sunflower); +} + +.RESOLVED { + color: rgba(46, 204, 113, 1.0); +} + +.ON-GOING { + color: rgba(230, 126, 34, 1.0); +} + +.FAILED{ + color:rgba(231, 76, 60,1.0); +} + +.no-assert{ + width: 100%; +} diff --git a/client/src/app/component/kata/kata.component.spec.ts b/client/src/app/component/kata/kata.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..5252818f836f87f91af3991f1cd2ad4e3b964d82 --- /dev/null +++ b/client/src/app/component/kata/kata.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { KataComponent } from './kata.component'; + +describe('KataComponent', () => { + let component: KataComponent; + let fixture: ComponentFixture<KataComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ KataComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(KataComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/kata/kata.component.ts b/client/src/app/component/kata/kata.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..14b1186ff7525a76552f8156b92addc7581c41f5 --- /dev/null +++ b/client/src/app/component/kata/kata.component.ts @@ -0,0 +1,218 @@ +import {Component, OnInit} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; +import {Location} from '@angular/common'; +import {Kata} from './kata'; +import {CompilationService} from '../../services/compilation/compilation.service'; +import {NgxUiLoaderService} from 'ngx-ui-loader'; +import {Canva} from '../../languages_canvas'; +import {LANGService} from '../../services/LANG/lang.service'; +import {AlertService} from 'ngx-alerts'; +import {AuthenticationService} from '../../services/auth/authentication.service'; +import {KataSubscription} from '../../interfaces/subscriptions/KataSubscription'; +import {v4 as uuid} from 'uuid'; +import {KataSubscriptionService} from '../../services/kata/kata-subscription.service'; +import {ProgramService} from '../../services/program/program.service'; +import {KataService} from '../../services/kata/kata.service'; + +@Component({ + selector: 'app-kata', + templateUrl: './kata.component.html', + styleUrls: ['./kata.component.scss'] +}) +export class KataComponent implements OnInit { + + kata: Kata; + idKata: string; + status = 2; + result = ''; + programID: string; + programTitle: string; + programSensei: string; + error = false; + nbAttempt = 0; + kataStatus = ''; + kataInfo: KataSubscription; + compiling = false; + isResolved = false; + filename = ''; + assertname = ''; + nbAttemptBeforeSurreding: number; + newTry = false; + + katareceived = false; + assert = true; + + LANG: Canva; + + constructor( + private route: ActivatedRoute, + private location: Location, + private kataService: KataService, + private compilationService: CompilationService, + private programService: ProgramService, + private ngxLoader: NgxUiLoaderService, + private langservice: LANGService, + private alertService: AlertService, + private kataSubscriptionService: KataSubscriptionService, + private auth: AuthenticationService, + private router: Router + ) { + } + + + getLANG(id: string): void { + this.LANG = this.langservice.getLANG(id)[0]; + this.assertname = this.LANG.assertname; + this.filename = this.LANG.filename; + } + + getKata(): void { + this.ngxLoader.start(); + this.programService.getDetails(this.programID).subscribe((data: string[]) => { + this.programSensei = data[2]; + this.programTitle = data[0]; + this.kataService.getKata(this.programID, this.idKata).subscribe((datas: Kata) => { + this.kata = datas; + this.assert = !datas.keepAssert; + this.nbAttemptBeforeSurreding = datas.nbAttempt; + this.getLANG(this.kata.language); + this.ngxLoader.stop(); + this.getSubscription(); + this.katareceived = true; + }, + (error1 => { + if (error1.status === 404) { + this.ngxLoader.stop(); + this.error = true; + } + })); + }, error1 => { + if (error1.status === 404) { + this.ngxLoader.stop(); + this.error = true; + } + }); + } + + newtry() { + this.newTry = true; + this.alertService.info('This won\'t affect your overall score'); + } + + Surrender() { + if (this.nbAttempt >= this.nbAttemptBeforeSurreding) { + if (confirm('Are you sure you want to surrender ? the solution will be displayed but you won\'t be able to make xp on this kata again.')) { + this.kataSubscriptionService.update(JSON.stringify({ + kataid: this.idKata, + programid: this.programID, + userid: this.auth.currentUserValue.id, + sol: this.kata.solution, + status: 'FAILED' + })).subscribe(() => { + this.kata.canva = this.kata.solution; + this.kataStatus = 'FAILED'; + this.isResolved = true; + }); + } + } else { + this.alertService.warning('Oh.. Looks like you did not try enough !\nThe surrender options is unlock at ' + this.nbAttemptBeforeSurreding + ' tries for this kata.'); + } + } + + OnNewEvent(event: any): void { + this.kata.canva = event.toString(); + } + + compile(language: string, stream: string, assert: string): void { + this.compiling = true; + let response; + this.compilationService.compilationServer(JSON.stringify({ + language: this.kata.language, + stream, + assert + })).subscribe((data: string) => { + console.log(data); + response = data; + + if (!this.isResolved && !this.newTry) { + this.nbAttempt++; + this.kataSubscriptionService.increment(JSON.stringify({ + kataid: this.idKata, + programid: this.programID, + userid: this.auth.currentUserValue.id + })).subscribe(() => { + + if (response.exit === 0) { + this.kataStatus = 'RESOLVED'; + this.kataSubscriptionService.update(JSON.stringify({ + kataid: this.idKata, + programid: this.programID, + userid: this.auth.currentUserValue.id, + sol: stream, + status: this.kataStatus + })).subscribe(() => { + this.alertService.success('Executed in : ' + response.time + 'ms'); + this.status = 0; + this.result = response.output + 'Exercise passed'; + this.isResolved = true; + }); + } else { + this.status = 1; + this.result = response.error; + this.alertService.danger('Run failed !'); + if (this.nbAttempt >= this.nbAttemptBeforeSurreding) { + this.alertService.info('Solution unlocked ! you can now surrender peasant.'); + } + } + this.compiling = false; + }); + } else { + if (response.exit === 0) { + this.alertService.success('Executed in : ' + response.time + 'ms'); + this.status = 0; + this.result = response.output + 'Exercise passed'; + } else { + this.status = 1; + this.result = response.error; + this.alertService.danger('Run failed !'); + } + this.compiling = false; + } + + + }); + } + + getSubscription() { + this.kataSubscriptionService.get(this.idKata, this.programID, this.auth.currentUserValue.id).subscribe((data: KataSubscription) => { + this.kataInfo = data; + this.nbAttempt = this.kataInfo.nbAttempt; + this.kataStatus = this.kataInfo.status; + if (this.kataInfo.status === 'RESOLVED' || this.kataInfo.status === 'FAILED') { + this.isResolved = true; + this.kata.canva = this.kataInfo.mysol; + } + }, error1 => { + if (error1.status === 404) { + this.kataSubscriptionService.create(JSON.stringify({ + id: uuid(), + kataid: this.idKata, + programid: this.programID, + userid: this.auth.currentUserValue.id + })).subscribe(() => { + this.nbAttempt = 0; + this.kataStatus = 'ON-GOING'; + }); + } else { + this.router.navigate([/kata-displayer/ + this.programID]); + } + + }); + } + + ngOnInit() { + this.programID = this.route.snapshot.paramMap.get('prid'); + this.idKata = this.route.snapshot.paramMap.get('id'); + this.getKata(); + } +} diff --git a/client/src/app/component/kata/kata.ts b/client/src/app/component/kata/kata.ts new file mode 100644 index 0000000000000000000000000000000000000000..603cb6b73cfd41b5dcf52350587485559be85614 --- /dev/null +++ b/client/src/app/component/kata/kata.ts @@ -0,0 +1,13 @@ +export interface Kata { + id: string; + title: string; + language: string; + solution: string; + canva: string; + rules: string; + cassert: string; + keepAssert: boolean; + nbAttempt: number; + programID: string; + difficulty: string; +} diff --git a/client/src/app/component/kata/kataMock.ts b/client/src/app/component/kata/kataMock.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e5cbbf391cf64d9909b7da52fcebdea2e15d72c --- /dev/null +++ b/client/src/app/component/kata/kataMock.ts @@ -0,0 +1,21 @@ +/* +import {Kata} from './kata'; + +// TODO un kata n'a pas besoin de programtitile, ca devrait être passé par la classe d'en dessus (idem pour sensei) +export const KATAS: Kata[] = [{ + id: 0, + language: 'python', + programTitle: 'Arrays in Python', + sensei: 'Orestis Pileas Malaspinas', + title: 'Multiplication par 2', + canva: 'def multiTwo(n):', + rules: 'Le but ici est de jouer avec les tableaux en python. dans cet exercice, il faut multiplier tous les éléments d\'un tableau par 2.\neasyline([2,4]) donnera par exemple [4,8]', + assert: 'from assertpy import assert_that\n' + + 'import sample as m\n' + + '\n' + + 'assert_that(m.multiTwo([1,2])).is_equal_to([2,4])\n' + + 'assert_that(m.multiTwo([45,53,12])).is_equal_to([90,106,24])\n' + + 'assert_that(m.multiTwo([3])).is_equal_to([6])', + solution: 'def multiTwo(n):\n' + ' return [i*2 for i in n]' +}]; +*/ diff --git a/client/src/app/component/login/login.component.css b/client/src/app/component/login/login.component.css new file mode 100644 index 0000000000000000000000000000000000000000..cad61d57bb6c4a3325f97b494ac22f63779773ed --- /dev/null +++ b/client/src/app/component/login/login.component.css @@ -0,0 +1,14 @@ +input{ + + background-color: rgba(43, 47, 57, 1); + border: 1px solid rgba(63, 67, 77, 1); + border-radius: 7px; + color: rgba(236, 240, 241, 1.0); + padding: .6em 1.4em .5em .8em; +} + +input:focus{ + background-color: rgba(43, 47, 57, 1); + color: var(--color-cloud); + outline:none; +} diff --git a/client/src/app/component/login/login.component.html b/client/src/app/component/login/login.component.html new file mode 100644 index 0000000000000000000000000000000000000000..f50fb176e67ca1873835cc37b844c05b453fde5b --- /dev/null +++ b/client/src/app/component/login/login.component.html @@ -0,0 +1,26 @@ +<div class="container" style="margin-top:10%"> + <form [formGroup]="loginForm" (ngSubmit)="onSubmit()"> + <div class="form-group"> + <label for="username">Username</label> + <input type="text" formControlName="username" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.username.errors }"/> + <div *ngIf="submitted && f.username.errors" class="invalid-feedback"> + <div *ngIf="f.username.errors.required">Username is required</div> + </div> + </div> + <div class="form-group"> + <label for="password">Password</label> + <input type="password" formControlName="password" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.password.errors }"/> + <div *ngIf="submitted && f.password.errors" class="invalid-feedback"> + <div *ngIf="f.password.errors.required">Password is required</div> + </div> + </div> + <div class="form-group"> + <button [disabled]="loading" mat-button style="float:right">Login</button> + <img *ngIf="loading" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" /> + </div> + <br> + <br> + <div *ngIf="error" class="alert alert-danger">{{error}}</div> + </form> +</div> + diff --git a/client/src/app/component/login/login.component.spec.ts b/client/src/app/component/login/login.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6d85a8465b79ee37cb75c371f6e6e936997c573 --- /dev/null +++ b/client/src/app/component/login/login.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LoginComponent } from './login.component'; + +describe('LoginComponent', () => { + let component: LoginComponent; + let fixture: ComponentFixture<LoginComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ LoginComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(LoginComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/login/login.component.ts b/client/src/app/component/login/login.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..de3f86b13178427b0901a340fd0a33f0c30bf634 --- /dev/null +++ b/client/src/app/component/login/login.component.ts @@ -0,0 +1,69 @@ +import {Component, OnInit} from '@angular/core'; +import {AuthenticationService} from '../../services/auth/authentication.service'; +import {first} from 'rxjs/operators'; +import {ActivatedRoute, Router} from '@angular/router'; +import {FormBuilder, FormGroup, Validators} from '@angular/forms'; + +@Component({ + selector: 'app-login', + templateUrl: './login.component.html', + styleUrls: ['./login.component.css'] +}) +export class LoginComponent implements OnInit { + + constructor(private route: ActivatedRoute, + private router: Router, + private auth: AuthenticationService, + private formBuilder: FormBuilder, + private authenticationService: AuthenticationService) { + if (this.authenticationService.currentUserValue) { + this.router.navigate(['/']); + } + } + + loginForm: FormGroup; + + loading = false; + submitted = false; + returnUrl: string; + error = ''; + + + onSubmit() { + this.submitted = true; + + // stop here if form is invalid + if (this.loginForm.invalid) { + return; + } + + this.loading = true; + this.auth.login(this.f.username.value, this.f.password.value) + .pipe(first()) + .subscribe( + data => { + this.router.navigate([this.returnUrl]); + location.reload(); + }, + error => { + this.error = error.error; + this.loading = false; + }); + } + + get f() { + return this.loginForm.controls; + } + + ngOnInit() { + this.loginForm = this.formBuilder.group({ + username: ['', Validators.required], + password: ['', Validators.required] + }); + + // get return url from route parameters or default to '/' + this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/'; + + } + +} diff --git a/client/src/app/component/main-left-side-nav/main-left-side-nav.component.html b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.html new file mode 100644 index 0000000000000000000000000000000000000000..289b809565d3e812f015c9a1605fcdfbff3302f7 --- /dev/null +++ b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.html @@ -0,0 +1,30 @@ +<mat-sidenav-container class="sidenav-container"> + <mat-sidenav #drawer class="sidenav" fixedInViewport="true" + [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'" + [mode]="(isHandset$ | async) ? 'over' : 'side'" + [opened]="!(isHandset$ | async)"> + <mat-toolbar routerLink="/">DOJO HEPIA</mat-toolbar> + <mat-nav-list *ngIf="currentUser"> + <a mat-list-item routerLink="/program">All programs</a> + <div *ngIf="currentUser.role != Role.monji"> + <a mat-list-item routerLink="/program/create">New program</a> + <a mat-list-item routerLink="/program/mine">My programs</a> + </div> + <a mat-list-item routerLink="/program/subscriptions">Subscriptions</a> + <a mat-list-item routerLink="/program/search">Search</a> + <a mat-list-item (click)="logout()">Log out</a> + </mat-nav-list> + </mat-sidenav> + <mat-sidenav-content> + <button + type="button" + aria-label="Toggle sidenav" + mat-icon-button + (click)="drawer.toggle()" + *ngIf="isHandset$ | async"> + <mat-icon aria-label="Side nav toggle icon">menu</mat-icon> + + </button> + <router-outlet></router-outlet> + </mat-sidenav-content> +</mat-sidenav-container> diff --git a/client/src/app/component/main-left-side-nav/main-left-side-nav.component.scss b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..f483fdbadc6de2f6f154e246cf011ad304c98d44 --- /dev/null +++ b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.scss @@ -0,0 +1,26 @@ +.sidenav-container { + height: 100%; +} + + +.mat-sidenav-content{ + background-color: var(--color-soft-light-blue); +} +.sidenav { + width: 150px; + background-color: var(--color-dark-blue); +} + +.sidenav .mat-toolbar { + background: inherit; +} + +.mat-toolbar.mat-primary { + position: sticky; + top: 0; + z-index: 1; +} + +*{ + color : var(--color-cloud); +} diff --git a/client/src/app/component/main-left-side-nav/main-left-side-nav.component.spec.ts b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..e365bd1eaf67f3be3b86f7c33ffa0171014d6b9b --- /dev/null +++ b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.spec.ts @@ -0,0 +1,42 @@ +import { LayoutModule } from '@angular/cdk/layout'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { + MatButtonModule, + MatIconModule, + MatListModule, + MatSidenavModule, + MatToolbarModule, +} from '@angular/material'; + +import { MainLeftSideNavComponent } from './main-left-side-nav.component'; + +describe('MainLeftSideNavComponent', () => { + let component: MainLeftSideNavComponent; + let fixture: ComponentFixture<MainLeftSideNavComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [MainLeftSideNavComponent], + imports: [ + NoopAnimationsModule, + LayoutModule, + MatButtonModule, + MatIconModule, + MatListModule, + MatSidenavModule, + MatToolbarModule, + ] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MainLeftSideNavComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should compile', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/main-left-side-nav/main-left-side-nav.component.ts b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d5d05820c6d144eb204a9e808123382b92e6c3b --- /dev/null +++ b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.ts @@ -0,0 +1,35 @@ +import {Component, OnInit} from '@angular/core'; +import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout'; +import {Observable} from 'rxjs'; +import {map} from 'rxjs/operators'; +import {AuthenticationService} from '../../services/auth/authentication.service'; +import {User} from '../../_helper/_models/user'; +import {Role} from '../../_helper/_models/roles'; + + +@Component({ + selector: 'app-main-left-side-nav', + templateUrl: './main-left-side-nav.component.html', + styleUrls: ['./main-left-side-nav.component.scss'] +}) +export class MainLeftSideNavComponent { + + currentUser: User; + Role = Role; + isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset) + .pipe( + map(result => result.matches) + ); + + logout() { + this.auth.logout(); + location.reload(); + // TODO unset globlas + } + + constructor(private breakpointObserver: BreakpointObserver, private auth: AuthenticationService) { + this.currentUser = this.auth.currentUserValue; + + } + +} diff --git a/client/src/app/component/mine/mine.component.css b/client/src/app/component/mine/mine.component.css new file mode 100644 index 0000000000000000000000000000000000000000..231cd737f2f5cbe1e3eef7613c231d939f3607de --- /dev/null +++ b/client/src/app/component/mine/mine.component.css @@ -0,0 +1,9 @@ +* { + color: var(--color-cloud); +} + + +.program-container{ + margin:5rem 10rem 0 10rem; +} + diff --git a/client/src/app/component/mine/mine.component.html b/client/src/app/component/mine/mine.component.html new file mode 100644 index 0000000000000000000000000000000000000000..8ba332477364efef4b478ca1427db5ec4034df80 --- /dev/null +++ b/client/src/app/component/mine/mine.component.html @@ -0,0 +1,14 @@ +<div class="container" *ngIf="programs"> + <h1 style="margin:2rem 0 0 2rem;text-align: center">My created programs</h1> + <hr> + <app-card-noneall-displayer [programs]="programs"></app-card-noneall-displayer> + + +</div> + +<div *ngIf="programReceivedFailed"> + <h1 style="margin:2rem 0 0 2rem;text-align: center">Oops.. you have not created any program yet..</h1> +</div> + + +<span *ngIf="!programs"><ngx-ui-loader></ngx-ui-loader></span> diff --git a/client/src/app/component/mine/mine.component.spec.ts b/client/src/app/component/mine/mine.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c848f864b683d83d13baf4da693f836190fdac7 --- /dev/null +++ b/client/src/app/component/mine/mine.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MineComponent } from './mine.component'; + +describe('MineComponent', () => { + let component: MineComponent; + let fixture: ComponentFixture<MineComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MineComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MineComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/mine/mine.component.ts b/client/src/app/component/mine/mine.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..884d28d83646aae2a9c0873a9009cd1765ff7596 --- /dev/null +++ b/client/src/app/component/mine/mine.component.ts @@ -0,0 +1,39 @@ +import {Component, OnInit} from '@angular/core'; +import {Program} from '../program-displayer/program'; +import {NgxUiLoaderService} from 'ngx-ui-loader'; +import {AuthenticationService} from '../../services/auth/authentication.service'; +import {ProgramSubscriptionService} from '../../services/program/subs/program-subscription.service'; + + +@Component({ + selector: 'app-mine', + templateUrl: './mine.component.html', + styleUrls: ['./mine.component.css'] +}) +export class MineComponent implements OnInit { + + programs: Program[]; + programReceivedFailed = false; + + constructor(private programSubscription: ProgramSubscriptionService, private ngxLoader: NgxUiLoaderService, private auth: AuthenticationService) { + } + + getProgram(): void { + + this.ngxLoader.start(); + this.programSubscription.getMine(this.auth.currentUserValue.id).subscribe((data: Program[]) => { + this.programs = data; + this.ngxLoader.stop(); + }, error1 => { + if (error1.status === 404) { + this.programReceivedFailed = true; + this.ngxLoader.stop(); + } + }); + } + + ngOnInit() { + this.getProgram(); + } + +} diff --git a/client/src/app/component/program-create/program-create.component.html b/client/src/app/component/program-create/program-create.component.html new file mode 100644 index 0000000000000000000000000000000000000000..cf6ca8b0b02d53c1dbcb3a2183d4e2af5e906f0b --- /dev/null +++ b/client/src/app/component/program-create/program-create.component.html @@ -0,0 +1,48 @@ +<div class="d-flex justify-content-center" style="margin-top:2%"> + <div class="d-flex flex-column"> + <fieldset> + <legend>New program</legend> + <form [formGroup]="CreateForm"> + <div class="form-group"> + <label for="title">Title</label> + <input type="text" formControlName="title" class="form-control" + [ngClass]="{ 'is-invalid': submitted && f.title.errors }"/> + <div *ngIf="submitted && f.title.errors" class="invalid-feedback"> + <div *ngIf="f.title.errors.required">Program needs a title</div> + </div> + </div> + <div class="form-group"> + <label for="language">Targeted language</label> + <select class="form-control" formControlName="language" + [ngClass]="{ 'is-invalid': submitted && f.language.errors}"> + <option value="python">python</option> + <option value="java">java</option> + </select> + <div *ngIf="submitted && f.language.errors" class="invalid-feedback"> + <div *ngIf="f.language.errors.required">Program needs a language</div> + </div> + </div> + <div class="form-group"> + <label for="description">Description</label> + <textarea class="form-control" formControlName="description" + [ngClass]="{ 'is-invalid': submitted && f.description.errors }"></textarea> + <div *ngIf="submitted && f.description.errors" class="invalid-feedback"> + <div *ngIf="f.description.errors.required">Program needs a description</div> + </div> + </div> + <div class="form-group"> + <label for="tags">Tags</label> + <input class="form-control" type="text" [ngClass]="{ 'is-invalid': submitted && f.tags.errors }" formControlName="tags" placeholder="format: tag1,tag2,.."/> + <div *ngIf="submitted && f.tags.errors" class="invalid-feedback"> + <div *ngIf="f.tags.errors.required">Program needs one or more tags</div> + </div> + </div> + <div class="form-group"> + <button mat-button (click)="createProgram(false)">Create</button> + <button mat-button (click)="createProgram(true)" class="button" style="float:right">Create with kata</button> + </div> + </form> + </fieldset> + </div> + +</div> diff --git a/client/src/app/component/program-create/program-create.component.scss b/client/src/app/component/program-create/program-create.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..c5adfa629aa3fb24ce45f1e3b379810ab1e8670b --- /dev/null +++ b/client/src/app/component/program-create/program-create.component.scss @@ -0,0 +1,80 @@ +input{ + width: 100%; + background-color: rgba(43, 47, 57, 1); + border: 1px solid rgba(63, 67, 77, 1); + border-radius: 7px; + color: rgba(236, 240, 241, 1.0); + padding: .6em 1.4em .5em .8em; +} + +input:focus{ + background-color: rgba(43, 47, 57, 1); + color: var(--color-cloud); + outline:none; +} + +select { + + //padding: .6em 1.4em .5em .8em; + color: rgba(236, 240, 241, 1.0); + background-color: rgba(43, 47, 57, 1); + width: 100%; + max-width: 100%; + margin: 0; + border: 1px solid rgba(63, 67, 77, 1); + border-radius: 7px; + -moz-appearance: none; + -webkit-appearance: none; + appearance: none; +} + +select:focus{ + background-color: rgba(43, 47, 57, 1); + color: var(--color-cloud); + outline:none; +} + +textarea:focus{ + background-color: rgba(43, 47, 57, 1); + color: var(--color-cloud); + outline:none; +} + +label{ + margin-top:.4em; + color : var(--color-cloud); +} + +textarea{ + padding: .6em 1.4em .5em .8em; + color: var(--color-cloud); + background-color: var(--color-dark-blue); + width: 100%; + max-width: 100%; + margin: 0; + height: 10rem; + border: 1px solid var(--color-light-blue); + border-radius: 7px; + -moz-appearance: none; + -webkit-appearance: none; + appearance: none; +} + +fieldset { + border: 3px solid var(--color-light-blue); + border-radius: 6px; + width:500px; + padding: 1rem; +} + +legend { + text-align: center; + color : var(--color-cloud); + +} + +*{ + font-family: "Helvetica Neue"; + +} + diff --git a/client/src/app/component/program-create/program-create.component.spec.ts b/client/src/app/component/program-create/program-create.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..97bc105501f18654aa6dcfc74f03f94f1c647d3b --- /dev/null +++ b/client/src/app/component/program-create/program-create.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProgramCreateComponent } from './program-create.component'; + +describe('ProgramCreateComponent', () => { + let component: ProgramCreateComponent; + let fixture: ComponentFixture<ProgramCreateComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ProgramCreateComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ProgramCreateComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/program-create/program-create.component.ts b/client/src/app/component/program-create/program-create.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..64f91823b75302294449b94df0f709b5eb9b5590 --- /dev/null +++ b/client/src/app/component/program-create/program-create.component.ts @@ -0,0 +1,84 @@ +import {Component, OnInit} from '@angular/core'; +import {Router} from '@angular/router'; +import {AuthenticationService} from '../../services/auth/authentication.service'; +import {User} from '../../_helper/_models/user'; +import {v4 as uuid} from 'uuid'; +import {ProgramSubscriptionService} from '../../services/program/subs/program-subscription.service'; +import {ProgramService} from '../../services/program/program.service'; +import {FormBuilder, FormGroup, Validators} from '@angular/forms'; + +@Component({ + selector: 'app-program-create', + templateUrl: './program-create.component.html', + styleUrls: ['./program-create.component.scss'] +}) +export class ProgramCreateComponent implements OnInit { + currentUser: User; + + constructor(private programService: ProgramService, + public router: Router, + private auth: AuthenticationService, + private programSubscription: ProgramSubscriptionService, + private formBuilder: FormBuilder) { + this.currentUser = this.auth.currentUserValue; + } + + CreateForm: FormGroup; + + submitted = false; + programToKata = 0; + + get f() { + return this.CreateForm.controls; + } + + createProgram(newkata: boolean): void { + this.submitted = true; + + if (this.CreateForm.invalid) { + return; + } + + this.programService.createProgram(JSON.stringify({ + id: this.programToKata, + sensei: this.currentUser.username, + language: this.f.language.value, + nbKata: 0, + title: this.f.title.value, + description: this.f.description.value, + tags: this.f.tags.value.split(','), + idsensei: this.currentUser.id, + katas: [] + })).subscribe(() => { + this.programSubscription.createSubscription(JSON.stringify({ + id: uuid(), + iduser: this.currentUser.id, + idprogram: this.programToKata, + status: true, + nbKataDone: 0, + katas: [] + })).subscribe(() => { + if (newkata) { + this.router.navigate(['/kata_create/' + this.programToKata + '/' + this.f.language.value + '']); + } else { + this.router.navigate(['/program/mine']); + } + } + ); + + }); + + } + + ngOnInit() { + this.programToKata = uuid(); + + this.CreateForm = this.formBuilder.group({ + title: ['', Validators.required], + language: ['', Validators.required], + description: ['', Validators.required], + tags: ['', Validators.required], + }); + } + +} diff --git a/client/src/app/component/program-displayer/card-displayer/card-displayer.component.css b/client/src/app/component/program-displayer/card-displayer/card-displayer.component.css new file mode 100644 index 0000000000000000000000000000000000000000..a9de49a9cbf3adc7ccb9639fc9a7117409aa8575 --- /dev/null +++ b/client/src/app/component/program-displayer/card-displayer/card-displayer.component.css @@ -0,0 +1,60 @@ +.language { + color: var(--color-language); + float: right; +} + +.language:hover { + + border-bottom: 1px solid var(--color-language-hover); + cursor: pointer; +} + +a:hover{ + color: var(--color-cloud); +} +.sensei { + color: var(--color-dark-grey) !important; +} + +.sensei:hover { + border-bottom: 1px solid var(--color-dark-grey); + cursor: pointer; +} + +.tag { + background-color: rgba(99, 110, 114, 0.4); + color: rgba(9, 132, 227, 1.0); + padding: 3px; + margin-right: 3px; +} + +.tag:hover { + border-bottom: 1px solid rgba(9, 132, 227, 1.0); + cursor: pointer; +} + +.nbkata { + font-size: 15px; + color: var(--color-amethyst); + float: right; +} + +.card { + background-color: var(--color-dark-blue); + width: 18.4rem; + margin:2rem; +} + + +.card:hover { + background-color: var(--color-electro); + border: 1px solid var(--color-electro); +} + +* { + color: var(--color-cloud); +} + +.filter-value { + color: var(--color-language); +} diff --git a/client/src/app/component/program-displayer/card-displayer/card-displayer.component.html b/client/src/app/component/program-displayer/card-displayer/card-displayer.component.html new file mode 100644 index 0000000000000000000000000000000000000000..2eeda515c009a757cc857bfb17700f5b79eed5c4 --- /dev/null +++ b/client/src/app/component/program-displayer/card-displayer/card-displayer.component.html @@ -0,0 +1,22 @@ +<h6 *ngIf="filter" style="margin:0 0 0 2rem">Filtered by {{filterType}} : <span + class="filter-value">{{filterValue}}</span></h6> +<div class="d-flex flex-wrap justify-content-around"> + <div *ngFor="let program of programs"> + <div class="card"> + <div class="card-body"> + <a routerLink="/kata-displayer/{{program.programID}}"><h5 class="card-title">{{program.title}}</h5></a> + <h6 class="card-subtitle mb-2 text-muted"><a><span (click)="querySearch('sensei',program.sensei)" + class="sensei">{{program.sensei}}</span> </a> + <a><span (click)="querySearch('language',program.language)" class="language">{{program.language}}</span></a> + </h6> + <br/> + <p class="card-text">{{program.description}}</p> + <span *ngFor="let tag of program.tags"> + <span class="tag" (click)="querySearch('tags',tag)">{{tag}}</span> + </span> + <span class="nbkata">#{{program.nbKata}}</span> + </div> + </div> + + </div> +</div> diff --git a/client/src/app/component/program-displayer/card-displayer/card-displayer.component.spec.ts b/client/src/app/component/program-displayer/card-displayer/card-displayer.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3185ee5eb6483f7fa8e4b283068b2236c764db9 --- /dev/null +++ b/client/src/app/component/program-displayer/card-displayer/card-displayer.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CardDisplayerComponent } from './card-displayer.component'; + +describe('CardDisplayerComponent', () => { + let component: CardDisplayerComponent; + let fixture: ComponentFixture<CardDisplayerComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CardDisplayerComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CardDisplayerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/program-displayer/card-displayer/card-displayer.component.ts b/client/src/app/component/program-displayer/card-displayer/card-displayer.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..d4f525ccaf5003732bab8c56219fb90bdf3d47e8 --- /dev/null +++ b/client/src/app/component/program-displayer/card-displayer/card-displayer.component.ts @@ -0,0 +1,32 @@ +import {Component, Input, OnInit} from '@angular/core'; +import {Program} from '../program'; +import {FetchProgramByTypeService} from '../../../services/program/search/fetch-program-by-type.service'; + +@Component({ + selector: 'app-card-displayer', + templateUrl: './card-displayer.component.html', + styleUrls: ['./card-displayer.component.css'] +}) +export class CardDisplayerComponent implements OnInit { + + constructor(private FetchProgramByQueryService: FetchProgramByTypeService) { + } + + @Input() programs; + filter = false; + filterValue: string; + filterType: string; + + querySearch(type: string, res: string) { + this.FetchProgramByQueryService.getPrograms(type, res).subscribe((data: Program[]) => { + this.filterType = type; + this.filterValue = res; + this.filter = true; + this.programs = data; + }); + } + + ngOnInit() { + } + +} diff --git a/client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.html b/client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.html new file mode 100644 index 0000000000000000000000000000000000000000..720470ddbed789f1b37c37c71d3fd0d332411616 --- /dev/null +++ b/client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.html @@ -0,0 +1,23 @@ +<h6 *ngIf="filter" style="margin:0 0 0 2rem">Filtered by {{filterType}} : <span + class="filter-value">{{filterValue}}</span></h6> +<div class="d-flex flex-wrap justify-content-around"> + <div *ngFor="let program of programs"> + <div class="card"> + <div class="card-body"> + <a routerLink="/kata-displayer/{{program.programID}}"><h5 class="card-title">{{program.title}}<span + style="float:right" [hidden]="program.nbKataDone == -1">{{+program.nbKataDone / +program.nbKata * 100}} + %</span></h5></a> + <h6 class="card-subtitle mb-2 text-muted"><a><span (click)="querySearch('sensei',program.sensei)" class="sensei">{{program.sensei}}</span> </a> + <a><span (click)="querySearch('language',program.language)" class="language">{{program.language}}</span></a> + </h6> + <br/> + <p class="card-text">{{program.description}}</p> + <span *ngFor="let tag of program.tags"> + <span class="tag" (click)="querySearch('tags',tag)">{{tag}}</span> + </span> + <span class="nbkata">#{{program.nbKata}}</span> + </div> + </div> + + </div> +</div> diff --git a/client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.spec.ts b/client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ef37b19c8adfafbdee82383181145fe6bfc600 --- /dev/null +++ b/client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CardNoneallDisplayerComponent } from './card-noneall-displayer.component'; + +describe('CardNoneallDisplayerComponent', () => { + let component: CardNoneallDisplayerComponent; + let fixture: ComponentFixture<CardNoneallDisplayerComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CardNoneallDisplayerComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CardNoneallDisplayerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.ts b/client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..b4125f5ff0ee0e0892098fb06ee9a9ae907c5788 --- /dev/null +++ b/client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.ts @@ -0,0 +1,39 @@ +import {Component, Input, OnInit} from '@angular/core'; + +@Component({ + selector: 'app-card-noneall-displayer', + templateUrl: './card-noneall-displayer.component.html', + styleUrls: ['../card-displayer/card-displayer.component.css'] +}) +export class CardNoneallDisplayerComponent implements OnInit { + + constructor() { + } + + @Input() programs; + filter = false; + filterValue: string; + filterType: string; + + programNonFiltered: object; + + querySearch(type: string, res: string) { + + this.programs = this.programNonFiltered; + this.filterType = type; + this.filterValue = res; + this.filter = true; + this.programs = this.programs.filter((x) => { + if (type === 'tags') { + return x[type].filter((t) => t === res); + } + return x[type] === res; + }); + } + + ngOnInit() { + this.programNonFiltered = this.programs; + + } + +} diff --git a/client/src/app/component/program-displayer/program-displayer.component.html b/client/src/app/component/program-displayer/program-displayer.component.html new file mode 100644 index 0000000000000000000000000000000000000000..08287c6d1ef74ab01bd58a54a7446c1ce13bcf91 --- /dev/null +++ b/client/src/app/component/program-displayer/program-displayer.component.html @@ -0,0 +1,13 @@ +<div class="container" *ngIf="programs"> + <h1 style="margin:2rem 0 0 2rem;text-align: center">All available programs</h1> +<hr/> + <app-card-displayer [programs]="programs"></app-card-displayer> + +</div> + +<div *ngIf="programReceivedFailed"> + <h1 style="margin:2rem 0 0 2rem;text-align: center">Oops.. no program available ..</h1> +</div> + + +<span *ngIf="!programs"><ngx-ui-loader></ngx-ui-loader></span> diff --git a/client/src/app/component/program-displayer/program-displayer.component.scss b/client/src/app/component/program-displayer/program-displayer.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..7be145c0da2a822352282a45c9cddd02db143a82 --- /dev/null +++ b/client/src/app/component/program-displayer/program-displayer.component.scss @@ -0,0 +1,16 @@ +* { + color: var(--color-cloud); +} + + +.program-container{ + margin:5rem 10rem 0 10rem; +} + +@media only screen and (max-width: 2000px) { + body { + .program-container{ + margin:0rem 0rem 0 0rem; + } + } +} diff --git a/client/src/app/component/program-displayer/program-displayer.component.spec.ts b/client/src/app/component/program-displayer/program-displayer.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..d7266448d9d5557faa57df96f990fad49753475a --- /dev/null +++ b/client/src/app/component/program-displayer/program-displayer.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProgramDisplayerComponent } from './program-displayer.component'; + +describe('ProgramDisplayerComponent', () => { + let component: ProgramDisplayerComponent; + let fixture: ComponentFixture<ProgramDisplayerComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ProgramDisplayerComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ProgramDisplayerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/program-displayer/program-displayer.component.ts b/client/src/app/component/program-displayer/program-displayer.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..59f45a0476af216f97a99cadca8e5f8a13fa7c64 --- /dev/null +++ b/client/src/app/component/program-displayer/program-displayer.component.ts @@ -0,0 +1,38 @@ +import {Component, OnInit} from '@angular/core'; +import {Program} from './program'; +import {NgxUiLoaderService} from 'ngx-ui-loader'; +import {ProgramService} from '../../services/program/program.service'; + +@Component({ + selector: 'app-program-displayer', + templateUrl: './program-displayer.component.html', + styleUrls: ['./program-displayer.component.scss'] +}) +export class ProgramDisplayerComponent implements OnInit { + + + programs: Program[]; + programReceivedFailed = false; + + constructor(private programService: ProgramService, private ngxLoader: NgxUiLoaderService) { + } + + getProgram(): void { + + this.ngxLoader.start(); + this.programService.getPrograms().subscribe((data: Program[]) => { + this.programs = data; + this.ngxLoader.stop(); + }, error1 => { + if (error1.status === 404) { + this.programReceivedFailed = true; + this.ngxLoader.stop(); + } + }); + } + + ngOnInit() { + this.getProgram(); + } + +} diff --git a/client/src/app/component/program-displayer/program.ts b/client/src/app/component/program-displayer/program.ts new file mode 100644 index 0000000000000000000000000000000000000000..435246862b0da5dfbca7c52960a2d0fdd2e09462 --- /dev/null +++ b/client/src/app/component/program-displayer/program.ts @@ -0,0 +1,10 @@ +export interface Program { + programID: string; + title: string; + language: string; + sensei: string; + nbKata: number; + description: string; + tags: string[]; + nbKataDone: number; +} diff --git a/client/src/app/component/program-displayer/programMock.ts b/client/src/app/component/program-displayer/programMock.ts new file mode 100644 index 0000000000000000000000000000000000000000..a505b6f54df64d27b2baef1b52111c39abd6b813 --- /dev/null +++ b/client/src/app/component/program-displayer/programMock.ts @@ -0,0 +1,23 @@ +/*import {Program} from './program'; + +export const PROGRAMS: Program[] = [ + { + id: 0, + title: 'Arrays in Python', + language: 'python', + sensei: 'Orestis Pileas Malaspinas', + nbKata: 1, + description: 'Apprenez à jouer avec les tableaux en python', + tag: ['arrays', 'numbers'] + }, { + id: 1, + title: 'Let IO !', + language: 'java', + sensei: 'Stéphane Malandin', + nbKata: 2, + description: 'I/O in java', + tag: ['I/O', 'writeable'] + } +]; + +*/ diff --git a/client/src/app/component/rnot-found/rnot-found.component.css b/client/src/app/component/rnot-found/rnot-found.component.css new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/client/src/app/component/rnot-found/rnot-found.component.css @@ -0,0 +1 @@ + diff --git a/client/src/app/component/rnot-found/rnot-found.component.html b/client/src/app/component/rnot-found/rnot-found.component.html new file mode 100644 index 0000000000000000000000000000000000000000..c28773ee2a059ac0b0b35c4898bc1ceaa9cce62a --- /dev/null +++ b/client/src/app/component/rnot-found/rnot-found.component.html @@ -0,0 +1,2 @@ +<span class="NOTFOUND">SERVER ERROR: 404 NOT FOUND</span> + diff --git a/client/src/app/component/rnot-found/rnot-found.component.spec.ts b/client/src/app/component/rnot-found/rnot-found.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b1d2803d5e65621ffce7df6a77a7e3130b980db --- /dev/null +++ b/client/src/app/component/rnot-found/rnot-found.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { RNotFoundComponent } from './rnot-found.component'; + +describe('RNotFoundComponent', () => { + let component: RNotFoundComponent; + let fixture: ComponentFixture<RNotFoundComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ RNotFoundComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(RNotFoundComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/rnot-found/rnot-found.component.ts b/client/src/app/component/rnot-found/rnot-found.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..c25c95fe769d6a886cf25a419c93fa37827c5e3c --- /dev/null +++ b/client/src/app/component/rnot-found/rnot-found.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-rnot-found', + templateUrl: './rnot-found.component.html', + styleUrls: ['./rnot-found.component.css'] +}) +export class RNotFoundComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/client/src/app/component/searchby/searchby.component.css b/client/src/app/component/searchby/searchby.component.css new file mode 100644 index 0000000000000000000000000000000000000000..cad61d57bb6c4a3325f97b494ac22f63779773ed --- /dev/null +++ b/client/src/app/component/searchby/searchby.component.css @@ -0,0 +1,14 @@ +input{ + + background-color: rgba(43, 47, 57, 1); + border: 1px solid rgba(63, 67, 77, 1); + border-radius: 7px; + color: rgba(236, 240, 241, 1.0); + padding: .6em 1.4em .5em .8em; +} + +input:focus{ + background-color: rgba(43, 47, 57, 1); + color: var(--color-cloud); + outline:none; +} diff --git a/client/src/app/component/searchby/searchby.component.html b/client/src/app/component/searchby/searchby.component.html new file mode 100644 index 0000000000000000000000000000000000000000..889a3b564f206e46ba5b813e8c8f576363d4d167 --- /dev/null +++ b/client/src/app/component/searchby/searchby.component.html @@ -0,0 +1,18 @@ +<div class="container" style="margin-top:10%"> + <form style="margin: 2rem" [formGroup]="SearchForm" > + <div class="form-group"> + <input type="text" formControlName="search" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.search.errors }"/> + <div *ngIf="submitted && f.search.errors" class="invalid-feedback"> + <div *ngIf="f.search.errors.required">Field is empty</div> + </div> + </div> + <div class="form-group"> + <button [disabled]="loading" mat-button style="float:right" (click)="onSubmit()">Search</button> + <img *ngIf="loading" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" /> + </div> + <br> + <br> + <div *ngIf="error" class="alert alert-danger">{{error}}</div> + </form> + <app-card-noneall-displayer [programs]="programs"></app-card-noneall-displayer> +</div> diff --git a/client/src/app/component/searchby/searchby.component.spec.ts b/client/src/app/component/searchby/searchby.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a71aa5279e6f11955ee061dc475a22d1e0eccb2 --- /dev/null +++ b/client/src/app/component/searchby/searchby.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SearchbyComponent } from './searchby.component'; + +describe('SearchbyComponent', () => { + let component: SearchbyComponent; + let fixture: ComponentFixture<SearchbyComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ SearchbyComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(SearchbyComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/searchby/searchby.component.ts b/client/src/app/component/searchby/searchby.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..0ebfb10bac23e763b0e13925e0d7caebe9eebd79 --- /dev/null +++ b/client/src/app/component/searchby/searchby.component.ts @@ -0,0 +1,52 @@ +import {Component, OnInit} from '@angular/core'; +import {FormBuilder, FormGroup, Validators} from '@angular/forms'; +import {FetchProgramByTypeService} from '../../services/program/search/fetch-program-by-type.service'; +import {Program} from '../program-displayer/program'; + +@Component({ + selector: 'app-searchby', + templateUrl: './searchby.component.html', + styleUrls: ['./searchby.component.css'] +}) +export class SearchbyComponent implements OnInit { + + constructor(private formBuilder: FormBuilder, private searchProgramService: FetchProgramByTypeService) { + } + + SearchForm: FormGroup; + + loading = false; + submitted = false; + + programs: object; + + error = ''; + + onSubmit() { + this.submitted = true; + + // stop here if form is invalid + if (this.SearchForm.invalid) { + return; + } + + this.searchProgramService.getPrograms('title', this.f.search.value).subscribe((data: Program[]) => { + this.programs = data; + this.error = ''; + }, error1 => { + this.programs = null; + this.error = error1.error; + }); + } + + get f() { + return this.SearchForm.controls; + } + + ngOnInit() { + this.SearchForm = this.formBuilder.group({ + search: ['', Validators.required], + }); + } + +} diff --git a/client/src/app/component/subscription/subscription.component.css b/client/src/app/component/subscription/subscription.component.css new file mode 100644 index 0000000000000000000000000000000000000000..231cd737f2f5cbe1e3eef7613c231d939f3607de --- /dev/null +++ b/client/src/app/component/subscription/subscription.component.css @@ -0,0 +1,9 @@ +* { + color: var(--color-cloud); +} + + +.program-container{ + margin:5rem 10rem 0 10rem; +} + diff --git a/client/src/app/component/subscription/subscription.component.html b/client/src/app/component/subscription/subscription.component.html new file mode 100644 index 0000000000000000000000000000000000000000..293248617134381cd9c82afce5ad6726cf155e13 --- /dev/null +++ b/client/src/app/component/subscription/subscription.component.html @@ -0,0 +1,13 @@ +<div class="container" *ngIf="programs"> + <h1 style="margin:2rem 0 0 2rem;text-align: center">My subscription</h1> +<hr> + <app-card-noneall-displayer [programs]="programs"></app-card-noneall-displayer> + +</div> + +<div *ngIf="programReceivedFailed"> + <h1 style="margin:2rem 0 0 2rem;text-align: center">Oops.. no subscriptions available ..</h1> +</div> + + +<span *ngIf="!programs"><ngx-ui-loader></ngx-ui-loader></span> diff --git a/client/src/app/component/subscription/subscription.component.spec.ts b/client/src/app/component/subscription/subscription.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4a220390bf497d5ad0dfad0e86df2a9d282dc96 --- /dev/null +++ b/client/src/app/component/subscription/subscription.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SubscriptionComponent } from './subscription.component'; + +describe('SubscriptionComponent', () => { + let component: SubscriptionComponent; + let fixture: ComponentFixture<SubscriptionComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ SubscriptionComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(SubscriptionComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/subscription/subscription.component.ts b/client/src/app/component/subscription/subscription.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..b611463b96c2f0ae42d3b62bc4526969c1b183c8 --- /dev/null +++ b/client/src/app/component/subscription/subscription.component.ts @@ -0,0 +1,38 @@ +import {Component, OnInit} from '@angular/core'; +import {Program} from '../program-displayer/program'; +import {NgxUiLoaderService} from 'ngx-ui-loader'; +import {AuthenticationService} from '../../services/auth/authentication.service'; +import {ProgramSubscriptionService} from '../../services/program/subs/program-subscription.service'; + +@Component({ + selector: 'app-subscription', + templateUrl: './subscription.component.html', + styleUrls: ['./subscription.component.css'] +}) +export class SubscriptionComponent implements OnInit { + + programs: Program[]; + programReceivedFailed = false; + + constructor(private programSubscription: ProgramSubscriptionService, private ngxLoader: NgxUiLoaderService, private auth: AuthenticationService) { + } + + getProgram(): void { + + this.ngxLoader.start(); + this.programSubscription.getSubscription(this.auth.currentUserValue.id).subscribe((data: Program[]) => { + this.programs = data.filter((x) => x.sensei !== this.auth.currentUserValue.username); + this.ngxLoader.stop(); + }, error1 => { + if (error1.status === 404) { + this.programReceivedFailed = true; + this.ngxLoader.stop(); + } + }); + } + + ngOnInit() { + this.getProgram(); + } + +} diff --git a/client/src/app/component/terminal-assert/terminal-assert.component.html b/client/src/app/component/terminal-assert/terminal-assert.component.html new file mode 100644 index 0000000000000000000000000000000000000000..860def6b6d98e1e2a0d068659ca54cf40d22edf0 --- /dev/null +++ b/client/src/app/component/terminal-assert/terminal-assert.component.html @@ -0,0 +1 @@ +<ace-editor [readOnly]="true" [mode]="type" [(text)]="code" #editor></ace-editor> diff --git a/client/src/app/component/terminal-assert/terminal-assert.component.scss b/client/src/app/component/terminal-assert/terminal-assert.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..39f409d93c6234fc1c3fd86dbcc5832bc536980a --- /dev/null +++ b/client/src/app/component/terminal-assert/terminal-assert.component.scss @@ -0,0 +1,9 @@ +ace-editor{ + width:500px; + height: 300px; + border-radius: 6px; + font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; + border: 2px solid rgba(44, 62, 80, 1.0); + margin-right: 20px; + padding: 10px; +} diff --git a/client/src/app/component/terminal-assert/terminal-assert.component.spec.ts b/client/src/app/component/terminal-assert/terminal-assert.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..408c8aa04931f9cf344f09108f3a4e966212c67e --- /dev/null +++ b/client/src/app/component/terminal-assert/terminal-assert.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TerminalAssertComponent } from './terminal-assert.component'; + +describe('TerminalAssertComponent', () => { + let component: TerminalAssertComponent; + let fixture: ComponentFixture<TerminalAssertComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TerminalAssertComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TerminalAssertComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/terminal-assert/terminal-assert.component.ts b/client/src/app/component/terminal-assert/terminal-assert.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..3cac49a2d5bc0e2183bcf80a1bd5fa4896efe7ea --- /dev/null +++ b/client/src/app/component/terminal-assert/terminal-assert.component.ts @@ -0,0 +1,26 @@ +import {AfterViewInit, Component, Input, ViewChild} from '@angular/core'; +import 'brace'; +import 'brace/theme/dracula'; +import 'brace/mode/python'; +import 'brace/mode/java'; +import 'brace/mode/plain_text'; + +@Component({ + selector: 'app-terminal-assert', + templateUrl: './terminal-assert.component.html', + styleUrls: ['./terminal-assert.component.scss'] +}) +export class TerminalAssertComponent implements AfterViewInit { + + @ViewChild('editor') editor; + @Input() code: string; + @Input() type: string; + + ngAfterViewInit() { + this.editor.setTheme('dracula'); + this.editor.getEditor().setOptions({ + enableBasicAutocompletion: true, + highlightActiveLine: false + }); + } +} diff --git a/client/src/app/component/terminal-code/terminal-code.component.html b/client/src/app/component/terminal-code/terminal-code.component.html new file mode 100644 index 0000000000000000000000000000000000000000..bb8fe6116690605222ab745312fb1fe790a6df54 --- /dev/null +++ b/client/src/app/component/terminal-code/terminal-code.component.html @@ -0,0 +1 @@ +<ace-editor [readOnly]="false" [mode]="type" (textChanged)="onChange($event)" [autoUpdateContent]="true" [(text)]="code" [durationBeforeCallback]="200" #editor></ace-editor> diff --git a/client/src/app/component/terminal-code/terminal-code.component.scss b/client/src/app/component/terminal-code/terminal-code.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..8ee76d770aa575af02e78dcb0de1ccf0e3d1d12d --- /dev/null +++ b/client/src/app/component/terminal-code/terminal-code.component.scss @@ -0,0 +1,9 @@ +ace-editor{ + width:500px; + height: 300px; + border-radius: 6px; + font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; + border: 2px solid rgba(44, 62, 80, 1.0); + padding: 10px; + +} diff --git a/client/src/app/component/terminal-code/terminal-code.component.spec.ts b/client/src/app/component/terminal-code/terminal-code.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..08e046968b3bfee61314bd8248096c67053ab7cc --- /dev/null +++ b/client/src/app/component/terminal-code/terminal-code.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TerminalCodeComponent } from './terminal-code.component'; + +describe('TerminalCodeComponent', () => { + let component: TerminalCodeComponent; + let fixture: ComponentFixture<TerminalCodeComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TerminalCodeComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TerminalCodeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/terminal-code/terminal-code.component.ts b/client/src/app/component/terminal-code/terminal-code.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..fa2516aabb6e7d4d0136a092cccbd414bfa53ebd --- /dev/null +++ b/client/src/app/component/terminal-code/terminal-code.component.ts @@ -0,0 +1,29 @@ +import {AfterViewInit, Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; +import 'brace'; +import 'brace/theme/dracula'; +import 'brace/mode/python'; +import 'brace/mode/java'; +import 'brace/mode/plain_text'; + +@Component({ + selector: 'app-terminal-code', + templateUrl: './terminal-code.component.html', + styleUrls: ['./terminal-code.component.scss'] +}) + +export class TerminalCodeComponent implements AfterViewInit { + + @ViewChild('editor') editor; + @Input() code: string; + @Input() type: string; + @Output() new = new EventEmitter<string>(); + + onChange(code) { + this.new.emit(code); + this.code = code; + } + + ngAfterViewInit() { + this.editor.setTheme('dracula'); + } +} diff --git a/client/src/app/app.component.css b/client/src/app/component/user/profil-card/profil-card.component.css similarity index 100% rename from client/src/app/app.component.css rename to client/src/app/component/user/profil-card/profil-card.component.css diff --git a/client/src/app/component/user/profil-card/profil-card.component.html b/client/src/app/component/user/profil-card/profil-card.component.html new file mode 100644 index 0000000000000000000000000000000000000000..1edafbd95d7b3833d5ad26078ee30717ec969461 --- /dev/null +++ b/client/src/app/component/user/profil-card/profil-card.component.html @@ -0,0 +1,3 @@ +<mat-card> + <mat-card-title>Hey !</mat-card-title> +</mat-card> diff --git a/client/src/app/component/user/profil-card/profil-card.component.spec.ts b/client/src/app/component/user/profil-card/profil-card.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..f827463e9f954cc089991829af735b5345f1a0d1 --- /dev/null +++ b/client/src/app/component/user/profil-card/profil-card.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProfilCardComponent } from './profil-card.component'; + +describe('ProfilCardComponent', () => { + let component: ProfilCardComponent; + let fixture: ComponentFixture<ProfilCardComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ProfilCardComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ProfilCardComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/component/user/profil-card/profil-card.component.ts b/client/src/app/component/user/profil-card/profil-card.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..b50a8347aff110721c01ac138063261ebb02e8e2 --- /dev/null +++ b/client/src/app/component/user/profil-card/profil-card.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-profil-card', + templateUrl: './profil-card.component.html', + styleUrls: ['./profil-card.component.css'] +}) +export class ProfilCardComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/client/src/app/interfaces/subscriptions/KataSubscription.ts b/client/src/app/interfaces/subscriptions/KataSubscription.ts new file mode 100644 index 0000000000000000000000000000000000000000..511e26d431ea0c10cc6081af800d302bb7601e8b --- /dev/null +++ b/client/src/app/interfaces/subscriptions/KataSubscription.ts @@ -0,0 +1,7 @@ +export interface KataSubscription { + _id: string; + id: string; + status: string; + mysol: string; + nbAttempt: number; +} diff --git a/client/src/app/interfaces/subscriptions/ProgramSubscription.ts b/client/src/app/interfaces/subscriptions/ProgramSubscription.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ae38ba695b0e8d0f64f87d234041350230c2932 --- /dev/null +++ b/client/src/app/interfaces/subscriptions/ProgramSubscription.ts @@ -0,0 +1,11 @@ +import {KataSubscription} from './KataSubscription'; + +export interface ProgramSubscription { + _id: string; + id: string; + iduser: string; + idprogram: string; + status: boolean; + nbKataDone: number; + katas: KataSubscription; +} diff --git a/client/src/app/languages_canvas.ts b/client/src/app/languages_canvas.ts new file mode 100644 index 0000000000000000000000000000000000000000..75ce14c9cba75e7e872a8208ad28557a455ffb28 --- /dev/null +++ b/client/src/app/languages_canvas.ts @@ -0,0 +1,34 @@ +export class Canva { + id: string; + assertCanva: string; + codeCanva: string; + filename: string; + assertname: string; +} + + +// TODO un kata n'a pas besoin de programtitile, ca devrait être passé par la classe d'en dessus (idem pour sensei) +export const LANG: Canva[] = [ + { + id: 'python', + assertCanva: 'from assertpy import assert_that\nimport sample as m' + '\n\n' + + '# Example : \n# assert_that(m.yourfunction(someValues)).is_equal_to(targetedValues)', + codeCanva: '# Write your code here', + filename: 'sample.py', + assertname: 'assert.py' + }, + { + id: 'java', assertCanva: 'import static org.junit.Assert.*;\n' + + '\n' + + 'public class Main {\n' + + '\n' + + ' public static void main(String[] args) {\n\n' + + '// Example : \n// assertEquals(Kata.yourfunction(someValues,targetedValues))' + + ' \n\n }\n' + + '}', codeCanva: 'public class Kata {\n' + + '\n' + + '}\n', + assertname: 'Main.java', + filename: 'kata.java' + } +]; diff --git a/client/src/app/services/LANG/lang.service.spec.ts b/client/src/app/services/LANG/lang.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..f6a3ea99d3891166fead476126bf15b7c0c231a1 --- /dev/null +++ b/client/src/app/services/LANG/lang.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { LANGService } from './lang.service'; + +describe('LANGService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: LANGService = TestBed.get(LANGService); + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/services/LANG/lang.service.ts b/client/src/app/services/LANG/lang.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9bb11a47a5fee7650290d49b8fb4f8a8f115fcd --- /dev/null +++ b/client/src/app/services/LANG/lang.service.ts @@ -0,0 +1,15 @@ +import {Injectable} from '@angular/core'; +import {Canva, LANG} from '../../languages_canvas'; + +@Injectable({ + providedIn: 'root' +}) +export class LANGService { + + getLANG(id: string): Canva[] { + return LANG.filter(x => x.id === id); + } + + constructor() { + } +} diff --git a/client/src/app/services/auth/authentication.service.spec.ts b/client/src/app/services/auth/authentication.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..91a1e97ea6661ea90fe386592be2403ebc0aed20 --- /dev/null +++ b/client/src/app/services/auth/authentication.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { AuthenticationService } from './authentication.service'; + +describe('AuthenticationService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: AuthenticationService = TestBed.get(AuthenticationService); + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/services/auth/authentication.service.ts b/client/src/app/services/auth/authentication.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..f327743ad4bcc244be147043c852786a24197957 --- /dev/null +++ b/client/src/app/services/auth/authentication.service.ts @@ -0,0 +1,38 @@ +import {Injectable} from '@angular/core'; +import {HttpClient} from '@angular/common/http'; +import {map} from 'rxjs/operators'; +import {User} from '../../_helper/_models/user'; +import {BehaviorSubject, Observable} from 'rxjs'; + +@Injectable({providedIn: 'root'}) +export class AuthenticationService { + private currentUserSubject: BehaviorSubject<User>; + public currentUser: Observable<User>; + + constructor(private http: HttpClient) { + this.currentUserSubject = new BehaviorSubject<User>(JSON.parse(localStorage.getItem('currentUser'))); + this.currentUser = this.currentUserSubject.asObservable(); + } + + public get currentUserValue(): User { + return this.currentUserSubject.value; + } + + login(username: string, password: string) { + return this.http.post<any>('http://localhost:7000/jwt/request/', {username, password}) + .pipe(map(user => { + // login successful if there's a jwt token in the response + if (user && user.token) { + // store user details and jwt token in local storage to keep user logged in between page refreshes + localStorage.setItem('currentUser', JSON.stringify(user)); + } + return user; + })); + } + + logout() { + // remove user from local storage to log user out + console.log('deleted current user from local storage'); + localStorage.removeItem('currentUser'); + } +} diff --git a/client/src/app/services/compilation/compilation.service.spec.ts b/client/src/app/services/compilation/compilation.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..bc52e8f21e97726e1e73803a410f237745910acb --- /dev/null +++ b/client/src/app/services/compilation/compilation.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { CompilationService } from './compilation.service'; + +describe('CompilationService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: CompilationService = TestBed.get(CompilationService); + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/services/compilation/compilation.service.ts b/client/src/app/services/compilation/compilation.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..35844fd747051ddb9d1a5451515b931a67972404 --- /dev/null +++ b/client/src/app/services/compilation/compilation.service.ts @@ -0,0 +1,15 @@ +import {Injectable} from '@angular/core'; +import {HttpClient} from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class CompilationService { + + compilationServer(obj: string) { + return this.http.post('http://localhost:7000/run/', obj); + } + + constructor(private http: HttpClient) { + } +} diff --git a/client/src/app/services/jwt-request/request-jwt.service.spec.ts b/client/src/app/services/jwt-request/request-jwt.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..63595f72c7edf6317c2998a414df8abbbbeca224 --- /dev/null +++ b/client/src/app/services/jwt-request/request-jwt.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { RequestJwtService } from './request-jwt.service'; + +describe('RequestJwtService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: RequestJwtService = TestBed.get(RequestJwtService); + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/services/jwt-request/request-jwt.service.ts b/client/src/app/services/jwt-request/request-jwt.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c35319152d43ab2014f8c48a9d0f88b94b5c777 --- /dev/null +++ b/client/src/app/services/jwt-request/request-jwt.service.ts @@ -0,0 +1,17 @@ +import {Injectable} from '@angular/core'; +import {HttpClient} from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class RequestJwtService { + + constructor(private http: HttpClient) { + } + + getJWT() { + + return this.http.get('http://localhost:7000/jwt/request/Shodai/Shodai'); + + } +} diff --git a/client/src/app/services/kata/kata-subscription.service.spec.ts b/client/src/app/services/kata/kata-subscription.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..7a793d45f35faafb077f9fa11d813f1942b3fdc8 --- /dev/null +++ b/client/src/app/services/kata/kata-subscription.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { KataSubscriptionService } from './kata-subscription.service'; + +describe('KataSubscriptionService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: KataSubscriptionService = TestBed.get(KataSubscriptionService); + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/services/kata/kata-subscription.service.ts b/client/src/app/services/kata/kata-subscription.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..45c3d54c7eb199faa28ce34084e5aa83add555d7 --- /dev/null +++ b/client/src/app/services/kata/kata-subscription.service.ts @@ -0,0 +1,28 @@ +import {Injectable} from '@angular/core'; +import {HttpClient} from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class KataSubscriptionService { + + create(obj: string) { + return this.http.post('http://localhost:7000/kata/create/subscription', obj); + } + + increment(obj: string) { + return this.http.post('http://localhost:7000/kata/inc/subscription', obj); + + } + + get(kataid: string, programid: string, userid: string) { + return this.http.get('http://localhost:7000/kata/get/subscriptioninfos/' + userid + '/' + programid + '/' + kataid); + } + + update(obj: string) { + return this.http.post('http://localhost:7000/kata/update/subscription', obj); + } + + constructor(private http: HttpClient) { + } +} diff --git a/client/src/app/services/kata/kata.service.spec.ts b/client/src/app/services/kata/kata.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..3865a0471fd408b016ce06c2b28288cb44482ddb --- /dev/null +++ b/client/src/app/services/kata/kata.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { KataService } from './kata.service'; + +describe('KataService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: KataService = TestBed.get(KataService); + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/services/kata/kata.service.ts b/client/src/app/services/kata/kata.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..a8b6aa8602df4cc22d6e6777a18ac067452f646d --- /dev/null +++ b/client/src/app/services/kata/kata.service.ts @@ -0,0 +1,23 @@ +import {Injectable} from '@angular/core'; +import {HttpClient} from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class KataService { + + publish(obj: string) { + return this.http.post('http://localhost:7000/kata/create', obj); + } + + getKatasDetails(program: string, userid: string) { + return this.http.get('http://localhost:7000/program/getkatas/details/' + program + '/' + userid); + } + + getKata(programID: string, kataID: string) { + return this.http.get('http://localhost:7000/program/getkata/' + programID + '/' + kataID + ''); + } + + constructor(private http: HttpClient) { + } +} diff --git a/client/src/app/services/program/program.service.spec.ts b/client/src/app/services/program/program.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..7eacf5d3e0cadeee01cfca6f0a4786ae6a798466 --- /dev/null +++ b/client/src/app/services/program/program.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { ProgramService } from './program.service'; + +describe('ProgramService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: ProgramService = TestBed.get(ProgramService); + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/services/program/program.service.ts b/client/src/app/services/program/program.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..e27a9295213c8df238b99e7e6196ba14ea96dd9a --- /dev/null +++ b/client/src/app/services/program/program.service.ts @@ -0,0 +1,27 @@ +import {Injectable} from '@angular/core'; +import {HttpClient} from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class ProgramService { + + createProgram(obj: string) { + return this.http.post('http://localhost:7000/program/create', obj); + } + + getPrograms() { + return this.http.get('http://localhost:7000/program/getdetails'); + } + + getDetails(id: string) { + return this.http.get('http://localhost:7000/program/getdetails/' + id + ''); + } + + deleteProgram(id: string) { + return this.http.post('http://localhost:7000/program/delete', JSON.stringify({programid: id})); + } + + constructor(private http: HttpClient) { + } +} diff --git a/client/src/app/services/program/search/fetch-program-by-type.service.spec.ts b/client/src/app/services/program/search/fetch-program-by-type.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..4de85aedb3cca06ef9022fb845b9b56ebab43956 --- /dev/null +++ b/client/src/app/services/program/search/fetch-program-by-type.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { FetchProgramByTypeService } from './fetch-program-by-type.service'; + +describe('FetchProgramByTypeService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: FetchProgramByTypeService = TestBed.get(FetchProgramByTypeService); + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/services/program/search/fetch-program-by-type.service.ts b/client/src/app/services/program/search/fetch-program-by-type.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..11466faabaf381ee974eee54aec64f4385d4bee2 --- /dev/null +++ b/client/src/app/services/program/search/fetch-program-by-type.service.ts @@ -0,0 +1,16 @@ +import {Injectable} from '@angular/core'; +import {HttpClient} from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class FetchProgramByTypeService { + + getPrograms(type: string, res: string) { + return this.http.get('http://localhost:7000/search/' + type + '/' + res); + } + + + constructor(private http: HttpClient) { + } +} diff --git a/client/src/app/services/program/subs/program-subscription.service.spec.ts b/client/src/app/services/program/subs/program-subscription.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..d36df49a3d19a03cbc918fc9dc30f3690d044dc2 --- /dev/null +++ b/client/src/app/services/program/subs/program-subscription.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { ProgramSubscriptionService } from './program-subscription.service'; + +describe('ProgramSubscriptionService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: ProgramSubscriptionService = TestBed.get(ProgramSubscriptionService); + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/services/program/subs/program-subscription.service.ts b/client/src/app/services/program/subs/program-subscription.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5c40ec5ba5c1633be20839c2857163fb43524cc --- /dev/null +++ b/client/src/app/services/program/subs/program-subscription.service.ts @@ -0,0 +1,31 @@ +import { Injectable } from '@angular/core'; +import {HttpClient} from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class ProgramSubscriptionService { + + createSubscription(obj: string) { + return this.http.post('http://localhost:7000/program/createsubscription', obj); + } + + getMine(userid: string) { + return this.http.get('http://localhost:7000/subscription/mine/' + userid + ''); + } + + getSubscription(userid: string) { + return this.http.get('http://localhost:7000/subscription/get/' + userid); + } + + getSubs(programid: string, userid: string) { + return this.http.get('http://localhost:7000/program/getsubscription/' + programid + '/' + userid + ''); + } + + toggle(obj: string) { + return this.http.post('http://localhost:7000/program/togglesubscription/', obj); + } + + constructor(private http: HttpClient) { + } +} diff --git a/client/src/index.html b/client/src/index.html index 87d768a7d41fe1a761a567838e925187324773f3..09fb83295ffbde884f3dc33ca2f2331debe07171 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -7,6 +7,8 @@ <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="favicon.ico"> + <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet"> + <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> </head> <body> <app-root></app-root> diff --git a/client/src/main.ts b/client/src/main.ts index c7b673cf44b388e9989fe908b78d7d73cd2e1409..3b2b7d07c9506a1c897baeebbb8bdde70958b08e 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -1,3 +1,4 @@ +import 'hammerjs'; import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; diff --git a/client/src/styles.css b/client/src/styles.css deleted file mode 100644 index 90d4ee0072ce3fc41812f8af910219f9eea3c3de..0000000000000000000000000000000000000000 --- a/client/src/styles.css +++ /dev/null @@ -1 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ diff --git a/client/src/styles.scss b/client/src/styles.scss new file mode 100644 index 0000000000000000000000000000000000000000..7f7ca8724520992f877b4a0f79c93c589ba16bec --- /dev/null +++ b/client/src/styles.scss @@ -0,0 +1,64 @@ +/* You can add global styles to this file, and also import other style files */ + +html, body { + height: 100%; + --color-cloud: rgba(236, 240, 241, 1); + --color-dark-blue: rgba(43, 47, 57, 1); + --color-light-blue: rgba(63, 67, 77, 1); + --color-soft-light-blue: rgba(47, 54, 64, 1); + --color-button-hover: rgba(52, 73, 94, 1.0); + --color-button-active: rgba(45, 66, 87, 1.0); + --color-language: rgba(230, 126, 34, 1); + --color-language-hover: rgba(210, 106, 14, 1.0); + --color-dark-grey: #6c757d; + --color-amethyst:rgba(155, 89, 182,1.0); + --color-emerald: rgba(52, 73, 94,1.0); + --color-sunflower: rgba(241, 196, 15,1.0); + --color-electro : rgba(38, 42, 52, 1); +} + +body { + margin: 0; + font-family: Roboto, "Helvetica Neue", sans-serif; +} + +.NOTFOUND { + color: rgba(83, 87, 97, 1); + font-size: 50px; +} +/* +.button { + background-color: var(--color-dark-blue); + border: 0; + padding: .4em .7em .4em .7em; + border-radius: .4em; + color: var(--color-cloud); + + +} + +.button:hover { + background-color: var(--color-button-hover); +} + +.button:focus { + outline: none; +} + +.button:active { + background-color: var(--color-button-active); +}*/ + +:focus { + outline: none; +} +button:focus{ + outline:none; +} +:active{ + outline: none; +} + +hr{ + border: 1px solid var(--color-dark-blue); +} diff --git a/compilation/.idea/compiler.xml b/compilation/.idea/compiler.xml new file mode 100644 index 0000000000000000000000000000000000000000..9e7b9fd57fe9ac0402fda14843a0f8fc00493b0e --- /dev/null +++ b/compilation/.idea/compiler.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CompilerConfiguration"> + <annotationProcessing> + <profile name="Maven default annotation processors profile" enabled="true"> + <sourceOutputDir name="target/generated-sources/annotations" /> + <sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> + <outputRelativeToContentRoot value="true" /> + <module name="05" /> + <module name="serveur_compilation_new" /> + </profile> + </annotationProcessing> + </component> +</project> \ No newline at end of file diff --git a/compilation/.idea/misc.xml b/compilation/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..6d752e8be6c71125a532e49eb36d37e9e32d89af --- /dev/null +++ b/compilation/.idea/misc.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ExternalStorageConfigurationManager" enabled="true" /> + <component name="MavenProjectsManager"> + <option name="originalFiles"> + <list> + <option value="$PROJECT_DIR$/pom.xml" /> + </list> + </option> + </component> + <component name="ProjectRootManager" version="2" languageLevel="JDK_12" project-jdk-name="12" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/out" /> + </component> +</project> \ No newline at end of file diff --git a/compilation/.idea/sbt.xml b/compilation/.idea/sbt.xml new file mode 100644 index 0000000000000000000000000000000000000000..20187435474e5ee4a31e9f6fdd531957b1ba89e3 --- /dev/null +++ b/compilation/.idea/sbt.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ScalaSbtSettings"> + <option name="customVMPath" /> + </component> +</project> \ No newline at end of file diff --git a/compilation/.idea/uiDesigner.xml b/compilation/.idea/uiDesigner.xml new file mode 100644 index 0000000000000000000000000000000000000000..e96534fb27b68192f27f985d3879e173ec77adb8 --- /dev/null +++ b/compilation/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="Palette2"> + <group name="Swing"> + <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> + </item> + <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> + </item> + <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true"> + <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> + <initial-values> + <property name="text" value="Button" /> + </initial-values> + </item> + <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="RadioButton" /> + </initial-values> + </item> + <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="CheckBox" /> + </initial-values> + </item> + <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="Label" /> + </initial-values> + </item> + <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> + <preferred-size width="200" height="200" /> + </default-constraints> + </item> + <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> + <preferred-size width="200" height="200" /> + </default-constraints> + </item> + <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" /> + </item> + <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1"> + <preferred-size width="-1" height="20" /> + </default-constraints> + </item> + <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" /> + </item> + <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> + </item> + </group> + </component> +</project> \ No newline at end of file diff --git a/compilation/.idea/vcs.xml b/compilation/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..9378d6dc69935724d288f515b9f8acb449bdb08d --- /dev/null +++ b/compilation/.idea/vcs.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$USER_HOME$" vcs="Git" /> + <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/compilation/.idea/workspace.xml b/compilation/.idea/workspace.xml new file mode 100644 index 0000000000000000000000000000000000000000..714e61bf531f18157adf03f92475899fb8cbf679 --- /dev/null +++ b/compilation/.idea/workspace.xml @@ -0,0 +1,442 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ChangeListManager"> + <list default="true" id="8d8fb2c1-8426-4933-8193-ee68625cf8de" name="Default Changelist" comment=""> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/kata/kata.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/kata/kata.component.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/mine/mine.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/mine/mine.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-displayer/card-displayer.component.css" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-displayer/card-displayer.component.css" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.css" beforeDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/program-displayer.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/program-displayer/program-displayer.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/subscription/subscription.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/subscription/subscription.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/styles.scss" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/styles.scss" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/share_docker_file/Kata.class" beforeDir="false" afterPath="$PROJECT_DIR$/share_docker_file/Kata.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/share_docker_file/Main.class" beforeDir="false" afterPath="$PROJECT_DIR$/share_docker_file/Main.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/main/java/DockerCompilation.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/DockerCompilation.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../gateway/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/.idea/workspace.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../gateway/src/main/java/LiveDB.java" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/src/main/java/LiveDB.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../gateway/src/main/java/MongoDB.java" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/src/main/java/MongoDB.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../gateway/src/main/java/ProgramShowCase.java" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/src/main/java/ProgramShowCase.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../gateway/src/main/java/app.java" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/src/main/java/app.java" afterDir="false" /> + </list> + <ignored path="$PROJECT_DIR$/out/" /> + <ignored path="$PROJECT_DIR$/target/" /> + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> + <option name="SHOW_DIALOG" value="false" /> + <option name="HIGHLIGHT_CONFLICTS" value="true" /> + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> + <option name="LAST_RESOLUTION" value="IGNORE" /> + </component> + <component name="DefaultGradleProjectSettings"> + <option name="isMigrated" value="true" /> + </component> + <component name="FileEditorManager"> + <leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> + <file pinned="false" current-in-tab="true"> + <entry file="file://$PROJECT_DIR$/src/main/java/DockerCompilation.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="45"> + <caret line="6" column="67" lean-forward="true" selection-start-line="6" selection-start-column="67" selection-end-line="6" selection-end-column="67" /> + </state> + </provider> + </entry> + </file> + </leaf> + </component> + <component name="FileTemplateManagerImpl"> + <option name="RECENT_TEMPLATES"> + <list> + <option value="Class" /> + </list> + </option> + </component> + <component name="Git.Settings"> + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." /> + </component> + <component name="IdeDocumentHistory"> + <option name="CHANGED_PATHS"> + <list> + <option value="$PROJECT_DIR$/share_docker_file/Main.java" /> + <option value="$PROJECT_DIR$/src/main/java/compilation.java" /> + <option value="$PROJECT_DIR$/src/main/java/Docker_compilation.java" /> + <option value="$PROJECT_DIR$/docker/java/.bashrc" /> + <option value="$PROJECT_DIR$/share_docker_file/java_test.sh" /> + <option value="$PROJECT_DIR$/docker/java/java_test.sh" /> + <option value="$PROJECT_DIR$/docker/java/dockerfile" /> + <option value="$PROJECT_DIR$/src/main/java/HostCompilation.java" /> + <option value="$PROJECT_DIR$/pom.xml" /> + <option value="$PROJECT_DIR$/src/main/java/DockerCompilation.java" /> + </list> + </option> + </component> + <component name="MavenImportPreferences"> + <option name="importingSettings"> + <MavenImportingSettings> + <option name="importAutomatically" value="true" /> + </MavenImportingSettings> + </option> + </component> + <component name="ProjectFrameBounds" fullScreen="true"> + <option name="y" value="23" /> + <option name="width" value="1920" /> + <option name="height" value="1121" /> + </component> + <component name="ProjectLevelVcsManager" settingsEditedManually="true" /> + <component name="ProjectView"> + <navigator proportions="" version="1"> + <foldersAlwaysOnTop value="true" /> + </navigator> + <panes> + <pane id="PackagesPane" /> + <pane id="Scope" /> + <pane id="ProjectPane"> + <subPane> + <expand> + <path> + <item name="compilation" type="b2602c69:ProjectViewProjectNode" /> + <item name="compilation" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="compilation" type="b2602c69:ProjectViewProjectNode" /> + <item name="compilation" type="462c0819:PsiDirectoryNode" /> + <item name="share_docker_file" type="462c0819:PsiDirectoryNode" /> + </path> + </expand> + <select /> + </subPane> + </pane> + </panes> + </component> + <component name="PropertiesComponent"> + <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> + <property name="WebServerToolWindowFactoryState" value="false" /> + <property name="aspect.path.notification.shown" value="true" /> + <property name="last_opened_file_path" value="$PROJECT_DIR$" /> + <property name="node.js.detected.package.eslint" value="true" /> + <property name="node.js.path.for.package.eslint" value="project" /> + <property name="node.js.selected.package.eslint" value="(autodetect)" /> + <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> + <property name="nodejs_npm_path_reset_for_default_project" value="true" /> + <property name="project.structure.last.edited" value="Modules" /> + <property name="project.structure.proportion" value="0.15" /> + <property name="project.structure.side.proportion" value="0.2" /> + <property name="restartRequiresConfirmation" value="false" /> + </component> + <component name="RecentsManager"> + <key name="MoveFile.RECENT_KEYS"> + <recent name="$PROJECT_DIR$/docker/java/files" /> + <recent name="$PROJECT_DIR$/docker/java" /> + </key> + <key name="CopyFile.RECENT_KEYS"> + <recent name="$PROJECT_DIR$/share_docker_file" /> + <recent name="$PROJECT_DIR$/src/main/java" /> + </key> + </component> + <component name="RunDashboard"> + <option name="ruleStates"> + <list> + <RuleState> + <option name="name" value="ConfigurationTypeDashboardGroupingRule" /> + </RuleState> + <RuleState> + <option name="name" value="StatusDashboardGroupingRule" /> + </RuleState> + </list> + </option> + </component> + <component name="RunManager"> + <configuration name="app" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> + <option name="MAIN_CLASS_NAME" value="app" /> + <module name="05" /> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + <recent_temporary> + <list> + <item itemvalue="Application.app" /> + </list> + </recent_temporary> + </component> + <component name="SbtLocalSettings"> + <option name="projectSyncType"> + <map> + <entry key="$PROJECT_DIR$/../../scalatra/scala_heroes_provider/my-scalatra-web-app" value="PREVIEW" /> + <entry key="$PROJECT_DIR$/../../scalatra/scalatra_heroes_provider" value="PREVIEW" /> + </map> + </option> + </component> + <component name="SvnConfiguration"> + <configuration /> + </component> + <component name="TaskManager"> + <task active="true" id="Default" summary="Default task"> + <changelist id="8d8fb2c1-8426-4933-8193-ee68625cf8de" name="Default Changelist" comment="" /> + <created>1556635807220</created> + <option name="number" value="Default" /> + <option name="presentableId" value="Default" /> + <updated>1556635807220</updated> + <workItem from="1556635811007" duration="263000" /> + <workItem from="1556699075828" duration="2375000" /> + <workItem from="1556724368190" duration="1020000" /> + <workItem from="1556780851092" duration="1114000" /> + <workItem from="1556782478266" duration="80000" /> + <workItem from="1556798541427" duration="1170000" /> + <workItem from="1556825709873" duration="971000" /> + <workItem from="1556827413018" duration="173000" /> + <workItem from="1556827741611" duration="619000" /> + <workItem from="1556829689470" duration="1450000" /> + <workItem from="1556864756289" duration="5129000" /> + <workItem from="1556875523919" duration="63000" /> + <workItem from="1556881783082" duration="8776000" /> + <workItem from="1556962294332" duration="589000" /> + <workItem from="1557124763282" duration="151000" /> + <workItem from="1557158060665" duration="1580000" /> + <workItem from="1557211629757" duration="2837000" /> + <workItem from="1557298034418" duration="470000" /> + <workItem from="1557322368264" duration="285000" /> + <workItem from="1557323560383" duration="425000" /> + <workItem from="1557391593502" duration="685000" /> + <workItem from="1557503425176" duration="255000" /> + <workItem from="1557730932798" duration="1630000" /> + <workItem from="1557747003109" duration="1499000" /> + <workItem from="1557817028907" duration="3195000" /> + <workItem from="1557833112052" duration="420000" /> + <workItem from="1557842013256" duration="237000" /> + <workItem from="1557902518593" duration="3056000" /> + </task> + <servers /> + </component> + <component name="TimeTrackingManager"> + <option name="totallyTimeSpent" value="40913000" /> + </component> + <component name="TodoView"> + <todo-panel id="selected-file"> + <is-autoscroll-to-source value="true" /> + </todo-panel> + <todo-panel id="all"> + <are-packages-shown value="true" /> + <is-autoscroll-to-source value="true" /> + </todo-panel> + </component> + <component name="ToolWindowManager"> + <frame x="0" y="0" width="1440" height="900" extended-state="6" /> + <layout> + <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.33404863" /> + <window_info id="Structure" order="1" side_tool="true" weight="0.25" /> + <window_info id="Image Layers" order="2" /> + <window_info id="Designer" order="3" /> + <window_info id="UI Designer" order="4" /> + <window_info id="Capture Tool" order="5" /> + <window_info id="Favorites" order="6" side_tool="true" /> + <window_info anchor="bottom" id="Message" order="0" /> + <window_info anchor="bottom" id="Find" order="1" weight="0.32891566" /> + <window_info anchor="bottom" id="Run" order="2" weight="0.48795182" /> + <window_info anchor="bottom" id="Debug" order="3" weight="0.3987952" /> + <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> + <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> + <window_info anchor="bottom" id="TODO" order="6" weight="0.3283186" /> + <window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" /> + <window_info anchor="bottom" id="Version Control" order="8" weight="0.32891566" /> + <window_info anchor="bottom" id="Database Changes" order="9" /> + <window_info anchor="bottom" id="Terminal" order="10" weight="0.24159291" /> + <window_info anchor="bottom" id="Event Log" order="11" side_tool="true" /> + <window_info anchor="bottom" id="Messages" order="12" weight="0.32920355" /> + <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> + <window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> + <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> + <window_info anchor="right" id="Palette" order="3" /> + <window_info anchor="right" id="Database" order="4" /> + <window_info anchor="right" id="Theme Preview" order="5" /> + <window_info anchor="right" id="Maven" order="6" /> + <window_info anchor="right" id="Capture Analysis" order="7" /> + <window_info anchor="right" id="Palette	" order="8" /> + </layout> + </component> + <component name="TypeScriptGeneratedFilesManager"> + <option name="version" value="1" /> + </component> + <component name="XDebuggerManager"> + <breakpoint-manager> + <breakpoints> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/main/java/DockerCompilation.java</url> + <line>86</line> + <properties /> + <option name="timeStamp" value="13" /> + </line-breakpoint> + </breakpoints> + </breakpoint-manager> + <watches-manager> + <configuration name="Application"> + <watch expression="output.equals("")" language="JAVA" /> + <watch expression="error.equals("")" language="JAVA" /> + </configuration> + </watches-manager> + </component> + <component name="debuggerHistoryManager"> + <expressions id="watch"> + <expression> + <expression-string>error.equals("")</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>output.equals("")</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>cmd</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>escapeJava()</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + </expressions> + </component> + <component name="editorHistoryManager"> + <entry file="file://$PROJECT_DIR$/share_docker_file/test.txt" /> + <entry file="file://$PROJECT_DIR$/docker/java/files/java_test.sh" /> + <entry file="file://$PROJECT_DIR$/src/main/java/HostCompilation.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="382"> + <caret line="42" column="40" selection-start-line="42" selection-start-column="34" selection-end-line="42" selection-end-column="40" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/docker/java/dockerfile"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="105"> + <caret line="7" selection-start-line="7" selection-end-line="7" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/docker/java/.bashrc"> + <provider selected="true" editor-type-id="text-editor"> + <state> + <caret column="33" selection-start-column="33" selection-end-column="33" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/share_docker_file/sample.py" /> + <entry file="file://$PROJECT_DIR$/share_docker_file/assert.py" /> + <entry file="file://$PROJECT_DIR$/src/main/java/app.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="195"> + <caret line="14" lean-forward="true" selection-start-line="14" selection-end-line="14" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/pom.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state> + <caret column="22" selection-start-column="22" selection-end-column="22" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/docker/python/dockerfile"> + <provider selected="true" editor-type-id="text-editor"> + <state> + <caret column="17" selection-start-column="17" selection-end-column="17" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/share_docker_file/java_test.sh"> + <provider selected="true" editor-type-id="text-editor" /> + </entry> + <entry file="file://$PROJECT_DIR$/share_docker_file/kata.java" /> + <entry file="file://$PROJECT_DIR$/share_docker_file/Main.java" /> + <entry file="file://$PROJECT_DIR$/src/main/java/DockerCompilation.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="45"> + <caret line="6" column="67" lean-forward="true" selection-start-line="6" selection-start-column="67" selection-end-line="6" selection-end-column="67" /> + </state> + </provider> + </entry> + </component> + <component name="masterDetails"> + <states> + <state key="ArtifactsStructureConfigurable.UI"> + <settings> + <artifact-editor /> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="FacetStructureConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="GlobalLibrariesConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="JdkListConfigurable.UI"> + <settings> + <last-edited>12</last-edited> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="ModuleStructureConfigurable.UI"> + <settings> + <last-edited>05</last-edited> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + <option value="0.6" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="ProjectLibrariesConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + </states> + </component> +</project> \ No newline at end of file diff --git a/compilation/__pycache__/sample.cpython-37.pyc b/compilation/__pycache__/sample.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4fc1f24fa24d2a8f9d515f49a3f31248170c1847 Binary files /dev/null and b/compilation/__pycache__/sample.cpython-37.pyc differ diff --git a/compilation/docker/java/.bashrc b/compilation/docker/java/.bashrc new file mode 100644 index 0000000000000000000000000000000000000000..6b34cbfe2e54e4a828b85fa1870adc78a1d7e6b1 --- /dev/null +++ b/compilation/docker/java/.bashrc @@ -0,0 +1 @@ +export CLASSPATH=junit-4.10.jar:. diff --git a/compilation/docker/java/dockerfile b/compilation/docker/java/dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..286cc6296e3581bacb5994a21dc0018e76b13d44 --- /dev/null +++ b/compilation/docker/java/dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:14.04 + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update && apt-get -y upgrade +RUN apt-get install -y default-jdk + +RUN mkdir /env/ +ADD .bashrc /root/ + +WORKDIR /env/ diff --git a/compilation/docker/java/files.tar b/compilation/docker/java/files.tar new file mode 100644 index 0000000000000000000000000000000000000000..6a6aa7353582f31310fb3701b0b0d3c873707ab5 Binary files /dev/null and b/compilation/docker/java/files.tar differ diff --git a/compilation/docker/python/dockerfile b/compilation/docker/python/dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..44733c5b9be7eb9168efe37f2c2e592852826375 --- /dev/null +++ b/compilation/docker/python/dockerfile @@ -0,0 +1,12 @@ +FROM ubuntu:14.04 + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update && apt-get -y upgrade +RUN apt-get install -y python3-pip python3-dev +RUN pip3 install assertpy + +RUN mkdir /env/ + +WORKDIR /env/ + diff --git a/compilation/pom.xml b/compilation/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..960bbc00e035a30a5715839d9275ad381013f721 --- /dev/null +++ b/compilation/pom.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>05</groupId> + <artifactId>05</artifactId> + <version>1.0-SNAPSHOT</version> + <build> + <plugins> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>java</goal> + </goals> + </execution> + </executions> + <configuration> + <mainClass>app</mainClass> + <cleanupDaemonThreads>false</cleanupDaemonThreads> + </configuration> + </plugin> + + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>8</source> + <target>8</target> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>io.javalin</groupId> + <artifactId>javalin</artifactId> + <version>2.8.0</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <version>1.7.26</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>2.9.8</version> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20180813</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + </dependency> + </dependencies> + +</project> \ No newline at end of file diff --git a/compilation/serveur_compilation_new.iml b/compilation/serveur_compilation_new.iml new file mode 100644 index 0000000000000000000000000000000000000000..78b2cc53b203f0b97534bb1184cdc7b474339fb4 --- /dev/null +++ b/compilation/serveur_compilation_new.iml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4" /> \ No newline at end of file diff --git a/compilation/share_docker_file/Kata.class b/compilation/share_docker_file/Kata.class new file mode 100644 index 0000000000000000000000000000000000000000..b1fa1177342df418b220cff96d8caed53c68d8e0 Binary files /dev/null and b/compilation/share_docker_file/Kata.class differ diff --git a/compilation/share_docker_file/Main.class b/compilation/share_docker_file/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..1851a4bf47c7c830118373aec92396149a74c6f1 Binary files /dev/null and b/compilation/share_docker_file/Main.class differ diff --git a/compilation/share_docker_file/__pycache__/sample.cpython-34.pyc b/compilation/share_docker_file/__pycache__/sample.cpython-34.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eee4e3510d11e77a706e8677a667da70212b8436 Binary files /dev/null and b/compilation/share_docker_file/__pycache__/sample.cpython-34.pyc differ diff --git a/compilation/share_docker_file/java_test.sh b/compilation/share_docker_file/java_test.sh new file mode 100755 index 0000000000000000000000000000000000000000..081d2811c6cf565eb42eaff705ca5fddc6a2d2ca --- /dev/null +++ b/compilation/share_docker_file/java_test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +source /root/.bashrc +javac -classpath ${CLASSPATH} Main.java Kata.java +java Main + + diff --git a/compilation/share_docker_file/junit-4.10.jar b/compilation/share_docker_file/junit-4.10.jar new file mode 100644 index 0000000000000000000000000000000000000000..954851e67d7424440592e8176c4aa034cc46aa85 Binary files /dev/null and b/compilation/share_docker_file/junit-4.10.jar differ diff --git a/compilation/src/main/java/DockerCompilation.java b/compilation/src/main/java/DockerCompilation.java new file mode 100644 index 0000000000000000000000000000000000000000..2efd38f5f0ac32aa04260f3c60c965bc758f6b4c --- /dev/null +++ b/compilation/src/main/java/DockerCompilation.java @@ -0,0 +1,98 @@ +import org.json.JSONObject; + +import java.io.*; +import java.util.HashMap; + +public class DockerCompilation { + public HashMap<String, Object> execute_kata(JSONObject input) { + + + String filename = "", filename_test = "todeleteifitstayslikethis", cmd = "", line, output = "", error = "", dir = System.getProperty("user.dir"); + + switch (input.get("language").toString()) { + case "python": + filename = "share_docker_file/sample.py"; + filename_test = "share_docker_file/assert.py"; + cmd = "docker run --rm --mount type=bind,source=" + dir + "/share_docker_file,dst=/env/ python:1.0 python3 assert.py"; + break; + case "java": + filename = "share_docker_file/kata.java"; + filename_test = "share_docker_file/Main.java"; + cmd = "docker run --rm --mount type=bind,source=" + dir + "/share_docker_file,dst=/env/ java:1.0 ./java_test.sh"; + break; + } + + try (PrintWriter writer = new PrintWriter(filename, "UTF-8")) { + writer.println(input.get("stream")); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + try (PrintWriter writer = new PrintWriter(filename_test, "UTF-8")) { + writer.println(input.get("assert")); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + + long start, elapsed = 0; + Process cmdProc = null; + + try { + start = System.currentTimeMillis(); + cmdProc = Runtime.getRuntime().exec(cmd); + cmdProc.waitFor(); + + // Compute the execute time + elapsed = System.currentTimeMillis() - start; + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + // Create Array lists that will contain output and error values of the executed program + /**************************/ + + try (BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(cmdProc.getInputStream()))) { + while ((line = stdoutReader.readLine()) != null) + output += line + "\n"; + } catch (IOException e) { + e.printStackTrace(); + } + + try (BufferedReader stderrReader = new BufferedReader(new InputStreamReader(cmdProc.getErrorStream()))) { + while ((line = stderrReader.readLine()) != null) + error += line + "\n"; + } catch (IOException e) { + e.printStackTrace(); + } + + /**************************/ + + HashMap<String, Object> json = new HashMap<>(); + + //exit value of the ran program + if (!error.equals("")) + //json.put("exit", cmdProc.exitValue()); + json.put("exit", 1); + else + json.put("exit", 0); + json.put("output", output); + json.put("error", error); + json.put("time", elapsed); + + // For delete purpose, create a File object also targeting sample.py + File file = new File(filename); + file.delete(); + + file = new File(filename_test); + file.delete(); + + return json; + } +} diff --git a/compilation/src/main/java/HostCompilation.java b/compilation/src/main/java/HostCompilation.java new file mode 100644 index 0000000000000000000000000000000000000000..6cc4030d3da9934eb1e59c2d1bcf029fe6911cd1 --- /dev/null +++ b/compilation/src/main/java/HostCompilation.java @@ -0,0 +1,80 @@ +import org.json.JSONObject; + +import java.io.*; +import java.util.HashMap; + +/** + * First version of the compilation server + */ +public class HostCompilation { + + /** + * This method expect a json input which contains at least key 'language' and key 'code' + * @param input JSON object sent by the front-end + * @return stdout output of the executed file + * @throws IOException // for code visibility purpose + */ + public HashMap<String, Object> hostcompilation(JSONObject input) throws IOException, InterruptedException { + + PrintWriter writer = null; + File file = null; + + String filename = ""; + String cmd = ""; + + if (input.get("language").equals("python")) { + // Create a PrintWriter object targeting sample.py + + filename = "sample.py"; + writer = new PrintWriter(filename, "UTF-8"); + cmd = "python " + filename; + + } else if (input.get("language").equals("java")) { + // Create a PrintWriter object targeting sample.py + filename = "app.java"; + writer = new PrintWriter(filename, "UTF-8"); + cmd = "java " + filename; + } + + // For delete purpose, create a File object also targeting sample.py + file = new File(filename); + + // Complex file with tabulation structure for test purpose + writer.println(input.get("stream")); + + // Close the writer, the file has been filled and is ready to be executed + writer.close(); + + long start = System.currentTimeMillis(); + Process cmdProc = Runtime.getRuntime().exec(cmd); + cmdProc.waitFor(); + long elapsed = System.currentTimeMillis() - start; + + // Create Array lists that will contain output and error values of the executed program + /**************************/ + + String line, output = "", error = ""; + BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(cmdProc.getInputStream())); + while ((line = stdoutReader.readLine()) != null) + output += line + "\n"; + + BufferedReader stderrReader = new BufferedReader(new InputStreamReader(cmdProc.getErrorStream())); + while ((line = stderrReader.readLine()) != null) + error += line + "\n"; + + /**************************/ + + HashMap<String, Object> json = new HashMap<>(); + + //exit value of the ran program + json.put("exit", cmdProc.exitValue()); + json.put("output", output); + json.put("error", error); + json.put("time", elapsed); + + file.delete(); + + return json; + } +} + diff --git a/compilation/src/main/java/app.java b/compilation/src/main/java/app.java new file mode 100644 index 0000000000000000000000000000000000000000..a7edb7976cce62a80a7e63cf493b85d28432dd83 --- /dev/null +++ b/compilation/src/main/java/app.java @@ -0,0 +1,14 @@ +import io.javalin.Javalin; +import org.json.JSONObject; + +public class app { + public static void main(String[] args) { + + Javalin app = Javalin.create().enableCorsForAllOrigins().start(6999); + + app.post("/", ctx -> { + DockerCompilation cpl = new DockerCompilation(); + ctx.json(cpl.execute_kata(new JSONObject(ctx.body()))); + }); + } +} diff --git a/compilation/target/05-1.0-SNAPSHOT.jar b/compilation/target/05-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..fa2e926592bbfc6c72468ce3938fb933d01d8676 Binary files /dev/null and b/compilation/target/05-1.0-SNAPSHOT.jar differ diff --git a/compilation/target/classes/DockerCompilation.class b/compilation/target/classes/DockerCompilation.class new file mode 100644 index 0000000000000000000000000000000000000000..a0c134b4c750980a63932588459f4250ff42af6c Binary files /dev/null and b/compilation/target/classes/DockerCompilation.class differ diff --git a/compilation/target/classes/HostCompilation.class b/compilation/target/classes/HostCompilation.class new file mode 100644 index 0000000000000000000000000000000000000000..298d88619445dcde43a2f193a505e6b1acb19417 Binary files /dev/null and b/compilation/target/classes/HostCompilation.class differ diff --git a/compilation/target/classes/app.class b/compilation/target/classes/app.class new file mode 100644 index 0000000000000000000000000000000000000000..4119c2d9c2e4787ee16109db9d7abacdf6b4c9e3 Binary files /dev/null and b/compilation/target/classes/app.class differ diff --git a/compilation/target/maven-archiver/pom.properties b/compilation/target/maven-archiver/pom.properties new file mode 100644 index 0000000000000000000000000000000000000000..5f6ddc19ad7d2fbb1848bc2affeb6f0be0b531a8 --- /dev/null +++ b/compilation/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Thu May 09 10:37:19 CEST 2019 +groupId=05 +artifactId=05 +version=1.0-SNAPSHOT diff --git a/compilation/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/compilation/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..671eb213e52ca20e888f0ec70b4e301ce786fb0f --- /dev/null +++ b/compilation/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,3 @@ +DockerCompilation.class +HostCompilation.class +app.class diff --git a/compilation/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/compilation/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..9b150db2aaa519a19d1139f0baa7bc2a6340282d --- /dev/null +++ b/compilation/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,3 @@ +/Users/freak/Desktop/dojo-hepia/compilation/src/main/java/HostCompilation.java +/Users/freak/Desktop/dojo-hepia/compilation/src/main/java/app.java +/Users/freak/Desktop/dojo-hepia/compilation/src/main/java/DockerCompilation.java diff --git a/compilation/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/compilation/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/gateway/.idea/compiler.xml b/gateway/.idea/compiler.xml new file mode 100644 index 0000000000000000000000000000000000000000..2acf55ff6a2012f66f1f23294071b73c1d06afe3 --- /dev/null +++ b/gateway/.idea/compiler.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CompilerConfiguration"> + <annotationProcessing> + <profile name="Maven default annotation processors profile" enabled="true"> + <sourceOutputDir name="target/generated-sources/annotations" /> + <sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> + <outputRelativeToContentRoot value="true" /> + <module name="server_rest" /> + <module name="09" /> + </profile> + </annotationProcessing> + </component> +</project> \ No newline at end of file diff --git a/gateway/.idea/misc.xml b/gateway/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..6d752e8be6c71125a532e49eb36d37e9e32d89af --- /dev/null +++ b/gateway/.idea/misc.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ExternalStorageConfigurationManager" enabled="true" /> + <component name="MavenProjectsManager"> + <option name="originalFiles"> + <list> + <option value="$PROJECT_DIR$/pom.xml" /> + </list> + </option> + </component> + <component name="ProjectRootManager" version="2" languageLevel="JDK_12" project-jdk-name="12" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/out" /> + </component> +</project> \ No newline at end of file diff --git a/gateway/.idea/sbt.xml b/gateway/.idea/sbt.xml new file mode 100644 index 0000000000000000000000000000000000000000..20187435474e5ee4a31e9f6fdd531957b1ba89e3 --- /dev/null +++ b/gateway/.idea/sbt.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ScalaSbtSettings"> + <option name="customVMPath" /> + </component> +</project> \ No newline at end of file diff --git a/gateway/.idea/uiDesigner.xml b/gateway/.idea/uiDesigner.xml new file mode 100644 index 0000000000000000000000000000000000000000..e96534fb27b68192f27f985d3879e173ec77adb8 --- /dev/null +++ b/gateway/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="Palette2"> + <group name="Swing"> + <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> + </item> + <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> + </item> + <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true"> + <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> + <initial-values> + <property name="text" value="Button" /> + </initial-values> + </item> + <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="RadioButton" /> + </initial-values> + </item> + <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="CheckBox" /> + </initial-values> + </item> + <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="Label" /> + </initial-values> + </item> + <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> + <preferred-size width="200" height="200" /> + </default-constraints> + </item> + <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> + <preferred-size width="200" height="200" /> + </default-constraints> + </item> + <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" /> + </item> + <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1"> + <preferred-size width="-1" height="20" /> + </default-constraints> + </item> + <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" /> + </item> + <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> + </item> + </group> + </component> +</project> \ No newline at end of file diff --git a/gateway/.idea/vcs.xml b/gateway/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..9378d6dc69935724d288f515b9f8acb449bdb08d --- /dev/null +++ b/gateway/.idea/vcs.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$USER_HOME$" vcs="Git" /> + <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/gateway/.idea/workspace.xml b/gateway/.idea/workspace.xml new file mode 100644 index 0000000000000000000000000000000000000000..c9f9a0aca62bfeefdfce8fc18609804a2da0ecd5 --- /dev/null +++ b/gateway/.idea/workspace.xml @@ -0,0 +1,578 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ChangeListManager"> + <list default="true" id="e6a1f2e5-4f60-4227-82bb-83eb10fa94a5" name="Default Changelist" comment=""> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/kata/kata.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/kata/kata.component.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/mine/mine.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/mine/mine.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-displayer/card-displayer.component.css" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-displayer/card-displayer.component.css" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.css" beforeDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/program-displayer/card-noneall-displayer/card-noneall-displayer.component.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/program-displayer.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/program-displayer/program-displayer.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/subscription/subscription.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/subscription/subscription.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/styles.scss" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/styles.scss" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../compilation/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../compilation/.idea/workspace.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../compilation/share_docker_file/Kata.class" beforeDir="false" afterPath="$PROJECT_DIR$/../compilation/share_docker_file/Kata.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../compilation/share_docker_file/Main.class" beforeDir="false" afterPath="$PROJECT_DIR$/../compilation/share_docker_file/Main.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../compilation/src/main/java/DockerCompilation.java" beforeDir="false" afterPath="$PROJECT_DIR$/../compilation/src/main/java/DockerCompilation.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/main/java/LiveDB.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/LiveDB.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/main/java/MongoDB.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/MongoDB.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/main/java/ProgramShowCase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ProgramShowCase.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/main/java/app.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/app.java" afterDir="false" /> + </list> + <ignored path="$PROJECT_DIR$/out/" /> + <ignored path="$PROJECT_DIR$/target/" /> + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> + <option name="SHOW_DIALOG" value="false" /> + <option name="HIGHLIGHT_CONFLICTS" value="true" /> + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> + <option name="LAST_RESOLUTION" value="IGNORE" /> + </component> + <component name="DatabaseView"> + <option name="SHOW_INTERMEDIATE" value="true" /> + <option name="GROUP_DATA_SOURCES" value="true" /> + <option name="GROUP_SCHEMA" value="true" /> + <option name="GROUP_CONTENTS" value="false" /> + <option name="SORT_POSITIONED" value="false" /> + <option name="SHOW_EMPTY_GROUPS" value="false" /> + <option name="AUTO_SCROLL_FROM_SOURCE" value="false" /> + <option name="HIDDEN_KINDS"> + <set /> + </option> + <expand /> + <select /> + </component> + <component name="DefaultGradleProjectSettings"> + <option name="isMigrated" value="true" /> + </component> + <component name="FileEditorManager"> + <leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/src/main/java/app.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="3390"> + <caret line="226" lean-forward="true" selection-start-line="225" selection-start-column="28" selection-end-line="226" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="true"> + <entry file="file://$PROJECT_DIR$/src/main/java/MongoDB.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="315"> + <caret line="21" column="91" lean-forward="true" selection-start-line="21" selection-start-column="91" selection-end-line="21" selection-end-column="91" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/src/main/java/LiveDB.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="-636"> + <caret line="5" column="4" selection-start-line="5" selection-start-column="4" selection-end-line="5" selection-end-column="4" /> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/src/main/java/ProgramShowCase.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="270"> + <caret line="18" column="8" selection-start-line="18" selection-start-column="8" selection-end-line="18" selection-end-column="8" /> + </state> + </provider> + </entry> + </file> + </leaf> + </component> + <component name="FileTemplateManagerImpl"> + <option name="RECENT_TEMPLATES"> + <list> + <option value="Class" /> + </list> + </option> + </component> + <component name="FindInProjectRecents"> + <findStrings> + <find>handler</find> + <find>get_id</find> + <find>slee</find> + <find>thread</find> + <find>out</find> + <find>println</find> + <find>programid</find> + <find>idprogram</find> + <find>programID</find> + <find>sea</find> + </findStrings> + </component> + <component name="Git.Settings"> + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." /> + </component> + <component name="IdeDocumentHistory"> + <option name="CHANGED_PATHS"> + <list> + <option value="$PROJECT_DIR$/src/main/java/programManagement.java" /> + <option value="$PROJECT_DIR$/src/main/java/liveDB.java" /> + <option value="$PROJECT_DIR$/src/main/java/KataShowCase.java" /> + <option value="$PROJECT_DIR$/src/main/java/JWT.java" /> + <option value="$PROJECT_DIR$/src/main/java/JWToken.java" /> + <option value="$PROJECT_DIR$/src/main/java/MockUser.java" /> + <option value="$PROJECT_DIR$/pom.xml" /> + <option value="$PROJECT_DIR$/src/main/java/Program.java" /> + <option value="$PROJECT_DIR$/src/main/java/Kata.java" /> + <option value="$PROJECT_DIR$/src/main/java/KataSubscription.java" /> + <option value="$PROJECT_DIR$/src/main/java/ProgramSubscription.java" /> + <option value="$PROJECT_DIR$/src/main/java/ProgramsDataBase.java" /> + <option value="$PROJECT_DIR$/src/main/java/app.java" /> + <option value="$PROJECT_DIR$/src/main/java/LiveDB.java" /> + <option value="$PROJECT_DIR$/src/main/java/ProgramShowCase.java" /> + <option value="$PROJECT_DIR$/src/main/java/MongoDB.java" /> + </list> + </option> + </component> + <component name="MavenImportPreferences"> + <option name="importingSettings"> + <MavenImportingSettings> + <option name="importAutomatically" value="true" /> + </MavenImportingSettings> + </option> + </component> + <component name="MavenProjectNavigator"> + <treeState> + <expand> + <path> + <item name="" type="16c1761:MavenProjectsStructure$RootNode" /> + <item name="04" type="9519ce18:MavenProjectsStructure$ProjectNode" /> + </path> + </expand> + <select /> + </treeState> + </component> + <component name="ProjectConfigurationFiles"> + <option name="files"> + <list> + <option value="$PROJECT_DIR$/.idea/compiler.xml" /> + <option value="$PROJECT_DIR$/.idea/vcs.xml" /> + </list> + </option> + </component> + <component name="ProjectFrameBounds" fullScreen="true"> + <option name="y" value="23" /> + <option name="width" value="1920" /> + <option name="height" value="1121" /> + </component> + <component name="ProjectLevelVcsManager" settingsEditedManually="true"> + <ConfirmationsSetting value="1" id="Add" /> + </component> + <component name="ProjectView"> + <navigator proportions="" version="1"> + <foldersAlwaysOnTop value="true" /> + </navigator> + <panes> + <pane id="ProjectPane"> + <subPane> + <expand> + <path> + <item name="gateway" type="b2602c69:ProjectViewProjectNode" /> + <item name="gateway" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="gateway" type="b2602c69:ProjectViewProjectNode" /> + <item name="gateway" type="462c0819:PsiDirectoryNode" /> + <item name="src" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="gateway" type="b2602c69:ProjectViewProjectNode" /> + <item name="gateway" type="462c0819:PsiDirectoryNode" /> + <item name="src" type="462c0819:PsiDirectoryNode" /> + <item name="main" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="gateway" type="b2602c69:ProjectViewProjectNode" /> + <item name="gateway" type="462c0819:PsiDirectoryNode" /> + <item name="src" type="462c0819:PsiDirectoryNode" /> + <item name="main" type="462c0819:PsiDirectoryNode" /> + <item name="java" type="462c0819:PsiDirectoryNode" /> + </path> + </expand> + <select /> + </subPane> + </pane> + <pane id="PackagesPane" /> + <pane id="Scope" /> + </panes> + </component> + <component name="PropertiesComponent"> + <property name="ASKED_SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> + <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> + <property name="WebServerToolWindowFactoryState" value="false" /> + <property name="aspect.path.notification.shown" value="true" /> + <property name="last_opened_file_path" value="$PROJECT_DIR$" /> + <property name="node.js.detected.package.eslint" value="true" /> + <property name="node.js.path.for.package.eslint" value="project" /> + <property name="node.js.selected.package.eslint" value="(autodetect)" /> + <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> + <property name="nodejs_npm_path_reset_for_default_project" value="true" /> + <property name="restartRequiresConfirmation" value="false" /> + </component> + <component name="RunDashboard"> + <option name="ruleStates"> + <list> + <RuleState> + <option name="name" value="ConfigurationTypeDashboardGroupingRule" /> + </RuleState> + <RuleState> + <option name="name" value="StatusDashboardGroupingRule" /> + </RuleState> + </list> + </option> + </component> + <component name="RunManager"> + <configuration name="app" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> + <option name="MAIN_CLASS_NAME" value="app" /> + <module name="09" /> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + <recent_temporary> + <list> + <item itemvalue="Application.app" /> + </list> + </recent_temporary> + </component> + <component name="SbtLocalSettings"> + <option name="projectSyncType"> + <map> + <entry key="$PROJECT_DIR$/../../scalatra/scala_heroes_provider/my-scalatra-web-app" value="PREVIEW" /> + <entry key="$PROJECT_DIR$/../../scalatra/scalatra_heroes_provider" value="PREVIEW" /> + </map> + </option> + </component> + <component name="SvnConfiguration"> + <configuration /> + </component> + <component name="TaskManager"> + <task active="true" id="Default" summary="Default task"> + <changelist id="e6a1f2e5-4f60-4227-82bb-83eb10fa94a5" name="Default Changelist" comment="" /> + <created>1556178762532</created> + <option name="number" value="Default" /> + <option name="presentableId" value="Default" /> + <updated>1556178762532</updated> + <workItem from="1556178766124" duration="8507000" /> + <workItem from="1556214856871" duration="3137000" /> + <workItem from="1556882486866" duration="3200000" /> + <workItem from="1556962451252" duration="434000" /> + <workItem from="1557124766550" duration="154000" /> + <workItem from="1557148397301" duration="9704000" /> + <workItem from="1557210949742" duration="17614000" /> + <workItem from="1557298032818" duration="4720000" /> + <workItem from="1557322451462" duration="202000" /> + <workItem from="1557327228313" duration="707000" /> + <workItem from="1557391556472" duration="31000" /> + <workItem from="1557401502275" duration="15900000" /> + <workItem from="1557428931742" duration="3948000" /> + <workItem from="1557469406279" duration="5073000" /> + <workItem from="1557487918416" duration="1045000" /> + <workItem from="1557490543401" duration="4129000" /> + <workItem from="1557515924719" duration="2347000" /> + <workItem from="1557575265194" duration="10073000" /> + <workItem from="1557598576481" duration="1674000" /> + <workItem from="1557730072445" duration="9505000" /> + <workItem from="1557747000214" duration="5376000" /> + <workItem from="1557817025145" duration="7221000" /> + <workItem from="1557833110452" duration="1791000" /> + <workItem from="1557842011080" duration="239000" /> + <workItem from="1557902516521" duration="5257000" /> + </task> + <servers /> + </component> + <component name="TimeTrackingManager"> + <option name="totallyTimeSpent" value="126009000" /> + </component> + <component name="TodoView"> + <todo-panel id="selected-file"> + <is-autoscroll-to-source value="true" /> + </todo-panel> + <todo-panel id="all"> + <are-packages-shown value="true" /> + <is-autoscroll-to-source value="true" /> + </todo-panel> + </component> + <component name="ToolWindowManager"> + <frame x="0" y="0" width="1440" height="900" extended-state="0" /> + <editor active="true" /> + <layout> + <window_info content_ui="combo" id="Project" order="0" sideWeight="0.49924126" visible="true" weight="0.17596567" /> + <window_info id="Structure" order="1" sideWeight="0.5007587" side_tool="true" weight="0.20127796" /> + <window_info id="Image Layers" order="2" /> + <window_info id="Designer" order="3" /> + <window_info id="UI Designer" order="4" /> + <window_info id="Capture Tool" order="5" /> + <window_info id="Favorites" order="6" side_tool="true" /> + <window_info anchor="bottom" id="Message" order="0" /> + <window_info anchor="bottom" id="Find" order="1" weight="0.32920355" /> + <window_info anchor="bottom" id="Run" order="2" weight="0.35903615" /> + <window_info anchor="bottom" id="Debug" order="3" weight="0.3987952" /> + <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> + <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> + <window_info anchor="bottom" id="TODO" order="6" weight="0.32891566" /> + <window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" /> + <window_info anchor="bottom" id="Version Control" order="8" weight="0.32891566" /> + <window_info anchor="bottom" id="Database Changes" order="9" /> + <window_info anchor="bottom" id="Terminal" order="10" weight="0.32891566" /> + <window_info anchor="bottom" id="Event Log" order="11" side_tool="true" /> + <window_info anchor="bottom" id="Messages" order="12" weight="0.3253012" /> + <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> + <window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> + <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> + <window_info anchor="right" id="Palette" order="3" /> + <window_info anchor="right" id="Database" order="4" weight="0.32960597" /> + <window_info anchor="right" id="Theme Preview" order="5" /> + <window_info anchor="right" id="Maven" order="6" weight="0.32960597" /> + <window_info anchor="right" id="Capture Analysis" order="7" /> + <window_info anchor="right" id="Palette	" order="8" /> + </layout> + </component> + <component name="TypeScriptGeneratedFilesManager"> + <option name="version" value="1" /> + </component> + <component name="XDebuggerManager"> + <breakpoint-manager> + <breakpoints> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/main/java/MongoDB.java</url> + <line>253</line> + <properties /> + <option name="timeStamp" value="1" /> + </line-breakpoint> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/main/java/MongoDB.java</url> + <line>105</line> + <properties /> + <option name="timeStamp" value="2" /> + </line-breakpoint> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/main/java/MongoDB.java</url> + <line>98</line> + <properties /> + <option name="timeStamp" value="3" /> + </line-breakpoint> + </breakpoints> + </breakpoint-manager> + <watches-manager> + <configuration name="Application"> + <watch expression=" database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).first()" language="JAVA" /> + <watch expression="database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).projection(include("katas")).first()" language="JAVA" /> + <watch expression="programs.updateOne(combine(eq("iduser", userid), eq("idprogram", programid)), inc("nbKataDone", 1))" /> + <watch expression="programs.find(combine(eq("iduser",userid),eq("idprogram",programid))).first().getNbKataDone()" language="JAVA" /> + <watch expression="programs.find(combine(eq("iduser", userid), eq("idprogram", programid))).first()" /> + <watch expression="x.getNbKataDone()" /> + </configuration> + </watches-manager> + </component> + <component name="debuggerHistoryManager"> + <expressions id="watch"> + <expression> + <expression-string>programs.find(combine(eq("iduser",userid),eq("idprogram",programid))).first().getNbKataDone()</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>programs.find(combine(eq("iduser",userid),eq("idprogram",programid)))</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).projection(include("katas")).first()</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).first()</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).firs</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).first().getKatas()</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).first().getKatas();</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).projection(include("katas")).first();</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).projection(include("idprogram")).first()</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + <expression> + <expression-string>database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("status", true))).projection(include("idprogram")).first()</expression-string> + <language-id>JAVA</language-id> + <evaluation-mode>EXPRESSION</evaluation-mode> + </expression> + </expressions> + </component> + <component name="editorHistoryManager"> + <entry file="jar:///Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home/lib/src.zip!/java.base/java/lang/String.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="207"> + <caret line="134" column="15" selection-start-line="134" selection-start-column="15" selection-end-line="134" selection-end-column="15" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/programManagement.java" /> + <entry file="jar://$MAVEN_REPOSITORY$/io/javalin/javalin/2.8.0/javalin-2.8.0.jar!/io/javalin/Handler.class"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="105"> + <caret line="8" column="9" selection-start-line="8" selection-start-column="9" selection-end-line="8" selection-end-column="9" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/JWToken.java" /> + <entry file="file://$PROJECT_DIR$/src/main/java/MockUser.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="90"> + <caret line="6" column="16" selection-start-line="6" selection-start-column="16" selection-end-line="6" selection-end-column="16" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/pom.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="455"> + <caret line="83" column="4" selection-start-line="83" selection-start-column="4" selection-end-line="83" selection-end-column="4" /> + </state> + </provider> + </entry> + <entry file="jar://$MAVEN_REPOSITORY$/io/javalin/javalin/2.8.0/javalin-2.8.0.jar!/io/javalin/Context.class"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="218"> + <caret line="166" selection-start-line="166" selection-end-line="166" /> + </state> + </provider> + </entry> + <entry file="jar://$MAVEN_REPOSITORY$/io/javalin/javalin/2.8.0/javalin-2.8.0.jar!/io/javalin/core/util/ContextUtil.class"> + <provider selected="true" editor-type-id="text-editor" /> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/KataShowCase.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="20"> + <caret line="7" column="25" selection-start-line="7" selection-start-column="19" selection-end-line="7" selection-end-column="25" /> + <folding> + <element signature="e#443#444#0" expanded="true" /> + <element signature="e#476#477#0" expanded="true" /> + <element signature="e#737#738#0" expanded="true" /> + <element signature="e#766#767#0" expanded="true" /> + <element signature="e#810#811#0" expanded="true" /> + <element signature="e#846#847#0" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/KataSubscription.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="75"> + <caret line="5" column="26" selection-start-line="5" selection-start-column="24" selection-end-line="5" selection-end-column="26" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/Program.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="45"> + <caret line="3" column="47" selection-start-line="3" selection-start-column="42" selection-end-line="3" selection-end-column="47" /> + <folding> + <element signature="e#1540#1541#0" expanded="true" /> + <element signature="e#1571#1572#0" expanded="true" /> + <element signature="e#1619#1620#0" expanded="true" /> + <element signature="e#1659#1660#0" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/ProgramsDataBase.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="455"> + <caret line="37" column="20" selection-start-line="37" selection-start-column="20" selection-end-line="37" selection-end-column="20" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/ProgramSubscription.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="165"> + <caret line="13" column="34" selection-start-line="13" selection-start-column="34" selection-end-line="13" selection-end-column="34" /> + <folding> + <element signature="e#401#402#0" expanded="true" /> + <element signature="e#431#432#0" expanded="true" /> + <element signature="e#1246#1247#0" expanded="true" /> + <element signature="e#1271#1272#0" expanded="true" /> + <element signature="e#1307#1308#0" expanded="true" /> + <element signature="e#1335#1336#0" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/Kata.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="90"> + <caret line="6" lean-forward="true" selection-start-line="6" selection-end-line="6" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/app.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="3390"> + <caret line="226" lean-forward="true" selection-start-line="225" selection-start-column="28" selection-end-line="226" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/LiveDB.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="-636"> + <caret line="5" column="4" selection-start-line="5" selection-start-column="4" selection-end-line="5" selection-end-column="4" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/ProgramShowCase.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="270"> + <caret line="18" column="8" selection-start-line="18" selection-start-column="8" selection-end-line="18" selection-end-column="8" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/MongoDB.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="315"> + <caret line="21" column="91" lean-forward="true" selection-start-line="21" selection-start-column="91" selection-end-line="21" selection-end-column="91" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </component> +</project> \ No newline at end of file diff --git a/gateway/pom.xml b/gateway/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..cd0341544210e2d316aa6dbcab837b352f8cf243 --- /dev/null +++ b/gateway/pom.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>09</groupId> + <artifactId>09</artifactId> + <version>1.0-SNAPSHOT</version> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>java</goal> + </goals> + </execution> + </executions> + <configuration> + <mainClass>app</mainClass> + <cleanupDaemonThreads>false</cleanupDaemonThreads> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>8</source> + <target>8</target> + </configuration> + </plugin> + </plugins> + </build> + <repositories> + <repository> + <id>jitpack.io</id> + <url>https://jitpack.io</url> + </repository> + </repositories> + <dependencies> + <dependency> + <groupId>com.auth0</groupId> + <artifactId>java-jwt</artifactId> + <version>3.8.0</version> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20180813</version> + </dependency> + <dependency> + <groupId>io.javalin</groupId> + <artifactId>javalin</artifactId> + <version>2.8.0</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <version>1.7.26</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>2.9.8</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + </dependency> + <dependency> + <groupId>org.mongodb</groupId> + <artifactId>mongo-java-driver</artifactId> + <version>3.10.2</version> + </dependency> + <dependency> + <groupId>com.github.kmehrunes</groupId> + <artifactId>javalin-jwt</artifactId> + <version>v0.1</version> + </dependency> + </dependencies> + +</project> \ No newline at end of file diff --git a/gateway/server_rest_new.iml b/gateway/server_rest_new.iml new file mode 100644 index 0000000000000000000000000000000000000000..78b2cc53b203f0b97534bb1184cdc7b474339fb4 --- /dev/null +++ b/gateway/server_rest_new.iml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4" /> \ No newline at end of file diff --git a/gateway/src/main/java/Kata.java b/gateway/src/main/java/Kata.java new file mode 100644 index 0000000000000000000000000000000000000000..280b4b4876b7929f77d1a22e3620fc9f93898061 --- /dev/null +++ b/gateway/src/main/java/Kata.java @@ -0,0 +1,105 @@ +public class Kata { + private String _id, id,title, canva, cassert, solution, rules,programID,difficulty,language; + private boolean keepAssert; + private int nbAttempt; + + + + + public boolean isKeepAssert() { + return keepAssert; + } + + public void setKeepAssert(boolean keepAssert) { + this.keepAssert = keepAssert; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getCanva() { + return canva; + } + + public void setCanva(String canva) { + this.canva = canva; + } + + public String getCassert() { + return cassert; + } + + public void setCassert(String cassert) { + this.cassert = cassert; + } + + public String getSolution() { + return solution; + } + + public void setSolution(String solution) { + this.solution = solution; + } + + public String getRules() { + return rules; + } + + public void setRules(String rules) { + this.rules = rules; + } + + public int getNbAttempt() { + return nbAttempt; + } + + public void setNbAttempt(int nbAttempt) { + this.nbAttempt = nbAttempt; + } + + + public String getProgramID() { + return programID; + } + + public void setProgramID(String programID) { + this.programID = programID; + } + + public String getDifficulty() { + return difficulty; + } + + public void setDifficulty(String difficulty) { + this.difficulty = difficulty; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/gateway/src/main/java/KataShowCase.java b/gateway/src/main/java/KataShowCase.java new file mode 100644 index 0000000000000000000000000000000000000000..345ea1e1390e0127dbb657610c0cd0132785180d --- /dev/null +++ b/gateway/src/main/java/KataShowCase.java @@ -0,0 +1,42 @@ +public class KataShowCase { + private String title,difficulty,id,status; + + public KataShowCase(String title, String difficulty, String id, String status){ + this.difficulty = difficulty; + this.title = title; + this.id = id; + this.status = status; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDifficulty() { + return difficulty; + } + + public void setDifficulty(String difficulty) { + this.difficulty = difficulty; + } + + public String getId() { + return id; + } + + public void setId(String programID) { + this.id = programID; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/gateway/src/main/java/KataSubscription.java b/gateway/src/main/java/KataSubscription.java new file mode 100644 index 0000000000000000000000000000000000000000..2c1745951287e5cd0aa3011888a888617482b406 --- /dev/null +++ b/gateway/src/main/java/KataSubscription.java @@ -0,0 +1,57 @@ +public class KataSubscription { + //katas [{id:1,status:"resolved",mysol:".."}] + + + + private String _id, id, status, mysol; + private int nbAttempt; + + public KataSubscription(String id, String status, String mysol, int nbAttempt) { + this.id = id; + this.status = status; + this.mysol = mysol; + this.nbAttempt = nbAttempt; + } + + public KataSubscription(){} + + public String getMysol() { + return mysol; + } + + public void setMysol(String mysol) { + this.mysol = mysol; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } + + public int getNbAttempt() { + return nbAttempt; + } + + public void setNbAttempt(int nbAttempt) { + this.nbAttempt = nbAttempt; + } +} diff --git a/gateway/src/main/java/LiveDB.java b/gateway/src/main/java/LiveDB.java new file mode 100644 index 0000000000000000000000000000000000000000..798101b6fd638727eed22ef5b84e0d8b0b83eff8 --- /dev/null +++ b/gateway/src/main/java/LiveDB.java @@ -0,0 +1,137 @@ +import java.util.ArrayList; + +public class LiveDB extends ProgramsDataBase { + + ArrayList<Kata> katas; + ArrayList<Program> programs; + + public LiveDB() { + this.programs = new ArrayList<>(); + this.katas = new ArrayList<>(); + } + + public void createProgram(Program prg) { + this.programs.add(prg); + } + + public void createKata(Kata kata) { + + for (Program p : this.programs) + if (p.getId().equals(kata.getProgramID())) { + p.setNbKata(p.getNbKata() + 1); + p.getKatas().add(kata); + break; + } + } + + public ArrayList<ProgramShowCase> getProgramsDetails() { + ArrayList<ProgramShowCase> p = new ArrayList<>(); + + for (Program prg : this.programs) + p.add(new ProgramShowCase(prg.getTitle(), prg.getSensei(), prg.getLanguage(), prg.getDescription(), prg.getNbKata(), prg.getTags(), prg.getId())); + + return p; + } + + public Kata getProgramKata(String programID, String kataID) { + ArrayList<Kata> ktemp = new ArrayList<>(); + Kata kata = new Kata(); + for (Program prg : this.programs) + if (prg.getId().equals(programID)) + ktemp = prg.getKatas(); + for(Kata k : ktemp) + if(k.getId().equals(kataID)) + kata = k; + return kata; + } + + public ArrayList<KataShowCase> getProgramKatasDetails(String programID, String userid) { + ArrayList<KataShowCase> ktsc = new ArrayList<>(); + ArrayList<Kata> kt = new ArrayList<>(); + for (Program prg : this.programs) + if (prg.getId().equals(programID)) { + kt = prg.getKatas(); + break; + } + + for (Kata k : kt) + ktsc.add(new KataShowCase(k.getTitle(), k.getDifficulty(), k.getId(), "TODO")); + return ktsc; + } + + public ArrayList<String> getProgramDetailsByID(String id){ + ArrayList<String> infos = new ArrayList<>(); + + for (Program p : this.programs) + if(p.getId().equals(id)){ + infos.add(p.getTitle()); + infos.add(p.getLanguage()); + infos.add(p.getSensei()); + break; + } + + return infos; + } + + @Override + public ArrayList<ProgramShowCase> getProgramDetailsByResource(String type, String resource) { + return null; + } + + @Override + public ProgramSubscription getSubscriptionByID(String userid, String idrogram) { + return null; + } + + @Override + public void createProgramSubscritpion(ProgramSubscription p) { + + } + + @Override + public void toggleSubscription(String userid, String idrogram) { + + } + + @Override + public ArrayList<ProgramShowCase> getUserSubscription(String userid) { + return null; + } + + @Override + public ArrayList<ProgramShowCase> getUserProgram(String userid) { + return null; + } + + @Override + public ArrayList<KataSubscription> getKataSubscription(String programid, String userid) { + return null; + } + + @Override + public KataSubscription getKataSubscriptionByID(String kataid, String programid, String userid) { + return null; + } + + @Override + public void createKataSubscription(String kataid, String programid, String userid) { + + } + + @Override + public void incKataSubscriptionAttempt(String kataid, String programid, String userid) { + + } + + @Override + public void updateKataSubscription(String kataid, String programid, String userid, String sol, String status) { + + } + + @Override + public void deleteProgram(String programid) { + + } + + +} \ No newline at end of file diff --git a/gateway/src/main/java/MockUser.java b/gateway/src/main/java/MockUser.java new file mode 100644 index 0000000000000000000000000000000000000000..2c8565fa582ba7bea9f2a2e310a3eb00607f0f6a --- /dev/null +++ b/gateway/src/main/java/MockUser.java @@ -0,0 +1,13 @@ +public class MockUser { + int id; + String name; + String password; + String level; + + MockUser(int id, String name, String level,String password) { + this.id = id; + this.name = name; + this.level = level; + this.password = password; + } +} \ No newline at end of file diff --git a/gateway/src/main/java/MongoDB.java b/gateway/src/main/java/MongoDB.java new file mode 100644 index 0000000000000000000000000000000000000000..8ee3a84a0542f4d1b00be3f5f33e042f6f57934e --- /dev/null +++ b/gateway/src/main/java/MongoDB.java @@ -0,0 +1,269 @@ +import com.mongodb.*; +import com.mongodb.client.MongoCollection; +import com.mongodb.client.MongoDatabase; +import com.mongodb.client.model.Indexes; +import org.bson.codecs.configuration.CodecRegistry; +import org.bson.codecs.pojo.PojoCodecProvider; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.regex.Pattern; + +import static com.mongodb.client.model.Filters.*; +import static com.mongodb.client.model.Updates.*; +import static com.mongodb.client.model.Projections.*; +import static org.bson.codecs.configuration.CodecRegistries.fromProviders; +import static org.bson.codecs.configuration.CodecRegistries.fromRegistries; + +public class MongoDB extends ProgramsDataBase { + private MongoClient mongoClient; + private MongoDatabase database; + + CodecRegistry pojoCodecRegistry = fromRegistries(MongoClient.getDefaultCodecRegistry(), + fromProviders(PojoCodecProvider.builder().automatic(true).build())); + + public MongoDB() { + MongoCredential credential = MongoCredential.createCredential("shodai", "DojoHepia", "shodai".toCharArray()); + this.mongoClient = new MongoClient(new ServerAddress("localhost", 27017), Arrays.asList(credential), MongoClientOptions.builder().codecRegistry(pojoCodecRegistry).build()); + this.database = mongoClient.getDatabase("DojoHepia"); + database.getCollection("Programs").createIndex(Indexes.ascending("title")); + + } + + public void createProgram(Program prg) { + MongoCollection<Program> programs = database.getCollection("Programs", Program.class); + programs.insertOne(prg); + } + + public void createKata(Kata kata) { + ArrayList<Kata> katas = database.getCollection("Programs", Program.class).find(eq("_id", kata.getProgramID())).first().getKatas(); + katas.add(kata); + + MongoCollection<Program> programs = database.getCollection("Programs", Program.class); + programs.updateOne(eq("_id", kata.getProgramID()), combine(inc("nbKata", 1), set("katas", katas))); + } + + public ArrayList<ProgramShowCase> getProgramsDetails() { + ArrayList<ProgramShowCase> p = new ArrayList<>(); + MongoCollection<Program> programs = database.getCollection("Programs", Program.class); + MongoCollection<ProgramSubscription> programSubs = database.getCollection("ProgramsSubscription", ProgramSubscription.class); + + for (Program prg : programs.find()) { + + p.add(new ProgramShowCase(prg.getTitle(), prg.getSensei(), prg.getLanguage(), prg.getDescription(), prg.getNbKata(), prg.getTags(), prg.getId())); + } + + return p; + } + + public Kata getProgramKata(String programID, String kataID) { + + Kata kata = new Kata(); + + MongoCollection<Program> programs = database.getCollection("Programs", Program.class); + ArrayList<Kata> katas = programs.find(eq("_id", programID)).first().getKatas(); + + for (Kata k : katas) + if (k.getId().equals(kataID)) { + kata = k; + break; + } + return kata; + + } + + public ArrayList<KataShowCase> getProgramKatasDetails(String programID, String userid) { + ArrayList<KataShowCase> ktsc = new ArrayList<>(); + MongoCollection<Program> programs = database.getCollection("Programs", Program.class); + + ArrayList<Kata> k = programs.find(eq("_id", programID)).first().getKatas(); + + k.forEach(x -> { + ktsc.add(new KataShowCase(x.getTitle(), x.getDifficulty(), x.getId(), getKataStatus(x.getId(), programID, userid))); + }); + + return ktsc; + } + + /** + * TODO Vraiment très couteux........ + * + * @param kataid + * @param programid + * @param userid + * @return + */ + + private String getKataStatus(String kataid, String programid, String userid) { + MongoCollection<ProgramSubscription> programs = database.getCollection("ProgramsSubscription", ProgramSubscription.class); + ProgramSubscription subscription = programs.find(combine(eq("iduser", userid), eq("idprogram", programid))).first(); + + if (subscription == null) + return "TODO"; + + ArrayList<KataSubscription> k = subscription.getKatas(); + + for (KataSubscription ks : k) { + if (ks.getId().equals(kataid)) + return ks.getStatus(); + } + return "TODO"; + } + + public ArrayList<String> getProgramDetailsByID(String id) { + ArrayList<String> infos = new ArrayList<>(); + + MongoCollection<Program> programs = database.getCollection("Programs", Program.class); + Program p = programs.find(eq("_id", id)).first(); + + if (p != null) { + infos.add(p.getTitle()); + infos.add(p.getLanguage()); + infos.add(p.getSensei()); + infos.add(p.getIdsensei()); + } + return infos; + } + + public ArrayList<ProgramShowCase> getProgramDetailsByResource(String type, String resource) { + ArrayList<ProgramShowCase> p = new ArrayList<>(); + + MongoCollection<Program> cprograms = database.getCollection("Programs", Program.class); + Pattern regex = Pattern.compile(resource, Pattern.CASE_INSENSITIVE); + Iterable<Program> programs = cprograms.find(eq(type, regex)); + + + programs.forEach(x -> { + p.add(new ProgramShowCase(x.getTitle(), x.getSensei(), x.getLanguage(), x.getDescription(), x.getNbKata(), x.getTags(), x.getId(), -1)); + }); + + return p; + } + + public ProgramSubscription getSubscriptionByID(String userid, String idrogram) { + MongoCollection<ProgramSubscription> programSubs = database.getCollection("ProgramsSubscription", ProgramSubscription.class); + ProgramSubscription prgsub = programSubs.find(combine(eq("idprogram", idrogram), eq("iduser", userid))).first(); + + return prgsub; + } + + public void createProgramSubscritpion(ProgramSubscription p) { + MongoCollection<ProgramSubscription> programSubs = database.getCollection("ProgramsSubscription", ProgramSubscription.class); + programSubs.insertOne(p); + } + + public void toggleSubscription(String userid, String idrogram) { + MongoCollection<ProgramSubscription> programSubs = database.getCollection("ProgramsSubscription", ProgramSubscription.class); + ProgramSubscription prog = programSubs.find(combine(eq("idprogram", idrogram), eq("iduser", userid))).first(); + + if (prog.getStatus()) + programSubs.updateOne(combine(eq("idprogram", idrogram), eq("iduser", userid)), set("status", false)); + else + programSubs.updateOne(combine(eq("idprogram", idrogram), eq("iduser", userid)), set("status", true)); + + } + + public ArrayList<ProgramShowCase> getUserSubscription(String userid) { + Iterable<ProgramSubscription> s = database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("status", true))).projection(include("idprogram", "nbKataDone")); + ArrayList<ProgramShowCase> prgsc = new ArrayList<>(); + + MongoCollection<Program> cprograms = database.getCollection("Programs", Program.class); + s.forEach(x -> { + Program p = cprograms.find(eq("_id", x.getIdprogram())).first(); + prgsc.add(new ProgramShowCase(p.getTitle(), p.getSensei(), p.getLanguage(), p.getDescription(), p.getNbKata(), p.getTags(), p.getId(), x.getNbKataDone())); + }); + + return prgsc; + } + + public ArrayList<ProgramShowCase> getUserProgram(String userid) { + Iterable<Program> cprograms = database.getCollection("Programs", Program.class).find(eq("idsensei", userid)); + ArrayList<ProgramShowCase> prgsc = new ArrayList<>(); + + for (Program p : cprograms) + prgsc.add(new ProgramShowCase(p.getTitle(), p.getSensei(), p.getLanguage(), p.getDescription(), p.getNbKata(), p.getTags(), p.getId(), -1)); + + return prgsc; + } + + public ArrayList<KataSubscription> getKataSubscription(String programid, String userid) { + ArrayList<KataSubscription> s = database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("programid", programid))).projection(include("katas")).first().getKatas(); + + return s; + } + + public KataSubscription getKataSubscriptionByID(String kataid, String programid, String userid) { + + ProgramSubscription s = database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid), eq("status", true))).projection(include("katas")).first(); + + if (s == null) { + return new KataSubscription(); + } else + for (KataSubscription k : s.getKatas()) { + if (k.getId().equals(kataid)) + return k; + } + return null; + } + + public void createKataSubscription(String kataid, String programid, String userid) { + ArrayList<KataSubscription> katas = database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).first().getKatas(); + katas.add(new KataSubscription(kataid, "ON-GOING", "", 0)); + + MongoCollection<ProgramSubscription> programs = database.getCollection("ProgramsSubscription", ProgramSubscription.class); + programs.updateOne(combine(eq("iduser", userid), eq("idprogram", programid)), set("katas", katas)); + } + + /** + * TODO trouver un moyen simple de rentrer dans la liste de kata avec mongo db, parce que la c'est vraiment très couteu à chaque appel. + * TODO voir si je peux pas transformer kataSubrription en une mongo collection dans ProgramSub.. et pourquoi pas + * TODO si 4a marche changer Arraylist kata en Mongo collection kata dans Program + * + * @param kataid + * @param programid + * @param userid + */ + public void incKataSubscriptionAttempt(String kataid, String programid, String userid) { + ArrayList<KataSubscription> katas = database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).first().getKatas(); + + for (KataSubscription k : katas) { + if (k.getId().equals(kataid)) { + k.setNbAttempt(k.getNbAttempt() + 1); + break; + } + } + + MongoCollection<ProgramSubscription> programs = database.getCollection("ProgramsSubscription", ProgramSubscription.class); + programs.updateOne(combine(eq("iduser", userid), eq("idprogram", programid)), set("katas", katas)); + } + + public void updateKataSubscription(String kataid, String programid, String userid, String sol, String status) { + ArrayList<KataSubscription> katas = database.getCollection("ProgramsSubscription", ProgramSubscription.class).find(combine(eq("iduser", userid), eq("idprogram", programid))).first().getKatas(); + + for (KataSubscription k : katas) { + if (k.getId().equals(kataid)) { + k.setStatus(status); + k.setMysol(sol); + break; + } + } + + MongoCollection<ProgramSubscription> programs = database.getCollection("ProgramsSubscription", ProgramSubscription.class); + programs.updateOne(combine(eq("iduser", userid), eq("idprogram", programid)), set("katas", katas)); + if (status.equals("RESOLVED")) + programs.updateOne(combine(eq("iduser", userid), eq("idprogram", programid)), inc("nbKataDone", 1)); + } + + public void deleteProgram(String programid) { + database.getCollection("Programs", Program.class).deleteMany(eq("_id", programid)); + database.getCollection("ProgramsSubscription", ProgramSubscription.class).deleteMany(eq("idprogram", programid)); + } +/* + public void deletekatas(String kataid, String programid){ + + database.getCollection("ProgramsSubscription",ProgramSubscription.class).deleteMany();// + database.getCollection("Programs",Program.class).deleteMany(eq("_id",programid)); + } +*/ + +} diff --git a/gateway/src/main/java/Program.java b/gateway/src/main/java/Program.java new file mode 100644 index 0000000000000000000000000000000000000000..7ffef7602c7354109ba75da1f14ebb6e6d80e22a --- /dev/null +++ b/gateway/src/main/java/Program.java @@ -0,0 +1,98 @@ +import java.util.ArrayList; + +public class Program { + private String _id,id,sensei,language,title,description,idsensei; + private ArrayList<String> tags; + private int nbKata; + private ArrayList<Kata> katas; + + public String getSensei() { + return sensei; + } + + public void setSensei(String sensei) { + this.sensei = sensei; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public int getNbKata() { + return nbKata; + } + + public void setNbKata(int nbKata) { + this.nbKata = nbKata; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + + + public ArrayList<Kata> getKatas() { + return katas; + } + + public void setKatas(ArrayList<Kata> katas) { + this.katas = katas; + } + + public ArrayList<String> getTags() { + return tags; + } + + public void setTags(ArrayList<String> tags) { + this.tags = tags; + } + + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIdsensei() { + return idsensei; + } + + public void setIdsensei(String idsensei) { + this.idsensei = idsensei; + } +/* + public ArrayList<Kata> getKata() { + return kata; + } + + public void setKata(ArrayList<Kata> kata) { + this.kata = kata; + }*/ +} diff --git a/gateway/src/main/java/ProgramShowCase.java b/gateway/src/main/java/ProgramShowCase.java new file mode 100644 index 0000000000000000000000000000000000000000..e5831a6c4eb3dca5b6fe1079416a8a5438f87022 --- /dev/null +++ b/gateway/src/main/java/ProgramShowCase.java @@ -0,0 +1,97 @@ +import java.util.ArrayList; + +public class ProgramShowCase { + private String title, sensei, language, description, programID; + private int nbKata; + private ArrayList<String> tags; + private int nbKataDone; + + + public ProgramShowCase(String title, String sensei, String language, String description, int nbKata, ArrayList<String> tags, String programID, int nbKataDone) { + this.title = title; + this.sensei = sensei; + this.language = language; + this.description = description; + this.nbKata = nbKata; + this.tags = tags; + this.programID = programID; + this.nbKataDone = nbKataDone; + + + } + + public ProgramShowCase(String title, String sensei, String language, String description, int nbKata, ArrayList<String> tags, String programID) { + this.title = title; + this.sensei = sensei; + this.language = language; + this.description = description; + this.nbKata = nbKata; + this.tags = tags; + this.programID = programID; + } + + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getSensei() { + return sensei; + } + + public void setSensei(String sensei) { + this.sensei = sensei; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getNbKata() { + return nbKata; + } + + public void setNbKata(int nbKata) { + this.nbKata = nbKata; + } + + public String getProgramID() { + return programID; + } + + public void setProgramID(String programID) { + this.programID = programID; + } + + public ArrayList<String> getTags() { + return tags; + } + + public void setTags(ArrayList<String> tags) { + this.tags = tags; + } + + public int getNbKataDone() { + return this.nbKataDone; + } + + public void setNbKataDone(int nbKataDone) { + this.nbKata = nbKataDone; + } +} diff --git a/gateway/src/main/java/ProgramSubscription.java b/gateway/src/main/java/ProgramSubscription.java new file mode 100644 index 0000000000000000000000000000000000000000..0c400eed123a379394904e4f7829d578e077b6ed --- /dev/null +++ b/gateway/src/main/java/ProgramSubscription.java @@ -0,0 +1,67 @@ +import java.util.ArrayList; + +public class ProgramSubscription {// [iduser, idprogram : 234, status : 1 , katas [{id:1,status:"resolved",mysol:".."}],done : 1] + + private String _id,id, iduser, idprogram; + private boolean status; + private int nbKataDone; + private ArrayList<KataSubscription> katas; + + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } + + public String getIduser() { + return iduser; + } + + public void setIduser(String iduser) { + this.iduser = iduser; + } + + public String getIdprogram() { + return idprogram; + } + + public void setIdprogram(String idprogram) { + this.idprogram = idprogram; + } + + public Boolean getStatus() { + return status; + } + + public void setStatus(Boolean status) { + this.status = status; + } + + + + public ArrayList<KataSubscription> getKatas() { + return katas; + } + + public void setKatas(ArrayList<KataSubscription> katas) { + this.katas = katas; + } + + public int getNbKataDone() { + return nbKataDone; + } + + public void setNbKataDone(int nbKataDone) { + this.nbKataDone = nbKataDone; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/gateway/src/main/java/ProgramsDataBase.java b/gateway/src/main/java/ProgramsDataBase.java new file mode 100644 index 0000000000000000000000000000000000000000..ed19c3071363a0d50df00fd481354553e8cff93b --- /dev/null +++ b/gateway/src/main/java/ProgramsDataBase.java @@ -0,0 +1,40 @@ +import java.util.ArrayList; + +public abstract class ProgramsDataBase { + public abstract void createProgram(Program prg); + + public abstract void createKata(Kata kata); + + public abstract ArrayList<ProgramShowCase> getProgramsDetails(); + + public abstract Kata getProgramKata(String programID, String kataID); + + public abstract ArrayList<KataShowCase> getProgramKatasDetails(String programID, String userid); + + public abstract ArrayList<String> getProgramDetailsByID(String id); + + public abstract ArrayList<ProgramShowCase> getProgramDetailsByResource(String type, String resource); + + public abstract ProgramSubscription getSubscriptionByID(String userid, String idrogram); + + public abstract void createProgramSubscritpion(ProgramSubscription p); + + public abstract void toggleSubscription(String userid, String idrogram); + + public abstract ArrayList<ProgramShowCase> getUserSubscription(String userid); + + public abstract ArrayList<ProgramShowCase> getUserProgram(String userid); + + public abstract ArrayList<KataSubscription> getKataSubscription(String programid, String userid); + + public abstract KataSubscription getKataSubscriptionByID(String kataid, String programid, String userid); + + public abstract void createKataSubscription(String kataid, String programid, String userid); + + public abstract void incKataSubscriptionAttempt(String kataid, String programid, String userid); + + public abstract void updateKataSubscription(String kataid, String programid, String userid, String sol, String status); + + public abstract void deleteProgram(String programid); + +} diff --git a/gateway/src/main/java/app.java b/gateway/src/main/java/app.java new file mode 100644 index 0000000000000000000000000000000000000000..373455079a89017909cf27004b28b7377b67e56e --- /dev/null +++ b/gateway/src/main/java/app.java @@ -0,0 +1,337 @@ +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTCreator; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.javalin.Context; +import io.javalin.Handler; +import io.javalin.Javalin; +import io.javalin.security.Role; +import javalinjwt.JWTAccessManager; +import javalinjwt.JWTGenerator; +import javalinjwt.JWTProvider; +import javalinjwt.JavalinJWT; +import org.json.JSONObject; + +import java.io.*; +import java.net.ConnectException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import static io.javalin.security.SecurityUtil.roles; + +/** + * Gateway of DojoHepia + * Created by Alexandre Vanini for Hepia © HEPIA 2019 (Bachelor Thesis project) + * Purpose : Http Server + */ +public class app { + + // Roles of the routes + enum Roles implements Role { + SHODAI, // Super user role + SENSEI, // High user role + MONJI, // Middle user role + ANYONE // Low user role + } + + // Data base object, can be changed if your object extends "ProgramsDataBase" + private static ProgramsDataBase db = new MongoDB(); + + // Jackson Object mapper, convert received stream into Java Designed Object + private static ObjectMapper objectMapper = new ObjectMapper(); + + // Temporary list of users + private static ArrayList<MockUser> users = new ArrayList<>(); + + /** + * Entry point of the gateway, no args needed + * @param args - Not needed + */ + public static void main(String[] args) { + + // JWT //secret + Algorithm algorithm = Algorithm.HMAC256("cd47488e09fa86d6e2549b824cb1f47422921539"); + + // Every time a user is requesting a token, it passes trough here + // It generates a token based on user's name and his level + JWTGenerator<MockUser> generator = (user, alg) -> { + JWTCreator.Builder token = JWT.create() + .withClaim("username", user.name) + .withClaim("level", user.level); + return token.sign(alg); + }; + + JWTVerifier verifier = JWT.require(algorithm).build(); + JWTProvider provider = new JWTProvider(algorithm, generator, verifier); + + // Mock list of users - Temporary + users.add(new MockUser(0, "monji", "monji", "monji")); + users.add(new MockUser(1, "shodai", "shodai", "shodai")); + users.add(new MockUser(2, "sensei", "sensei", "sensei")); + + // Decoder Handler + Handler decodeHandler = JavalinJWT.createHeaderDecodeHandler(provider); + + + // Javalin server creation + Javalin app = Javalin.create().enableCorsForAllOrigins(); + + // Every time a user tries to reach a route of the server, it passes trough the before handler. + // This ensure the user has a compatible token to reach routes, if the token is faked or deprecated, it returns a 401 status (Unauthorized) + app.before(decodeHandler); + + Map<String, Role> rolesMapping = new HashMap<String, Role>(); + + rolesMapping.put("shodai", Roles.SHODAI); + rolesMapping.put("anyone", Roles.ANYONE); + rolesMapping.put("monji", Roles.MONJI); + rolesMapping.put("sensei", Roles.SENSEI); + + + // Tells the access manager that, ANYONE is the most basic role. + JWTAccessManager accessManager = new JWTAccessManager("level", rolesMapping, Roles.ANYONE); + app.accessManager(accessManager); + + // Start the server at port 7000 + app.start(7000); + // END OF JWT + + + /** + * Compilation route - body must contain data to compile + */ + app.post("/run/", ctx -> { + + HttpURLConnection connection = null; + + try { + // Create a new connection on compilation server (port 6999) + URL compilator = new URL("http://localhost:6999"); + connection = (HttpURLConnection) compilator.openConnection(); + connection.setRequestMethod("POST"); + connection.setDoOutput(true); + } catch (ConnectException e) { + e.printStackTrace(); + } + + try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) { + // Write body content into http post + wr.writeBytes(ctx.body()); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } catch (ConnectException e) { + e.printStackTrace(); + } + + // Reads the result got from the compilation server + try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { + String response = in.readLine(); + ctx.result(response); + } catch (IOException e) { + e.printStackTrace(); + } + + // This tells that /run/ is only accessible by users who have these roles + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + /** PROGRAM **/ + + /** + * Create a program -> Expect complete object like Program in body + */ + app.post("/program/create", ctx -> { + Program prg = objectMapper.readValue(ctx.body(), Program.class); + db.createProgram(prg); + ctx.status(200); + }, roles(Roles.SHODAI, Roles.SENSEI)); + + app.get("/program/getdetails", ctx -> { + ArrayList<ProgramShowCase> prgsc = db.getProgramsDetails(); + if (prgsc != null) + if (prgsc.size() == 0) + ctx.status(404); + else + ctx.json(prgsc); + else + ctx.status(404); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + app.get("program/getdetails/:id", ctx -> { + ArrayList<String> s = db.getProgramDetailsByID(ctx.pathParam("id")); + if (s.size() == 0) + ctx.status(404); + else + ctx.json(s); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + app.post("/kata/create", ctx -> { + Kata kt = objectMapper.readValue(ctx.body(), Kata.class); + db.createKata(kt); + ctx.status(200); + }, roles(Roles.SHODAI, Roles.SENSEI)); + + app.post("program/delete",ctx -> { + db.deleteProgram(new JSONObject(ctx.body()).getString("programid")); + ctx.status(200); + },roles(Roles.SHODAI, Roles.SENSEI)); + + /******************/ + + + /** KATAS **/ + + app.get("/program/getkatas/details/:id/:userid", ctx -> { + ArrayList<KataShowCase> ktsc = db.getProgramKatasDetails(ctx.pathParam("id"),ctx.pathParam("userid")); + ctx.json(ktsc); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + app.get("/program/getkata/:prid/:id", ctx -> { + + Kata kata = db.getProgramKata(ctx.pathParam("prid"), ctx.pathParam("id")); + if (kata.getId() == null) + ctx.status(404); + else + ctx.json(kata); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + /******************/ + + /** USER **/ + + app.post("jwt/request/", ctx -> { + MockUser u = checkUser(ctx); + + if (!(u == null)) { + String token = provider.generateToken(u); + + HashMap<String, String> p = new HashMap<>(); + p.put("id", String.valueOf(u.id)); + p.put("username", u.name); + p.put("token", token); + p.put("role", u.level); + + ctx.json(p); + } else { + ctx.status(400).json("Username or password is incorrect"); + } + + }, roles(Roles.ANYONE)); + + /******************/ + + /** PROGRAM SEARCH **/ + app.get("search/:type/:resource", ctx -> { + ArrayList<ProgramShowCase> p = db.getProgramDetailsByResource(ctx.pathParam("type"), ctx.pathParam("resource")); + + if (p != null) + if (p.size() == 0) + ctx.status(404).json("No program matched the specified query"); + else + ctx.json(p); + else + ctx.status(404).json("No program matched the specified query"); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + /******************/ + + + /** PROGRAM SUBSCRIPTION **/ + + app.get("program/getsubscription/:programid/:userid", ctx -> { + ProgramSubscription p = db.getSubscriptionByID(ctx.pathParam("userid"), ctx.pathParam("programid")); + if (!(p == null)) + ctx.json(p); + else { + ctx.status(404); + } + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + app.get("/subscription/get/:userid", ctx -> { + ArrayList<ProgramShowCase> prgsc = db.getUserSubscription(ctx.pathParam("userid")); + if (prgsc != null) + if (prgsc.size() == 0) + ctx.status(404); + else + ctx.json(prgsc); + else + ctx.status(404); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + app.get("/subscription/mine/:userid", ctx -> { + ArrayList<ProgramShowCase> prgsc = db.getUserProgram(ctx.pathParam("userid")); + if (prgsc != null) + if (prgsc.size() == 0) + ctx.status(404); + else + ctx.json(prgsc); + else + ctx.status(404); + }, roles(Roles.SHODAI, Roles.SENSEI)); + + app.post("program/createsubscription", ctx -> { + ProgramSubscription prg = objectMapper.readValue(ctx.body(), ProgramSubscription.class); + db.createProgramSubscritpion(prg); + ctx.status(200); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + app.post("program/togglesubscription", ctx -> { + JSONObject input = new JSONObject(ctx.body()); + db.toggleSubscription(input.getString("userid"), input.getString("programid")); + ctx.status(200); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + /******************/ + + /** KATA SUBSCRIPTION **/ + + app.get("kata/get/subscriptioninfos/:userid/:programid/:kataid", ctx -> { + KataSubscription k = db.getKataSubscriptionByID(ctx.pathParam("kataid"), ctx.pathParam("programid"), ctx.pathParam("userid")); + + if (!(k == null)) + if (k.getId() == null) + ctx.status(402); + else + ctx.status(200).json(k); + else if (k == null) + ctx.status(404); + + + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + app.post("kata/create/subscription", ctx -> { + JSONObject obj = new JSONObject(ctx.body()); + db.createKataSubscription(obj.getString("kataid"), obj.getString("programid"), obj.getString("userid")); + ctx.status(200); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + app.post("kata/inc/subscription", ctx -> { + JSONObject obj = new JSONObject(ctx.body()); + db.incKataSubscriptionAttempt(obj.getString("kataid"), obj.getString("programid"), obj.getString("userid")); + ctx.status(200); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + app.post("kata/update/subscription", ctx -> { + JSONObject obj = new JSONObject(ctx.body()); + db.updateKataSubscription(obj.getString("kataid"), obj.getString("programid"), obj.getString("userid"), obj.getString("sol"),obj.getString("status")); + ctx.status(200); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + + /******************/ + } + + + public static MockUser checkUser(Context ctx) { + JSONObject ids = new JSONObject(ctx.body()); + + for (MockUser u : users) + if (u.name.equals(ids.get("username")) && u.password.equals(ids.get("password"))) + return u; + return null; + } +} diff --git a/gateway/target/09-1.0-SNAPSHOT.jar b/gateway/target/09-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..2381c521d3c4ad868ed9777c4c7c1c8c4722fa86 Binary files /dev/null and b/gateway/target/09-1.0-SNAPSHOT.jar differ diff --git a/gateway/target/classes/Kata.class b/gateway/target/classes/Kata.class new file mode 100644 index 0000000000000000000000000000000000000000..19e7b2c45129d7ab6919bd2def1a9070180f3bec Binary files /dev/null and b/gateway/target/classes/Kata.class differ diff --git a/gateway/target/classes/KataShowCase.class b/gateway/target/classes/KataShowCase.class new file mode 100644 index 0000000000000000000000000000000000000000..0cd30bb503988e17695e5101e37861fec13e46c1 Binary files /dev/null and b/gateway/target/classes/KataShowCase.class differ diff --git a/gateway/target/classes/KataSubscription.class b/gateway/target/classes/KataSubscription.class new file mode 100644 index 0000000000000000000000000000000000000000..6afe70bbb7a9ed7a739d7c10f2b67abd4f00f572 Binary files /dev/null and b/gateway/target/classes/KataSubscription.class differ diff --git a/gateway/target/classes/LiveDB.class b/gateway/target/classes/LiveDB.class new file mode 100644 index 0000000000000000000000000000000000000000..41cad6a6f656cdda2c19b807d166106c265dbd21 Binary files /dev/null and b/gateway/target/classes/LiveDB.class differ diff --git a/gateway/target/classes/MockUser.class b/gateway/target/classes/MockUser.class new file mode 100644 index 0000000000000000000000000000000000000000..8f9dff4d0fbf1e8dc569af3217c1cacd4419f244 Binary files /dev/null and b/gateway/target/classes/MockUser.class differ diff --git a/gateway/target/classes/MongoDB.class b/gateway/target/classes/MongoDB.class new file mode 100644 index 0000000000000000000000000000000000000000..c75c8ccfa3ebbe95ace5f6f6b368b7b320e1002c Binary files /dev/null and b/gateway/target/classes/MongoDB.class differ diff --git a/gateway/target/classes/Program.class b/gateway/target/classes/Program.class new file mode 100644 index 0000000000000000000000000000000000000000..b90cce2a458199d8e1c735cdbcf628e1dc17f8f3 Binary files /dev/null and b/gateway/target/classes/Program.class differ diff --git a/gateway/target/classes/ProgramShowCase.class b/gateway/target/classes/ProgramShowCase.class new file mode 100644 index 0000000000000000000000000000000000000000..c1a0eead2fdc0398e887c1f64269e64775af3475 Binary files /dev/null and b/gateway/target/classes/ProgramShowCase.class differ diff --git a/gateway/target/classes/ProgramSubscription.class b/gateway/target/classes/ProgramSubscription.class new file mode 100644 index 0000000000000000000000000000000000000000..d854a98e25b5874cff272a34d0e9ea353d773f2b Binary files /dev/null and b/gateway/target/classes/ProgramSubscription.class differ diff --git a/gateway/target/classes/ProgramsDataBase.class b/gateway/target/classes/ProgramsDataBase.class new file mode 100644 index 0000000000000000000000000000000000000000..73f4ea12c0f3cc9e2e19df185b957496eab9d782 Binary files /dev/null and b/gateway/target/classes/ProgramsDataBase.class differ diff --git a/gateway/target/classes/app$Roles.class b/gateway/target/classes/app$Roles.class new file mode 100644 index 0000000000000000000000000000000000000000..7fd0a8d175306585e897c571a1a78fb67665262c Binary files /dev/null and b/gateway/target/classes/app$Roles.class differ diff --git a/gateway/target/classes/app.class b/gateway/target/classes/app.class new file mode 100644 index 0000000000000000000000000000000000000000..15cacf490efeb00aa9c56d5dbd249490e3bf7e1f Binary files /dev/null and b/gateway/target/classes/app.class differ diff --git a/gateway/target/maven-archiver/pom.properties b/gateway/target/maven-archiver/pom.properties new file mode 100644 index 0000000000000000000000000000000000000000..2c5c7655b9b01bd73bd26dca773942bdd8324dcc --- /dev/null +++ b/gateway/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Thu May 09 11:01:21 CEST 2019 +groupId=09 +artifactId=09 +version=1.0-SNAPSHOT diff --git a/gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..e8545315b0608c56cb3421477889a560d1624f53 --- /dev/null +++ b/gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,7 @@ +/Users/freak/Desktop/dojo-hepia/gateway/src/main/java/KataShowCase.java +/Users/freak/Desktop/dojo-hepia/gateway/src/main/java/ProgramShowCase.java +/Users/freak/Desktop/dojo-hepia/gateway/src/main/java/Program.java +/Users/freak/Desktop/dojo-hepia/gateway/src/main/java/app.java +/Users/freak/Desktop/dojo-hepia/gateway/src/main/java/LiveDB.java +/Users/freak/Desktop/dojo-hepia/gateway/src/main/java/Kata.java +/Users/freak/Desktop/dojo-hepia/gateway/src/main/java/ProgramsDataBase.java diff --git a/gateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/gateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/mongodb/data/programs b/mongodb/data/programs new file mode 100644 index 0000000000000000000000000000000000000000..5645e090c719a09ac91c7424d24ad4d728d20d76 --- /dev/null +++ b/mongodb/data/programs @@ -0,0 +1 @@ +[{"_id":"baac03de-2816-470e-8789-3c10b438364f","description":"Let's play with arrays in python !","idsensei":"1","katas":[{"_id":"41ea64c1-0711-46a8-aece-fae593283ad1","canva":"def add(arr,m):","cassert":"from assertpy import assert_that\nimport sample as m\n\nassert_that(m.add([2,3,4],3)).is_equal_to([2,3,4,3])","difficulty":"Ceinture blanche","keepAssert":false,"language":"python","nbAttempt":3,"programID":"baac03de-2816-470e-8789-3c10b438364f","rules":"Add the given element to the given array\n\nexemple :\nafter you've added the number '3' to the array [2,3,4], it becomes [2,3,4,3]","solution":"def add(arr,m):\n arr.append(m)\n return arr","title":"Add element"},{"_id":"55501e10-12fe-446f-aea1-2d4db550f1f6","canva":"def mult(arr,n):\n # begin code here\n ","cassert":"from assertpy import assert_that\nimport sample as m\n\nassert_that(m.mult([2,3,4],2)).is_equal_to([4,6,8])\nassert_that(m.mult([2,3,4],5)).is_equal_to([10,15,20])","difficulty":"Ceinture blanche","keepAssert":true,"language":"python","nbAttempt":10,"programID":"baac03de-2816-470e-8789-3c10b438364f","rules":"You'll multiply each element of a given array by the given number.","solution":"def mult(arr,n):\n return [i * n for i in arr]","title":"Multiply elements"}],"language":"python","nbKata":2,"sensei":"shodai","tags":["arrays","hashmap","list"],"title":"Arrays"},{"_id":"26f8bb8a-e872-4b21-94a4-56308d500399","description":"Basics of the python language","idsensei":"2","katas":[{"_id":"4603ffd1-054f-4163-af51-d84a84c894e9","canva":"def ret(n):\n ","cassert":"from assertpy import assert_that\nimport sample as m\n\nassert_that(m.ret(5)).is_equal_to(5)\nassert_that(m.ret(4)).is_equal_to(4)","difficulty":"Ceinture blanche","keepAssert":false,"language":"python","nbAttempt":100,"programID":"26f8bb8a-e872-4b21-94a4-56308d500399","rules":"Just return the given value.","solution":"def ret(n):\n return n","title":"Return n"}],"language":"python","nbKata":1,"sensei":"sensei","tags":["basics","python"],"title":"Fundamentals"},{"_id":"86a3991a-a02e-4e0a-9323-7f4cedca2e3b","description":"Arrays in java are not that easy.","idsensei":"2","katas":[{"_id":"24ba470b-5678-482b-a888-95a02b6bf90e","canva":"import java.util.ArrayList;\n\npublic class Kata {\n public static int sum(ArrayList<Integer> list){\n \n }\n}\n","cassert":"import static org.junit.Assert.*;\nimport java.util.ArrayList;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n ArrayList<Integer> mylist = new ArrayList<>();\n mylist.add(15);\n mylist.add(5);\n mylist.add(10);\n\n assertEquals(Kata.sum(mylist),30); \n\n }\n}","difficulty":"Ceinture blanche","keepAssert":true,"language":"java","nbAttempt":2,"programID":"86a3991a-a02e-4e0a-9323-7f4cedca2e3b","rules":"Return a sum of all element in an arraylist","solution":"import java.util.ArrayList;\n\npublic class Kata {\n public static int sum(ArrayList<Integer> list){\n int sum = 0;\n for(int n : list)\n sum += n;\n return sum;\n }\n}\n","title":"Sum up element"}],"language":"java","nbKata":1,"sensei":"sensei","tags":["arrays","arraylist","hashmap"],"title":"Arrays"}] diff --git a/mongodb/data/programssubscriptions b/mongodb/data/programssubscriptions new file mode 100644 index 0000000000000000000000000000000000000000..b8000b92a304c98ba2f4202ebaa30d420f7666ec --- /dev/null +++ b/mongodb/data/programssubscriptions @@ -0,0 +1 @@ +[{"_id":"c1eed8bf-da7d-4780-948b-3bdf03af47e2","idprogram":"baac03de-2816-470e-8789-3c10b438364f","iduser":"1","katas":[],"nbKataDone":0,"status":true},{"_id":"95fe5168-f463-493d-8357-c05aee8caeb8","idprogram":"26f8bb8a-e872-4b21-94a4-56308d500399","iduser":"2","katas":[],"nbKataDone":0,"status":true},{"_id":"4863a985-ad1f-4de9-8ae9-98f4721d81d9","idprogram":"86a3991a-a02e-4e0a-9323-7f4cedca2e3b","iduser":"2","katas":[{"_id":"24ba470b-5678-482b-a888-95a02b6bf90e","mysol":"import java.util.ArrayList;\n\npublic class Kata {\n public static int sum(ArrayList<Integer> list){\n int sum = 0;\n for(int i = 0;i<list.size();i++)\n sum += list.get(i);\n return sum;\n }\n}\n","nbAttempt":3,"status":"RESOLVED"}],"nbKataDone":1,"status":true},{"_id":"0a8e6a59-835c-4936-857d-4d10a8fea2c9","idprogram":"baac03de-2816-470e-8789-3c10b438364f","iduser":"0","katas":[{"_id":"41ea64c1-0711-46a8-aece-fae593283ad1","mysol":"def add(arr,m):\n arr.append(m)\n return arr","nbAttempt":1,"status":"RESOLVED"}],"nbKataDone":1,"status":true}] diff --git a/mongodb/docker-compose.yml b/mongodb/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..ff4f75e904a33ef21ac228edfb04afff955ed996 --- /dev/null +++ b/mongodb/docker-compose.yml @@ -0,0 +1,25 @@ +version: '3.1' + +services: + + mongo: + image: mongo + restart: always + ports: + - 27017:27017 + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: example + MONGO_INITDB_DATABASE: DojoHepia + MONGODB_USER: shodai + MONGODB_DATABASE: DojoHepia + MONGODB_PASS: shodai + + mongo-express: + image: mongo-express + restart: always + ports: + - 8081:8081 + environment: + ME_CONFIG_MONGODB_ADMINUSERNAME: root + ME_CONFIG_MONGODB_ADMINPASSWORD: example \ No newline at end of file diff --git a/tests/python/assert_test01/.idea/workspace.xml b/tests/python/assert_test01/.idea/workspace.xml index 3415de75d417b10a7997b79f657b9351991de080..c40c041cfccba5ff584c198d45dc8c5d9ae52c4d 100644 --- a/tests/python/assert_test01/.idea/workspace.xml +++ b/tests/python/assert_test01/.idea/workspace.xml @@ -2,13 +2,22 @@ <project version="4"> <component name="ChangeListManager"> <list default="true" id="9effdb46-08d0-4cbd-b283-1a3f84f5311a" name="Default Changelist" comment=""> - <change afterPath="$PROJECT_DIR$/.idea/assert_test01.iml" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/main.py" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/test.py" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../../serveur_compilation/front-end-compilation/src/app/app.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../../serveur_compilation/front-end-compilation/src/app/app.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../client/src/app/kata-displayer/kataShowCase.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../../../client/src/app/kata-displayer/kataShowCase.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../client/src/app/program-create/program-create.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../../../client/src/app/program-create/program-create.component.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../client/src/app/program-displayer/program-displayer.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../../../client/src/app/program-displayer/program-displayer.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../client/src/app/program-displayer/program.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../../../client/src/app/program-displayer/program.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/.idea/workspace.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/pom.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/src/main/java/Kata.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/src/main/java/Kata.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/src/main/java/LiveDB.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/src/main/java/LiveDB.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/src/main/java/Program.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/src/main/java/Program.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/src/main/java/ProgramShowCase.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/src/main/java/ProgramShowCase.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/src/main/java/app.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/src/main/java/app.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/target/classes/Kata.class" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/target/classes/Kata.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/target/classes/LiveDB.class" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/target/classes/LiveDB.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/target/classes/Program.class" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/target/classes/Program.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/target/classes/ProgramShowCase.class" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/target/classes/ProgramShowCase.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../../../gateway/target/classes/app.class" beforeDir="false" afterPath="$PROJECT_DIR$/../../../gateway/target/classes/app.class" afterDir="false" /> </list> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="SHOW_DIALOG" value="false" /> @@ -146,16 +155,17 @@ <updated>1556636994757</updated> <workItem from="1556636997623" duration="502000" /> <workItem from="1556696058143" duration="2450000" /> + <workItem from="1557408015513" duration="6000" /> </task> <servers /> </component> <component name="TimeTrackingManager"> - <option name="totallyTimeSpent" value="2952000" /> + <option name="totallyTimeSpent" value="2958000" /> </component> <component name="ToolWindowManager"> <frame x="355" y="87" width="1400" height="1000" extended-state="0" /> <layout> - <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.2533137" /> + <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.2569956" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Favorites" order="2" side_tool="true" /> <window_info anchor="bottom" id="Message" order="0" /> diff --git a/tests/serveur_compilation/server_rest/pom.xml b/tests/serveur_compilation/server_rest/pom.xml index 1756ee2631f18359c2a345391c0422aacc6c3673..c5be4794edffccfd186a19e6f5e75d4ea4fc3a2c 100644 --- a/tests/serveur_compilation/server_rest/pom.xml +++ b/tests/serveur_compilation/server_rest/pom.xml @@ -20,6 +20,11 @@ </plugins> </build> <dependencies> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20180813</version> + </dependency> <dependency> <groupId>io.javalin</groupId> <artifactId>javalin</artifactId> diff --git a/tests/serveur_compilation/server_rest/src/main/java/Kata.java b/tests/serveur_compilation/server_rest/src/main/java/Kata.java new file mode 100644 index 0000000000000000000000000000000000000000..55f94dcfeed3d00b25b7f18d5e56ba392d72c0e4 --- /dev/null +++ b/tests/serveur_compilation/server_rest/src/main/java/Kata.java @@ -0,0 +1,94 @@ +public class Kata { + private String id, title, canva, cassert, solution, rules,programID,difficulty,language; + private boolean keepAssert; + private int nbAttempt; + + + public boolean isKeepAssert() { + return keepAssert; + } + + public void setKeepAssert(boolean keepAssert) { + this.keepAssert = keepAssert; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getCanva() { + return canva; + } + + public void setCanva(String canva) { + this.canva = canva; + } + + public String getCassert() { + return cassert; + } + + public void setCassert(String cassert) { + this.cassert = cassert; + } + + public String getSolution() { + return solution; + } + + public void setSolution(String solution) { + this.solution = solution; + } + + public String getRules() { + return rules; + } + + public void setRules(String rules) { + this.rules = rules; + } + + public int getNbAttempt() { + return nbAttempt; + } + + public void setNbAttempt(int nbAttempt) { + this.nbAttempt = nbAttempt; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getProgramID() { + return programID; + } + + public void setProgramID(String programID) { + this.programID = programID; + } + + public String getDifficulty() { + return difficulty; + } + + public void setDifficulty(String difficulty) { + this.difficulty = difficulty; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } +} diff --git a/tests/serveur_compilation/server_rest/src/main/java/KataShowCase.java b/tests/serveur_compilation/server_rest/src/main/java/KataShowCase.java new file mode 100644 index 0000000000000000000000000000000000000000..345ea1e1390e0127dbb657610c0cd0132785180d --- /dev/null +++ b/tests/serveur_compilation/server_rest/src/main/java/KataShowCase.java @@ -0,0 +1,42 @@ +public class KataShowCase { + private String title,difficulty,id,status; + + public KataShowCase(String title, String difficulty, String id, String status){ + this.difficulty = difficulty; + this.title = title; + this.id = id; + this.status = status; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDifficulty() { + return difficulty; + } + + public void setDifficulty(String difficulty) { + this.difficulty = difficulty; + } + + public String getId() { + return id; + } + + public void setId(String programID) { + this.id = programID; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/tests/serveur_compilation/server_rest/src/main/java/LiveDB.java b/tests/serveur_compilation/server_rest/src/main/java/LiveDB.java new file mode 100644 index 0000000000000000000000000000000000000000..2d8063ca68214f7d5b14668a8289e1b9bb96a63b --- /dev/null +++ b/tests/serveur_compilation/server_rest/src/main/java/LiveDB.java @@ -0,0 +1,77 @@ +import java.util.ArrayList; + +public class LiveDB extends ProgramsDataBase { + + ArrayList<Kata> katas; + + ArrayList<Program> programs; + + public LiveDB() { + this.programs = new ArrayList<>(); + this.katas = new ArrayList<>(); + } + + public void createProgram(Program prg) { + this.programs.add(prg); + } + + public void createKata(Kata kata) { + + for (Program p : this.programs) + if (p.getId().equals(kata.getProgramID())) { + p.setNbKata(p.getNbKata() + 1); + p.getKatas().add(kata); + break; + } + } + + public ArrayList<ProgramShowCase> getProgramsDetails() { + ArrayList<ProgramShowCase> p = new ArrayList<>(); + + for (Program prg : this.programs) + p.add(new ProgramShowCase(prg.getTitle(), prg.getSensei(), prg.getLanguage(), prg.getDescription(), prg.getNbKata(), prg.getTags(), prg.getId())); + + return p; + } + + public Kata getProgramKata(String programID, String kataID) { + ArrayList<Kata> ktemp = new ArrayList<>(); + Kata kata = new Kata(); + for (Program prg : this.programs) + if (prg.getId().equals(programID)) + ktemp = prg.getKatas(); + for(Kata k : ktemp) + if(k.getId().equals(kataID)) + kata = k; + return kata; + } + + public ArrayList<KataShowCase> getProgramKatasDetails(String programID) { + ArrayList<KataShowCase> ktsc = new ArrayList<>(); + ArrayList<Kata> kt = new ArrayList<>(); + for (Program prg : this.programs) + if (prg.getId().equals(programID)) { + kt = prg.getKatas(); + break; + } + + for (Kata k : kt) + ktsc.add(new KataShowCase(k.getTitle(), k.getDifficulty(), k.getId(), "TODO")); + return ktsc; + } + + public ArrayList<String> getProgramDetailsByID(String id){ + ArrayList<String> infos = new ArrayList<>(); + + for (Program p : this.programs) + if(p.getId().equals(id)){ + infos.add(p.getTitle()); + infos.add(p.getLanguage()); + infos.add(p.getSensei()); + break; + } + + return infos; + } + +} \ No newline at end of file diff --git a/tests/serveur_compilation/server_rest/src/main/java/Program.java b/tests/serveur_compilation/server_rest/src/main/java/Program.java new file mode 100644 index 0000000000000000000000000000000000000000..40ced1914b050bc844664e10926797549c3bd58b --- /dev/null +++ b/tests/serveur_compilation/server_rest/src/main/java/Program.java @@ -0,0 +1,80 @@ +import java.util.ArrayList; + +public class Program { + private String id,sensei,language,title,description; + private String[] tags; + private int nbKata; + private ArrayList<Kata> katas; + + public String getSensei() { + return sensei; + } + + public void setSensei(String sensei) { + this.sensei = sensei; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public int getNbKata() { + return nbKata; + } + + public void setNbKata(int nbKata) { + this.nbKata = nbKata; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String[] getTags() { + return tags; + } + + public void setTags(String[] tags) { + this.tags = tags; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ArrayList<Kata> getKatas() { + return katas; + } + + public void setKatas(ArrayList<Kata> katas) { + this.katas = katas; + } +/* + public ArrayList<Kata> getKata() { + return kata; + } + + public void setKata(ArrayList<Kata> kata) { + this.kata = kata; + }*/ +} diff --git a/tests/serveur_compilation/server_rest/src/main/java/ProgramShowCase.java b/tests/serveur_compilation/server_rest/src/main/java/ProgramShowCase.java new file mode 100644 index 0000000000000000000000000000000000000000..5f1974c31a6c93f62ad3c67aedf72d4c3dfc713b --- /dev/null +++ b/tests/serveur_compilation/server_rest/src/main/java/ProgramShowCase.java @@ -0,0 +1,71 @@ +public class ProgramShowCase { + private String title,sensei,language,description,programID; + private int nbKata; + private String[] tags; + + public ProgramShowCase(String title, String sensei, String language, String description, int nbKata, String[] tags, String programID){ + this.title = title; + this.sensei = sensei; + this.language = language; + this.description = description; + this.nbKata = nbKata; + this.tags = tags; + this.programID = programID; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getSensei() { + return sensei; + } + + public void setSensei(String sensei) { + this.sensei = sensei; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getNbKata() { + return nbKata; + } + + public void setNbKata(int nbKata) { + this.nbKata = nbKata; + } + + public String[] getTags() { + return tags; + } + + public void setTags(String[] tags) { + this.tags = tags; + } + + public String getProgramID() { + return programID; + } + + public void setProgramID(String programID) { + this.programID = programID; + } +} diff --git a/tests/serveur_compilation/server_rest/src/main/java/ProgramsDataBase.java b/tests/serveur_compilation/server_rest/src/main/java/ProgramsDataBase.java new file mode 100644 index 0000000000000000000000000000000000000000..f0ece141928330037e3ac090d576d52dd302316e --- /dev/null +++ b/tests/serveur_compilation/server_rest/src/main/java/ProgramsDataBase.java @@ -0,0 +1,10 @@ +import java.util.ArrayList; + +public abstract class ProgramsDataBase { + public abstract void createProgram(Program prg); + public abstract void createKata(Kata kata); + public abstract ArrayList<ProgramShowCase> getProgramsDetails(); + public abstract Kata getProgramKata(String programID, String kataID); + public abstract ArrayList<KataShowCase> getProgramKatasDetails(String programID); + public abstract ArrayList<String> getProgramDetailsByID(String id); +} diff --git a/tests/serveur_compilation/server_rest/src/main/java/app.java b/tests/serveur_compilation/server_rest/src/main/java/app.java index 19c6cb7fd5629091e380d8c06ff57f4ff8fa0aad..a30622df207525a986be370534baa6983b50d856 100644 --- a/tests/serveur_compilation/server_rest/src/main/java/app.java +++ b/tests/serveur_compilation/server_rest/src/main/java/app.java @@ -1,48 +1,48 @@ +import com.fasterxml.jackson.databind.ObjectMapper; import io.javalin.Javalin; import java.io.*; import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.URL; -import org.apache.commons.lang.StringEscapeUtils; - +import java.util.ArrayList; public class app { - public static void main(String[] args) { + + private static ProgramsDataBase db = new LiveDB(); + private static ObjectMapper objectMapper = new ObjectMapper(); + + public static void main(String[] args) { Javalin app = Javalin.create().enableCorsForAllOrigins().start(7000); - app.get("/run/", ctx -> { + app.post("/run/", ctx -> { HttpURLConnection connection = null; - try{ + + try { URL compilator = new URL("http://localhost:6999"); connection = (HttpURLConnection) compilator.openConnection(); connection.setRequestMethod("POST"); connection.setDoOutput(true); - }catch (ConnectException e){ + } catch (ConnectException e) { e.printStackTrace(); } - //Send request - String type = StringEscapeUtils.escapeJava(ctx.queryParams("language").get(0)); - String code = StringEscapeUtils.escapeJava(ctx.queryParams("code").get(0)); - String vassert = StringEscapeUtils.escapeJava(ctx.queryParams("test").get(0)); - - try(DataOutputStream wr = new DataOutputStream (connection.getOutputStream())){ - wr.writeBytes("{\"language\":\""+type+"\",\"stream\":\""+code+"\",\"assert\":\""+vassert+"\"}"); + try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) { + wr.writeBytes(ctx.body()); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); - }catch (ConnectException e){ + } catch (ConnectException e) { e.printStackTrace(); } - try(BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()))){ + try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { String response = in.readLine(); ctx.result(response); - } catch(IOException e){ + } catch (IOException e) { e.printStackTrace(); } @@ -54,11 +54,48 @@ public class app { // For now, we can assume we will only need to fetch one response since the compilation // server does send one json object with all the required data. + }); + app.post("/program/create", ctx -> { + Program prg = objectMapper.readValue(ctx.body(), Program.class); + db.createProgram(prg); + }); + app.post("/kata/create", ctx -> { + Kata kt = objectMapper.readValue(ctx.body(), Kata.class); + db.createKata(kt); + }); + app.get("/program/getdetails", ctx -> { + ArrayList<ProgramShowCase> prgsc = db.getProgramsDetails(); + if (prgsc.size() == 0) + ctx.status(404); + else + ctx.json(prgsc); + }); + + app.get("/program/getkatas/details/:id", ctx -> { + ArrayList<KataShowCase> ktsc = db.getProgramKatasDetails(ctx.pathParam("id")); + ctx.json(ktsc); + }); + + app.get("/program/getkata/:prid/:id", ctx -> { + Kata kata = db.getProgramKata(ctx.pathParam("prid"), ctx.pathParam("id")); + if (kata.getId() == null) + ctx.status(404); + else + ctx.json(kata); }); + + app.get("program/getdetails/:id", ctx -> { + ArrayList<String> s = db.getProgramDetailsByID(ctx.pathParam("id")); + if (s.size() == 0) + ctx.status(404); + else + ctx.json(s); + }); + } } diff --git a/tests/serveur_compilation/server_rest/target/classes/Kata.class b/tests/serveur_compilation/server_rest/target/classes/Kata.class new file mode 100644 index 0000000000000000000000000000000000000000..f25c79bcda09dd0d6749bcb29e8197d9ff1f8e99 Binary files /dev/null and b/tests/serveur_compilation/server_rest/target/classes/Kata.class differ diff --git a/tests/serveur_compilation/server_rest/target/classes/KataShowCase.class b/tests/serveur_compilation/server_rest/target/classes/KataShowCase.class new file mode 100644 index 0000000000000000000000000000000000000000..0cd30bb503988e17695e5101e37861fec13e46c1 Binary files /dev/null and b/tests/serveur_compilation/server_rest/target/classes/KataShowCase.class differ diff --git a/tests/serveur_compilation/server_rest/target/classes/LiveDB.class b/tests/serveur_compilation/server_rest/target/classes/LiveDB.class new file mode 100644 index 0000000000000000000000000000000000000000..ab6ebb636dbde39b1bc15d10352aff1beab6f9e2 Binary files /dev/null and b/tests/serveur_compilation/server_rest/target/classes/LiveDB.class differ diff --git a/tests/serveur_compilation/server_rest/target/classes/Program.class b/tests/serveur_compilation/server_rest/target/classes/Program.class new file mode 100644 index 0000000000000000000000000000000000000000..28a6aa780e25735f56a5623fa57bcb5ccfcefe45 Binary files /dev/null and b/tests/serveur_compilation/server_rest/target/classes/Program.class differ diff --git a/tests/serveur_compilation/server_rest/target/classes/ProgramShowCase.class b/tests/serveur_compilation/server_rest/target/classes/ProgramShowCase.class new file mode 100644 index 0000000000000000000000000000000000000000..787ad292fa0c3d49f6f3f9376aa49f0cc0621a24 Binary files /dev/null and b/tests/serveur_compilation/server_rest/target/classes/ProgramShowCase.class differ diff --git a/tests/serveur_compilation/server_rest/target/classes/ProgramsDataBase.class b/tests/serveur_compilation/server_rest/target/classes/ProgramsDataBase.class new file mode 100644 index 0000000000000000000000000000000000000000..4f73f058ad7f7eb5a64a9773bbba0c50cc4f7ed6 Binary files /dev/null and b/tests/serveur_compilation/server_rest/target/classes/ProgramsDataBase.class differ diff --git a/tests/serveur_compilation/server_rest/target/classes/app.class b/tests/serveur_compilation/server_rest/target/classes/app.class index 42f739678407485c85fb4bae067343b87f49dc1f..1c9802a0ba2547a05908d5756ebce45a16bfac3e 100644 Binary files a/tests/serveur_compilation/server_rest/target/classes/app.class and b/tests/serveur_compilation/server_rest/target/classes/app.class differ diff --git a/tests/serveur_compilation/serveur_compilation/share_docker_file/Kata.class b/tests/serveur_compilation/serveur_compilation/share_docker_file/Kata.class new file mode 100644 index 0000000000000000000000000000000000000000..959da4d1550e115f347b94ad691e223177edf53f Binary files /dev/null and b/tests/serveur_compilation/serveur_compilation/share_docker_file/Kata.class differ diff --git a/tests/serveur_compilation/serveur_compilation/share_docker_file/Main.class b/tests/serveur_compilation/serveur_compilation/share_docker_file/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..ad3d50357a4ab5201cd1114a5a4b54ac4491bda4 Binary files /dev/null and b/tests/serveur_compilation/serveur_compilation/share_docker_file/Main.class differ diff --git a/tests/serveur_compilation/serveur_compilation/share_docker_file/__pycache__/sample.cpython-34.pyc b/tests/serveur_compilation/serveur_compilation/share_docker_file/__pycache__/sample.cpython-34.pyc index c307a156cefae4a96b140b2be5cbfa9a640c3a5c..4b2b97347f54e0cdff7575275d98bb69a86cbb8c 100644 Binary files a/tests/serveur_compilation/serveur_compilation/share_docker_file/__pycache__/sample.cpython-34.pyc and b/tests/serveur_compilation/serveur_compilation/share_docker_file/__pycache__/sample.cpython-34.pyc differ diff --git a/tests/serveur_compilation/serveur_compilation/src/main/java/DockerCompilation.java b/tests/serveur_compilation/serveur_compilation/src/main/java/DockerCompilation.java index 6ad789e25dcd538f91dffbeef5c9ea71dc432482..cce482e90a1da238e05f25688473af0f9edb6161 100644 --- a/tests/serveur_compilation/serveur_compilation/src/main/java/DockerCompilation.java +++ b/tests/serveur_compilation/serveur_compilation/src/main/java/DockerCompilation.java @@ -13,14 +13,12 @@ public class DockerCompilation { case "python": filename = "share_docker_file/sample.py"; filename_test = "share_docker_file/assert.py"; - // cmd = "python3 " + filename_test; cmd = "docker run --rm --mount type=bind,source=/Users/freak/Desktop/dojo-hepia/tests/serveur_compilation/serveur_compilation/share_docker_file,dst=/env/ hey:1.1 python3 assert.py"; break; case "java": filename = "share_docker_file/kata.java"; filename_test = "share_docker_file/Main.java"; cmd = "docker run --rm --mount type=bind,source=/Users/freak/Desktop/dojo-hepia/tests/serveur_compilation/serveur_compilation/share_docker_file,dst=/env/ java:4.0 ./java_test.sh"; - //cmd = "java " + filename_test; break; } @@ -91,15 +89,6 @@ public class DockerCompilation { file = new File(filename_test); file.delete(); - switch (input.get("language").toString()){ - case "java": - file = new File("share_docker_file/Main.class"); - file.delete(); - file = new File("share_docker_file/kata.class"); - file.delete(); - break; - } - return json; } } diff --git a/tests/serveur_compilation/serveur_compilation/target/classes/DockerCompilation.class b/tests/serveur_compilation/serveur_compilation/target/classes/DockerCompilation.class index 994cf1cca332b9d916993ed58361757ca7d99761..055e62c73585cc38dbc2ffde36ada2f9e0700bc8 100644 Binary files a/tests/serveur_compilation/serveur_compilation/target/classes/DockerCompilation.class and b/tests/serveur_compilation/serveur_compilation/target/classes/DockerCompilation.class differ