Fixed download actionable missing in some cases due to a failed admin check.
Fixed download missing on series-detail page.
This commit is contained in:
parent
c9f1e32c14
commit
31859aaa0b
2 changed files with 22 additions and 5 deletions
|
|
@ -102,11 +102,22 @@ export class AccountService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the user has any role in the restricted roles array or is an Admin
|
||||||
|
* @param user
|
||||||
|
* @param roles
|
||||||
|
* @param restrictedRoles
|
||||||
|
*/
|
||||||
hasAnyRole(user: User, roles: Array<Role>, restrictedRoles: Array<Role> = []) {
|
hasAnyRole(user: User, roles: Array<Role>, restrictedRoles: Array<Role> = []) {
|
||||||
if (!user || !user.roles) {
|
if (!user || !user.roles) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the user is an admin, they have the role
|
||||||
|
if (this.hasAdminRole(user)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// If restricted roles are provided and the user has any of them, deny access
|
// If restricted roles are provided and the user has any of them, deny access
|
||||||
if (restrictedRoles.length > 0 && restrictedRoles.some(role => user.roles.includes(role))) {
|
if (restrictedRoles.length > 0 && restrictedRoles.some(role => user.roles.includes(role))) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,7 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
|
||||||
this.location.replaceState(newUrl)
|
this.location.replaceState(newUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSeriesActionCallback(action: ActionItem<Series>, series: Series) {
|
async handleSeriesActionCallback(action: ActionItem<Series>, series: Series) {
|
||||||
this.cdRef.markForCheck();
|
this.cdRef.markForCheck();
|
||||||
switch(action.action) {
|
switch(action.action) {
|
||||||
case(Action.MarkAsRead):
|
case(Action.MarkAsRead):
|
||||||
|
|
@ -565,16 +565,16 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case(Action.Scan):
|
case(Action.Scan):
|
||||||
this.actionService.scanSeries(series);
|
await this.actionService.scanSeries(series);
|
||||||
break;
|
break;
|
||||||
case(Action.RefreshMetadata):
|
case(Action.RefreshMetadata):
|
||||||
this.actionService.refreshSeriesMetadata(series, undefined, true, false);
|
await this.actionService.refreshSeriesMetadata(series, undefined, true, false);
|
||||||
break;
|
break;
|
||||||
case(Action.GenerateColorScape):
|
case(Action.GenerateColorScape):
|
||||||
this.actionService.refreshSeriesMetadata(series, undefined, false, true);
|
await this.actionService.refreshSeriesMetadata(series, undefined, false, true);
|
||||||
break;
|
break;
|
||||||
case(Action.Delete):
|
case(Action.Delete):
|
||||||
this.deleteSeries(series);
|
await this.deleteSeries(series);
|
||||||
break;
|
break;
|
||||||
case(Action.AddToReadingList):
|
case(Action.AddToReadingList):
|
||||||
this.actionService.addSeriesToReadingList(series);
|
this.actionService.addSeriesToReadingList(series);
|
||||||
|
|
@ -645,6 +645,9 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
|
||||||
this.actionService.sendToDevice(volume.chapters.map(c => c.id), device);
|
this.actionService.sendToDevice(volume.chapters.map(c => c.id), device);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case (Action.Download):
|
||||||
|
this.downloadService.download('volume', volume);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -679,6 +682,9 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
|
||||||
this.cdRef.markForCheck();
|
this.cdRef.markForCheck();
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case (Action.Download):
|
||||||
|
this.downloadService.download('chapter', chapter);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue