Skip to content

DashboardLibraryService

reference
2 min readUpdated

Kind: Class

Source: Frontend/src/app/services/dashboard/dashboard-library.service.ts (line 228)

Part of: Frontend

DashboardLibraryService manages dashboard widgets, tab mappings, role-based dashboard data, and saved dashboard changes. It connects dashboard UI state with widget data, subscription checks, role endpoints, and dashboard persistence methods.

Methods

MethodSignatureReturns
getAllWidgetsgetAllWidgets()Widget[]
mappingDashboardmappingDashboard(OldDashboardTabs: OldDashboardTabs[], disabling: boolean, isReport: boolean)DashboardTabs[]
unmappingDashboardunmappingDashboard(newModelDashboard: DashboardTabs[])OldDashboardTabs[]
checkFeatureSubscriptioncheckFeatureSubscription(chartEnumId: undefined)boolean
getWidgetDatagetWidgetData(widgetEnum: number, useNominal: boolean, useLocalVendor: boolean, yearId: number, yearEnum: number, useTendency: boolean, skip: number, take: number, teamId: number, widgetTargetId: number, forecastRuleId: number, OnlyActiveOffers: boolean, useForecast: boolean, getRateByVal: boolean)void
getRolesDashboardgetRolesDashboard()void
getRoleDashboardByIdgetRoleDashboardById(id: number)void
savelatestmodificationssavelatestmodifications(logHistory: DashboardLog)void
saveRoleDashboardsaveRoleDashboard(roleDashboard: RoleDashboard)void
saveDashboardTabssaveDashboardTabs(tabs: DashboardTabs[])void
getDashboardTabsgetDashboardTabs()void
changeActiveDashboardchangeActiveDashboard(roleId: number)void
toggoleSeparateBranchesViewstoggoleSeparateBranchesViews(separateBranchesViews: boolean)void
onReportsParamsChangedonReportsParamsChanged(reportsParamsChanged: ReportParams)void
getRolesReportsgetRolesReports()void
getRoleReportsByIdgetRoleReportsById(id: number)void
getReportsTabsgetReportsTabs()void
saveRoleReportssaveRoleReports(roleDashboard: RoleDashboard)void
savelatestmodificationsForReportsavelatestmodificationsForReport(logHistory: DashboardLog)void
changeActiveReportchangeActiveReport(roleId: number)void
checkForcountOfEditablePrevMonthsRolecheckForcountOfEditablePrevMonthsRole(yearId: number, monthId: number, countOfPrevMonths: number)boolean
getBookingByProductTypegetBookingByProductType(useNominal: boolean, yearId: number, periodId: number)void
getBookingByTeamgetBookingByTeam(useNominal: boolean, yearId: number, periodId: number)void
getBookingBySuppliergetBookingBySupplier(yearId: number, periodId: number)void
getMRMBookingByNonSalesTeamgetMRMBookingByNonSalesTeam(yearId: number, periodId: number, useNominal: boolean)void
saveMRMBookingByNonSalesTeamsaveMRMBookingByNonSalesTeam(monthData: any[])void
getMRMBacklogByProductTypegetMRMBacklogByProductType(vendorTypeId: number, yearId: number, periodId: number)void
getMRMForLGsgetMRMForLGs(yearId: number, periodId: number)void
getMRMWrehousegetMRMWrehouse(yearId: number, periodId: number)void
saveMRMWrehousesaveMRMWrehouse(monthData: any[])void
getMRMScrapStockgetMRMScrapStock(yearId: number, periodId: number)void
saveMRMScrapStocksaveMRMScrapStock(monthData: any[])void
getMRMTotalSalesgetMRMTotalSales(calculateBy: number, yearId: number, periodId: number)void
saveMRMTotalSalessaveMRMTotalSales(monthData: any[])void
getMRMCOGSgetMRMCOGS(yearId: number, periodId: number)void
saveMRMCOGSsaveMRMCOGS(monthData: any[])void
getMRMSGAndAgetMRMSGAndA(yearId: number, periodId: number)void
saveMRMSGAndAsaveMRMSGAndA(monthData: any[])void
getMRMDepreciationgetMRMDepreciation(yearId: number, periodId: number)void
saveMRMDepreciationsaveMRMDepreciation(monthData: any[])void
getMRMProfitAndLossgetMRMProfitAndLoss(yearId: number, periodId: number)void
saveMRMProfitAndLosssaveMRMProfitAndLoss(monthData: any[])void
getMRMCurrenciesRategetMRMCurrenciesRate(yearId: number, periodId: number)void
saveMRMCurrenciesRatesaveMRMCurrenciesRate(monthData: any[])void
getMRMPMBackloggetMRMPMBacklog(yearId: number, periodId: number)void
getMRMPMShipmentgetMRMPMShipment(yearId: number, periodId: number)void
getMRMCashPositiongetMRMCashPosition(yearId: number, periodId: number)void
saveMRMCashPositionsaveMRMCashPosition(monthData: any[])void
getMRMAccountReceivablegetMRMAccountReceivable(yearId: number, periodId: number)void
saveMRMAccountReceivablesaveMRMAccountReceivable(monthData: any[])void

