Add option to add or remove users from Dataset Templates

This commit is contained in:
George Kalampokis 2021-04-07 19:03:22 +03:00
parent 037e246262
commit bc3c8b44d2
17 changed files with 201 additions and 117 deletions

View File

@ -119,6 +119,14 @@ public class Users extends BaseController {
ResponseEntity exportCsv(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
return userManager.exportToCsv(principal);
}
@RequestMapping(method = RequestMethod.POST, value = {"/find"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<UserProfile>> find(@Valid @RequestBody String email) throws Exception {
UserProfile userProfile = userManager.getFromEmail(email);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UserProfile>().payload(userProfile).status(ApiMessageCode.NO_MESSAGE));
}
}

View File

@ -240,4 +240,9 @@ public class UserManager {
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
}
public UserProfile getFromEmail(String email) {
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), email)).getSingle();
return new UserProfile().fromDataModel(user);
}
}

View File

@ -1,4 +1,5 @@
import { ValidationType } from "../../../common/enum/validation-type";
import { UserInfoListingModel } from "../../user/user-info-listing";
export interface DatasetProfile {
label: string;
@ -8,6 +9,7 @@ export interface DatasetProfile {
version: number;
description: string;
language: string;
users: UserInfoListingModel[];
}
export interface Page {

View File

@ -53,6 +53,10 @@ export class UserService {
return this.http.post<DataTableData<UserListingModel>>(this.actionUrl + 'getCollaboratorsPaged', JSON.stringify(dataTableRequest), { headers: this.headers });
}
getFromEmail(email: string): Observable<UserListingModel> {
return this.http.post<UserListingModel>(this.actionUrl + 'find', email, {headers: this.headers});
}
public hasDOIToken(): Observable<any> {
const url = this.actionUrl + 'hasDOIToken';
return this.http.get(url, { headers: this.headers });

View File

@ -54,6 +54,7 @@ import {DragulaModule} from 'ng2-dragula';
import {MatBadgeModule} from '@angular/material/badge';
import { DatasetProfileEditorSectionFieldSetComponent } from './editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component';
import { FinalPreviewComponent } from './editor/components/final-preview/final-preview.component';
import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module';
@NgModule({
imports: [
@ -68,7 +69,8 @@ import { FinalPreviewComponent } from './editor/components/final-preview/final-p
AngularStickyThingsModule,
DragDropModule,
MatBadgeModule,
DragulaModule
DragulaModule,
AutoCompleteModule
],
declarations: [
DatasetProfileListingComponent,

View File

@ -1,4 +1,5 @@
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { UserInfoListingModel } from '@app/core/model/user/user-info-listing';
import { DatasetProfile } from '../../../../core/model/admin/dataset-profile/dataset-profile';
import { BaseFormModel } from '../../../../core/model/base-form-model';
import { PageEditorModel } from '../admin/page-editor-model';
@ -15,6 +16,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
public version: number;
private description: string;
private language: string;
private users: UserInfoListingModel[] = [];
fromModel(item: DatasetProfile): DatasetProfileEditorModel {
if (item.sections) { this.sections = item.sections.map(x => new SectionEditorModel().fromModel(x)); }
@ -24,6 +26,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
this.version = item.version;
this.description = item.description;
this.language = item.language;
this.users = item.users;
return this;
}
@ -33,7 +36,8 @@ export class DatasetProfileEditorModel extends BaseFormModel {
description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.description')) }, [Validators.required]],
language: [{ value: this.language, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.language')) }, [Validators.required]],
status: [{ value: this.status, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.status')) }],
version: [{ value: this.version, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.version')) }]
version: [{ value: this.version, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.version')) }],
users: [{ value: this.users, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.users')) }]
});
const sectionsFormArray = new Array<FormGroup>();

View File

@ -164,6 +164,29 @@
</mat-form-field>
</div>
<div class="col-12">
<!-- <div class="heading">1.3 {{'DMP-EDITOR.FIELDS.LANGUAGE' | translate}}</div> -->
<div class="heading">1.4 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS'| translate}}</div>
<div class="full-width basic-info-input">
<table class="col-12">
<tr class="row">
<th class="col-4">{{'USERS.LISTING.NAME' | translate}}</th>
<th class="col-4">{{'USERS.LISTING.EMAIL' | translate}}</th>
<th class="col-4"></th>
</tr>
<tr *ngFor="let user of userChipList" class="row">
<td class="col-4">{{user.name}}</td>
<td class="col-4">{{user.email}}</td>
<td class="col-4">
<button mat-raised-button class="delete-btn" (click)="removeUser(user)">delete</button>
</td>
</tr>
</table>
</div>
<input matInput #email class = "col-8" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS'| translate}}">
<button mat-raised-button color="primary" (click)="checkAndAdd(email.value)">Add and Validate</button>
</div>
<!-- <div class="col-12">
<button mat-button class="full-width" (click)="addPage()"
[disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.NEXT' | translate}}</button>

View File

@ -228,3 +228,8 @@ $blue-color-light: #5cf7f2;
margin-top: 2em;
margin-bottom: 2em;
}
.delete-btn {
background-color: rgba(255, 0, 0, 0.76);
color: white;
}

View File

@ -45,6 +45,12 @@ import { EditorCustomValidators, EditorCustomValidatorsEnum } from './custom-val
import { CustomErrorValidator } from '@common/forms/validation/custom-validator';
import { STEPPER_ANIMATIONS } from './animations/animations';
import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type';
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
import { DmpInvitationUser } from '@app/core/model/dmp/invitation/dmp-invitation-user';
import { RequestItem } from '@app/core/query/request-item';
import { DmpInvitationUserCriteria } from '@app/core/query/dmp/dmp-invitation-user-criteria';
import { DmpInvitationService } from '@app/core/services/dmp/dmp-invitation.service';
import { UserService } from '@app/core/services/user/user.service';
const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json');
@ -75,6 +81,8 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
nestedIndex: number = 0;
errorMessages: string[] = [];
tocEntryEnumValues = ToCEntryType;
public userChipList:any[] = [];
displayedColumns: String[] = ['name', 'email', 'button'];
colorizeInvalid:boolean = false;
@ -101,7 +109,8 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
private datasetWizardService: DatasetWizardService,
private visibilityRulesService: VisibilityRulesService,
private fb: FormBuilder,
private sidenavService: SideNavService
private sidenavService: SideNavService,
private userService: UserService
) {
super();
// this.profileID = route.snapshot.params['id'];
@ -248,6 +257,8 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this.steps = this.stepper.steps;
});
this._initializeToCEntries();
console.log(this.form.get('users').value);
this.userChipList = [...this.form.get('users').value];
}
@ -1824,6 +1835,18 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
}
checkAndAdd(ev: any) {
this.userService.getFromEmail(ev).pipe(takeUntil(this._destroyed)).subscribe((result) => {
this.userChipList.push(result);
this.form.patchValue({'users': this.userChipList});
});
}
removeUser(user: any) {
this.userChipList.splice(this.userChipList.indexOf(user), 1);
this.form.patchValue({'users': this.userChipList});
}
}
interface InvalidControl{

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",