Skip to content

Commit

Permalink
changes for epic - EMBEDDED_GROUP_APPLICATION (#686)
Browse files Browse the repository at this point in the history
* changes for epic - EMBEDDED_GROUP_APPLICATION
* changed icon for new type of application
* on application detail the EMBEDDED_GROUP_APPLICATION cant be edited
* added slide-toogle to group-settings-application-form.component to add/remove the group from the set of groups to register


Co-authored-by: Vojtěch Sassmann <[email protected]>
  • Loading branch information
xkureck and Vojtech-Sassmann authored Apr 30, 2021
1 parent b4f5d87 commit c1d95ff
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h2 class="page-subtitle">
Extension
</span>
<span *ngIf="application.type == 'EMBEDDED'">
<mat-icon class="align-text-top" >cached</mat-icon>
<mat-icon class="align-text-top" >nat</mat-icon>
Embedded
</span>
</div>
Expand Down Expand Up @@ -106,7 +106,8 @@ <h2 class="page-subtitle">
<td class="word-break-all" mat-cell *matCellDef="let userData"> {{userData.value}}
<button
*ngIf="!userData.formItem.type.startsWith('FROM_FEDERATION') &&
(application.state === 'NEW' || application.state === 'VERIFIED')"
(application.state === 'NEW' || application.state === 'VERIFIED') &&
userData.formItem.type !== 'EMBEDDED_GROUP_APPLICATION'"
mat-icon-button
aria-label="Edit Application data"
(click)="editApplicationData(userData)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<mat-icon matTooltip="Extension" matTooltipPosition="above">restore</mat-icon>
</div>
<div *ngIf="application.type == 'EMBEDDED'">
<mat-icon matTooltip="Embedded" matTooltipPosition="above">cached</mat-icon>
<mat-icon matTooltip="Embedded" matTooltipPosition="above">nat</mat-icon>
</div>
</td>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@ <h1 class="page-subtitle">
{{applicationForm.automaticApprovalExtension ?
('GROUP_DETAIL.SETTINGS.APPLICATION_FORM.AUTOMATIC'| translate) : ('GROUP_DETAIL.SETTINGS.APPLICATION_FORM.MANUAL'| translate)}},

<mat-icon class="align-text-top" matTooltip="Embedded">cached</mat-icon>
<mat-icon class="align-text-top" matTooltip="Embedded">nat</mat-icon>
{{applicationForm.automaticApprovalEmbedded ?
('GROUP_DETAIL.SETTINGS.APPLICATION_FORM.AUTOMATIC'| translate) : ('GROUP_DETAIL.SETTINGS.APPLICATION_FORM.MANUAL'| translate)}}
</div>
<div *ngIf="voHasEmbeddedGroupApplication">
<mat-slide-toggle (change)="updateAutoRegistration()"
[disabled]="!changeAutoRegistration"
[ngModel]="autoRegistrationEnabled"
color="primary"
#autoRegToggle>
{{'GROUP_DETAIL.SETTINGS.APPLICATION_FORM.ALLOW_EMBEDDED' | translate}}
</mat-slide-toggle>
</div>
</div>
<div class="w-25">
<button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, HostBinding, OnInit } from '@angular/core';
import { Component, HostBinding, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { GuiAuthResolver, NotificatorService } from '@perun-web-apps/perun/services';
Expand All @@ -18,12 +18,14 @@ import {
import {
ApplicationForm,
ApplicationFormItem,
AttributesManagerService,
Group,
GroupsManagerService,
RegistrarManagerService
} from '@perun-web-apps/perun/openapi';
import { ApiRequestConfigurationService } from '@perun-web-apps/perun/services';
import { getDefaultDialogConfig } from '@perun-web-apps/perun/utils';
import { MatSlideToggle } from '@angular/material/slide-toggle';

@Component({
selector: 'app-group-settings-application-form',
Expand All @@ -45,9 +47,13 @@ export class GroupSettingsApplicationFormComponent implements OnInit {
private apiRequest: ApiRequestConfigurationService,
private router: Router,
private guiAuthResolver: GuiAuthResolver,
private groupsManager: GroupsManagerService) {
private groupsManager: GroupsManagerService,
private attributesManager: AttributesManagerService) {
}

@ViewChild('autoRegToggle')
autoRegToggle: MatSlideToggle;

loading = false;
applicationForm: ApplicationForm;
applicationFormItems: ApplicationFormItem[] = [];
Expand All @@ -58,6 +64,9 @@ export class GroupSettingsApplicationFormComponent implements OnInit {
group: Group;
editAuth = false;
createEmptyForm = false;
voHasEmbeddedGroupApplication = false;
autoRegistrationEnabled: boolean;
changeAutoRegistration: boolean;

// This counter is used to generate ids for newly added items. This fake ids are used in backend
// to recognize new items in other items' dependencies
Expand All @@ -76,8 +85,12 @@ export class GroupSettingsApplicationFormComponent implements OnInit {
this.applicationForm = form;
this.registrarManager.getFormItemsForGroup(this.groupId).subscribe(formItems => {
this.applicationFormItems = formItems;
this.setAuth();
this.loading = false;
this.attributesManager.getGroupAttributeByName(this.groupId, "urn:perun:group:attribute-def:virt:autoRegistrationEnabled").subscribe(attr => {
this.voHasEmbeddedGroupApplication = attr.value !== null;
this.autoRegistrationEnabled = !!attr.value;
this.setAuth();
this.loading = false;
});
}, () => this.loading = false);
}, error => {
if (error.error.name === 'FormNotExistsException') {
Expand All @@ -95,6 +108,7 @@ export class GroupSettingsApplicationFormComponent implements OnInit {
setAuth() {
this.editAuth = this.guiAuthResolver.isAuthorized('group-updateFormItems_ApplicationForm_List<ApplicationFormItem>_policy', [this.group]);
this.createEmptyForm = this.guiAuthResolver.isAuthorized('createApplicationFormInGroup_Group_policy', [this.group]);
this.changeAutoRegistration = this.guiAuthResolver.isAuthorized('addGroupsToAutoRegistration_List<Group>_policy', [this.group]);
}

add() {
Expand Down Expand Up @@ -213,4 +227,27 @@ export class GroupSettingsApplicationFormComponent implements OnInit {
this.applicationFormItems = [];
this.itemsChanged = true;
}

updateAutoRegistration() {
this.autoRegToggle.setDisabledState(true);
if (this.autoRegistrationEnabled) {
this.groupsManager.deleteGroupsFromAutoRegistration([this.group.id]).subscribe(() => {
this.autoRegistrationEnabled = !this.autoRegistrationEnabled;
this.translate.get('VO_DETAIL.SETTINGS.APPLICATION_FORM.CHANGE_SETTINGS_SUCCESS')
.subscribe(successMessage => {
this.notificator.showSuccess(successMessage);
});
this.autoRegToggle.setDisabledState(false)
}, () => this.autoRegToggle.setDisabledState(false));
} else {
this.groupsManager.addGroupsToAutoRegistration([this.group.id]).subscribe(() => {
this.autoRegistrationEnabled = !this.autoRegistrationEnabled;
this.translate.get('VO_DETAIL.SETTINGS.APPLICATION_FORM.CHANGE_SETTINGS_SUCCESS')
.subscribe(successMessage => {
this.notificator.showSuccess(successMessage);
});
this.autoRegToggle.setDisabledState(false)
}, () => this.autoRegToggle.setDisabledState(false));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1 class="page-subtitle">
{{applicationForm.automaticApproval ?
('VO_DETAIL.SETTINGS.APPLICATION_FORM.AUTOMATIC'| translate) : ('VO_DETAIL.SETTINGS.APPLICATION_FORM.MANUAL'| translate)}},

<mat-icon class="align-text-bottom" matTooltip="Extension">cached</mat-icon>
<mat-icon class="align-text-bottom" matTooltip="Extension">restore</mat-icon>
{{applicationForm.automaticApprovalExtension ?
('VO_DETAIL.SETTINGS.APPLICATION_FORM.AUTOMATIC'| translate) : ('VO_DETAIL.SETTINGS.APPLICATION_FORM.MANUAL'| translate)}}
</div>
Expand Down
3 changes: 2 additions & 1 deletion apps/admin-gui/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,8 @@
"CREATE_APPLICATION_FORM": "Create empty form",
"CLEAR": "Clear form",
"CLEAR_TOOLTIP": "Removes all form items",
"CHANGE_SETTINGS_SUCCESS": "Application from settings successfully changed."
"CHANGE_SETTINGS_SUCCESS": "Application form settings successfully changed.",
"ALLOW_EMBEDDED": "Allowed for embedded applications"
},
"NOTIFICATIONS": {
"TITLE": "Email notifications",
Expand Down

0 comments on commit c1d95ff

Please sign in to comment.