This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Commit 737d7336 authored by Michael Breu's avatar Michael Breu 💬
Browse files

Intermediate commit (extended version mit ZIP download)

parent 4c4b0dbe
......@@ -47,22 +47,14 @@ public class SharingDemoService {
request().
accept(MediaType.APPLICATION_JSON).
get(ShoppingBasket.class);
if(shoppingBasket!=null) {
for(ShoppingBasket.ExerciseInfo ex: shoppingBasket.exerciseInfo) {
convertKeyWordsToArtemisJSON(ex);
}
}
// if(shoppingBasket!=null) {
// for(ShoppingBasket.ExerciseInfo ex: shoppingBasket.exerciseInfo) {
// convertKeyWordsToArtemisJSON(ex);
// }
// }
return Optional.of(shoppingBasket);
}
// TODO this is the wrong place, should be done in GUI.
private void convertKeyWordsToArtemisJSON(ShoppingBasket.ExerciseInfo ex) {
// TODO escape keyword for JSON
for(int i=0; i<ex.keywords.size(); i++) {
ex.keywords.set(i, "{ \"category\": \"" + ex.keywords.get(i) + "\", \"color\":\"#691b0b\"}");
}
}
LoadingCache<Pair<String, Integer>, File> repositoryCache = CacheBuilder.newBuilder()
.maximumSize(10000)
......
......@@ -81,8 +81,7 @@ public class SharingDemoResource {
* @param basketToken the basket
* @return the ResponseEntity with status 200 (OK) and with body the exercise, or with status 404 (Not Found)
*/
@PostMapping("/sharingImport/basket/exercise/{exercisePosition}/readMe.md")
// @PreAuthorize("hasAnyRole('INSTRUCTOR', 'ADMIN')")
@PostMapping("/sharingImport/basket/exercise/{exercisePosition}/README.md")
public ResponseEntity<String> getProblemStatement(@PathVariable("exercisePosition") int exercisePosition, @RequestBody SharingInfoDTO basketToken) throws IOException {
InputStream repositoryStream = null;
try {
......@@ -93,9 +92,9 @@ public class SharingDemoResource {
ZipInputStream zippedRepositoryStream = new ZipInputStream(repositoryStream);
ZipEntry statement = getEntry("exercise.md", zippedRepositoryStream);
ZipEntry statement = getEntry("README.md", zippedRepositoryStream);
if (statement == null) {
return ResponseEntity.ok().body("Statement not found!") ;
return ResponseEntity.ok().body("README.md not found in Repository!") ;
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
......
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
......@@ -9,7 +9,7 @@ export type ExerciseInfo = {
title: string;
gitLabProjectId: string;
gitLabURI: string;
keywords: string[];
keywords: Array<string>;
};
export type ShoppingBasket = {
exerciseInfo: Array<ExerciseInfo>;
......@@ -28,4 +28,9 @@ export class SharingDemoService {
return this.http.post<ShoppingBasket>(this.resourceUrl + '/basket', this.sharingInfo);
}
loadExerciseREADME(exercisePosition: number): Observable<string> {
const headers = new HttpHeaders(); // .set('Content-Type', 'text/plain; charset=utf-8');
return this.http.post<string>(this.resourceUrlPS + exercisePosition + '/README.md', this.sharingInfo, { headers, responseType: 'text' as 'json' });
}
}
<body>
<div class="wrapper">
<div class="header">
<h1>Happy Sharing</h1>
</div>
<div class="content">
<h1>Data from URL</h1>
<div class="wrapper">
<div class="header">
<h1>Happy Sharing</h1>
</div>
<div class="content">
<h1>Data from URL</h1>
<div>basketToken: {{this.sharingInfo.basketToken}}</div>
<div>returnURL: {{this.sharingInfo.returnURL}}</div>
<div>apiBaseURL: {{this.sharingInfo.apiBaseURL}}</div>
</div>
<h1>Shopping Basket Data from SharingPlattform (loaded via plugin backend)</h1>
<div><span *ngIf="!shoppingBasket" >No Shopping Basket loaded</span></div>
<div *ngIf="shoppingBasket">
<div >
The Shopping Basket contains {{shoppingBasket.exerciseInfo.length}} element(s):
</div>
<div *ngFor="let execInfo of shoppingBasket.exerciseInfo">
<div>title: {{execInfo.title}}</div>
<div>gitLabURI: {{execInfo.gitLabURI}}</div>
<div>gitLabProjectId: {{execInfo.gitLabProjectId}}</div>
<div>keywords: <span *ngFor="let kw of execInfo.keywords"></span>"{{kw}}" </div>
</div>
</div>
</div>
<div>apiBaseURL: {{this.sharingInfo.apiBaseURL}}</div>
</div>
<h1>Shopping Basket Data from SharingPlattform (loaded via plugin
backend)</h1>
<div>
<span *ngIf="!shoppingBasket.exerciseInfo">No Shopping Basket
loaded (or shopping basket token timed out?)</span>
</div>
<div *ngIf="shoppingBasket.exerciseInfo">
<div>The Shopping Basket contains
{{shoppingBasket.exerciseInfo.length}} element(s):</div>
<div *ngFor="let execInfo of shoppingBasket.exerciseInfo; index as i;">
<h3>{{i}} {{execInfo.title}}</h3>
<div>gitLabURI: {{execInfo.gitLabURI}}</div>
<div>gitLabProjectId: {{execInfo.gitLabProjectId}}</div>
<div>
keywords: <span *ngFor="let keyword of execInfo.keywords">"{{keyword}}"
</span>
</div>
<h4>README.md</h4>
<div>{{readme[i]}}</div>
</div>
</div>
</div>
</body>
......@@ -12,6 +12,7 @@ import { SharingDemoService, ShoppingBasket } from './service/sharing-demo.servi
export class SharingComponent implements OnInit {
public shoppingBasket: ShoppingBasket;
public readme: Array<string>;
constructor(
private route: ActivatedRoute,
......@@ -28,11 +29,20 @@ export class SharingComponent implements OnInit {
this.loadShoppingBasket();
});
this.shoppingBasket = {} as ShoppingBasket;
this.readme = new Array(10) ;
}
loadShoppingBasket(): void {
this.sharingDemoService.loadShoppingBasket().subscribe((res:ShoppingBasket) => {
this.shoppingBasket = res;
for (let i = 0; i < this.shoppingBasket.exerciseInfo.length; i++)
{this.loadReadMe(i);}
});
}
loadReadMe(exercisePosition: number): void {
this.sharingDemoService.loadExerciseREADME(exercisePosition).subscribe((res:string) => {
this.readme[exercisePosition] = res;
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment