From 094e1ce69fcf3773f0d5d959838fd9734fc4aa0c Mon Sep 17 00:00:00 2001 From: tidusjar Date: Thu, 25 Feb 2021 20:11:46 +0000 Subject: [PATCH] Fixed the report issue button appearing when issues were not enabled --- src/Ombi/ClientApp/src/app/app.component.ts | 2 -- .../movie/movie-details.component.html | 2 +- .../components/movie/movie-details.component.ts | 6 ++++-- .../components/tv/tv-details.component.html | 2 +- .../components/tv/tv-details.component.ts | 6 ++++-- .../src/app/my-nav/my-nav.component.ts | 7 +++++-- .../src/app/services/filedownload.service.ts | 6 +++--- src/Ombi/ClientApp/src/app/services/index.ts | 1 + .../src/app/services/settingsState.service.ts | 17 +++++++++++++++++ 9 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 src/Ombi/ClientApp/src/app/services/settingsState.service.ts diff --git a/src/Ombi/ClientApp/src/app/app.component.ts b/src/Ombi/ClientApp/src/app/app.component.ts index 40ece5d31..edc20610d 100644 --- a/src/Ombi/ClientApp/src/app/app.component.ts +++ b/src/Ombi/ClientApp/src/app/app.component.ts @@ -10,7 +10,6 @@ import { SettingsService } from "./services"; import { MatSnackBar } from '@angular/material/snack-bar'; import { ICustomizationSettings, ICustomPage } from "./interfaces"; -import { StorageService } from './shared/storage/storage-service'; import { SignalRNotificationService } from './services/signlarnotification.service'; import { DOCUMENT } from '@angular/common'; @@ -46,7 +45,6 @@ export class AppComponent implements OnInit { public readonly translate: TranslateService, private readonly customPageService: CustomPageService, public overlayContainer: OverlayContainer, - private storage: StorageService, private signalrNotification: SignalRNotificationService, private readonly snackBar: MatSnackBar, private readonly identity: IdentityService, diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html index ffa06a502..f41884170 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html @@ -91,7 +91,7 @@ - - diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts index a5f80d2cf..b88678110 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts @@ -1,5 +1,5 @@ import { Component, ViewEncapsulation, OnInit } from "@angular/core"; -import { ImageService, SearchV2Service, MessageService, RequestService, SonarrService } from "../../../services"; +import { ImageService, SearchV2Service, MessageService, RequestService, SonarrService, SettingsStateService } from "../../../services"; import { ActivatedRoute } from "@angular/router"; import { DomSanitizer } from "@angular/platform-browser"; import { ISearchTvResultV2 } from "../../../interfaces/ISearchTvResultV2"; @@ -29,6 +29,7 @@ export class TvDetailsComponent implements OnInit { public advancedOptions: IAdvancedData; public showAdvanced: boolean; // Set on the UI public requestType = RequestType.tvShow; + public issuesEnabled: boolean; private tvdbId: number; @@ -36,7 +37,7 @@ export class TvDetailsComponent implements OnInit { private sanitizer: DomSanitizer, private imageService: ImageService, public dialog: MatDialog, public messageService: MessageService, private requestService: RequestService, private requestService2: RequestServiceV2, - private auth: AuthService, private sonarrService: SonarrService) { + private auth: AuthService, private sonarrService: SonarrService, private settingsState: SettingsStateService) { this.route.params.subscribe((params: any) => { this.tvdbId = params.tvdbId; this.fromSearch = params.search; @@ -49,6 +50,7 @@ export class TvDetailsComponent implements OnInit { public async load() { + this.issuesEnabled = this.settingsState.getIssue(); this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser"); if (this.isAdmin) { diff --git a/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts b/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts index d7216d114..0ab4dc07e 100644 --- a/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts +++ b/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts @@ -4,7 +4,7 @@ import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { INavBar } from '../interfaces/ICommon'; import { StorageService } from '../shared/storage/storage-service'; -import { SettingsService } from '../services'; +import { SettingsService, SettingsStateService } from '../services'; import { MatSlideToggleChange } from '@angular/material/slide-toggle'; import { SearchFilter } from './SearchFilter'; import { Md5 } from 'ts-md5/dist/md5'; @@ -49,7 +49,8 @@ export class MyNavComponent implements OnInit { constructor(private breakpointObserver: BreakpointObserver, private settingsService: SettingsService, private store: StorageService, - private filterService: FilterService) { + private filterService: FilterService, + private readonly settingState: SettingsStateService) { } public async ngOnInit() { @@ -68,6 +69,8 @@ export class MyNavComponent implements OnInit { } this.issuesEnabled = await this.settingsService.issueEnabled().toPromise(); + this.settingState.setIssue(this.issuesEnabled); + const customizationSettings = await this.settingsService.getCustomization().toPromise(); console.log("issues enabled: " + this.issuesEnabled); this.theme = this.store.get("theme"); diff --git a/src/Ombi/ClientApp/src/app/services/filedownload.service.ts b/src/Ombi/ClientApp/src/app/services/filedownload.service.ts index a87f3b178..59cc00def 100644 --- a/src/Ombi/ClientApp/src/app/services/filedownload.service.ts +++ b/src/Ombi/ClientApp/src/app/services/filedownload.service.ts @@ -14,18 +14,18 @@ export class FileDownloadService extends ServiceHelpers { downloadFile(url: string, contentType: string): void { this.http.get(url).subscribe((response: any) => { - + // It is necessary to create a new blob object with mime-type explicitly set // otherwise only Chrome works like it should const newBlob = new Blob([(response)], { type: contentType }); - + // IE doesn't allow using a blob object directly as link href // instead it is necessary to use msSaveOrOpenBlob if (window.navigator && window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveOrOpenBlob(newBlob); return; } - + // For other browsers: // Create a link pointing to the ObjectURL containing the blob. const downloadURL = URL.createObjectURL(response); diff --git a/src/Ombi/ClientApp/src/app/services/index.ts b/src/Ombi/ClientApp/src/app/services/index.ts index 107cd07f2..d80212f36 100644 --- a/src/Ombi/ClientApp/src/app/services/index.ts +++ b/src/Ombi/ClientApp/src/app/services/index.ts @@ -22,3 +22,4 @@ export * from "./message.service"; export * from "./hub.service"; export * from "./system.service"; export * from "./filedownload.service"; +export * from "./settingsState.service"; \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/services/settingsState.service.ts b/src/Ombi/ClientApp/src/app/services/settingsState.service.ts new file mode 100644 index 000000000..07af5719d --- /dev/null +++ b/src/Ombi/ClientApp/src/app/services/settingsState.service.ts @@ -0,0 +1,17 @@ +import { Injectable } from "@angular/core"; + +@Injectable({ + providedIn: 'root', +}) +export class SettingsStateService { + + private issuesEnabled: boolean; + + public getIssue(): boolean { + return this.issuesEnabled; + } + + public setIssue(settings: boolean): void { + this.issuesEnabled = settings; + } +} \ No newline at end of file