add subtype to resources
This commit is contained in:
parent
1f801cb4bf
commit
1a6cc4ae2a
|
@ -25,11 +25,12 @@ public class ResourceAjaxController extends AbstractResourceController {
|
||||||
@PostMapping("/")
|
@PostMapping("/")
|
||||||
public SimpleResource newResource(@RequestParam final String name,
|
public SimpleResource newResource(@RequestParam final String name,
|
||||||
@RequestParam final String type,
|
@RequestParam final String type,
|
||||||
|
@RequestParam(required = false, defaultValue = "") final String subtype,
|
||||||
@RequestParam(required = false, defaultValue = "") final String description,
|
@RequestParam(required = false, defaultValue = "") final String description,
|
||||||
@RequestParam final String content)
|
@RequestParam final String content)
|
||||||
throws InformationServiceException {
|
throws InformationServiceException {
|
||||||
|
|
||||||
return service.saveNewResource(name, type, description, content);
|
return service.saveNewResource(name, type, subtype, description, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{resId}")
|
@DeleteMapping("/{resId}")
|
||||||
|
|
|
@ -54,6 +54,7 @@ export interface SimpleResource {
|
||||||
id: string,
|
id: string,
|
||||||
name: string,
|
name: string,
|
||||||
type: string,
|
type: string,
|
||||||
|
subtype?: string,
|
||||||
description?: string,
|
description?: string,
|
||||||
creationDate?: string,
|
creationDate?: string,
|
||||||
modificationDate?: string
|
modificationDate?: string
|
||||||
|
|
|
@ -72,11 +72,12 @@ export class ISService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addSimpleResource(name: string, type: string, description: string, content: string, onSuccess: Function, relatedForm?: FormGroup): void {
|
addSimpleResource(name: string, type: string, subtype: string, description: string, content: string, onSuccess: Function, relatedForm?: FormGroup): void {
|
||||||
const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
|
const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
let body = new HttpParams()
|
let body = new HttpParams()
|
||||||
.set('name', name)
|
.set('name', name)
|
||||||
.set('type', type)
|
.set('type', type)
|
||||||
|
.set('subtype', subtype)
|
||||||
.set('description', description)
|
.set('description', description)
|
||||||
.set('content', content);
|
.set('content', content);
|
||||||
this.client.post<void>('/ajax/resources/', body, { headers: headers }).subscribe({
|
this.client.post<void>('/ajax/resources/', body, { headers: headers }).subscribe({
|
||||||
|
|
|
@ -13,9 +13,14 @@
|
||||||
<input matInput readonly value="{{data.type}}" />
|
<input matInput readonly value="{{data.type}}" />
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
||||||
|
<mat-label>SubType (optional)</mat-label>
|
||||||
|
<input matInput formControlName="subtype" />
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
||||||
<mat-label>Name</mat-label>
|
<mat-label>Name</mat-label>
|
||||||
<input matInput formControlName="name" required />
|
<input matInput formControlName="name" />
|
||||||
<mat-error *ngIf="metadataForm.get('name')?.invalid">This field is <strong>required</strong></mat-error>
|
<mat-error *ngIf="metadataForm.get('name')?.invalid">This field is <strong>required</strong></mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,15 @@
|
||||||
|
|
||||||
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
||||||
<mat-label>Name</mat-label>
|
<mat-label>Name</mat-label>
|
||||||
<input matInput formControlName="name" required />
|
<input matInput formControlName="name" />
|
||||||
<mat-error *ngIf="newResourceForm.get('name')?.invalid">This field is <strong>required</strong></mat-error>
|
<mat-error *ngIf="newResourceForm.get('name')?.invalid">This field is <strong>required</strong></mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
||||||
|
<mat-label>SubType (optional)</mat-label>
|
||||||
|
<input matInput formControlName="subtype" />
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
||||||
<mat-label>Description</mat-label>
|
<mat-label>Description</mat-label>
|
||||||
<textarea matInput formControlName="description" rows="2"></textarea>
|
<textarea matInput formControlName="description" rows="2"></textarea>
|
||||||
|
@ -16,7 +21,7 @@
|
||||||
|
|
||||||
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
||||||
<mat-label>Content ({{data.contentType}})</mat-label>
|
<mat-label>Content ({{data.contentType}})</mat-label>
|
||||||
<textarea matInput formControlName="content" required rows="10" style="font-size: 0.8em;"></textarea>
|
<textarea matInput formControlName="content" rows="10" style="font-size: 0.8em;"></textarea>
|
||||||
<mat-error *ngIf="newResourceForm.get('content')?.invalid">This field is <strong>required</strong></mat-error>
|
<mat-error *ngIf="newResourceForm.get('content')?.invalid">This field is <strong>required</strong></mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,18 @@
|
||||||
|
|
||||||
<mat-card *ngFor="let r of resources | searchFilter: searchText" style="margin-top: 10px;">
|
<mat-card *ngFor="let r of resources | searchFilter: searchText" style="margin-top: 10px;">
|
||||||
<mat-card-header>
|
<mat-card-header>
|
||||||
<mat-card-title title="{{r.id}}">{{r.name}} <span class="badge-label badge-info"
|
<mat-card-title title="{{r.id}}">
|
||||||
style="font-size: 0.7em;">{{type.contentType}}</span></mat-card-title>
|
{{r.name}}
|
||||||
|
<span class="badge-label badge-warning" style="font-size: 0.7em;" *ngIf="r.subtype">{{r.subtype}}</span>
|
||||||
|
<span class="badge-label badge-info" style="font-size: 0.7em;">{{type.contentType}}</span>
|
||||||
|
</mat-card-title>
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<p>{{r.description}}</p>
|
<p>{{r.description}}</p>
|
||||||
<p class="muted small">
|
<p class="muted small">
|
||||||
<b>Id:</b> {{r.id}}<br /> <b>Creation date:</b> {{r.creationDate}}<br /> <b>Modification date:</b>
|
<b>Id:</b> {{r.id}}<br />
|
||||||
{{r.modificationDate}}
|
<b>Creation date:</b> {{r.creationDate}}<br />
|
||||||
|
<b>Modification date:</b> {{r.modificationDate}}
|
||||||
</p>
|
</p>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
<mat-card-actions>
|
<mat-card-actions>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { ISService } from '../common/is.service';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { ResourceType, SimpleResource } from '../common/is.model';
|
import { ResourceType, SimpleResource } from '../common/is.model';
|
||||||
import { FormControl, FormGroup } from '@angular/forms';
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-resources',
|
selector: 'app-resources',
|
||||||
|
@ -115,12 +115,16 @@ export class ResContentDialog {
|
||||||
})
|
})
|
||||||
export class ResMetadataDialog {
|
export class ResMetadataDialog {
|
||||||
metadataForm = new FormGroup({
|
metadataForm = new FormGroup({
|
||||||
name: new FormControl(''),
|
name: new FormControl('', [Validators.required]),
|
||||||
|
subtype: new FormControl(''),
|
||||||
description: new FormControl('')
|
description: new FormControl('')
|
||||||
});
|
});
|
||||||
|
|
||||||
constructor(public dialogRef: MatDialogRef<ResMetadataDialog>, @Inject(MAT_DIALOG_DATA) public data: any, public service: ISService) {
|
constructor(public dialogRef: MatDialogRef<ResMetadataDialog>, @Inject(MAT_DIALOG_DATA) public data: any, public service: ISService) {
|
||||||
this.metadataForm.get('name')?.setValue(data.name);
|
this.metadataForm.get('name')?.setValue(data.name);
|
||||||
|
if (data.subtype) {
|
||||||
|
this.metadataForm.get('subtype')?.setValue(data.subtype);
|
||||||
|
}
|
||||||
if (data.description) {
|
if (data.description) {
|
||||||
this.metadataForm.get('description')?.setValue(data.description);
|
this.metadataForm.get('description')?.setValue(data.description);
|
||||||
}
|
}
|
||||||
|
@ -143,9 +147,10 @@ export class ResMetadataDialog {
|
||||||
})
|
})
|
||||||
export class ResCreateNewDialog {
|
export class ResCreateNewDialog {
|
||||||
newResourceForm = new FormGroup({
|
newResourceForm = new FormGroup({
|
||||||
name: new FormControl(''),
|
name: new FormControl('', [Validators.required]),
|
||||||
|
subtype: new FormControl(''),
|
||||||
description: new FormControl(''),
|
description: new FormControl(''),
|
||||||
content: new FormControl('')
|
content: new FormControl('', [Validators.required])
|
||||||
});
|
});
|
||||||
|
|
||||||
constructor(public dialogRef: MatDialogRef<ResCreateNewDialog>, @Inject(MAT_DIALOG_DATA) public data: any, public service: ISService) { }
|
constructor(public dialogRef: MatDialogRef<ResCreateNewDialog>, @Inject(MAT_DIALOG_DATA) public data: any, public service: ISService) { }
|
||||||
|
@ -153,10 +158,11 @@ export class ResCreateNewDialog {
|
||||||
onSubmit(): void {
|
onSubmit(): void {
|
||||||
let name: string = this.newResourceForm.get('name')?.value!;
|
let name: string = this.newResourceForm.get('name')?.value!;
|
||||||
let type: string = this.data.id!;
|
let type: string = this.data.id!;
|
||||||
|
let subtype: string = this.newResourceForm.get('subtype')?.value!;
|
||||||
let description: string = this.newResourceForm.get('description')?.value!;
|
let description: string = this.newResourceForm.get('description')?.value!;
|
||||||
let content: string = this.newResourceForm.get('content')?.value!;
|
let content: string = this.newResourceForm.get('content')?.value!;
|
||||||
|
|
||||||
this.service.addSimpleResource(name, type, description, content, (data: void) => this.dialogRef.close(1), this.newResourceForm);
|
this.service.addSimpleResource(name, type, subtype, description, content, (data: void) => this.dialogRef.close(1), this.newResourceForm);
|
||||||
}
|
}
|
||||||
onNoClick(): void {
|
onNoClick(): void {
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
|
|
|
@ -24,6 +24,9 @@ public class SimpleResource implements Serializable {
|
||||||
@Column(name = "type")
|
@Column(name = "type")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
@Column(name = "subtype")
|
||||||
|
private String subtype;
|
||||||
|
|
||||||
@Column(name = "description")
|
@Column(name = "description")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
@ -57,6 +60,14 @@ public class SimpleResource implements Serializable {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSubtype() {
|
||||||
|
return subtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubtype(final String subtype) {
|
||||||
|
this.subtype = subtype;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,7 @@ CREATE TABLE resources (
|
||||||
description text,
|
description text,
|
||||||
content text NOT NULL DEFAULT '',
|
content text NOT NULL DEFAULT '',
|
||||||
type text NOT NULL REFERENCES resource_types(id),
|
type text NOT NULL REFERENCES resource_types(id),
|
||||||
|
subtype text,
|
||||||
creation_date timestamp NOT NULL DEFAULT now(),
|
creation_date timestamp NOT NULL DEFAULT now(),
|
||||||
modification_date timestamp NOT NULL DEFAULT now()
|
modification_date timestamp NOT NULL DEFAULT now()
|
||||||
);
|
);
|
||||||
|
|
|
@ -60,6 +60,7 @@ public class SimpleResourceService {
|
||||||
@Transactional
|
@Transactional
|
||||||
public SimpleResource saveNewResource(final String name,
|
public SimpleResource saveNewResource(final String name,
|
||||||
final String type,
|
final String type,
|
||||||
|
final String subtype,
|
||||||
final String description,
|
final String description,
|
||||||
final String content) throws InformationServiceException {
|
final String content) throws InformationServiceException {
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ public class SimpleResourceService {
|
||||||
res.setId(UUID.randomUUID().toString());
|
res.setId(UUID.randomUUID().toString());
|
||||||
res.setName(name);
|
res.setName(name);
|
||||||
res.setType(type);
|
res.setType(type);
|
||||||
|
res.setSubtype(subtype);
|
||||||
res.setDescription(description);
|
res.setDescription(description);
|
||||||
res.setCreationDate(now);
|
res.setCreationDate(now);
|
||||||
res.setModificationDate(now);
|
res.setModificationDate(now);
|
||||||
|
|
Loading…
Reference in New Issue