Properties

PropertyType
yearDropdownany[]
yearSinceJanDropdownany[]
AccountTypesany[]
noResizeboolean
noMoveboolean
forecastRulesany[]
_separateBranchesViewsboolean
separateBranchesViewsany
_reportsParamsChangedReportParams
reportsParamsChangedany
allWidgetsWidget[]
MRMReportTabsDashboardTabs[]
MRMWidgetsWidget[]

Where it refuses work

  • DashboardLibraryService stops the work with an early return when AppSettings.ifSubscriptionInclude(ItemEnum).

Diagram

mermaid
graph LR
  UI[Dashboard UI] --> Service[DashboardLibraryService]
  Service --> Widgets[getAllWidgets]
  Service --> Mapping[mappingDashboard]
  Service --> Unmapping[unmappingDashboard]
  Service --> Subscription[checkFeatureSubscription]
  Service --> Roles[getRolesDashboard]
  Service --> RoleById[getRoleDashboardById]
  Service --> Data[getWidgetData]
  Service --> Save[savelatestmodifications]
  Service --> SaveRole[saveRoleDashboard]
  Service --> SaveTabs[saveDashboardTabs]

Usage

ts
import { Component, OnInit } from '@angular/core';
import { DashboardLibraryService } from
  'src/app/services/dashboard/dashboard-library.service';

@Component({
  selector: 'app-dashboard',
  template: ''
})
export class DashboardComponent implements OnInit {
  widgets = [];
  dashboardTabs = [];

  constructor(
    private readonly dashboardLibraryService: DashboardLibraryService
  ) {}

  ngOnInit(): void {
    if (this.dashboardLibraryService.checkFeatureSubscription()) {
      this.widgets = this.dashboardLibraryService.getAllWidgets();
      this.dashboardTabs = this.dashboardLibraryService.mappingDashboard();
      this.dashboardLibraryService.getRolesDashboard();
    }
  }

  saveChanges(): void {
    this.dashboardLibraryService.savelatestmodifications();
    this.dashboardLibraryService.saveDashboardTabs();
  }
}

AI Coding Instructions

  • Call checkFeatureSubscription() before exposing dashboard features that depend on subscription state.
  • Use mappingDashboard() for current dashboard tab data and unmappingDashboard() when working with legacy tab structures.
  • Keep widget selection aligned with the Widget[] returned by getAllWidgets().
  • Use the save methods after dashboard, tab, or role changes so UI changes are persisted.
  • Keep role dashboard calls grouped with dashboard access logic when using getRolesDashboard() or getRoleDashboardById().

Used by

116 references from 116 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (116)

  • DashboardSettingsComponentFrontend/src/app/components/configuration/dashboard-settings/dashboard-settings/dashboard-settings.component.ts:1
  • DashboardSettingsDetailsComponentFrontend/src/app/components/configuration/dashboard-settings/dashboard-settings-details/dashboard-settings-details.component.ts:1
  • ReportsSettingsComponentFrontend/src/app/components/configuration/reports-settings/reports-settings/reports-settings.component.ts:1
  • ReportsSettingsDetailsComponentFrontend/src/app/components/configuration/reports-settings/reports-settings-details/reports-settings-details.component.ts:1
  • DashboardLibaryComponentFrontend/src/app/components/dashboard/dashboard-libary/dashboard-libary.component.ts:1
  • DashboardTabComponentFrontend/src/app/components/dashboard/dashboard-libary/dashboard-tab/dashboard-tab.component.ts:1
  • BranchDataFrontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-account-payable/mrm-account-payable.component.ts:1
  • BranchDataFrontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-account-receivable/mrm-account-receivable.component.ts:1

…and 108 more.

Was this page helpful?

Download as PDF