create Supportive Material query public
This commit is contained in:
parent
9b9cf0de4d
commit
11bb1a3c8c
|
@ -38,7 +38,7 @@ public class SupportiveMaterialCensor extends BaseCensor {
|
||||||
if (fields == null || fields.isEmpty())
|
if (fields == null || fields.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDmpBlueprint);
|
this.authService.authorizeForce(Permission.BrowseSupportiveMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.ReferenceEntity;
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.model.Reference;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.query.FieldResolver;
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
import gr.cite.tools.data.query.QueryBase;
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
|
@ -213,18 +214,18 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
||||||
@Override
|
@Override
|
||||||
protected String fieldNameOf(FieldResolver item) {
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
if (item.match(ReferenceEntity._id)) return ReferenceEntity._id;
|
if (item.match(ReferenceEntity._id)) return ReferenceEntity._id;
|
||||||
else if (item.match(ReferenceEntity._label)) return ReferenceEntity._label;
|
else if (item.match(Reference._label)) return ReferenceEntity._label;
|
||||||
else if (item.match(ReferenceEntity._description)) return ReferenceEntity._description;
|
else if (item.match(Reference._description)) return ReferenceEntity._description;
|
||||||
else if (item.match(ReferenceEntity._createdAt)) return ReferenceEntity._createdAt;
|
else if (item.match(Reference._createdAt)) return ReferenceEntity._createdAt;
|
||||||
else if (item.match(ReferenceEntity._updatedAt)) return ReferenceEntity._updatedAt;
|
else if (item.match(Reference._updatedAt)) return ReferenceEntity._updatedAt;
|
||||||
else if (item.match(ReferenceEntity._isActive)) return ReferenceEntity._isActive;
|
else if (item.match(Reference._isActive)) return ReferenceEntity._isActive;
|
||||||
else if (item.match(ReferenceEntity._definition)) return ReferenceEntity._definition;
|
else if (item.match(Reference._definition)) return ReferenceEntity._definition;
|
||||||
else if (item.match(ReferenceEntity._abbreviation)) return ReferenceEntity._abbreviation;
|
else if (item.match(Reference._abbreviation)) return ReferenceEntity._abbreviation;
|
||||||
else if (item.match(ReferenceEntity._reference)) return ReferenceEntity._reference;
|
else if (item.match(Reference._reference)) return ReferenceEntity._reference;
|
||||||
else if (item.match(ReferenceEntity._source)) return ReferenceEntity._source;
|
else if (item.match(Reference._source)) return ReferenceEntity._source;
|
||||||
else if (item.match(ReferenceEntity._sourceType)) return ReferenceEntity._sourceType;
|
else if (item.match(Reference._sourceType)) return ReferenceEntity._sourceType;
|
||||||
else if (item.match(ReferenceEntity._type)) return ReferenceEntity._type;
|
else if (item.match(Reference._type)) return ReferenceEntity._type;
|
||||||
//else if (item.prefix(ReferenceEntity._createdBy)) return ReferenceEntity._createdBy;
|
//else if (item.prefix(Reference._createdBy)) return ReferenceEntity._createdBy;
|
||||||
else return null;
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,6 +210,7 @@ public class SupportiveMaterialQuery extends QueryBase<SupportiveMaterialEntity>
|
||||||
if (item.match(SupportiveMaterial._id)) return SupportiveMaterialEntity._id;
|
if (item.match(SupportiveMaterial._id)) return SupportiveMaterialEntity._id;
|
||||||
else if (item.match(SupportiveMaterial._type)) return SupportiveMaterialEntity._type;
|
else if (item.match(SupportiveMaterial._type)) return SupportiveMaterialEntity._type;
|
||||||
else if (item.match(SupportiveMaterial._languageCode)) return SupportiveMaterialEntity._languageCode;
|
else if (item.match(SupportiveMaterial._languageCode)) return SupportiveMaterialEntity._languageCode;
|
||||||
|
else if (item.match(SupportiveMaterial._payload)) return SupportiveMaterialEntity._payload;
|
||||||
else if (item.match(SupportiveMaterial._createdAt)) return SupportiveMaterialEntity._createdAt;
|
else if (item.match(SupportiveMaterial._createdAt)) return SupportiveMaterialEntity._createdAt;
|
||||||
else if (item.match(SupportiveMaterial._updatedAt)) return SupportiveMaterialEntity._updatedAt;
|
else if (item.match(SupportiveMaterial._updatedAt)) return SupportiveMaterialEntity._updatedAt;
|
||||||
else if (item.match(SupportiveMaterial._isActive)) return SupportiveMaterialEntity._isActive;
|
else if (item.match(SupportiveMaterial._isActive)) return SupportiveMaterialEntity._isActive;
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{
|
||||||
} else {
|
} else {
|
||||||
List<SupportiveMaterialEntity> datas = this.queryFactory.query(SupportiveMaterialQuery.class).authorize(AuthorizationFlags.OwnerOrPermission).languageCodes(model.getLanguageCode()).types(model.getType()).collect();
|
List<SupportiveMaterialEntity> datas = this.queryFactory.query(SupportiveMaterialQuery.class).authorize(AuthorizationFlags.OwnerOrPermission).languageCodes(model.getLanguageCode()).types(model.getType()).collect();
|
||||||
|
|
||||||
if(datas != null){
|
if(datas != null && !datas.isEmpty()){
|
||||||
throw new MyApplicationException("Could not create a new Data with same type and lang code !");
|
throw new MyApplicationException("Could not create a new Data with same type and lang code !");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,26 +112,23 @@ public class SupportiveMaterialController {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("get/{lang}")
|
@PostMapping("public")
|
||||||
public ResponseEntity<byte[]> getMaterial(@PathVariable(name = "lang") String lang, int field) throws IOException {
|
public ResponseEntity<byte[]> queryPublic(@RequestBody SupportiveMaterialLookup lookup) throws IOException {
|
||||||
if( !EnumUtils.isValidEnum(SupportiveMaterialFieldType.class, SupportiveMaterialFieldType.of((short) field).name())){
|
logger.debug("querying {}", SupportiveMaterial.class.getSimpleName());
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
|
||||||
|
this.censorFactory.censor(SupportiveMaterialCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
|
SupportiveMaterialQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrPermission);
|
||||||
|
List<SupportiveMaterialEntity> datas = query.collectAs(lookup.getProject());
|
||||||
|
if (datas.size() == 1){
|
||||||
|
return new ResponseEntity<>(datas.get(0).getPayload().getBytes(), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty(SupportiveMaterialFieldType.of((short) field).name().toLowerCase() +".path"))))) {
|
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty(lookup.getTypes().stream().toList().get(0).name().toLowerCase() +".path"))))) {
|
||||||
return this.supportiveMaterialService.getResponseEntity(lang, paths);
|
return this.supportiveMaterialService.getResponseEntity(lookup.getLanguageCodes().get(0), paths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @PostMapping("persist")
|
|
||||||
// public @ResponseBody
|
|
||||||
// ResponseEntity<ResponseItem<String>> persist(@RequestBody SupportiveMaterialPersist model) throws IOException {
|
|
||||||
// this.authorizationService.authorizeForce(Permission.AdminRole);
|
|
||||||
//
|
|
||||||
// //String fileName = this.environment.getProperty(model.getName()+ ".path");
|
|
||||||
// this.supportiveMaterialService.persist(model);
|
|
||||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Updated").payload("Updated"));
|
|
||||||
// }
|
|
||||||
|
|
||||||
@PostMapping("persist")
|
@PostMapping("persist")
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|
|
@ -300,6 +300,28 @@ permissions:
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
|
|
||||||
|
# SupportiveMaterial Permissions
|
||||||
|
BrowseSupportiveMaterial:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: yes
|
||||||
|
allowAuthenticated: yes
|
||||||
|
EditSupportiveMaterial:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
DeleteSupportiveMaterial:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
claims: [ ]
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
|
||||||
|
|
||||||
# DmpDescriptionTemplate Permissions
|
# DmpDescriptionTemplate Permissions
|
||||||
BrowseDmpDescriptionTemplate:
|
BrowseDmpDescriptionTemplate:
|
||||||
roles:
|
roles:
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<p> </p>
|
|
||||||
<p>
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>
|
|
||||||
</p>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<h1>Σχετικά με το Argos</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<p>Το ARGOS είναι ένα διαδικτυακό εργαλείο για την υποστήριξη αυτοματοποιημένων διαδικασιών για τη δημιουργία, τη διαχείριση, την κοινή χρήση και τη σύνδεση των DMP με ερευνητικά αντικείμενα στα οποία αντιστοιχούν. Αποτελεί κοινή προσπάθεια του OpenAIRE και της EUDAT να παραδώσουν μια ανοιχτή πλατφόρμα για τον Σχεδιασμό Διαχείρισης Δεδομένων που να αντιμετωπίζει τις βέλτιστες πρακτικές FAIR και Open και να μην προϋποθέτει εμπόδια για τη χρήση και την υιοθέτησή της. Το κάνει εφαρμόζοντας κοινά πρότυπα για μηχανικά ενεργά DMPs, όπως ορίζονται από την παγκόσμια κοινότητα ερευνητικών δεδομένων της RDA και επικοινωνώντας και διαβουλεύοντας τους ερευνητές, τις ερευνητικές κοινότητες και τους χρηματοδότες για να προβληματιστούν καλύτερα για τις ανάγκες τους.<br><br>Το ARGOS παρέχει ένα ευέλικτο περιβάλλον και μια εύκολη διεπαφή για την πλοήγηση και χρήση των χρηστών.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -10,6 +10,7 @@ import { catchError } from "rxjs/operators";
|
||||||
import { Guid } from "@common/types/guid";
|
import { Guid } from "@common/types/guid";
|
||||||
import { nameof } from "ts-simple-nameof";
|
import { nameof } from "ts-simple-nameof";
|
||||||
import { IsActive } from "@app/core/common/enum/is-active.enum";
|
import { IsActive } from "@app/core/common/enum/is-active.enum";
|
||||||
|
import { SupportiveMaterialFieldType } from "@app/core/common/enum/supportive-material-field-type";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SupportiveMaterialService{
|
export class SupportiveMaterialService{
|
||||||
|
@ -22,14 +23,10 @@ export class SupportiveMaterialService{
|
||||||
|
|
||||||
private get apiBase(): string { return `${this.configurationService.server}supportive-material`; }
|
private get apiBase(): string { return `${this.configurationService.server}supportive-material`; }
|
||||||
|
|
||||||
public getMaterial(lang: string, field: number): Observable<HttpResponse<Blob>> {
|
queryPublic(q: SupportiveMaterialLookup): Observable<HttpResponse<Blob>> {
|
||||||
return this.http.get(`${this.apiBase}/get/${lang}`, {params: {field}, responseType: 'blob', observe: 'response' });
|
return this.http.post<HttpResponse<Blob>>(`${this.apiBase}/public`, q , {responseType: 'blob', observe: 'response' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// public persist(item :SupportiveMaterialPersist): Observable<String> {
|
|
||||||
// return this.http.post<string>(`${this.apiBase}/persist`, item);
|
|
||||||
// }
|
|
||||||
|
|
||||||
query(q: SupportiveMaterialLookup): Observable<QueryResult<SupportiveMaterial>> {
|
query(q: SupportiveMaterialLookup): Observable<QueryResult<SupportiveMaterial>> {
|
||||||
const url = `${this.apiBase}/query`;
|
const url = `${this.apiBase}/query`;
|
||||||
return this.http.post<QueryResult<SupportiveMaterial>>(url, q).pipe(catchError((error: any) => throwError(error)));
|
return this.http.post<QueryResult<SupportiveMaterial>>(url, q).pipe(catchError((error: any) => throwError(error)));
|
||||||
|
@ -63,7 +60,7 @@ export class SupportiveMaterialService{
|
||||||
|
|
||||||
// LOOKUP
|
// LOOKUP
|
||||||
|
|
||||||
public static DefaultSupportiveMaterialLookup(params?: {}): SupportiveMaterialLookup{
|
public static DefaultSupportiveMaterialLookup(): SupportiveMaterialLookup{
|
||||||
const lookup = new SupportiveMaterialLookup();
|
const lookup = new SupportiveMaterialLookup();
|
||||||
|
|
||||||
lookup.project = {
|
lookup.project = {
|
||||||
|
|
|
@ -33,7 +33,11 @@ export class AboutComponent extends BaseComponent implements OnInit {
|
||||||
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
|
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||||
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/about']));
|
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/about']));
|
||||||
});
|
});
|
||||||
this.supportiveMaterialService.getMaterial(this.languageService.getCurrentLanguage(), SupportiveMaterialFieldType.About)
|
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup();
|
||||||
|
lookup.languageCodes = [this.languageService.getCurrentLanguage()];
|
||||||
|
lookup.types = [SupportiveMaterialFieldType.About];
|
||||||
|
|
||||||
|
this.supportiveMaterialService.queryPublic(lookup)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(response => {
|
.subscribe(response => {
|
||||||
const blob = new Blob([response.body], { type: 'text/html' });
|
const blob = new Blob([response.body], { type: 'text/html' });
|
||||||
|
|
|
@ -28,7 +28,11 @@ export class FaqContentComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.matomoService.trackPageView('FAQ');
|
this.matomoService.trackPageView('FAQ');
|
||||||
this.supportiveMaterialService.getMaterial(this.languageService.getCurrentLanguage(), SupportiveMaterialFieldType.Faq)
|
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup();
|
||||||
|
lookup.languageCodes = [this.languageService.getCurrentLanguage()];
|
||||||
|
lookup.types = [SupportiveMaterialFieldType.Faq];
|
||||||
|
|
||||||
|
this.supportiveMaterialService.queryPublic(lookup)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(response => {
|
.subscribe(response => {
|
||||||
const blob = new Blob([response.body], { type: 'text/html' });
|
const blob = new Blob([response.body], { type: 'text/html' });
|
||||||
|
|
|
@ -36,7 +36,11 @@ export class GlossaryContentComponent extends BaseComponent implements OnInit {
|
||||||
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/glossary']));
|
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/glossary']));
|
||||||
|
|
||||||
});
|
});
|
||||||
this.supportiveMaterialService.getMaterial(this.languageService.getCurrentLanguage(), SupportiveMaterialFieldType.Glossary)
|
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup();
|
||||||
|
lookup.languageCodes = [this.languageService.getCurrentLanguage()];
|
||||||
|
lookup.types = [SupportiveMaterialFieldType.Glossary];
|
||||||
|
|
||||||
|
this.supportiveMaterialService.queryPublic(lookup)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(response => {
|
.subscribe(response => {
|
||||||
const blob = new Blob([response.body], { type: 'text/html' });
|
const blob = new Blob([response.body], { type: 'text/html' });
|
||||||
|
|
|
@ -33,7 +33,11 @@ export class TermsComponent extends BaseComponent implements OnInit {
|
||||||
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
|
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||||
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/terms-and-conditions']));
|
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/terms-and-conditions']));
|
||||||
});
|
});
|
||||||
this.supportiveMaterialService.getMaterial(this.languageService.getCurrentLanguage(), SupportiveMaterialFieldType.TermsOfService)
|
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup();
|
||||||
|
lookup.languageCodes = [this.languageService.getCurrentLanguage()];
|
||||||
|
lookup.types = [SupportiveMaterialFieldType.TermsOfService];
|
||||||
|
|
||||||
|
this.supportiveMaterialService.queryPublic(lookup)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(response => {
|
.subscribe(response => {
|
||||||
const blob = new Blob([response.body], { type: 'text/html' });
|
const blob = new Blob([response.body], { type: 'text/html' });
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { HttpClient } from '@angular/common/http';
|
||||||
import { SupportiveMaterialService } from '@app/core/services/supportive-material/supportive-material.service';
|
import { SupportiveMaterialService } from '@app/core/services/supportive-material/supportive-material.service';
|
||||||
import { SupportiveMaterialFieldType } from '@app/core/common/enum/supportive-material-field-type';
|
import { SupportiveMaterialFieldType } from '@app/core/common/enum/supportive-material-field-type';
|
||||||
import { SupportiveMaterialPersist } from '@app/core/model/supportive-material/supportive-material';
|
import { SupportiveMaterialPersist } from '@app/core/model/supportive-material/supportive-material';
|
||||||
|
import { Guid } from '@common/types/guid';
|
||||||
|
|
||||||
interface VisibleMaterialType{
|
interface VisibleMaterialType{
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -71,6 +72,7 @@ export class SupportiveMaterialEditorComponent extends BaseComponent implements
|
||||||
|
|
||||||
selectedMaterial: VisibleMaterialType;
|
selectedMaterial: VisibleMaterialType;
|
||||||
selectedLang: VisibleLangType;
|
selectedLang: VisibleLangType;
|
||||||
|
materialId: Guid = null;
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.selectedMaterial = this.visiblesMaterialsTypes.find(x => x.type == SupportiveMaterialFieldType.Faq);
|
this.selectedMaterial = this.visiblesMaterialsTypes.find(x => x.type == SupportiveMaterialFieldType.Faq);
|
||||||
|
@ -96,12 +98,21 @@ export class SupportiveMaterialEditorComponent extends BaseComponent implements
|
||||||
name: [''],
|
name: [''],
|
||||||
html: ['']
|
html: ['']
|
||||||
});
|
});
|
||||||
this.supportiveMaterialService.getMaterial(this.selectedLang.type, this.selectedMaterial.type).pipe(takeUntil(this._destroyed)).subscribe(data => {
|
// this.supportiveMaterialService.getPublic(this.selectedLang.type, this.selectedMaterial.type).pipe(takeUntil(this._destroyed)).subscribe(data => {
|
||||||
const contentDispositionHeader = data.headers.get('Content-Disposition');
|
// const contentDispositionHeader = data.headers.get('Content-Disposition');
|
||||||
const filename = contentDispositionHeader.split(';')[1].trim().split('=')[1].replace(/"/g, '');
|
// const filename = contentDispositionHeader.split(';')[1].trim().split('=')[1].replace(/"/g, '');
|
||||||
|
|
||||||
this.formGroup.get('name').patchValue(filename);
|
// this.formGroup.get('name').patchValue(filename);
|
||||||
this.loadFile(data.body);
|
// this.loadFile(data.body);
|
||||||
|
// });
|
||||||
|
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup();
|
||||||
|
lookup.types = [this.selectedMaterial.type];
|
||||||
|
lookup.languageCodes = [this.selectedLang.type];
|
||||||
|
this.supportiveMaterialService.query(lookup).pipe(takeUntil(this._destroyed)).subscribe(data => {
|
||||||
|
if(data.count == 1){
|
||||||
|
this.materialId = data.items[0].id;
|
||||||
|
this.formGroup.get('html').patchValue(data.items[0].payload);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,30 +129,24 @@ export class SupportiveMaterialEditorComponent extends BaseComponent implements
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadFile(data: Blob) {
|
// loadFile(data: Blob) {
|
||||||
const reader = new FileReader();
|
// const reader = new FileReader();
|
||||||
reader.addEventListener('load', () => {
|
// reader.addEventListener('load', () => {
|
||||||
let result = this.parseText(reader.result as string);
|
// let result = this.parseText(reader.result as string);
|
||||||
//result = result.replace(/class="href" path="/g, 'href="#');
|
// //result = result.replace(/class="href" path="/g, 'href="#');
|
||||||
this.formGroup.get('html').patchValue(result);
|
// this.formGroup.get('html').patchValue(result);
|
||||||
}, false);
|
// }, false);
|
||||||
reader.readAsText(data);
|
// reader.readAsText(data);
|
||||||
}
|
// }
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
let result = this.parseText(this.formGroup.get('html').value);
|
let result = this.parseText(this.formGroup.get('html').value);
|
||||||
//result = result.replace(/href="#/g, 'class="href" path="');
|
|
||||||
this.formGroup.get('html').patchValue(result);
|
this.formGroup.get('html').patchValue(result);
|
||||||
//const item = {name: this.formGroup.value['name'], type: this.selectedMaterial.type ,html: this.formGroup.value['html']} as SupportiveMaterialPersist
|
const item = {id: this.materialId,
|
||||||
const item = {id: null,
|
|
||||||
type: this.selectedMaterial.type,
|
type: this.selectedMaterial.type,
|
||||||
languageCode: this.selectedLang.type,
|
languageCode: this.selectedLang.type,
|
||||||
payload: this.formGroup.value['html']} as SupportiveMaterialPersist;
|
payload: this.formGroup.value['html']} as SupportiveMaterialPersist;
|
||||||
|
|
||||||
// if(item.name.endsWith("_en.html") && this.selectedLang.type != "en" ){
|
|
||||||
// item.name = item.name.replace("_en.html", `_${this.selectedLang.type}.html`);
|
|
||||||
// }
|
|
||||||
|
|
||||||
this.supportiveMaterialService.persist(item).pipe(takeUntil(this._destroyed))
|
this.supportiveMaterialService.persist(item).pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => {
|
complete => {
|
||||||
|
|
|
@ -51,7 +51,11 @@ export class UserGuideContentComponent extends BaseComponent implements OnInit {
|
||||||
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
|
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||||
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/user-guide']));
|
this.router.navigate(['/reload'], { skipLocationChange: true }).then(() => this.router.navigate(['/user-guide']));
|
||||||
});
|
});
|
||||||
this.supportiveMaterialService.getMaterial(this.languageService.getCurrentLanguage(), SupportiveMaterialFieldType.UserGuide)
|
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup();
|
||||||
|
lookup.languageCodes = [this.languageService.getCurrentLanguage()];
|
||||||
|
lookup.types = [SupportiveMaterialFieldType.UserGuide];
|
||||||
|
|
||||||
|
this.supportiveMaterialService.queryPublic(lookup)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(response => {
|
.subscribe(response => {
|
||||||
const blob = new Blob([response.body], { type: 'text/html' });
|
const blob = new Blob([response.body], { type: 'text/html' });
|
||||||
|
|
Loading…
Reference in New Issue