{ "version": 3, "sources": ["src/app/shared/services/grafana-dashboard.service.ts"], "sourcesContent": ["/**\n * Copyright (c) 2020-2023 by Bosch.IO GmbH\n *\n * http://www.bosch.io\n * All rights reserved,\n * also regarding any disposal, exploitation, reproduction,\n * editing, distribution, as well as in the event of\n * applications for industrial property rights.\n *\n * This software is the confidential and proprietary information\n * of Bosch.IO GmbH. You shall not disclose\n * such Confidential Information and shall use it only in\n * accordance with the terms of the license agreement you\n * entered into with Bosch.IO.\n */\nimport { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Store } from '@ngrx/store';\nimport {\n BehaviorSubject,\n distinctUntilChanged,\n filter,\n first,\n map,\n} from 'rxjs';\nimport { env } from 'src/environments/environment';\nimport { AppState } from '../data/state/app.state.model';\nimport { IGrafanaDashboard, IGrafanaDashboards } from '../models';\nimport { LoggerService } from './logger.service';\nimport { UserSubscriptionService } from './user-subscriptions.service';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GrafanaDashboardService {\n readonly #baseUrl: string;\n\n readonly dashboardCRUDUrl = `tools/dashboards`;\n dashboardList$ = this.store\n .select((state) => state.subscription.grafanaDashboards)\n .pipe(\n filter((data) => !!data.loaded),\n map((data) => data.list)\n );\n\n needDoubleTryLoadingIframe$ = new BehaviorSubject(true);\n constructor(\n private httpClient: HttpClient,\n private logger: LoggerService,\n private store: Store,\n private userSubscriptionService: UserSubscriptionService\n ) {\n this.#baseUrl = env.API_URL;\n this.logger.log('ViewService.constructor: baseUrl = ', this.#baseUrl);\n\n // when subscription changes - mark grafana to try double loading iframe to prevent login/blank screen appearance\n this.userSubscriptionService.activeSubscription$\n .pipe(distinctUntilChanged((prev, curr) => prev?.id === curr?.id))\n .subscribe(() => this.needDoubleTryLoadingIframe$.next(true));\n }\n\n findAll() {\n const url = `${this.#baseUrl}/${this.dashboardCRUDUrl}`;\n return this.httpClient.get(url).pipe(first());\n }\n\n createDashboard({ data }: { data: { label: string } }) {\n const url = `${this.#baseUrl}/${this.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WAAvBxC;IAAuByC,SAAvBzC,yBAAuB0C;IAAAC,YAFtB;EAAM,CAAA;AAEd,MAAO3C,2BAAP;SAAOA;AAAuB,GAAA;", "names": ["GrafanaDashboardService", "constructor", "httpClient", "logger", "store", "userSubscriptionService", "dashboardCRUDUrl", "dashboardList$", "select", "state", "subscription", "grafanaDashboards", "pipe", "filter", "data", "loaded", "map", "list", "needDoubleTryLoadingIframe$", "BehaviorSubject", "env", "API_URL", "log", "activeSubscription$", "distinctUntilChanged", "prev", "curr", "id", "subscribe", "next", "findAll", "url", "get", "first", "createDashboard", "post", "\u0275\u0275inject", "HttpClient", "LoggerService", "Store", "UserSubscriptionService", "factory", "\u0275fac", "providedIn"] }