Delete isLoggedIn from portals and class-contents

This commit is contained in:
Konstantinos Triantafyllou 2022-07-08 21:57:12 +03:00
parent 2d0893ff45
commit 02bf9abee4
2 changed files with 57 additions and 90 deletions

View File

@ -192,31 +192,22 @@ export class ClassHelpContentsComponent implements OnInit {
}
public togglePageHelpContents(status: boolean, ids: string[]) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_VALID,
'redirectUrl': this.router.url
this.subscriptions.push(this._helpService.toggleDivHelpContents(ids, status, this.properties.adminToolsAPIURL, this.portal).subscribe(
() => {
for (let id of ids) {
let i = this.checkboxes.findIndex(_ => _.divHelpContent._id == id);
this.checkboxes[i].divHelpContent.isActive = status;
}
});
} else {
this.subscriptions.push(this._helpService.toggleDivHelpContents(ids, status, this.properties.adminToolsAPIURL, this.portal).subscribe(
() => {
for (let id of ids) {
let i = this.checkboxes.findIndex(_ => _.divHelpContent._id == id);
this.checkboxes[i].divHelpContent.isActive = status;
}
this.countClassHelpContents();
this.applyCheck(false);
UIkit.notification('Page content(s) has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error changing the status of the selected page content(s)', error)
));
}
this.countClassHelpContents();
this.applyCheck(false);
UIkit.notification('Page content(s) has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error changing the status of the selected page content(s)', error)
));
}

View File

@ -81,24 +81,18 @@ export class PortalsComponent implements OnInit {
}
getPortals() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
});
} else {
this.showLoading = true;
this.subscriptions.push(this._helpContentService.getPortalsFull(this.properties.adminToolsAPIURL).subscribe(
portals => {
this.portals = portals;
if (portals) {
portals.forEach(_ => {
this.checkboxes.push(<CheckPortal>{portal: _, checked: false});
});
}
this.showLoading = false;
},
error => this.handleError('System error retrieving portals', error)));
}
this.showLoading = true;
this.subscriptions.push(this._helpContentService.getPortalsFull(this.properties.adminToolsAPIURL).subscribe(
portals => {
this.portals = portals;
if (portals) {
portals.forEach(_ => {
this.checkboxes.push(<CheckPortal>{portal: _, checked: false});
});
}
this.showLoading = false;
},
error => this.handleError('System error retrieving portals', error)));
}
public toggleCheckBoxes(event) {
@ -187,59 +181,41 @@ export class PortalsComponent implements OnInit {
}
private portalModalOpen(title: string, yesBtn: string) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
this.editModal.okButtonLeft = false;
this.editModal.alertTitle = title;
this.editModal.okButtonText = yesBtn;
this.editModal.open();
}
this.editModal.okButtonLeft = false;
this.editModal.alertTitle = title;
this.editModal.okButtonText = yesBtn;
this.editModal.open();
}
public portalSaveConfirmed(data: any) {
this.showLoading = true;
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
if (this.portalForm.value._id) {
this.portalForm.get('type').enable();
this.subscriptions.push(this._helpContentService.updateCommunity(<Portal>this.portalForm.value,
this.properties.adminToolsAPIURL).subscribe(
portal => {
this.portalUpdatedSuccessfully(portal);
UIkit.notification('Portal <b>' + portal.name + '</b> has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error updating portal', error)
));
} else {
if (this.portalForm.value._id) {
this.portalForm.get('type').enable();
this.subscriptions.push(this._helpContentService.updateCommunity(<Portal>this.portalForm.value,
this.properties.adminToolsAPIURL).subscribe(
portal => {
this.portalUpdatedSuccessfully(portal);
UIkit.notification('Portal <b>' + portal.name + '</b> has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error updating portal', error)
));
} else {
this.subscriptions.push(this._helpContentService.saveCommunity(<Portal>this.portalForm.value,
this.properties.adminToolsAPIURL).subscribe(
portal => {
this.portalSavedSuccessfully(portal);
UIkit.notification('Portal <b>' + portal.name + '</b> has been <b>successfully created</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error creating portal', error)
));
}
this.subscriptions.push(this._helpContentService.saveCommunity(<Portal>this.portalForm.value,
this.properties.adminToolsAPIURL).subscribe(
portal => {
this.portalSavedSuccessfully(portal);
UIkit.notification('Portal <b>' + portal.name + '</b> has been <b>successfully created</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error creating portal', error)
));
}
}