diff --git a/angular.json b/angular.json index ab533141..f6326194 100644 --- a/angular.json +++ b/angular.json @@ -39,7 +39,8 @@ "src/assets/styles/forms.css", "src/assets/styles/sidebar.css", "src/assets/styles/report.css", - "src/assets/styles/helpText.css" + "src/assets/styles/helpText.css", + "src/assets/styles/dashboards.css" ], "scripts": [ "node_modules/bootstrap/dist/js/bootstrap.bundle.js", diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts deleted file mode 100644 index cbdadfe5..00000000 --- a/src/app/app-routing.module.ts +++ /dev/null @@ -1,319 +0,0 @@ -import { NgModule } from '@angular/core'; -import { ExtraOptions, RouterModule, Routes } from '@angular/router'; -import { WelcomeComponent } from './core-components/welcome/welcome.component'; -import { PageNotFoundComponent } from './core-components/page-not-found/page-not-found.component'; -import { UserDashboardComponent } from './user-dashboard/user-dashboard.component'; -import { UserDashboardHomeComponent } from './user-dashboard/user-dashboard-home/user-dashboard-home.component'; -import { CompanyDashboardComponent } from './company-dashboard/company-dashboard.component'; -import { CompanyDashboardHomeComponent } from './company-dashboard/company-dashboard-home/company-dashboard-home.component'; -import { FacilityDashboardComponent } from './facility-dashboard/facility-dashboard.component'; -import { FacilityDashboardHomeComponent } from './facility-dashboard/facility-dashboard-home/facility-dashboard-home.component'; -import { SetupWizardComponent } from './setup-wizard/setup-wizard.component'; -import { CompanySetupComponent } from './setup-wizard/pre-visit/company-setup/company-setup.component'; -import { FacilitySetupComponent } from './setup-wizard/pre-visit/facility-setup/facility-setup.component'; -import { UserSettingsComponent } from './user-dashboard/user-settings/user-settings.component'; -import { CompanySettingsComponent } from './company-dashboard/company-settings/company-settings.component'; -import { CompanyReportsComponent } from './company-dashboard/company-reports/company-reports.component'; -import { FacilitySettingsComponent } from './facility-dashboard/facility-settings/facility-settings.component'; -import { FacilityReportsComponent } from './facility-dashboard/facility-reports/facility-reports.component'; -import { UserDashboardHelpComponent } from './user-dashboard/user-dashboard-help/user-dashboard-help.component'; -import { ExploreNEBsComponent } from './user-dashboard/explore-nebs/explore-nebs.component'; -import { CompanyGoalsComponent } from './company-dashboard/company-goals/company-goals.component'; -import { FacilityGoalsComponent } from './facility-dashboard/facility-goals/facility-goals.component'; -import { AssessmentDashboardComponent } from './assessment-dashboard/assessment-dashboard.component'; -import { AssessmentDashboardHomeComponent } from './assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component'; -import { AssessmentSettingsComponent } from './assessment-dashboard/assessment-settings/assessment-settings.component'; -import { CompanyContactsSetupComponent } from './setup-wizard/pre-visit/company-contacts-setup/company-contacts-setup.component'; -import { FacilityProcessEquipmentSetupComponent } from './setup-wizard/pre-visit/facility-process-equipment-setup/facility-process-equipment-setup.component'; -import { PreAssessmentSetupComponent } from './setup-wizard/pre-visit/pre-assessment-setup/pre-assessment-setup.component'; -import { ReviewPreVisitSetupComponent } from './setup-wizard/pre-visit/review-pre-visit-setup/review-pre-visit-setup.component'; -import { OnSiteAssessmentComponent } from './setup-wizard/data-collection/on-site-assessment/on-site-assessment.component'; -import { ReviewOnSiteComponent } from './setup-wizard/data-collection/review-on-site/review-on-site.component'; -import { PreVisitComponent } from './setup-wizard/pre-visit/pre-visit.component'; -import { DataCollectionComponent } from './setup-wizard/data-collection/data-collection.component'; -import { CompanyKpiSelectComponent } from './setup-wizard/pre-visit/company-kpi-select/company-kpi-select.component'; -import { DataCollectionManageAssessmentsComponent } from './setup-wizard/data-collection/data-collection-manage-assessments/data-collection-manage-assessments.component'; -import { CompanyKpiDetailsComponent } from './setup-wizard/pre-visit/company-kpi-details/company-kpi-details.component'; -import { AssessmentDetailsFormComponent } from './setup-wizard/data-collection/on-site-assessment/assessment-details-form/assessment-details-form.component'; -import { AssessmentEnergyOpportunitiesFormComponent } from './setup-wizard/data-collection/on-site-assessment/assessment-energy-opportunities-form/assessment-energy-opportunities-form.component'; -import { AssessmentNebsFormComponent } from './setup-wizard/data-collection/on-site-assessment/assessment-nebs-form/assessment-nebs-form.component'; -import { CanDeactivateGuard } from './guards/can-deactivate.guard'; -import { DataEvaluationComponent } from './setup-wizard/data-evaluation/data-evaluation.component'; -import { DataFollowUpComponent } from './setup-wizard/data-evaluation/data-follow-up/data-follow-up.component'; -import { VisitReportComponent } from './setup-wizard/data-evaluation/visit-report/visit-report.component'; -import { AssessmentEvaluationComponent } from './setup-wizard/data-evaluation/assessment-evaluation/assessment-evaluation.component'; -import { OnSiteAssessmentResultsComponent } from './setup-wizard/data-collection/on-site-assessment/on-site-assessment-results/on-site-assessment-results.component'; -import { FacilityEnergyEquipmentSetupComponent } from './setup-wizard/pre-visit/facility-energy-equipment-setup/facility-energy-equipment-setup.component'; -import { FeedbackPageComponent } from './core-components/feedback-page/feedback-page.component'; -import { HelpComponent } from './core-components/help/help.component'; -import { AboutComponent } from './core-components/about/about.component'; -import { AcknowledgmentsComponent } from './core-components/acknowledgments/acknowledgments.component'; -import { NebsDatabaseComponent } from './nebs-database/nebs-database.component'; - -const routes: Routes = [ - { - path: '', - pathMatch: 'full', - redirectTo: 'welcome' - }, - { - path: 'welcome', - component: WelcomeComponent - }, - { - path: 'help', - component: HelpComponent - }, - { - path: 'about', - component: AboutComponent - }, - { - path: 'feedback', - component: FeedbackPageComponent - }, - { - path: 'acknowledgments', - component: AcknowledgmentsComponent - }, - { - path: 'nebs-database', - component: NebsDatabaseComponent, - }, - { - path: 'setup-wizard', - component: SetupWizardComponent, - children: [ - { - path: 'pre-visit/:id', - component: PreVisitComponent, - children: [ - { - path: '', - pathMatch: 'full', - redirectTo: 'company-setup' - }, - { - path: 'company-setup', - component: CompanySetupComponent, - canDeactivate: [CanDeactivateGuard] - }, - { - path: 'company-kpi-select', - component: CompanyKpiSelectComponent - }, - { - path: 'company-kpi-detail/:id', - component: CompanyKpiDetailsComponent - }, - { - path: 'company-contacts', - component: CompanyContactsSetupComponent, - canDeactivate: [CanDeactivateGuard] - }, - { - path: 'facility-setup', - component: FacilitySetupComponent, - canDeactivate: [CanDeactivateGuard] - }, - { - path: 'energy-equipment', - component: FacilityEnergyEquipmentSetupComponent - }, - { - path: 'end-uses', - component: FacilityProcessEquipmentSetupComponent - }, - { - path: 'pre-assessment', - component: PreAssessmentSetupComponent - }, - { - path: 'review-pre-visit', - component: ReviewPreVisitSetupComponent - } - ] - }, - { - path: 'data-collection/:id', - component: DataCollectionComponent, - children: [ - { - path: 'manage-assessments', - component: DataCollectionManageAssessmentsComponent - }, - { - path: 'assessment/:id', - component: OnSiteAssessmentComponent, - children: [ - { - path: '', - pathMatch: 'full', - redirectTo: 'details' - }, - { - path: 'details', - component: AssessmentDetailsFormComponent - }, - { - path: 'energy-opportunities', - component: AssessmentEnergyOpportunitiesFormComponent - }, - { - path: 'nebs', - component: AssessmentNebsFormComponent - }, - { - path: 'results', - component: OnSiteAssessmentResultsComponent - } - ] - }, - { - path: 'review-data-collection', - component: ReviewOnSiteComponent - }, - ] - }, - { - path: 'data-evaluation/:id', - component: DataEvaluationComponent, - children: [ - { - path: '', - pathMatch: 'full', - redirectTo: 'follow-up' - }, - { - path: 'follow-up', - component: DataFollowUpComponent - }, - { - path: 'assessment-report/:id', - component: AssessmentEvaluationComponent, - }, - { - path: 'visit-report', - component: VisitReportComponent, - } - ] - } - ] - }, - { - path: 'user', - component: UserDashboardComponent, - children: [ - { - path: '', - pathMatch: 'full', - redirectTo: 'home' - }, - { - path: 'home', - component: UserDashboardHomeComponent - }, - { - path: 'settings', - component: UserSettingsComponent - }, - { - path: 'help', - component: UserDashboardHelpComponent - }, - { - path: 'nebs-database', - component: ExploreNEBsComponent - } - ] - }, - { - path: 'company/:id', - component: CompanyDashboardComponent, - children: [ - { - path: '', - pathMatch: 'full', - redirectTo: 'home' - }, - { - path: 'home', - component: CompanyDashboardHomeComponent - }, - { - path: 'settings', - component: CompanySettingsComponent - }, - { - path: 'reports', - component: CompanyReportsComponent - }, - { - path: 'goals', - component: CompanyGoalsComponent - } - ] - }, - { - path: 'facility/:id', - component: FacilityDashboardComponent, - children: [ - { - path: '', - pathMatch: 'full', - redirectTo: 'home' - }, - { - path: 'home', - component: FacilityDashboardHomeComponent - }, - { - path: 'settings', - component: FacilitySettingsComponent - }, - { - path: 'reports', - component: FacilityReportsComponent - }, - { - path: 'goals', - component: FacilityGoalsComponent - } - ] - }, - { - path: 'assessment/:id', - component: AssessmentDashboardComponent, - children: [ - { - path: '', - pathMatch: 'full', - redirectTo: 'home' - }, - { - path: 'home', - component: AssessmentDashboardHomeComponent - }, - { - path: 'settings', - component: AssessmentSettingsComponent - } - ] - }, - //wildcard/page not found needs to be last route - //triggered after entire route tree is checked - { path: "**", component: PageNotFoundComponent }, - -]; - -const routerOptions: ExtraOptions = { - anchorScrolling: 'enabled', - scrollPositionRestoration: 'enabled', - useHash: true -} - -@NgModule({ - imports: [RouterModule.forRoot(routes, routerOptions)], - exports: [RouterModule] -}) -export class AppRoutingModule { } diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 085460c4..a4988607 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -3,115 +3,21 @@ import { RouterTestingModule } from '@angular/router/testing'; import { AppComponent } from './app.component'; import { NavbarComponent } from './core-components/navbar/navbar.component'; import { WelcomeComponent } from './core-components/welcome/welcome.component'; -import { CompanyIdbService } from './indexed-db/company-idb.service'; -import { FacilityIdbService } from './indexed-db/facility-idb.service'; -import { UserIdbService } from './indexed-db/user-idb.service'; import { LoadingComponent } from './core-components/loading/loading.component'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { AssessmentIdbService } from './indexed-db/assessment-idb.service'; -import { ContactIdbService } from './indexed-db/contact-idb.service'; -import { NonEnergyBenefitsIdbService } from './indexed-db/non-energy-benefits-idb.service'; -import { OnSiteVisitIdbService } from './indexed-db/on-site-visit-idb.service'; import { SetupWizardModalComponent } from './core-components/setup-wizard-modal/setup-wizard-modal.component'; -import { SetupWizardService } from './setup-wizard/setup-wizard.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbCompany } from './models/company'; -import { IdbFacility } from './models/facility'; -import { IdbUser } from './models/user'; -import { IdbAssessment } from './models/assessment'; -import { IdbContact } from './models/contact'; -import { IdbNonEnergyBenefit } from './models/nonEnergyBenefit'; -import { IdbOnSiteVisit } from './models/onSiteVisit'; -import { EnergyOpportunityIdbService } from './indexed-db/energy-opportunity-idb.service'; -import { IdbEnergyOpportunity } from './models/energyOpportunity'; -import { KeyPerformanceIndicatorsIdbService } from './indexed-db/key-performance-indicators-idb.service'; -import { IdbKeyPerformanceIndicator } from './models/keyPerformanceIndicator'; import { ImportBackupModalComponent } from './core-components/import-backup-modal/import-backup-modal.component'; -import { EnergyEquipmentIdbService } from './indexed-db/energy-equipment-idb.service'; -import { IdbEnergyEquipment } from './models/energyEquipment'; -import { ProcessEquipmentIdbService } from './indexed-db/process-equipment-idb.service'; -import { IdbProcessEquipment } from './models/processEquipment'; -import { IdbKeyPerformanceMetricImpact } from './models/keyPerformanceMetricImpact'; -import { KeyPerformanceMetricImpactsIdbService } from './indexed-db/key-performance-metric-impacts-idb.service'; import { FeedbackPageComponent } from './core-components/feedback-page/feedback-page.component'; import { AlphaDisclaimerComponent } from './core-components/alpha-disclaimer/alpha-disclaimer.component'; -import { LocalStorageDataService } from './shared/shared-services/local-storage-data.service'; +import { stubServiceProviders } from './spec-helpers/spec-test-service-stub'; describe('AppComponent', () => { - let companyIdbService: Partial = { - companies: new BehaviorSubject>([]), - selectedCompany: new BehaviorSubject(undefined) - }; - - let facilityIdbService: Partial = { - facilities: new BehaviorSubject>([]), - selectedFacility: new BehaviorSubject(undefined) - }; - - let userIdbService: Partial = { - user: new BehaviorSubject(undefined) - }; - - let energyOpportunityIdbService: Partial = { - energyOpportunities: new BehaviorSubject>([]), - }; - - let assessmentIdbService: Partial = { - assessments: new BehaviorSubject>([]), - selectedAssessment: new BehaviorSubject(undefined) - }; - - let contactIdbService: Partial = { - contacts: new BehaviorSubject>([]) - }; - - let nonEnergyBenefitsIdbService: Partial = { - nonEnergyBenefits: new BehaviorSubject>([]) - }; - - let onSiteVisitIdbService: Partial = { - onSiteVisits: new BehaviorSubject>([]) - }; - - let setupWizardService: Partial = {}; - - let keyPerformanceIndicatorService: Partial = { - keyPerformanceIndicators: new BehaviorSubject>([]) - } - - let energyEquipmentIdbService: Partial = { - energyEquipments: new BehaviorSubject>([]) - }; - - let processEquipmentIdbService: Partial = { - processEquipments: new BehaviorSubject>([]) - } - - let keyPerformanceMetricImpactIdbService: Partial = { - keyPerformanceMetricImpacts: new BehaviorSubject>([]) - } - beforeEach(() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, FontAwesomeModule], declarations: [AppComponent, NavbarComponent, WelcomeComponent, LoadingComponent, SetupWizardModalComponent, ImportBackupModalComponent, AlphaDisclaimerComponent, FeedbackPageComponent], - providers: [ - { provide: CompanyIdbService, useValue: companyIdbService }, - { provide: FacilityIdbService, useValue: facilityIdbService }, - { provide: UserIdbService, useValue: userIdbService }, - { provide: EnergyOpportunityIdbService, useValue: energyOpportunityIdbService }, - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - { provide: ContactIdbService, useValue: contactIdbService }, - { provide: NonEnergyBenefitsIdbService, useValue: nonEnergyBenefitsIdbService }, - { provide: OnSiteVisitIdbService, useValue: onSiteVisitIdbService }, - { provide: SetupWizardService, useValue: setupWizardService }, - { provide: KeyPerformanceIndicatorsIdbService, useValue: keyPerformanceIndicatorService }, - { provide: EnergyEquipmentIdbService, useValue: energyEquipmentIdbService }, - { provide: ProcessEquipmentIdbService, useValue: processEquipmentIdbService }, - { provide: KeyPerformanceMetricImpactsIdbService, useValue: keyPerformanceMetricImpactIdbService }, - { provide: LocalStorageDataService, useValue: {}}, - ] + providers: stubServiceProviders }) }); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 9162482e..7f4ad8c5 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -93,7 +93,7 @@ export class AppComponent { let user: IdbUser = this.userIdbService.user.getValue(); if (user.skipSplashScreen) { //if user skips the home screen navigate to dashboard. - this.router.navigateByUrl('/user') + this.router.navigateByUrl('/portfolio') } } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1825235d..5434e34f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,24 +1,21 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; -import { AppRoutingModule } from './app-routing.module'; +import { AppRoutingModule } from './routing/app-routing.module'; import { AppComponent } from './app.component'; import { NavbarComponent } from './core-components/navbar/navbar.component'; import { WelcomeComponent } from './core-components/welcome/welcome.component'; import { PageNotFoundComponent } from './core-components/page-not-found/page-not-found.component'; -import { UserDashboardModule } from './user-dashboard/user-dashboard.module'; -import { CompanyDashboardModule } from './company-dashboard/company-dashboard.module'; -import { FacilityDashboardModule } from './facility-dashboard/facility-dashboard.module'; import { IndexedDbModule } from './indexed-db/indexed-db.module'; import { LoadingComponent } from './core-components/loading/loading.component'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { FormsModule } from '@angular/forms'; import { SetupWizardModule } from './setup-wizard/setup-wizard.module'; import { SidebarComponent } from './core-components/sidebar/sidebar.component'; -import { HelperPipesModule } from './shared/helper-pipes/helper-pipes.module'; -import { AssessmentDashboardModule } from './assessment-dashboard/assessment-dashboard.module'; +import { HelperPipesModule } from './shared/helper-pipes/_helper-pipes.module'; import { SetupWizardModalComponent } from './core-components/setup-wizard-modal/setup-wizard-modal.component'; import { ImportBackupModalComponent } from './core-components/import-backup-modal/import-backup-modal.component'; +import { UserPortfolioModule } from './user-portfolio/user-portfolio.module'; import { PlotlyViaWindowModule } from 'angular-plotly.js'; import { FeedbackPageComponent } from './core-components/feedback-page/feedback-page.component'; import { AcknowledgmentsComponent } from './core-components/acknowledgments/acknowledgments.component'; @@ -48,15 +45,13 @@ import { NebsDatabaseModule } from './nebs-database/nebs-database.module'; imports: [ BrowserModule, AppRoutingModule, - UserDashboardModule, - CompanyDashboardModule, - FacilityDashboardModule, IndexedDbModule, FontAwesomeModule, FormsModule, SetupWizardModule, HelperPipesModule, - AssessmentDashboardModule, + UserPortfolioModule, + PlotlyViaWindowModule, PlotlyViaWindowModule, NebsDatabaseModule ], diff --git a/src/app/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.html b/src/app/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.html deleted file mode 100644 index 3c0236cf..00000000 --- a/src/app/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.html +++ /dev/null @@ -1,50 +0,0 @@ -
-
- -
-
-
-
- {{assessment.name}} Details -
-
- - - - - - - - - - - - - - - -
- Equipment Type - - -
- Annual Energy Use - - {{assessment.energyUse}} -
- Annual Costs - - {{assessment.cost}} -
-
-
-
-
-
-
-
\ No newline at end of file diff --git a/src/app/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.spec.ts b/src/app/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.spec.ts deleted file mode 100644 index 46c6ddb5..00000000 --- a/src/app/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.spec.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AssessmentDashboardHomeComponent } from './assessment-dashboard-home.component'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbAssessment, getNewIdbAssessment } from 'src/app/models/assessment'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { SetupWizardService } from 'src/app/setup-wizard/setup-wizard.service'; -import { RouterTestingModule } from '@angular/router/testing'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { HelperPipesModule } from 'src/app/shared/helper-pipes/helper-pipes.module'; -import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; -import { IdbOnSiteVisit } from 'src/app/models/onSiteVisit'; -import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service'; -import { getDefaultUnitSettings } from 'src/app/models/unitSettings'; - -describe('AssessmentDashboardHomeComponent', () => { - let component: AssessmentDashboardHomeComponent; - let fixture: ComponentFixture; - - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(getNewIdbAssessment('', '', '', getDefaultUnitSettings())) - }; - let companyIdbService: Partial = {}; - let facilityIdbService: Partial = {}; - let setupWizardService: Partial = {}; - let onSiteVisitIdbService: Partial = { - onSiteVisits: new BehaviorSubject>([]) - }; - - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [RouterTestingModule, FontAwesomeModule, HelperPipesModule], - declarations: [AssessmentDashboardHomeComponent], - providers: [ - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - { provide: CompanyIdbService, useValue: companyIdbService }, - { provide: FacilityIdbService, useValue: facilityIdbService }, - { provide: SetupWizardService, useValue: setupWizardService }, - { provide: OnSiteVisitIdbService, useValue: onSiteVisitIdbService }, - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(AssessmentDashboardHomeComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/assessment-dashboard/assessment-dashboard-tabs/assessment-dashboard-tabs.component.html b/src/app/assessment-dashboard/assessment-dashboard-tabs/assessment-dashboard-tabs.component.html deleted file mode 100644 index 4854e9c0..00000000 --- a/src/app/assessment-dashboard/assessment-dashboard-tabs/assessment-dashboard-tabs.component.html +++ /dev/null @@ -1,29 +0,0 @@ - \ No newline at end of file diff --git a/src/app/assessment-dashboard/assessment-dashboard-tabs/assessment-dashboard-tabs.component.spec.ts b/src/app/assessment-dashboard/assessment-dashboard-tabs/assessment-dashboard-tabs.component.spec.ts deleted file mode 100644 index ef09e7a6..00000000 --- a/src/app/assessment-dashboard/assessment-dashboard-tabs/assessment-dashboard-tabs.component.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AssessmentDashboardTabsComponent } from './assessment-dashboard-tabs.component'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbAssessment, getNewIdbAssessment } from 'src/app/models/assessment'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { RouterTestingModule } from '@angular/router/testing'; -import { getDefaultUnitSettings } from 'src/app/models/unitSettings'; - -describe('AssessmentDashboardTabsComponent', () => { - let component: AssessmentDashboardTabsComponent; - let fixture: ComponentFixture; - - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(getNewIdbAssessment('', '', '', getDefaultUnitSettings())) - }; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [RouterTestingModule, FontAwesomeModule], - declarations: [AssessmentDashboardTabsComponent], - providers: [ - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(AssessmentDashboardTabsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/assessment-dashboard/assessment-dashboard-tabs/assessment-dashboard-tabs.component.ts b/src/app/assessment-dashboard/assessment-dashboard-tabs/assessment-dashboard-tabs.component.ts deleted file mode 100644 index a30a459b..00000000 --- a/src/app/assessment-dashboard/assessment-dashboard-tabs/assessment-dashboard-tabs.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Component } from '@angular/core'; -import { IconDefinition, faBuilding, faChartLine, faFileLines, faFolderOpen, faGears, faIndustry } from '@fortawesome/free-solid-svg-icons'; -import { Subscription } from 'rxjs'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { IdbAssessment } from 'src/app/models/assessment'; -@Component({ - selector: 'app-assessment-dashboard-tabs', - templateUrl: './assessment-dashboard-tabs.component.html', - styleUrl: './assessment-dashboard-tabs.component.css' -}) -export class AssessmentDashboardTabsComponent { - - faBuilding: IconDefinition = faBuilding; - faIndustry: IconDefinition = faIndustry; - faGears: IconDefinition = faGears; - faFolderOpen: IconDefinition = faFolderOpen; - faChartLine: IconDefinition = faChartLine; - faFileLines: IconDefinition = faFileLines; - - assessment: IdbAssessment; - assessmentSub: Subscription; - - constructor(private assessmentIdbService: AssessmentIdbService){ - } - - ngOnInit(){ - this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(_assessment => { - this.assessment = _assessment; - }); - } - - ngOnDestroy(){ - this.assessmentSub.unsubscribe(); - } -} diff --git a/src/app/assessment-dashboard/assessment-dashboard.component.html b/src/app/assessment-dashboard/assessment-dashboard.component.html deleted file mode 100644 index 6aaa11ca..00000000 --- a/src/app/assessment-dashboard/assessment-dashboard.component.html +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
\ No newline at end of file diff --git a/src/app/assessment-dashboard/assessment-dashboard.component.ts b/src/app/assessment-dashboard/assessment-dashboard.component.ts deleted file mode 100644 index 266e8422..00000000 --- a/src/app/assessment-dashboard/assessment-dashboard.component.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Component } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { AssessmentIdbService } from '../indexed-db/assessment-idb.service'; - -@Component({ - selector: 'app-assessment-dashboard', - templateUrl: './assessment-dashboard.component.html', - styleUrl: './assessment-dashboard.component.css' -}) -export class AssessmentDashboardComponent { - - constructor(private activatedRoute: ActivatedRoute, private assessmentIdbService: AssessmentIdbService, - private router: Router) { - } - - ngOnInit() { - this.activatedRoute.params.subscribe(params => { - let assessmentGUID: string = params['id']; - let assessmentExists: boolean = this.assessmentIdbService.setSelectedFromGUID(assessmentGUID); - if(!assessmentExists){ - this.router.navigateByUrl('/user'); - } - }); - } -} diff --git a/src/app/assessment-dashboard/assessment-dashboard.module.ts b/src/app/assessment-dashboard/assessment-dashboard.module.ts deleted file mode 100644 index 9e56ad9b..00000000 --- a/src/app/assessment-dashboard/assessment-dashboard.module.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { AssessmentDashboardComponent } from './assessment-dashboard.component'; -import { AssessmentDashboardHomeComponent } from './assessment-dashboard-home/assessment-dashboard-home.component'; -import { AssessmentDashboardTabsComponent } from './assessment-dashboard-tabs/assessment-dashboard-tabs.component'; -import { AssessmentSettingsComponent } from './assessment-settings/assessment-settings.component'; -import { RouterModule } from '@angular/router'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { ManageAssessmentComponent } from './assessment-settings/manage-assessment/manage-assessment.component'; -import { FormsModule } from '@angular/forms'; -import { HelperPipesModule } from '../shared/helper-pipes/helper-pipes.module'; - - - -@NgModule({ - declarations: [ - AssessmentDashboardComponent, - AssessmentDashboardHomeComponent, - AssessmentDashboardTabsComponent, - AssessmentSettingsComponent, - ManageAssessmentComponent - ], - imports: [ - CommonModule, - RouterModule, - FontAwesomeModule, - FormsModule, - HelperPipesModule - ] -}) -export class AssessmentDashboardModule { } diff --git a/src/app/assessment-dashboard/assessment-settings/assessment-settings.component.html b/src/app/assessment-dashboard/assessment-settings/assessment-settings.component.html deleted file mode 100644 index 8038c8ab..00000000 --- a/src/app/assessment-dashboard/assessment-settings/assessment-settings.component.html +++ /dev/null @@ -1,15 +0,0 @@ -
-
-
-
-
- - -
-
-
- -
- -
\ No newline at end of file diff --git a/src/app/assessment-dashboard/assessment-settings/assessment-settings.component.spec.ts b/src/app/assessment-dashboard/assessment-settings/assessment-settings.component.spec.ts deleted file mode 100644 index 241bf80e..00000000 --- a/src/app/assessment-dashboard/assessment-settings/assessment-settings.component.spec.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AssessmentSettingsComponent } from './assessment-settings.component'; -import { ManageAssessmentComponent } from './manage-assessment/manage-assessment.component'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbAssessment, getNewIdbAssessment } from 'src/app/models/assessment'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { FormsModule } from '@angular/forms'; -import { ContactIdbService } from 'src/app/indexed-db/contact-idb.service'; -import { DbChangesService } from 'src/app/indexed-db/db-changes.service'; -import { getDefaultUnitSettings } from 'src/app/models/unitSettings'; - -describe('AssessmentSettingsComponent', () => { - let component: AssessmentSettingsComponent; - let fixture: ComponentFixture; - - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(getNewIdbAssessment('', '', '', getDefaultUnitSettings())) - }; - let companyIdbService: Partial = {}; - let facilityIdbService: Partial = {}; - let contactIdbService: Partial = {}; - let dbChangesService: Partial = {}; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [FontAwesomeModule, FormsModule], - declarations: [AssessmentSettingsComponent, ManageAssessmentComponent], - providers: [ - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - { provide: CompanyIdbService, useValue: companyIdbService }, - { provide: FacilityIdbService, useValue: facilityIdbService }, - { provide: ContactIdbService, useValue: contactIdbService }, - { provide: DbChangesService, useValue: dbChangesService }, - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(AssessmentSettingsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/assessment-dashboard/assessment-settings/assessment-settings.component.ts b/src/app/assessment-dashboard/assessment-settings/assessment-settings.component.ts deleted file mode 100644 index a53b1e71..00000000 --- a/src/app/assessment-dashboard/assessment-settings/assessment-settings.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Component } from '@angular/core'; -import { Subscription } from 'rxjs'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { IdbAssessment } from 'src/app/models/assessment'; - -@Component({ - selector: 'app-assessment-settings', - templateUrl: './assessment-settings.component.html', - styleUrl: './assessment-settings.component.css' -}) -export class AssessmentSettingsComponent { - selectedAssessment: IdbAssessment; - selectedAssessmentSub: Subscription; - constructor(private assessmentIdbService: AssessmentIdbService) { - } - - ngOnInit() { - this.selectedAssessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(_assessment => { - this.selectedAssessment = _assessment; - }); - } - - ngOnDestroy() { - this.selectedAssessmentSub.unsubscribe(); - } - - - async saveChanges(){ - await this.assessmentIdbService.asyncUpdate(this.selectedAssessment); - } -} diff --git a/src/app/assessment-dashboard/assessment-settings/manage-assessment/manage-assessment.component.html b/src/app/assessment-dashboard/assessment-settings/manage-assessment/manage-assessment.component.html deleted file mode 100644 index 3ed7d71e..00000000 --- a/src/app/assessment-dashboard/assessment-settings/manage-assessment/manage-assessment.component.html +++ /dev/null @@ -1,40 +0,0 @@ - -
-
-

- -

-
-
- -
-
-
-
- - - -
- \ No newline at end of file diff --git a/src/app/assessment-dashboard/assessment-settings/manage-assessment/manage-assessment.component.spec.ts b/src/app/assessment-dashboard/assessment-settings/manage-assessment/manage-assessment.component.spec.ts deleted file mode 100644 index dfaa97d5..00000000 --- a/src/app/assessment-dashboard/assessment-settings/manage-assessment/manage-assessment.component.spec.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ManageAssessmentComponent } from './manage-assessment.component'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbAssessment, getNewIdbAssessment } from 'src/app/models/assessment'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { ContactIdbService } from 'src/app/indexed-db/contact-idb.service'; -import { NonEnergyBenefitsIdbService } from 'src/app/indexed-db/non-energy-benefits-idb.service'; -import { DbChangesService } from 'src/app/indexed-db/db-changes.service'; -import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service'; -import { getDefaultUnitSettings } from 'src/app/models/unitSettings'; - -describe('ManageAssessmentComponent', () => { - let component: ManageAssessmentComponent; - let fixture: ComponentFixture; - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(getNewIdbAssessment('', '', '', getDefaultUnitSettings())), - assessments: new BehaviorSubject>([]) - }; - let companyIdbService: Partial = {}; - let facilityIdbService: Partial = {}; - let energyOpportunityIdbService: Partial = {}; - let contactIdbService: Partial = {}; - let nonEnergyBenefitsIdbService: Partial = {} - let dbChangesService: Partial = {} - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [FontAwesomeModule], - declarations: [ManageAssessmentComponent], - providers: [ - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - { provide: CompanyIdbService, useValue: companyIdbService }, - { provide: FacilityIdbService, useValue: facilityIdbService }, - { provide: EnergyOpportunityIdbService, useValue: energyOpportunityIdbService }, - { provide: ContactIdbService, useValue: contactIdbService }, - { provide: NonEnergyBenefitsIdbService, useValue: nonEnergyBenefitsIdbService }, - { provide: DbChangesService, useValue: dbChangesService } - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(ManageAssessmentComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/assessment-dashboard/assessment-settings/manage-assessment/manage-assessment.component.ts b/src/app/assessment-dashboard/assessment-settings/manage-assessment/manage-assessment.component.ts deleted file mode 100644 index 8accdaf3..00000000 --- a/src/app/assessment-dashboard/assessment-settings/manage-assessment/manage-assessment.component.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Component } from '@angular/core'; -import { Router } from '@angular/router'; -import { IconDefinition, faPenToSquare, faTrash } from '@fortawesome/free-solid-svg-icons'; -import { Subscription } from 'rxjs'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { DbChangesService } from 'src/app/indexed-db/db-changes.service'; -import { IdbAssessment } from 'src/app/models/assessment'; - -@Component({ - selector: 'app-manage-assessment', - templateUrl: './manage-assessment.component.html', - styleUrl: './manage-assessment.component.css' -}) -export class ManageAssessmentComponent { - - faPenToSquare: IconDefinition = faPenToSquare; - faTrash: IconDefinition = faTrash; - - accordionOpen: boolean = false; - assessment: IdbAssessment; - assessmentSub: Subscription; - displayDeleteModal: boolean = false; - constructor(private assessmentIdbService: AssessmentIdbService, - private dbChangesService: DbChangesService, private router: Router) { - } - - ngOnInit() { - this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(_assessment => { - this.assessment = _assessment; - }); - } - - ngOnDestroy() { - this.assessmentSub.unsubscribe(); - } - - toggleAccordion() { - this.accordionOpen = !this.accordionOpen; - } - - openDeleteModal() { - this.displayDeleteModal = true; - } - - closeDeleteModal() { - this.displayDeleteModal = false; - } - - async confirmDelete() { - await this.dbChangesService.deleteAssessment(this.assessment); - this.router.navigateByUrl('/user') - } -} diff --git a/src/app/company-dashboard/company-dashboard-home/assessments-table/assessments-table.component.html b/src/app/company-dashboard/company-dashboard-home/assessments-table/assessments-table.component.html deleted file mode 100644 index 8ceae03f..00000000 --- a/src/app/company-dashboard/company-dashboard-home/assessments-table/assessments-table.component.html +++ /dev/null @@ -1,55 +0,0 @@ -
-
- - - Assessments - - -
-
- - - - - - - - - - - - - - - - - - -
- Name - - Facility - - Visit Date -
- - {{assessment.name}} - - - {{assessment.facilityId | facilityName:facilities}} - - - {{assessment.visitDate | date:'shortDate'}} - -
-
- - -
- No assessments found. Please click "Add New" to get started. -
-
-
-
\ No newline at end of file diff --git a/src/app/company-dashboard/company-dashboard-home/assessments-table/assessments-table.component.spec.ts b/src/app/company-dashboard/company-dashboard-home/assessments-table/assessments-table.component.spec.ts deleted file mode 100644 index aec9d4bb..00000000 --- a/src/app/company-dashboard/company-dashboard-home/assessments-table/assessments-table.component.spec.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AssessmentsTableComponent } from './assessments-table.component'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { HelperPipesModule } from 'src/app/shared/helper-pipes/helper-pipes.module'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { SetupWizardService } from 'src/app/setup-wizard/setup-wizard.service'; -import { IdbAssessment, getNewIdbAssessment } from 'src/app/models/assessment'; -import { BehaviorSubject } from 'rxjs'; -import { IdbFacility, getNewIdbFacility } from 'src/app/models/facility'; -import { IdbCompany, getNewIdbCompany } from 'src/app/models/company'; -import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; -import { IdbOnSiteVisit } from 'src/app/models/onSiteVisit'; -import { getDefaultUnitSettings } from 'src/app/models/unitSettings'; - -describe('AssessmentsTableComponent', () => { - let component: AssessmentsTableComponent; - let fixture: ComponentFixture; - - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(getNewIdbAssessment('', '', '', getDefaultUnitSettings())), - assessments: new BehaviorSubject>([]) - }; - let facilityIdbService: Partial = { - selectedFacility: new BehaviorSubject(getNewIdbFacility('', '')), - facilities: new BehaviorSubject>([]) - }; - let companyIdbService: Partial = { - selectedCompany: new BehaviorSubject(getNewIdbCompany('')) - }; - let setupWizardService: Partial = {}; - let onSiteVisitIdbService: Partial = { - onSiteVisits: new BehaviorSubject>([]) - }; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [FontAwesomeModule, HelperPipesModule], - declarations: [AssessmentsTableComponent], - providers: [ - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - { provide: FacilityIdbService, useValue: facilityIdbService }, - { provide: CompanyIdbService, useValue: companyIdbService }, - { provide: SetupWizardService, useValue: setupWizardService }, - { provide: OnSiteVisitIdbService, useValue: onSiteVisitIdbService }, - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(AssessmentsTableComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/company-dashboard/company-dashboard-home/assessments-table/assessments-table.component.ts b/src/app/company-dashboard/company-dashboard-home/assessments-table/assessments-table.component.ts deleted file mode 100644 index 47adaa87..00000000 --- a/src/app/company-dashboard/company-dashboard-home/assessments-table/assessments-table.component.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { Component } from '@angular/core'; -import { Router } from '@angular/router'; -import { IconDefinition, faFileLines, faWandMagicSparkles } from '@fortawesome/free-solid-svg-icons'; -import { Subscription } from 'rxjs'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; -import { IdbAssessment } from 'src/app/models/assessment'; -import { IdbCompany } from 'src/app/models/company'; -import { IdbFacility } from 'src/app/models/facility'; -import { SetupWizardService } from 'src/app/setup-wizard/setup-wizard.service'; -import { SharedDataService } from 'src/app/shared/shared-services/shared-data.service'; - -@Component({ - selector: 'app-assessments-table', - templateUrl: './assessments-table.component.html', - styleUrl: './assessments-table.component.css' -}) -export class AssessmentsTableComponent { - - faWandMagicSparkles: IconDefinition = faWandMagicSparkles; - faFileLines: IconDefinition = faFileLines; - - company: IdbCompany; - companySub: Subscription; - - facilities: Array; - facilitiesSub: Subscription; - - assessments: Array; - assessmentsSub: Subscription; - - constructor(private companyIdbService: CompanyIdbService, - private facilityIdbService: FacilityIdbService, - private assessmentIdbService: AssessmentIdbService, - private sharedDataService: SharedDataService, - private onSiteVisitIdbService: OnSiteVisitIdbService) { - } - - ngOnInit() { - this.companySub = this.companyIdbService.selectedCompany.subscribe(_company => { - this.company = _company; - }); - - this.facilitiesSub = this.facilityIdbService.facilities.subscribe(_facilities => { - this.facilities = _facilities; - }); - this.assessmentsSub = this.assessmentIdbService.assessments.subscribe(_assessments => { - this.assessments = _assessments; - }) - } - - ngOnDestroy() { - this.companySub.unsubscribe(); - this.facilitiesSub.unsubscribe(); - this.assessmentsSub.unsubscribe(); - } - - openAddNewModal() { - this.facilityIdbService.selectedFacility.next(undefined); - this.onSiteVisitIdbService.selectedVisit.next(undefined); - this.sharedDataService.createAssessmentModalOpen.next(true); - } - - goToVisit(assessment: IdbAssessment) { - this.companyIdbService.setSelectedFromGUID(assessment.companyId); - this.facilityIdbService.setSelectedFromGUID(assessment.facilityId); - this.onSiteVisitIdbService.setSelectedFromAssessmentGUID(assessment.guid); - this.sharedDataService.createAssessmentModalOpen.next(true); - } -} diff --git a/src/app/company-dashboard/company-dashboard-home/company-dashboard-home.component.html b/src/app/company-dashboard/company-dashboard-home/company-dashboard-home.component.html deleted file mode 100644 index 51aa39c4..00000000 --- a/src/app/company-dashboard/company-dashboard-home/company-dashboard-home.component.html +++ /dev/null @@ -1,20 +0,0 @@ -
-
- -
-
- -
-
-
-
-
- -
-
\ No newline at end of file diff --git a/src/app/company-dashboard/company-dashboard-home/company-dashboard-home.component.spec.ts b/src/app/company-dashboard/company-dashboard-home/company-dashboard-home.component.spec.ts deleted file mode 100644 index 6c5de4a6..00000000 --- a/src/app/company-dashboard/company-dashboard-home/company-dashboard-home.component.spec.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CompanyDashboardHomeComponent } from './company-dashboard-home.component'; -import { RouterTestingModule } from '@angular/router/testing'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { DbChangesService } from 'src/app/indexed-db/db-changes.service'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbCompany, getNewIdbCompany } from 'src/app/models/company'; -import { IdbFacility } from 'src/app/models/facility'; -import { FormsModule } from '@angular/forms'; -import { FacilitiesTableComponent } from './facilities-table/facilities-table.component'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { HelperPipesModule } from 'src/app/shared/helper-pipes/helper-pipes.module'; -import { AssessmentsTableComponent } from './assessments-table/assessments-table.component'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { IdbAssessment } from 'src/app/models/assessment'; -import { ContactIdbService } from 'src/app/indexed-db/contact-idb.service'; -import { UserIdbService } from 'src/app/indexed-db/user-idb.service'; -import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; -import { IdbOnSiteVisit } from 'src/app/models/onSiteVisit'; -import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service'; -import { IdbEnergyOpportunity } from 'src/app/models/energyOpportunity'; - -describe('CompanyDashboardHomeComponent', () => { - let component: CompanyDashboardHomeComponent; - let fixture: ComponentFixture; - let companyDbServiceStub: Partial = { - companies: new BehaviorSubject>([]), - selectedCompany: new BehaviorSubject(getNewIdbCompany('')) - }; - let facilityDbServiceStub: Partial = { - facilities: new BehaviorSubject>([]), - selectedFacility: new BehaviorSubject(undefined) - } - let energyOpportunityIdbService: Partial = { - energyOpportunities: new BehaviorSubject>([]) - }; - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(undefined), - assessments: new BehaviorSubject>([]) - }; - let contactIdbService: Partial = {}; - let userIdbService: Partial = {}; - - let onSiteVisitIdbService: Partial = { - onSiteVisits: new BehaviorSubject>([]) - }; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [RouterTestingModule, FormsModule, FontAwesomeModule, HelperPipesModule], - declarations: [CompanyDashboardHomeComponent, FacilitiesTableComponent, AssessmentsTableComponent], - providers: [ - { provide: CompanyIdbService, useValue: companyDbServiceStub }, - { provide: FacilityIdbService, useValue: facilityDbServiceStub }, - { provide: DbChangesService, useValue: {} }, - { provide: EnergyOpportunityIdbService, useValue: energyOpportunityIdbService }, - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - { provide: ContactIdbService, useValue: contactIdbService }, - { provide: UserIdbService, useValue: userIdbService }, - { provide: OnSiteVisitIdbService, useValue: onSiteVisitIdbService }, - ] - }); - fixture = TestBed.createComponent(CompanyDashboardHomeComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/company-dashboard/company-dashboard-home/company-dashboard-home.component.ts b/src/app/company-dashboard/company-dashboard-home/company-dashboard-home.component.ts deleted file mode 100644 index e48b8c77..00000000 --- a/src/app/company-dashboard/company-dashboard-home/company-dashboard-home.component.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Component } from '@angular/core'; -import { Router } from '@angular/router'; -import { IconDefinition, faBuilding } from '@fortawesome/free-solid-svg-icons'; -import { Subscription } from 'rxjs'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { DbChangesService } from 'src/app/indexed-db/db-changes.service'; -import { IdbCompany } from 'src/app/models/company'; -@Component({ - selector: 'app-company-dashboard-home', - templateUrl: './company-dashboard-home.component.html', - styleUrls: ['./company-dashboard-home.component.css'] -}) -export class CompanyDashboardHomeComponent { - - faBuilding: IconDefinition = faBuilding; - - selectedCompany: IdbCompany; - selectedCompanySub: Subscription; - constructor(private companyIdbService: CompanyIdbService, - private dbChangesService: DbChangesService, - private router: Router) { - } - - ngOnInit() { - this.selectedCompanySub = this.companyIdbService.selectedCompany.subscribe(_company => { - this.selectedCompany = _company; - }); - } - - ngOnDestroy() { - this.selectedCompanySub.unsubscribe(); - } - - async deleteCompany(){ - await this.dbChangesService.deleteCompany(this.selectedCompany); - this.router.navigateByUrl('/user') - } -} diff --git a/src/app/company-dashboard/company-dashboard-home/facilities-table/facilities-table.component.html b/src/app/company-dashboard/company-dashboard-home/facilities-table/facilities-table.component.html deleted file mode 100644 index 5ee96d35..00000000 --- a/src/app/company-dashboard/company-dashboard-home/facilities-table/facilities-table.component.html +++ /dev/null @@ -1,70 +0,0 @@ -
-
- - - Facilities - - -
-
- - - - - - - - - - - - - - - - - -
- Name - - Location - - Assessments -
- - {{facility.generalInformation.name}} - - - {{facility.generalInformation | addressDisplay}} - - {{(facility.guid | assessmentsList: assessments).length}} -
-
- - -
- No facilities found. Please click "Add New" to get started. -
-
-
-
- - -
- \ No newline at end of file diff --git a/src/app/company-dashboard/company-dashboard-home/facilities-table/facilities-table.component.spec.ts b/src/app/company-dashboard/company-dashboard-home/facilities-table/facilities-table.component.spec.ts deleted file mode 100644 index a67b076b..00000000 --- a/src/app/company-dashboard/company-dashboard-home/facilities-table/facilities-table.component.spec.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { FacilitiesTableComponent } from './facilities-table.component'; -import { UserIdbService } from 'src/app/indexed-db/user-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbUser, getNewIdbUser } from 'src/app/models/user'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { IdbCompany, getNewIdbCompany } from 'src/app/models/company'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { IdbFacility } from 'src/app/models/facility'; -import { RouterTestingModule } from '@angular/router/testing'; -import { FormsModule } from '@angular/forms'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { HelperPipesModule } from 'src/app/shared/helper-pipes/helper-pipes.module'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { IdbAssessment, getNewIdbAssessment } from 'src/app/models/assessment'; -import { getDefaultUnitSettings } from 'src/app/models/unitSettings'; - -describe('FacilitiesTableComponent', () => { - let component: FacilitiesTableComponent; - let fixture: ComponentFixture; - let userIdbService: Partial = { - user: new BehaviorSubject(getNewIdbUser()) - } - let companyIdbService: Partial = { - companies: new BehaviorSubject>([]), - selectedCompany: new BehaviorSubject(getNewIdbCompany('')) - }; - let facilityIdbService: Partial = { - facilities: new BehaviorSubject>([]) - }; - - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(getNewIdbAssessment('', '', '', getDefaultUnitSettings())), - assessments: new BehaviorSubject>([]) - }; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [RouterTestingModule, FormsModule, FontAwesomeModule, HelperPipesModule], - declarations: [FacilitiesTableComponent], - providers: [ - { provide: UserIdbService, useValue: userIdbService }, - { provide: CompanyIdbService, useValue: companyIdbService }, - { provide: FacilityIdbService, useValue: facilityIdbService }, - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(FacilitiesTableComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/company-dashboard/company-dashboard-home/facilities-table/facilities-table.component.ts b/src/app/company-dashboard/company-dashboard-home/facilities-table/facilities-table.component.ts deleted file mode 100644 index 02c04c03..00000000 --- a/src/app/company-dashboard/company-dashboard-home/facilities-table/facilities-table.component.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { Component } from '@angular/core'; -import { Router } from '@angular/router'; -import { IconDefinition, faIndustry, faPlus } from '@fortawesome/free-solid-svg-icons'; -import { Subscription, firstValueFrom } from 'rxjs'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { IdbAssessment } from 'src/app/models/assessment'; -import { IdbCompany } from 'src/app/models/company'; -import { IdbFacility, getNewIdbFacility } from 'src/app/models/facility'; - -@Component({ - selector: 'app-facilities-table', - templateUrl: './facilities-table.component.html', - styleUrl: './facilities-table.component.css' -}) -export class FacilitiesTableComponent { - - faPlus: IconDefinition = faPlus; - faIndustry: IconDefinition = faIndustry; - - - facilities: Array; - facilitiesSub: Subscription; - - assessments: Array; - assessmentsSub: Subscription; - - company: IdbCompany; - companySub: Subscription; - displayAddNewModal: boolean = false; - constructor( - private companyIdbService: CompanyIdbService, - private facilityIdbService: FacilityIdbService, - private assessmentIdbService: AssessmentIdbService, - private router: Router) { - } - - ngOnInit() { - this.companySub = this.companyIdbService.selectedCompany.subscribe(_company => { - this.company = _company; - }); - this.facilitiesSub = this.facilityIdbService.facilities.subscribe(_facilities => { - this.facilities = _facilities; - }); - this.assessmentsSub = this.assessmentIdbService.assessments.subscribe(_assessments => { - this.assessments = _assessments; - }) - } - - ngOnDestroy() { - this.facilitiesSub.unsubscribe(); - this.assessmentsSub.unsubscribe(); - this.companySub.unsubscribe(); - } - - - openAddNewModal() { - this.displayAddNewModal = true; - } - - closeAddNewModal() { - this.displayAddNewModal = false; - } - - async confirmCreate() { - let newFacility: IdbFacility = getNewIdbFacility(this.company.userId, this.company.guid); - newFacility = await firstValueFrom(this.facilityIdbService.addWithObservable(newFacility)); - await this.facilityIdbService.setFacilities(); - this.router.navigateByUrl('/facility/' + newFacility.guid + '/settings'); - } -} diff --git a/src/app/company-dashboard/company-dashboard-tabs/company-dashboard-tabs.component.html b/src/app/company-dashboard/company-dashboard-tabs/company-dashboard-tabs.component.html deleted file mode 100644 index 67bd04d5..00000000 --- a/src/app/company-dashboard/company-dashboard-tabs/company-dashboard-tabs.component.html +++ /dev/null @@ -1,31 +0,0 @@ - \ No newline at end of file diff --git a/src/app/company-dashboard/company-dashboard-tabs/company-dashboard-tabs.component.spec.ts b/src/app/company-dashboard/company-dashboard-tabs/company-dashboard-tabs.component.spec.ts deleted file mode 100644 index 337cffcd..00000000 --- a/src/app/company-dashboard/company-dashboard-tabs/company-dashboard-tabs.component.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CompanyDashboardTabsComponent } from './company-dashboard-tabs.component'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbCompany, getNewIdbCompany } from 'src/app/models/company'; -import { RouterTestingModule } from '@angular/router/testing'; - -describe('CompanyDashboardTabsComponent', () => { - let component: CompanyDashboardTabsComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - let companyIdbService: Partial = { - selectedCompany: new BehaviorSubject(getNewIdbCompany('')) - }; - await TestBed.configureTestingModule({ - imports: [FontAwesomeModule, RouterTestingModule], - declarations: [CompanyDashboardTabsComponent], - providers: [ - { provide: CompanyIdbService, useValue: companyIdbService } - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(CompanyDashboardTabsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/company-dashboard/company-dashboard-tabs/company-dashboard-tabs.component.ts b/src/app/company-dashboard/company-dashboard-tabs/company-dashboard-tabs.component.ts deleted file mode 100644 index bea0318e..00000000 --- a/src/app/company-dashboard/company-dashboard-tabs/company-dashboard-tabs.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Component } from '@angular/core'; -import { IconDefinition, faBuilding, faBullseye, faChartLine, faChevronLeft, faFolderOpen, faGears } from '@fortawesome/free-solid-svg-icons'; -import { Subscription } from 'rxjs'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { IdbCompany } from 'src/app/models/company'; - -@Component({ - selector: 'app-company-dashboard-tabs', - templateUrl: './company-dashboard-tabs.component.html', - styleUrl: './company-dashboard-tabs.component.css' -}) -export class CompanyDashboardTabsComponent { - - - faBuilding: IconDefinition = faBuilding; - faGears: IconDefinition = faGears; - faFolderOpen: IconDefinition = faFolderOpen; - faChartLine: IconDefinition = faChartLine; - faBullseye: IconDefinition = faBullseye - - company: IdbCompany; - copmanySub: Subscription; - - constructor(private companyIdbService: CompanyIdbService) { - - } - - ngOnInit() { - this.copmanySub = this.companyIdbService.selectedCompany.subscribe(_company => { - this.company = _company; - }); - } - - ngOnDestroy() { - this.copmanySub.unsubscribe(); - } -} diff --git a/src/app/company-dashboard/company-dashboard.component.html b/src/app/company-dashboard/company-dashboard.component.html deleted file mode 100644 index 3bbef2d9..00000000 --- a/src/app/company-dashboard/company-dashboard.component.html +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
\ No newline at end of file diff --git a/src/app/company-dashboard/company-dashboard.component.ts b/src/app/company-dashboard/company-dashboard.component.ts deleted file mode 100644 index da56887e..00000000 --- a/src/app/company-dashboard/company-dashboard.component.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Component } from '@angular/core'; -import { CompanyIdbService } from '../indexed-db/company-idb.service'; -import { ActivatedRoute, Router } from '@angular/router'; - -@Component({ - selector: 'app-company-dashboard', - templateUrl: './company-dashboard.component.html', - styleUrls: ['./company-dashboard.component.css'] -}) -export class CompanyDashboardComponent { - - constructor(private activatedRoute: ActivatedRoute, private companyIdbService: CompanyIdbService, - private router: Router) { - } - - ngOnInit() { - this.activatedRoute.params.subscribe(params => { - let companyGUID: string = params['id']; - let companyExists: boolean = this.companyIdbService.setSelectedFromGUID(companyGUID); - if (!companyExists) { - this.router.navigateByUrl('/user'); - } - }); - } -} diff --git a/src/app/company-dashboard/company-dashboard.module.ts b/src/app/company-dashboard/company-dashboard.module.ts deleted file mode 100644 index ea87d790..00000000 --- a/src/app/company-dashboard/company-dashboard.module.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { CompanyDashboardComponent } from './company-dashboard.component'; -import { CompanyDashboardHomeComponent } from './company-dashboard-home/company-dashboard-home.component'; -import { RouterModule } from '@angular/router'; -import { FormsModule } from '@angular/forms'; -import { HelperPipesModule } from '../shared/helper-pipes/helper-pipes.module'; -import { SharedSettingsFormsModule } from '../shared/shared-settings-forms/shared-settings-forms.module'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { CompanyGoalsComponent } from './company-goals/company-goals.component'; -import { CompanyDashboardTabsComponent } from './company-dashboard-tabs/company-dashboard-tabs.component'; -import { CompanyReportsComponent } from './company-reports/company-reports.component'; -import { CompanySettingsComponent } from './company-settings/company-settings.component'; -import { FacilitiesTableComponent } from './company-dashboard-home/facilities-table/facilities-table.component'; -import { AssessmentsTableComponent } from './company-dashboard-home/assessments-table/assessments-table.component'; - -@NgModule({ - declarations: [ - CompanyDashboardComponent, - CompanyDashboardHomeComponent, - CompanyGoalsComponent, - CompanyDashboardTabsComponent, - CompanyReportsComponent, - CompanySettingsComponent, - FacilitiesTableComponent, - AssessmentsTableComponent - ], - imports: [ - CommonModule, - RouterModule, - FormsModule, - HelperPipesModule, - SharedSettingsFormsModule, - FontAwesomeModule - ] -}) -export class CompanyDashboardModule { } diff --git a/src/app/company-dashboard/company-goals/company-goals.component.html b/src/app/company-dashboard/company-goals/company-goals.component.html deleted file mode 100644 index a82e8d04..00000000 --- a/src/app/company-dashboard/company-goals/company-goals.component.html +++ /dev/null @@ -1,40 +0,0 @@ -
-
-
-
-

- -

-
-
- -
-
- Strategic Goals -
- -
-
-
- Sustainability Goals -
- -
-
-
- Marketing Goals -
- -
-
-
-
-
-
-
\ No newline at end of file diff --git a/src/app/company-dashboard/company-goals/company-goals.component.spec.ts b/src/app/company-dashboard/company-goals/company-goals.component.spec.ts deleted file mode 100644 index 3d7d4e4a..00000000 --- a/src/app/company-dashboard/company-goals/company-goals.component.spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CompanyGoalsComponent } from './company-goals.component'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; - -describe('CompanyGoalsComponent', () => { - let component: CompanyGoalsComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [FontAwesomeModule] - }) - .compileComponents(); - - fixture = TestBed.createComponent(CompanyGoalsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/company-dashboard/company-goals/company-goals.component.ts b/src/app/company-dashboard/company-goals/company-goals.component.ts deleted file mode 100644 index 913fc8d3..00000000 --- a/src/app/company-dashboard/company-goals/company-goals.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component } from '@angular/core'; -import { IconDefinition, faBullseye } from '@fortawesome/free-solid-svg-icons'; - -@Component({ - selector: 'app-company-goals', - templateUrl: './company-goals.component.html', - styleUrl: './company-goals.component.css' -}) -export class CompanyGoalsComponent { - - faBullseye: IconDefinition = faBullseye; - accordionOpen: boolean = false; - - - constructor(){ - - } - - toggleAccordion(){ - this.accordionOpen = !this.accordionOpen; - } -} diff --git a/src/app/company-dashboard/company-reports/company-reports.component.html b/src/app/company-dashboard/company-reports/company-reports.component.html deleted file mode 100644 index fb8d5aae..00000000 --- a/src/app/company-dashboard/company-reports/company-reports.component.html +++ /dev/null @@ -1 +0,0 @@ -

company-reports works!

diff --git a/src/app/company-dashboard/company-settings/company-settings.component.css b/src/app/company-dashboard/company-settings/company-settings.component.css deleted file mode 100644 index 2d909ba7..00000000 --- a/src/app/company-dashboard/company-settings/company-settings.component.css +++ /dev/null @@ -1,5 +0,0 @@ -.settings-content{ - height: calc(100% - 3rem); - /* background-color: red; */ - overflow-y: auto; -} \ No newline at end of file diff --git a/src/app/company-dashboard/company-settings/company-settings.component.html b/src/app/company-dashboard/company-settings/company-settings.component.html deleted file mode 100644 index e5abf0b7..00000000 --- a/src/app/company-dashboard/company-settings/company-settings.component.html +++ /dev/null @@ -1,50 +0,0 @@ -
-
-
-
-
- Company Details -
-
-
- - -
-
- - -
- - -
- -
- -
-
-
-
-
- - - -
- \ No newline at end of file diff --git a/src/app/company-dashboard/company-settings/company-settings.component.spec.ts b/src/app/company-dashboard/company-settings/company-settings.component.spec.ts deleted file mode 100644 index b4c3e59f..00000000 --- a/src/app/company-dashboard/company-settings/company-settings.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CompanySettingsComponent } from './company-settings.component'; -import { SharedSettingsFormsModule } from 'src/app/shared/shared-settings-forms/shared-settings-forms.module'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbCompany, getNewIdbCompany } from 'src/app/models/company'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { FormsModule } from '@angular/forms'; -import { RouterTestingModule } from '@angular/router/testing'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { IdbFacility, getNewIdbFacility } from 'src/app/models/facility'; -import { LocalStorageDataService } from 'src/app/shared/shared-services/local-storage-data.service'; -import { DbChangesService } from 'src/app/indexed-db/db-changes.service'; -import { UserIdbService } from 'src/app/indexed-db/user-idb.service'; - -describe('CompanySettingsComponent', () => { - let component: CompanySettingsComponent; - let fixture: ComponentFixture; - let companyIdbService: Partial = { - companies: new BehaviorSubject>([]), - selectedCompany: new BehaviorSubject(getNewIdbCompany('')) - }; - let facilityIdbService: Partial = { - facilities: new BehaviorSubject>([]), - selectedFacility: new BehaviorSubject(getNewIdbFacility('', '')) - }; - let userIdbService: Partial = {}; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [SharedSettingsFormsModule, FontAwesomeModule, FormsModule, RouterTestingModule], - declarations: [CompanySettingsComponent], - providers: [ - { provide: CompanyIdbService, useValue: companyIdbService }, - { provide: FacilityIdbService, useValue: facilityIdbService }, - { provide: LocalStorageDataService, useValue: {}}, - { provide: DbChangesService, useValue: {}}, - { provide: UserIdbService, useValue: userIdbService} - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(CompanySettingsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/company-dashboard/company-settings/company-settings.component.ts b/src/app/company-dashboard/company-settings/company-settings.component.ts deleted file mode 100644 index d568fed1..00000000 --- a/src/app/company-dashboard/company-settings/company-settings.component.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Component } from '@angular/core'; -import { Router } from '@angular/router'; -import { IconDefinition, faBuilding, faTrash } from '@fortawesome/free-solid-svg-icons'; -import { Subscription } from 'rxjs'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { DbChangesService } from 'src/app/indexed-db/db-changes.service'; -import { IdbCompany } from 'src/app/models/company'; - -@Component({ - selector: 'app-company-settings', - templateUrl: './company-settings.component.html', - styleUrl: './company-settings.component.css' -}) -export class CompanySettingsComponent { - - - faBuilding: IconDefinition = faBuilding; - faTrash: IconDefinition = faTrash; - - company: IdbCompany; - companySub: Subscription; - isFormChange: boolean = false; - displayDeleteModal: boolean = false; - constructor(private companyIdbService: CompanyIdbService, - private dbChangesService: DbChangesService, - private router: Router - ) { - } - - ngOnInit() { - this.companySub = this.companyIdbService.selectedCompany.subscribe(_company => { - if (!this.isFormChange) { - this.company = _company; - } else { - this.isFormChange = false; - } - }); - } - - ngOnDestroy() { - this.companySub.unsubscribe(); - } - - async saveChanges() { - this.isFormChange = true; - await this.companyIdbService.asyncUpdate(this.company); - } - - openDeleteModal() { - this.displayDeleteModal = true; - } - - closeDeleteModal() { - this.displayDeleteModal = false; - } - - async confirmDelete() { - await this.dbChangesService.deleteCompany(this.company); - this.router.navigateByUrl('/user') - } -} diff --git a/src/app/core-components/sidebar/sidebar.component.html b/src/app/core-components/sidebar/sidebar.component.html index f703700b..cf309d88 100644 --- a/src/app/core-components/sidebar/sidebar.component.html +++ b/src/app/core-components/sidebar/sidebar.component.html @@ -13,20 +13,16 @@
-
-
diff --git a/src/app/core-components/sidebar/sidebar.component.ts b/src/app/core-components/sidebar/sidebar.component.ts index d17e9427..457bdaba 100644 --- a/src/app/core-components/sidebar/sidebar.component.ts +++ b/src/app/core-components/sidebar/sidebar.component.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import { IconDefinition, faBuilding, faChevronDown, faChevronRight, faCircleInfo, faDatabase, faFileLines, faFolder, faFolderOpen, faHome, faInbox, faIndustry, faMinusSquare, faPlusSquare, faQuestionCircle, faTrophy, faWandMagicSparkles } from '@fortawesome/free-solid-svg-icons'; +import { IconDefinition, faBuilding, faChevronDown, faChevronRight, faCircleInfo, faDatabase, faFolder, faFolderOpen, faHome, faInbox, faIndustry, faMinusSquare, faPlusSquare, faQuestionCircle, faScrewdriverWrench, faTrophy, faWandMagicSparkles } from '@fortawesome/free-solid-svg-icons'; import { Subscription } from 'rxjs'; import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; @@ -24,7 +24,7 @@ export class SidebarComponent { faChevronDown: IconDefinition = faChevronDown; faBuilding: IconDefinition = faBuilding; faIndustry: IconDefinition = faIndustry; - faFileLines: IconDefinition = faFileLines; + faScrewdriverWrench: IconDefinition = faScrewdriverWrench; faTrophy: IconDefinition = faTrophy; faCircleInfo: IconDefinition = faCircleInfo; faInbox: IconDefinition = faInbox; diff --git a/src/app/core-components/toast-notifications/toast-notifications.component.html b/src/app/core-components/toast-notifications/toast-notifications.component.html index 78fc82a5..40f4cef4 100644 --- a/src/app/core-components/toast-notifications/toast-notifications.component.html +++ b/src/app/core-components/toast-notifications/toast-notifications.component.html @@ -6,7 +6,7 @@ {{toastNotification.title}} -
+
-
\ No newline at end of file + + + + + \ No newline at end of file diff --git a/src/app/setup-wizard/setup-wizard.component.spec.ts b/src/app/setup-wizard/setup-wizard.component.spec.ts index d9ca9ce9..a6f47a7f 100644 --- a/src/app/setup-wizard/setup-wizard.component.spec.ts +++ b/src/app/setup-wizard/setup-wizard.component.spec.ts @@ -2,27 +2,23 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { SetupWizardComponent } from './setup-wizard.component'; import { RouterTestingModule } from '@angular/router/testing'; +import { ContactModalModule } from '../shared/contact-modal/contact-modal.module'; +import { stubServiceProviders } from '../spec-helpers/spec-test-service-stub'; import { SetupWizardSidebarComponent } from './setup-wizard-sidebar/setup-wizard-sidebar.component'; -import { UserIdbService } from '../indexed-db/user-idb.service'; -import { IdbUser, getNewIdbUser } from '../models/user'; -import { BehaviorSubject } from 'rxjs'; +import { SetupWizardHelpPanelComponent } from './setup-wizard-help-panel/setup-wizard-help-panel.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { HelperPipesModule } from '../shared/helper-pipes/_helper-pipes.module'; describe('SetupWizardComponent', () => { let component: SetupWizardComponent; let fixture: ComponentFixture; - - let userIdbService: Partial = { - user: new BehaviorSubject(getNewIdbUser()) - }; beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [RouterTestingModule], - declarations: [SetupWizardSidebarComponent], - providers: [ - { provide: UserIdbService, useValue: userIdbService } - ] + imports: [RouterTestingModule, ContactModalModule, FontAwesomeModule, HelperPipesModule], + declarations: [SetupWizardComponent, SetupWizardSidebarComponent, SetupWizardHelpPanelComponent], + providers: stubServiceProviders }) .compileComponents(); diff --git a/src/app/setup-wizard/setup-wizard.component.ts b/src/app/setup-wizard/setup-wizard.component.ts index f6081a8a..79b02630 100644 --- a/src/app/setup-wizard/setup-wizard.component.ts +++ b/src/app/setup-wizard/setup-wizard.component.ts @@ -1,4 +1,7 @@ import { Component } from '@angular/core'; +import { SharedDataService } from '../shared/shared-services/shared-data.service'; +import { Subscription } from 'rxjs'; +import { ContactContext, IdbContact } from '../models/contact'; @Component({ selector: 'app-setup-wizard', @@ -7,4 +10,24 @@ import { Component } from '@angular/core'; }) export class SetupWizardComponent { + + displayContactModal: { context: ContactContext, viewContact: IdbContact, contextGuid: string, companyId: string }; + displayContactModalSub: Subscription; + constructor(private sharedDataService: SharedDataService) { + + } + + ngOnInit() { + this.displayContactModalSub = this.sharedDataService.displayContactModal.subscribe(_displayContactModal => { + this.displayContactModal = _displayContactModal; + }); + } + + ngOnDestroy() { + this.displayContactModalSub.unsubscribe(); + } + + closeContactModal() { + this.sharedDataService.displayContactModal.next(undefined); + } } diff --git a/src/app/setup-wizard/setup-wizard.module.ts b/src/app/setup-wizard/setup-wizard.module.ts index 8601d3c7..be4a9676 100644 --- a/src/app/setup-wizard/setup-wizard.module.ts +++ b/src/app/setup-wizard/setup-wizard.module.ts @@ -7,13 +7,12 @@ import { CompanySetupComponent } from './pre-visit/company-setup/company-setup.c import { FacilitySetupComponent } from './pre-visit/facility-setup/facility-setup.component'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { SharedSettingsFormsModule } from '../shared/shared-settings-forms/shared-settings-forms.module'; -import { HelperPipesModule } from '../shared/helper-pipes/helper-pipes.module'; +import { HelperPipesModule } from '../shared/helper-pipes/_helper-pipes.module'; import { SetupWizardSidebarComponent } from './setup-wizard-sidebar/setup-wizard-sidebar.component'; import { CompanyContactsSetupComponent } from './pre-visit/company-contacts-setup/company-contacts-setup.component'; import { FacilityProcessEquipmentSetupComponent } from './pre-visit/facility-process-equipment-setup/facility-process-equipment-setup.component'; import { PreAssessmentSetupComponent } from './pre-visit/pre-assessment-setup/pre-assessment-setup.component'; import { ReviewPreVisitSetupComponent } from './pre-visit/review-pre-visit-setup/review-pre-visit-setup.component'; -import { CompanyKpiListComponent } from './pre-visit/company-kpi-select/company-kpi-list/company-kpi-list.component'; import { ContactModalModule } from '../shared/contact-modal/contact-modal.module'; import { ReviewOnSiteComponent } from './data-collection/review-on-site/review-on-site.component'; import { CompanyDetailsSummaryComponent } from './pre-visit/review-pre-visit-setup/company-details-summary/company-details-summary.component'; @@ -25,44 +24,30 @@ import { ProcessEquipmentSummaryComponent } from './pre-visit/review-pre-visit-s import { PreAssessmentSummaryComponent } from './pre-visit/review-pre-visit-setup/pre-assessment-summary/pre-assessment-summary.component'; import { TableEntriesModule } from '../shared/table-entries/table-entries.module'; import { OnSiteAssessmentComponent } from './data-collection/on-site-assessment/on-site-assessment.component'; -import { AssessmentDetailsFormComponent } from './data-collection/on-site-assessment/assessment-details-form/assessment-details-form.component'; import { AssessmentNebsFormComponent } from './data-collection/on-site-assessment/assessment-nebs-form/assessment-nebs-form.component'; -import { NebSetupFormComponent } from './data-collection/on-site-assessment/neb-forms-accordion/neb-setup-form/neb-setup-form.component'; import { PreVisitComponent } from './pre-visit/pre-visit.component'; import { DataCollectionComponent } from './data-collection/data-collection.component'; -import { CompanyContactsFormComponent } from './pre-visit/company-contacts-setup/company-contacts-form/company-contacts-form.component'; import { CompanyKpiSelectComponent } from './pre-visit/company-kpi-select/company-kpi-select.component'; import { CompanyKpiDetailsComponent } from './pre-visit/company-kpi-details/company-kpi-details.component'; import { DataCollectionManageAssessmentsComponent } from './data-collection/data-collection-manage-assessments/data-collection-manage-assessments.component'; -import { AssessmentEnergyOpportunitiesFormComponent } from './data-collection/on-site-assessment/assessment-energy-opportunities-form/assessment-energy-opportunities-form.component'; -import { EnergyOpportunitySetupFormComponent } from './data-collection/on-site-assessment/assessment-energy-opportunities-form/energy-opportunity-setup-form/energy-opportunity-setup-form.component'; -import { AddKpiSearchComponent } from './pre-visit/company-kpi-select/add-kpi-search/add-kpi-search.component'; -import { SelectedKpiOptionPipe } from './pre-visit/company-kpi-select/add-kpi-search/selected-kpi-option.pipe'; -import { AddNebsModalComponent } from './data-collection/on-site-assessment/add-nebs-modal/add-nebs-modal.component'; -import { PerformanceMetricImpactFormComponent } from './data-collection/on-site-assessment/neb-forms-accordion/neb-setup-form/performance-metric-impact-form/performance-metric-impact-form.component'; -import { NebFormsAccordionComponent } from './data-collection/on-site-assessment/neb-forms-accordion/neb-forms-accordion.component'; import { DataEvaluationComponent } from './data-evaluation/data-evaluation.component'; import { DataFollowUpComponent } from './data-evaluation/data-follow-up/data-follow-up.component'; import { VisitReportComponent } from './data-evaluation/visit-report/visit-report.component'; import { ReportsModule } from '../shared/reports/reports.module'; import { AssessmentEvaluationComponent } from './data-evaluation/assessment-evaluation/assessment-evaluation.component'; import { OnSiteAssessmentResultsComponent } from './data-collection/on-site-assessment/on-site-assessment-results/on-site-assessment-results.component'; -import { ProcessEquipmentFormComponent } from './pre-visit/facility-process-equipment-setup/process-equipment-form/process-equipment-form.component'; import { FacilityEnergyEquipmentSetupComponent } from './pre-visit/facility-energy-equipment-setup/facility-energy-equipment-setup.component'; -import { EnergyEquipmentFormComponent } from './pre-visit/facility-energy-equipment-setup/energy-equipment-form/energy-equipment-form.component'; import { PrimaryKpiBadgeModule } from "../shared/primary-kpi-badge/primary-kpi-badge.module"; -import { PerformanceMetricsModalComponent } from './data-collection/on-site-assessment/neb-forms-accordion/neb-setup-form/performance-metrics-modal/performance-metrics-modal.component'; -import { MetricOptionsModalListPipe } from './data-collection/on-site-assessment/neb-forms-accordion/neb-setup-form/performance-metrics-modal/metric-options-modal-list.pipe'; -import { AssociatedMetricIndicatorPipe } from './data-collection/on-site-assessment/neb-forms-accordion/neb-setup-form/performance-metrics-modal/associated-metric-indicator.pipe'; -import { KpmImpactsTableComponent } from './pre-visit/company-kpi-details/kpm-impacts-table/kpm-impacts-table.component'; import { EnergyOpportunityNebsTableComponent } from './data-collection/on-site-assessment/assessment-nebs-form/energy-opportunity-nebs-table/energy-opportunity-nebs-table.component'; import { EnergyOpportunityNebsListPipe } from './data-collection/on-site-assessment/assessment-nebs-form/energy-opportunity-nebs-table/energy-opportunity-nebs-list.pipe'; import { SetupWizardHelpPanelModule } from './setup-wizard-help-panel/setup-wizard-help-panel.module'; import { LabelWithTooltipModule } from '../shared/label-with-tooltip/label-with-tooltip.module'; import { KpmDetailsFormModule } from '../shared/kpm-details-form/kpm-details-form.module'; -import { KpiDescriptionPipe } from './pre-visit/company-kpi-details/kpi-description.pipe'; -import { NebsDatabaseModule } from "../nebs-database/nebs-database.module"; -import { KpmDatabaseModalComponent } from './pre-visit/company-kpi-details/kpm-database-modal/kpm-database-modal.component'; +import { SharedAssessmentFormsModule } from '../shared/shared-assessment-forms/shared-assessment-forms.module'; +import { SharedCompanyFormsModule } from "../shared/shared-company-forms/shared-company-forms.module"; +import { SharedFacilityFormsModule } from '../shared/shared-facility-forms/shared-facility-forms.module'; +import { AssessmentEnergyOpportunitiesFormComponent } from './data-collection/on-site-assessment/assessment-energy-opportunities-form/assessment-energy-opportunities-form.component'; +import { CompanyContactsSetupFormComponent } from './pre-visit/company-contacts-setup/company-contacts-setup-form/company-contacts-setup-form.component'; @NgModule({ declarations: [ @@ -74,8 +59,6 @@ import { KpmDatabaseModalComponent } from './pre-visit/company-kpi-details/kpm-d FacilityProcessEquipmentSetupComponent, PreAssessmentSetupComponent, ReviewPreVisitSetupComponent, - AddKpiSearchComponent, - CompanyKpiListComponent, ReviewOnSiteComponent, CompanyDetailsSummaryComponent, TeamDetailsSummaryComponent, @@ -85,37 +68,22 @@ import { KpmDatabaseModalComponent } from './pre-visit/company-kpi-details/kpm-d ProcessEquipmentSummaryComponent, PreAssessmentSummaryComponent, OnSiteAssessmentComponent, - AssessmentDetailsFormComponent, AssessmentNebsFormComponent, - NebSetupFormComponent, PreVisitComponent, DataCollectionComponent, - CompanyContactsFormComponent, CompanyKpiSelectComponent, CompanyKpiDetailsComponent, - SelectedKpiOptionPipe, DataCollectionManageAssessmentsComponent, - AssessmentEnergyOpportunitiesFormComponent, - EnergyOpportunitySetupFormComponent, - AddNebsModalComponent, - PerformanceMetricImpactFormComponent, - NebFormsAccordionComponent, DataEvaluationComponent, DataFollowUpComponent, VisitReportComponent, AssessmentEvaluationComponent, OnSiteAssessmentResultsComponent, - ProcessEquipmentFormComponent, FacilityEnergyEquipmentSetupComponent, - EnergyEquipmentFormComponent, - PerformanceMetricsModalComponent, - MetricOptionsModalListPipe, - AssociatedMetricIndicatorPipe, - KpmImpactsTableComponent, EnergyOpportunityNebsTableComponent, EnergyOpportunityNebsListPipe, - KpiDescriptionPipe, - KpmDatabaseModalComponent + AssessmentEnergyOpportunitiesFormComponent, + CompanyContactsSetupFormComponent ], imports: [ CommonModule, @@ -133,7 +101,9 @@ import { KpmDatabaseModalComponent } from './pre-visit/company-kpi-details/kpm-d SetupWizardHelpPanelModule, LabelWithTooltipModule, KpmDetailsFormModule, - NebsDatabaseModule + SharedAssessmentFormsModule, + SharedCompanyFormsModule, + SharedFacilityFormsModule ] }) export class SetupWizardModule { } diff --git a/src/app/setup-wizard/setup-wizard.service.ts b/src/app/setup-wizard/setup-wizard.service.ts index 750f4df0..3fec30a6 100644 --- a/src/app/setup-wizard/setup-wizard.service.ts +++ b/src/app/setup-wizard/setup-wizard.service.ts @@ -1,6 +1,5 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; -import { ContactContext, IdbContact } from '../models/contact'; @Injectable({ providedIn: 'root' @@ -8,19 +7,7 @@ import { ContactContext, IdbContact } from '../models/contact'; export class SetupWizardService { sidebarOpen: BehaviorSubject; - displayAddNebsModal: BehaviorSubject<{ - assessmentId: string, - energyOpportunityId: string - }>; - - displayContactModal: BehaviorSubject<{ - context: ContactContext, - viewContact: IdbContact, - contextGuid: string - }>; constructor( ) { this.sidebarOpen = new BehaviorSubject(true); - this.displayAddNebsModal = new BehaviorSubject<{ assessmentId: string, energyOpportunityId: string }>(undefined); - this.displayContactModal = new BehaviorSubject<{ context: ContactContext, viewContact: IdbContact, contextGuid: string }>(undefined); } } \ No newline at end of file diff --git a/src/app/shared/contact-modal/contact-modal.module.ts b/src/app/shared/contact-modal/contact-modal.module.ts index 560550e4..772b9f94 100644 --- a/src/app/shared/contact-modal/contact-modal.module.ts +++ b/src/app/shared/contact-modal/contact-modal.module.ts @@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common'; import { ContactModalComponent } from './contact-modal.component'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { FormsModule } from '@angular/forms'; -import { HelperPipesModule } from '../helper-pipes/helper-pipes.module'; +import { HelperPipesModule } from '../helper-pipes/_helper-pipes.module'; diff --git a/src/app/shared/helper-pipes/helper-pipes.module.ts b/src/app/shared/helper-pipes/_helper-pipes.module.ts similarity index 88% rename from src/app/shared/helper-pipes/helper-pipes.module.ts rename to src/app/shared/helper-pipes/_helper-pipes.module.ts index 39be708b..72c97814 100644 --- a/src/app/shared/helper-pipes/helper-pipes.module.ts +++ b/src/app/shared/helper-pipes/_helper-pipes.module.ts @@ -32,6 +32,10 @@ import { LinkedUnitOptionsPipe } from './linked-unit-options.pipe'; import { LinkedUtilityOptionsPipe } from './linked-utility-options.pipe'; import { IsStandardUnitPipe } from './is-standard-unit.pipe'; import { UtilityHhvDisplayPipe } from './utility-hhv-display.pipe'; +import { ContactInvalidPipe } from './contact-invalid.pipe'; +import { AssociatedPerformanceMetricImpactsPipe } from './associated-performance-metric-impacts.pipe'; +import { KpmLabelPipe } from './kpm-label.pipe'; +import { NebTotalSavingsPipe } from './neb-total-savings.pipe'; @NgModule({ declarations: [ @@ -67,6 +71,10 @@ import { UtilityHhvDisplayPipe } from './utility-hhv-display.pipe'; LinkedUtilityOptionsPipe, IsStandardUnitPipe, UtilityHhvDisplayPipe, + ContactInvalidPipe, + AssociatedPerformanceMetricImpactsPipe, + KpmLabelPipe, + NebTotalSavingsPipe ], imports: [ CommonModule @@ -104,6 +112,10 @@ import { UtilityHhvDisplayPipe } from './utility-hhv-display.pipe'; LinkedUtilityOptionsPipe, IsStandardUnitPipe, UtilityHhvDisplayPipe, + ContactInvalidPipe, + AssociatedPerformanceMetricImpactsPipe, + KpmLabelPipe, + NebTotalSavingsPipe ] }) export class HelperPipesModule { } diff --git a/src/app/shared/helper-pipes/associated-performance-metric-impacts.pipe.spec.ts b/src/app/shared/helper-pipes/associated-performance-metric-impacts.pipe.spec.ts new file mode 100644 index 00000000..13b1ce1b --- /dev/null +++ b/src/app/shared/helper-pipes/associated-performance-metric-impacts.pipe.spec.ts @@ -0,0 +1,8 @@ +import { AssociatedPerformanceMetricImpactsPipe } from './associated-performance-metric-impacts.pipe'; + +describe('AssociatedPerformanceMetricImpactsPipe', () => { + it('create an instance', () => { + const pipe = new AssociatedPerformanceMetricImpactsPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/src/app/shared/helper-pipes/associated-performance-metric-impacts.pipe.ts b/src/app/shared/helper-pipes/associated-performance-metric-impacts.pipe.ts new file mode 100644 index 00000000..0ae6b573 --- /dev/null +++ b/src/app/shared/helper-pipes/associated-performance-metric-impacts.pipe.ts @@ -0,0 +1,15 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { IdbKeyPerformanceMetricImpact } from 'src/app/models/keyPerformanceMetricImpact'; + +@Pipe({ + name: 'associatedPerformanceMetricImpacts' +}) +export class AssociatedPerformanceMetricImpactsPipe implements PipeTransform { + + transform(guid: string, keyPerformanceMetricImpacts: Array): Array { + return keyPerformanceMetricImpacts.filter(kpmImpact => { + return kpmImpact.nebId == guid; + }); + } + +} diff --git a/src/app/shared/helper-pipes/contact-invalid.pipe.spec.ts b/src/app/shared/helper-pipes/contact-invalid.pipe.spec.ts new file mode 100644 index 00000000..421d89c9 --- /dev/null +++ b/src/app/shared/helper-pipes/contact-invalid.pipe.spec.ts @@ -0,0 +1,11 @@ +import { FormBuilder } from '@angular/forms'; +import { CompanyContactsFormService } from '../shared-company-forms/company-contacts-form/company-contacts-form.service'; +import { ContactInvalidPipe } from './contact-invalid.pipe'; + +describe('ContactInvalidPipe', () => { + let formService: CompanyContactsFormService = new CompanyContactsFormService(new FormBuilder()); + it('create an instance', () => { + const pipe = new ContactInvalidPipe(formService); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/src/app/shared/helper-pipes/contact-invalid.pipe.ts b/src/app/shared/helper-pipes/contact-invalid.pipe.ts new file mode 100644 index 00000000..a1700a41 --- /dev/null +++ b/src/app/shared/helper-pipes/contact-invalid.pipe.ts @@ -0,0 +1,19 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { CompanyContactsFormService } from '../shared-company-forms/company-contacts-form/company-contacts-form.service'; +import { IdbContact } from 'src/app/models/contact'; +import { FormGroup } from '@angular/forms'; + +@Pipe({ + name: 'contactInvalid' +}) +export class ContactInvalidPipe implements PipeTransform { + + constructor(private companyContactsFormService: CompanyContactsFormService) { } + + transform(contactGuid: string, contacts: Array): boolean { + let contact: IdbContact = contacts.find(c => { return c.guid == contactGuid }); + let form: FormGroup = this.companyContactsFormService.getFormFromIdbContact(contact); + return form.invalid; + } + +} diff --git a/src/app/shared/helper-pipes/contact-name.pipe.spec.ts b/src/app/shared/helper-pipes/contact-name.pipe.spec.ts index d127cc0c..e57c2144 100644 --- a/src/app/shared/helper-pipes/contact-name.pipe.spec.ts +++ b/src/app/shared/helper-pipes/contact-name.pipe.spec.ts @@ -1,19 +1,10 @@ -import { TestBed } from '@angular/core/testing'; -import { ContactNameDisplayPipe } from './contact-name-display.pipe'; import { ContactNamePipe } from './contact-name.pipe'; describe('ContactNamePipe', () => { let pipe: ContactNamePipe; - let contactNameDisplayPipe: ContactNameDisplayPipe; - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [ContactNameDisplayPipe] - }); - contactNameDisplayPipe = TestBed.inject(ContactNameDisplayPipe); - }) it('create an instance', () => { - pipe = new ContactNamePipe(contactNameDisplayPipe); + pipe = new ContactNamePipe(); expect(pipe).toBeTruthy(); }); }); diff --git a/src/app/shared/helper-pipes/contact-name.pipe.ts b/src/app/shared/helper-pipes/contact-name.pipe.ts index bd8d4d37..0433ed3c 100644 --- a/src/app/shared/helper-pipes/contact-name.pipe.ts +++ b/src/app/shared/helper-pipes/contact-name.pipe.ts @@ -8,13 +8,12 @@ import { ContactNameDisplayPipe } from './contact-name-display.pipe'; }) export class ContactNamePipe implements PipeTransform { - constructor(private contactDisplayPipe: ContactNameDisplayPipe) {} transform(contactGuid: string, contacts: Array): string { let contact: IdbContact = contacts.find(contact => { return contact.guid == contactGuid; }); - return this.contactDisplayPipe.transform(contact); + let contactNameDisplayPipe = new ContactNameDisplayPipe(); + return contactNameDisplayPipe.transform(contact); } - } diff --git a/src/app/shared/helper-pipes/kpm-label.pipe.spec.ts b/src/app/shared/helper-pipes/kpm-label.pipe.spec.ts new file mode 100644 index 00000000..1f411ea1 --- /dev/null +++ b/src/app/shared/helper-pipes/kpm-label.pipe.spec.ts @@ -0,0 +1,8 @@ +import { KpmLabelPipe } from './kpm-label.pipe'; + +describe('KpmLabelPipe', () => { + it('create an instance', () => { + const pipe = new KpmLabelPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/src/app/shared/helper-pipes/kpm-label.pipe.ts b/src/app/shared/helper-pipes/kpm-label.pipe.ts new file mode 100644 index 00000000..d40ea5e9 --- /dev/null +++ b/src/app/shared/helper-pipes/kpm-label.pipe.ts @@ -0,0 +1,19 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { KeyPerformanceMetric } from '../constants/keyPerformanceMetrics'; + +@Pipe({ + name: 'kpmLabel' +}) +export class KpmLabelPipe implements PipeTransform { + + transform(guid: string, keyPerformanceMetrics: Array): string { + let kpm: KeyPerformanceMetric = keyPerformanceMetrics.find(kpm => { + return kpm.guid == guid + }); + if (kpm) { + return kpm.htmlLabel; + } + return ''; + } + +} diff --git a/src/app/shared/helper-pipes/neb-total-savings.pipe.spec.ts b/src/app/shared/helper-pipes/neb-total-savings.pipe.spec.ts new file mode 100644 index 00000000..1549c197 --- /dev/null +++ b/src/app/shared/helper-pipes/neb-total-savings.pipe.spec.ts @@ -0,0 +1,8 @@ +import { NebTotalSavingsPipe } from './neb-total-savings.pipe'; + +describe('NebTotalSavingsPipe', () => { + it('create an instance', () => { + const pipe = new NebTotalSavingsPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/src/app/shared/helper-pipes/neb-total-savings.pipe.ts b/src/app/shared/helper-pipes/neb-total-savings.pipe.ts new file mode 100644 index 00000000..e9d8d830 --- /dev/null +++ b/src/app/shared/helper-pipes/neb-total-savings.pipe.ts @@ -0,0 +1,22 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { IdbKeyPerformanceMetricImpact } from 'src/app/models/keyPerformanceMetricImpact'; + +@Pipe({ + name: 'nebTotalSavings' +}) +export class NebTotalSavingsPipe implements PipeTransform { + + transform(nebGuid: string, performanceMetricImpacts: Array): number { + let associatedImpacts: Array = performanceMetricImpacts.filter(kpmImpact => { + return kpmImpact.nebId == nebGuid; + }); + let totalSavings: number = 0; + associatedImpacts.forEach(impact => { + if (isNaN(impact.costAdjustment) == false) { + totalSavings += impact.costAdjustment; + } + }) + return totalSavings; + } + +} diff --git a/src/app/shared/kpm-details-form/kpm-details-form.component.spec.ts b/src/app/shared/kpm-details-form/kpm-details-form.component.spec.ts index 3aa5cbe2..c855647f 100644 --- a/src/app/shared/kpm-details-form/kpm-details-form.component.spec.ts +++ b/src/app/shared/kpm-details-form/kpm-details-form.component.spec.ts @@ -4,7 +4,7 @@ import { KpmDetailsFormComponent } from './kpm-details-form.component'; import { getCustomKPM } from '../constants/keyPerformanceMetrics'; import { LabelWithTooltipModule } from '../label-with-tooltip/label-with-tooltip.module'; import { FormsModule } from '@angular/forms'; -import { HelperPipesModule } from '../helper-pipes/helper-pipes.module'; +import { HelperPipesModule } from '../helper-pipes/_helper-pipes.module'; describe('KpmDetailsFormComponent', () => { let component: KpmDetailsFormComponent; diff --git a/src/app/shared/kpm-details-form/kpm-details-form.module.ts b/src/app/shared/kpm-details-form/kpm-details-form.module.ts index fe1445e1..05d25bf2 100644 --- a/src/app/shared/kpm-details-form/kpm-details-form.module.ts +++ b/src/app/shared/kpm-details-form/kpm-details-form.module.ts @@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common'; import { KpmDetailsFormComponent } from './kpm-details-form.component'; import { FormsModule } from '@angular/forms'; import { LabelWithTooltipModule } from '../label-with-tooltip/label-with-tooltip.module'; -import { HelperPipesModule } from '../helper-pipes/helper-pipes.module'; +import { HelperPipesModule } from '../helper-pipes/_helper-pipes.module'; diff --git a/src/app/shared/reports/assessment-report/assessment-report.component.spec.ts b/src/app/shared/reports/assessment-report/assessment-report.component.spec.ts index 18d62214..25cfd11f 100644 --- a/src/app/shared/reports/assessment-report/assessment-report.component.spec.ts +++ b/src/app/shared/reports/assessment-report/assessment-report.component.spec.ts @@ -20,7 +20,7 @@ import { IdbNonEnergyBenefit } from 'src/app/models/nonEnergyBenefit'; import { IdbEnergyOpportunity } from 'src/app/models/energyOpportunity'; import { IdbKeyPerformanceIndicator } from 'src/app/models/keyPerformanceIndicator'; import { TableEntriesModule } from '../../table-entries/table-entries.module'; -import { HelperPipesModule } from '../../helper-pipes/helper-pipes.module'; +import { HelperPipesModule } from '../../helper-pipes/_helper-pipes.module'; import { AssessmentSavingsTableComponent } from './assessment-savings-table/assessment-savings-table.component'; import { PaybackTableComponent } from './payback-table/payback-table.component'; import { EnergyEquipmentIdbService } from 'src/app/indexed-db/energy-equipment-idb.service'; diff --git a/src/app/shared/reports/calculations/nebReport.ts b/src/app/shared/reports/calculations/nebReport.ts index d6e1aaf8..89afd0cc 100644 --- a/src/app/shared/reports/calculations/nebReport.ts +++ b/src/app/shared/reports/calculations/nebReport.ts @@ -15,10 +15,12 @@ export function getNebReport(nonEnergyBenefit: IdbNonEnergyBenefit, companyPerfo return companyKPM.guid == performanceMetricImpact.kpmGuid } }); - reportPerformanceMetrics.push({ - performanceMetricImpact: performanceMetricImpact, - keyPerformanceMetric: keyPerformanceMetric - }) + if (keyPerformanceMetric) { + reportPerformanceMetrics.push({ + performanceMetricImpact: performanceMetricImpact, + keyPerformanceMetric: keyPerformanceMetric + }) + } } }); let costSavings: number = nonEnergyBenefit.costImpact || 0; diff --git a/src/app/shared/reports/on-site-visit-report/on-site-visit-report.component.spec.ts b/src/app/shared/reports/on-site-visit-report/on-site-visit-report.component.spec.ts index 45cd440f..19b51962 100644 --- a/src/app/shared/reports/on-site-visit-report/on-site-visit-report.component.spec.ts +++ b/src/app/shared/reports/on-site-visit-report/on-site-visit-report.component.spec.ts @@ -23,7 +23,7 @@ import { IdbEnergyEquipment } from 'src/app/models/energyEquipment'; import { KeyPerformanceMetricImpactsIdbService } from 'src/app/indexed-db/key-performance-metric-impacts-idb.service'; import { IdbKeyPerformanceMetricImpact } from 'src/app/models/keyPerformanceMetricImpact'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { HelperPipesModule } from '../../helper-pipes/helper-pipes.module'; +import { HelperPipesModule } from '../../helper-pipes/_helper-pipes.module'; import { PaybackTableComponent } from '../assessment-report/payback-table/payback-table.component'; import { AssessmentSavingsTableComponent } from '../assessment-report/assessment-savings-table/assessment-savings-table.component'; import { TableEntriesModule } from '../../table-entries/table-entries.module'; diff --git a/src/app/shared/reports/reports.module.ts b/src/app/shared/reports/reports.module.ts index 9cd0bb11..121a5afe 100644 --- a/src/app/shared/reports/reports.module.ts +++ b/src/app/shared/reports/reports.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { AssessmentReportComponent } from './assessment-report/assessment-report.component'; -import { HelperPipesModule } from '../helper-pipes/helper-pipes.module'; +import { HelperPipesModule } from '../helper-pipes/_helper-pipes.module'; import { TableEntriesModule } from '../table-entries/table-entries.module'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { AssessmentSavingsTableComponent } from './assessment-report/assessment-savings-table/assessment-savings-table.component'; diff --git a/src/app/setup-wizard/data-collection/on-site-assessment/add-nebs-modal/add-nebs-modal.component.css b/src/app/shared/shared-assessment-forms/add-nebs-modal/add-nebs-modal.component.css similarity index 100% rename from src/app/setup-wizard/data-collection/on-site-assessment/add-nebs-modal/add-nebs-modal.component.css rename to src/app/shared/shared-assessment-forms/add-nebs-modal/add-nebs-modal.component.css diff --git a/src/app/setup-wizard/data-collection/on-site-assessment/add-nebs-modal/add-nebs-modal.component.html b/src/app/shared/shared-assessment-forms/add-nebs-modal/add-nebs-modal.component.html similarity index 100% rename from src/app/setup-wizard/data-collection/on-site-assessment/add-nebs-modal/add-nebs-modal.component.html rename to src/app/shared/shared-assessment-forms/add-nebs-modal/add-nebs-modal.component.html diff --git a/src/app/shared/shared-assessment-forms/add-nebs-modal/add-nebs-modal.component.spec.ts b/src/app/shared/shared-assessment-forms/add-nebs-modal/add-nebs-modal.component.spec.ts new file mode 100644 index 00000000..7eeeac20 --- /dev/null +++ b/src/app/shared/shared-assessment-forms/add-nebs-modal/add-nebs-modal.component.spec.ts @@ -0,0 +1,59 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AddNebsModalComponent } from './add-nebs-modal.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { FormsModule } from '@angular/forms'; +import { BehaviorSubject } from 'rxjs'; +import { NebsDatabaseModule } from 'src/app/nebs-database/nebs-database.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { SharedDataService } from '../../shared-services/shared-data.service'; +import { ContactContext, IdbContact } from 'src/app/models/contact'; + +describe('AddNebsModalComponent', () => { + let component: AddNebsModalComponent; + let fixture: ComponentFixture; + + + let sharedDataService: Partial = { + createAssessmentModalOpen: new BehaviorSubject(false), + sidebarOpen: new BehaviorSubject(false), + displayAddNebsModal: new BehaviorSubject<{ assessmentId: string, energyOpportunityId: string }>({ + assessmentId: '123', + energyOpportunityId: '123' + }), + displayContactModal: new BehaviorSubject<{ context: ContactContext, viewContact: IdbContact, contextGuid: string, companyId: string }>({ + context: 'assessment', + viewContact: undefined, + contextGuid: '123', + companyId: '123' + }) + } + let tmpStubServiceProviders: Array<{ provide: any, useValue: any }> = new Array(); + stubServiceProviders.forEach(serviceProvider => { + if (serviceProvider.provide == SharedDataService) { + tmpStubServiceProviders.push({ + provide: SharedDataService, + useValue: sharedDataService + }); + } else { + tmpStubServiceProviders.push(serviceProvider); + } + }); + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, FormsModule, NebsDatabaseModule], + declarations: [AddNebsModalComponent], + providers: tmpStubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(AddNebsModalComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/setup-wizard/data-collection/on-site-assessment/add-nebs-modal/add-nebs-modal.component.ts b/src/app/shared/shared-assessment-forms/add-nebs-modal/add-nebs-modal.component.ts similarity index 93% rename from src/app/setup-wizard/data-collection/on-site-assessment/add-nebs-modal/add-nebs-modal.component.ts rename to src/app/shared/shared-assessment-forms/add-nebs-modal/add-nebs-modal.component.ts index 47edeb4b..a587b04f 100644 --- a/src/app/setup-wizard/data-collection/on-site-assessment/add-nebs-modal/add-nebs-modal.component.ts +++ b/src/app/shared/shared-assessment-forms/add-nebs-modal/add-nebs-modal.component.ts @@ -10,9 +10,9 @@ import { IdbAssessment } from 'src/app/models/assessment'; import { IdbEnergyOpportunity } from 'src/app/models/energyOpportunity'; import { getNewIdbKeyPerformanceMetricImpact, IdbKeyPerformanceMetricImpact } from 'src/app/models/keyPerformanceMetricImpact'; import { IdbNonEnergyBenefit, getNewIdbNonEnergyBenefit } from 'src/app/models/nonEnergyBenefit'; -import { SetupWizardService } from 'src/app/setup-wizard/setup-wizard.service'; import { KeyPerformanceMetric } from 'src/app/shared/constants/keyPerformanceMetrics'; import { NebOption, NebOptions } from 'src/app/shared/constants/nonEnergyBenefitOptions'; +import { SharedDataService } from '../../shared-services/shared-data.service'; @Component({ selector: 'app-add-nebs-modal', @@ -30,7 +30,7 @@ export class AddNebsModalComponent { selectedNebs: Array =[]; - constructor(private setupWizardService: SetupWizardService, private keyPerformanceIndicatorIdbService: KeyPerformanceIndicatorsIdbService, + constructor(private sharedDataService: SharedDataService, private keyPerformanceIndicatorIdbService: KeyPerformanceIndicatorsIdbService, private nonEnergyBenefitIdbService: NonEnergyBenefitsIdbService, private assessmentIdbService: AssessmentIdbService, private energyOpportunityIdbService: EnergyOpportunityIdbService, @@ -39,7 +39,7 @@ export class AddNebsModalComponent { } ngOnInit() { - let modalData: { assessmentId: string, energyOpportunityId: string } = this.setupWizardService.displayAddNebsModal.getValue(); + let modalData: { assessmentId: string, energyOpportunityId: string } = this.sharedDataService.displayAddNebsModal.getValue(); this.assessment = this.assessmentIdbService.getByGuid(modalData.assessmentId); if (modalData.energyOpportunityId) { this.energyOpportunity = this.energyOpportunityIdbService.getByGuid(modalData.energyOpportunityId); @@ -87,7 +87,7 @@ export class AddNebsModalComponent { NebOptions.forEach(option => { option.selected = false; }); - this.setupWizardService.displayAddNebsModal.next(undefined); + this.sharedDataService.displayAddNebsModal.next(undefined); } setSelectedNebs(selectedNebs: Array) { diff --git a/src/app/setup-wizard/data-collection/on-site-assessment/assessment-details-form/assessment-details-form.component.css b/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.css similarity index 100% rename from src/app/setup-wizard/data-collection/on-site-assessment/assessment-details-form/assessment-details-form.component.css rename to src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.css diff --git a/src/app/setup-wizard/data-collection/on-site-assessment/assessment-details-form/assessment-details-form.component.html b/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.html similarity index 74% rename from src/app/setup-wizard/data-collection/on-site-assessment/assessment-details-form/assessment-details-form.component.html rename to src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.html index 9c19c70e..ad8e0b2a 100644 --- a/src/app/setup-wizard/data-collection/on-site-assessment/assessment-details-form/assessment-details-form.component.html +++ b/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.html @@ -3,22 +3,19 @@
+ (input)="saveChanges()" minlength="1" maxlength="42" id="assessmentName" [disabled]="isDisabled">
- +
@@ -28,41 +25,34 @@
Utility Types
applicable to this assessment and enter the annual energy use for each type.

-
-
+
+
+ [(ngModel)]="use.include" (change)="calculateEnergyUseCost()" [disabled]="isDisabled">
- +
-
+
+ id="{{'energyUse_' + use.utilityType + assessment.guid}}" [(ngModel)]="use.energyUse" + (input)="calculateEnergyUseCost()" [disabled]="isDisabled">
@@ -72,24 +62,23 @@
Utility Types
-
+
+ value="{{use.utilityType | utilityHhvDisplay}}" [disabled]="isDisabled">
-
+
- + [(ngModel)]="use.energyUnitStandard" (change)="calculateEnergyUseCost()" + [disabled]="isDisabled">
-
-
- - \ No newline at end of file +
\ No newline at end of file diff --git a/src/app/shared/shared-facility-forms/process-equipment-form/process-equipment-form.component.spec.ts b/src/app/shared/shared-facility-forms/process-equipment-form/process-equipment-form.component.spec.ts new file mode 100644 index 00000000..92c52ae1 --- /dev/null +++ b/src/app/shared/shared-facility-forms/process-equipment-form/process-equipment-form.component.spec.ts @@ -0,0 +1,29 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProcessEquipmentFormComponent } from './process-equipment-form.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { FormsModule } from '@angular/forms'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('ProcessEquipmentFormComponent', () => { + let component: ProcessEquipmentFormComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, HelperPipesModule, FormsModule], + declarations: [ProcessEquipmentFormComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(ProcessEquipmentFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/setup-wizard/pre-visit/facility-process-equipment-setup/process-equipment-form/process-equipment-form.component.ts b/src/app/shared/shared-facility-forms/process-equipment-form/process-equipment-form.component.ts similarity index 58% rename from src/app/setup-wizard/pre-visit/facility-process-equipment-setup/process-equipment-form/process-equipment-form.component.ts rename to src/app/shared/shared-facility-forms/process-equipment-form/process-equipment-form.component.ts index 7a4013f7..ecbd3d4c 100644 --- a/src/app/setup-wizard/pre-visit/facility-process-equipment-setup/process-equipment-form/process-equipment-form.component.ts +++ b/src/app/shared/shared-facility-forms/process-equipment-form/process-equipment-form.component.ts @@ -1,13 +1,14 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; import { faContactBook, faTrash, faUser, IconDefinition } from '@fortawesome/free-solid-svg-icons'; import { Subscription } from 'rxjs'; +import { ToastNotificationsService } from 'src/app/core-components/toast-notifications/toast-notifications.service'; import { ContactIdbService } from 'src/app/indexed-db/contact-idb.service'; import { DbChangesService } from 'src/app/indexed-db/db-changes.service'; import { ProcessEquipmentIdbService } from 'src/app/indexed-db/process-equipment-idb.service'; import { IdbContact } from 'src/app/models/contact'; import { IdbProcessEquipment } from 'src/app/models/processEquipment'; -import { EquipmentType, EquipmentTypes } from 'src/app/shared/constants/equipmentTypes'; -import { UtilityType, UtilityTypes } from 'src/app/shared/constants/utilityTypes'; +import { SharedDataService } from 'src/app/shared/shared-services/shared-data.service'; @Component({ selector: 'app-process-equipment-form', @@ -15,7 +16,7 @@ import { UtilityType, UtilityTypes } from 'src/app/shared/constants/utilityTypes styleUrl: './process-equipment-form.component.css' }) export class ProcessEquipmentFormComponent { - @Input({required: true}) + @Input({ required: true }) processEquipmentGuid: string; @Output('emitInitialized') emitInitialized = new EventEmitter(); @@ -28,15 +29,24 @@ export class ProcessEquipmentFormComponent { displayDeleteModal: boolean = false; contacts: Array; contactSub: Subscription; - viewContact: IdbContact; - displayContactModal: boolean = false; constructor(private processEquipmentIdbService: ProcessEquipmentIdbService, private dbChangesService: DbChangesService, - private contactIdbService: ContactIdbService + private contactIdbService: ContactIdbService, + private sharedDataService: SharedDataService, + private activatedRoute: ActivatedRoute, + private router: Router, + private toastNotificationService: ToastNotificationsService ) { } ngOnInit() { - this.processEquipment = this.processEquipmentIdbService.getByGuid(this.processEquipmentGuid); + if (!this.processEquipmentGuid) { + this.activatedRoute.params.subscribe(params => { + this.processEquipmentGuid = params['id']; + this.processEquipment = this.processEquipmentIdbService.getByGuid(this.processEquipmentGuid); + }); + } else { + this.processEquipment = this.processEquipmentIdbService.getByGuid(this.processEquipmentGuid); + } this.contactSub = this.contactIdbService.contacts.subscribe(_contacts => { this.contacts = _contacts; }); @@ -66,15 +76,18 @@ export class ProcessEquipmentFormComponent { async deleteEquipment() { await this.dbChangesService.deleteProcessEquipment(this.processEquipment); + this.toastNotificationService.showToast("End Use Deleted!", "End use item has been removed from the facility inventory.", 'bg-success', true, false); + if (this.router.url.includes('portfolio')) { + this.router.navigateByUrl('/portfolio/facility/' + this.processEquipment.facilityId + '/end-use-inventory'); + } + this.closeDeleteModal(); } openContactModal(viewContact: IdbContact) { - this.viewContact = viewContact; - this.displayContactModal = true; + this.sharedDataService.displayContactModal.next({ context: 'processEquipment', viewContact: viewContact, contextGuid: this.processEquipment.guid, companyId: this.processEquipment.companyId }); } closeContactModal() { - this.displayContactModal = false; - this.viewContact = undefined; + this.sharedDataService.displayContactModal.next(undefined) } } diff --git a/src/app/shared/shared-facility-forms/shared-facility-forms.module.ts b/src/app/shared/shared-facility-forms/shared-facility-forms.module.ts new file mode 100644 index 00000000..1ad8d9b7 --- /dev/null +++ b/src/app/shared/shared-facility-forms/shared-facility-forms.module.ts @@ -0,0 +1,33 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FacilitySetupFormComponent } from './facility-setup-form/facility-setup-form.component'; +import { SharedSettingsFormsModule } from '../shared-settings-forms/shared-settings-forms.module'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { EnergyEquipmentFormComponent } from './energy-equipment-form/energy-equipment-form.component'; +import { HelperPipesModule } from '../helper-pipes/_helper-pipes.module'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { ProcessEquipmentFormComponent } from './process-equipment-form/process-equipment-form.component'; + + + +@NgModule({ + declarations: [ + FacilitySetupFormComponent, + EnergyEquipmentFormComponent, + ProcessEquipmentFormComponent + ], + imports: [ + CommonModule, + SharedSettingsFormsModule, + FormsModule, + ReactiveFormsModule, + HelperPipesModule, + FontAwesomeModule + ], + exports: [ + FacilitySetupFormComponent, + EnergyEquipmentFormComponent, + ProcessEquipmentFormComponent + ] +}) +export class SharedFacilityFormsModule { } diff --git a/src/app/shared/shared-services/shared-data.service.ts b/src/app/shared/shared-services/shared-data.service.ts index b199baca..64aa6aef 100644 --- a/src/app/shared/shared-services/shared-data.service.ts +++ b/src/app/shared/shared-services/shared-data.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; +import { ContactContext, IdbContact } from 'src/app/models/contact'; @Injectable({ providedIn: 'root' @@ -8,8 +9,22 @@ export class SharedDataService { sidebarOpen: BehaviorSubject; createAssessmentModalOpen: BehaviorSubject; + + displayAddNebsModal: BehaviorSubject<{ + assessmentId: string, + energyOpportunityId: string + }>; + + displayContactModal: BehaviorSubject<{ + context: ContactContext, + viewContact: IdbContact, + contextGuid: string, + companyId: string + }>; constructor() { this.createAssessmentModalOpen = new BehaviorSubject(false); this.sidebarOpen = new BehaviorSubject(false); + this.displayAddNebsModal = new BehaviorSubject<{ assessmentId: string, energyOpportunityId: string }>(undefined); + this.displayContactModal = new BehaviorSubject<{ context: ContactContext, viewContact: IdbContact, contextGuid: string, companyId: string }>(undefined); } } diff --git a/src/app/shared/shared-settings-forms/shared-settings-forms.module.ts b/src/app/shared/shared-settings-forms/shared-settings-forms.module.ts index 6524a3ac..dc7e488e 100644 --- a/src/app/shared/shared-settings-forms/shared-settings-forms.module.ts +++ b/src/app/shared/shared-settings-forms/shared-settings-forms.module.ts @@ -6,7 +6,7 @@ import { NaicsListPipe } from './additional-details-form/naics-list.pipe'; import { LocationFormComponent } from './location-form/location-form.component'; import { AdditionalDetailsFormComponent } from './additional-details-form/additional-details-form.component'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { HelperPipesModule } from '../helper-pipes/helper-pipes.module'; +import { HelperPipesModule } from '../helper-pipes/_helper-pipes.module'; @NgModule({ declarations: [ diff --git a/src/app/shared/shared-settings-forms/units-form/units-form.component.spec.ts b/src/app/shared/shared-settings-forms/units-form/units-form.component.spec.ts index 1438605e..6713da3d 100644 --- a/src/app/shared/shared-settings-forms/units-form/units-form.component.spec.ts +++ b/src/app/shared/shared-settings-forms/units-form/units-form.component.spec.ts @@ -9,7 +9,7 @@ import { IdbFacility, getNewIdbFacility } from 'src/app/models/facility'; import { SetupWizardService } from 'src/app/setup-wizard/setup-wizard.service'; import { ReactiveFormsModule } from '@angular/forms'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { HelperPipesModule } from '../../helper-pipes/helper-pipes.module'; +import { HelperPipesModule } from '../../helper-pipes/_helper-pipes.module'; import { PreAssessmentSetupService } from 'src/app/setup-wizard/pre-visit/pre-assessment-setup/pre-assessment-setup.service'; import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; diff --git a/src/app/shared/shared-settings-forms/units-form/units-form.component.ts b/src/app/shared/shared-settings-forms/units-form/units-form.component.ts index 8c4f21b7..057018ca 100644 --- a/src/app/shared/shared-settings-forms/units-form/units-form.component.ts +++ b/src/app/shared/shared-settings-forms/units-form/units-form.component.ts @@ -1,27 +1,20 @@ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { EnergyUnitOptions, MassUnitOptions, UnitOption, VolumeGasOptions, VolumeLiquidOptions } from '../../constants/unitOptions'; +import { Component, OnDestroy, OnInit } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { EnergyUnitOptions, UnitOption } from '../../constants/unitOptions'; import { Subscription } from 'rxjs'; -import { UnitSettings } from 'src/app/models/unitSettings'; import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; import { IdbFacility } from 'src/app/models/facility'; import { IconDefinition, faGear } from '@fortawesome/free-solid-svg-icons'; import { SharedSettingsFormsService } from '../shared-settings-forms.service'; import { PreAssessmentSetupService } from 'src/app/setup-wizard/pre-visit/pre-assessment-setup/pre-assessment-setup.service'; -import { IdbOnSiteVisit } from 'src/app/models/onSiteVisit'; -import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; import { IdbAssessment } from 'src/app/models/assessment'; import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { IdbCompany } from 'src/app/models/company'; import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; import { UtilityOptions } from '../../constants/utilityTypes'; import { ConvertValue } from '../../conversions/convertValue'; import { IdbEnergyEquipment } from 'src/app/models/energyEquipment'; import { EnergyEquipmentIdbService } from 'src/app/indexed-db/energy-equipment-idb.service'; import { FacilityEnergyEquipmentSetupService } from 'src/app/setup-wizard/pre-visit/facility-energy-equipment-setup/facility-energy-equipment-setup.service'; -import { IdbEnergyOpportunity } from 'src/app/models/energyOpportunity'; -import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service'; -import { AssessmentEnergyOpportunitiesFormService } from 'src/app/setup-wizard/data-collection/on-site-assessment/assessment-energy-opportunities-form/assessment-energy-opportunities-form.service'; @Component({ selector: 'app-units-form', diff --git a/src/app/shared/table-entries/single-cell-item/single-cell-item.component.html b/src/app/shared/table-entries/single-cell-item/single-cell-item.component.html index e5959c91..fe91538a 100644 --- a/src/app/shared/table-entries/single-cell-item/single-cell-item.component.html +++ b/src/app/shared/table-entries/single-cell-item/single-cell-item.component.html @@ -12,7 +12,7 @@ - {{numValue | number:'1.0-2'}} + {{numValue | number:numValueDigits}} {{numValue | currency : 'USD' : 'symbol' : '1.0-0'}} diff --git a/src/app/shared/table-entries/single-cell-item/single-cell-item.component.ts b/src/app/shared/table-entries/single-cell-item/single-cell-item.component.ts index d1ea7787..9e361105 100644 --- a/src/app/shared/table-entries/single-cell-item/single-cell-item.component.ts +++ b/src/app/shared/table-entries/single-cell-item/single-cell-item.component.ts @@ -16,4 +16,6 @@ export class SingleCellItemComponent { per: string; @Input() isCurrency: boolean; + @Input() + numValueDigits: string = '1.0-2'; } diff --git a/src/app/shared/table-entries/table-entries.module.ts b/src/app/shared/table-entries/table-entries.module.ts index 8d4f1ae0..88839ba8 100644 --- a/src/app/shared/table-entries/table-entries.module.ts +++ b/src/app/shared/table-entries/table-entries.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { SingleCellItemComponent } from './single-cell-item/single-cell-item.component'; -import { HelperPipesModule } from '../helper-pipes/helper-pipes.module'; +import { HelperPipesModule } from '../helper-pipes/_helper-pipes.module'; diff --git a/src/app/shared/table-pagination/table-pagination.component.css b/src/app/shared/table-pagination/table-pagination.component.css new file mode 100644 index 00000000..52851ef9 --- /dev/null +++ b/src/app/shared/table-pagination/table-pagination.component.css @@ -0,0 +1,7 @@ +/* .page-link{ + padding: .35rem !important; +} */ + +.page-link:hover{ + cursor: pointer; +} \ No newline at end of file diff --git a/src/app/shared/table-pagination/table-pagination.component.html b/src/app/shared/table-pagination/table-pagination.component.html new file mode 100644 index 00000000..f38ebc50 --- /dev/null +++ b/src/app/shared/table-pagination/table-pagination.component.html @@ -0,0 +1,22 @@ + +
+ +
+
\ No newline at end of file diff --git a/src/app/shared/table-pagination/table-pagination.component.spec.ts b/src/app/shared/table-pagination/table-pagination.component.spec.ts new file mode 100644 index 00000000..f1ee64c8 --- /dev/null +++ b/src/app/shared/table-pagination/table-pagination.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TablePaginationComponent } from './table-pagination.component'; + +describe('TablePaginationComponent', () => { + let component: TablePaginationComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [TablePaginationComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(TablePaginationComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/shared/table-pagination/table-pagination.component.ts b/src/app/shared/table-pagination/table-pagination.component.ts new file mode 100644 index 00000000..243bb8f5 --- /dev/null +++ b/src/app/shared/table-pagination/table-pagination.component.ts @@ -0,0 +1,44 @@ +import { Component, EventEmitter, Input, Output, SimpleChanges } from '@angular/core'; + +@Component({ + selector: 'app-table-pagination', + templateUrl: './table-pagination.component.html', + styleUrl: './table-pagination.component.css' +}) +export class TablePaginationComponent { + @Input({ required: true }) + pageNumber: number; + @Input({ required: true }) + collectionSize: number; + @Input({ required: true }) + itemsPerPage: number; + @Output('emitPageNumber') + emitPageNumber: EventEmitter = new EventEmitter(); + + pageNumberOptions: Array; + numberOfPages: number; + + ngOnInit() { + this.setValues(); + } + + ngOnChanges(changes: SimpleChanges) { + //update values on collection size change or items per page change + if ((changes['collectionSize'] && !changes['collectionSize'].firstChange) || (changes['itemsPerPage'] && !changes['itemsPerPage'].firstChange)) { + this.setValues(); + } + } + + setValues() { + this.numberOfPages = Math.ceil(this.collectionSize / this.itemsPerPage); + this.pageNumberOptions = new Array(); + for (let i = 1; i <= this.numberOfPages; i++) { + this.pageNumberOptions.push(i); + } + } + + setPageNumber(pageNumber: number) { + this.pageNumber = pageNumber; + this.emitPageNumber.emit(this.pageNumber); + } +} diff --git a/src/app/shared/table-pagination/table-pagination.module.ts b/src/app/shared/table-pagination/table-pagination.module.ts new file mode 100644 index 00000000..19d0d986 --- /dev/null +++ b/src/app/shared/table-pagination/table-pagination.module.ts @@ -0,0 +1,18 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { TablePaginationComponent } from './table-pagination.component'; + + + +@NgModule({ + declarations: [ + TablePaginationComponent + ], + imports: [ + CommonModule + ], + exports: [ + TablePaginationComponent + ] +}) +export class TablePaginationModule { } diff --git a/src/app/spec-helpers/spec-test-service-stub.ts b/src/app/spec-helpers/spec-test-service-stub.ts new file mode 100644 index 00000000..24619775 --- /dev/null +++ b/src/app/spec-helpers/spec-test-service-stub.ts @@ -0,0 +1,185 @@ +import { BehaviorSubject } from "rxjs"; +import { UserIdbService } from "../indexed-db/user-idb.service" +import { CompanyIdbService } from "../indexed-db/company-idb.service"; +import { getNewIdbCompany, IdbCompany } from "../models/company"; +import { FacilityIdbService } from "../indexed-db/facility-idb.service"; +import { getNewIdbFacility, IdbFacility } from "../models/facility"; +import { getNewIdbUser, IdbUser } from "../models/user"; +import { EnergyOpportunityIdbService } from "../indexed-db/energy-opportunity-idb.service"; +import { getNewIdbEnergyOpportunity, IdbEnergyOpportunity } from "../models/energyOpportunity"; +import { AssessmentIdbService } from "../indexed-db/assessment-idb.service"; +import { getNewIdbAssessment, IdbAssessment } from "../models/assessment"; +import { ContactIdbService } from "../indexed-db/contact-idb.service"; +import { ContactContext, getNewIdbContact, IdbContact } from "../models/contact"; +import { NonEnergyBenefitsIdbService } from "../indexed-db/non-energy-benefits-idb.service"; +import { getNewIdbNonEnergyBenefit, IdbNonEnergyBenefit } from "../models/nonEnergyBenefit"; +import { OnSiteVisitIdbService } from "../indexed-db/on-site-visit-idb.service"; +import { getNewIdbOnSiteVisit, IdbOnSiteVisit } from "../models/onSiteVisit"; +import { SetupWizardService } from "../setup-wizard/setup-wizard.service"; +import { KeyPerformanceIndicatorsIdbService } from "../indexed-db/key-performance-indicators-idb.service"; +import { getNewKeyPerformanceIndicator, IdbKeyPerformanceIndicator } from "../models/keyPerformanceIndicator"; +import { EnergyEquipmentIdbService } from "../indexed-db/energy-equipment-idb.service"; +import { getNewIdbEnergyEquipment, IdbEnergyEquipment } from "../models/energyEquipment"; +import { ProcessEquipmentIdbService } from "../indexed-db/process-equipment-idb.service"; +import { getNewIdbProcessEquipment, IdbProcessEquipment } from "../models/processEquipment"; +import { KeyPerformanceMetricImpactsIdbService } from "../indexed-db/key-performance-metric-impacts-idb.service"; +import { getNewIdbKeyPerformanceMetricImpact, IdbKeyPerformanceMetricImpact } from "../models/keyPerformanceMetricImpact"; +import { LocalStorageDataService } from "../shared/shared-services/local-storage-data.service"; +import { ActivatedRoute } from "@angular/router"; +import { getDefaultUnitSettings } from "../models/unitSettings"; +import { KeyPerformanceIndicatorOption } from "../shared/constants/keyPerformanceIndicatorOptions"; +import { SharedDataService } from "../shared/shared-services/shared-data.service"; +import { CompanyContactsFormService } from "../shared/shared-company-forms/company-contacts-form/company-contacts-form.service"; +import { FormControl, FormGroup } from "@angular/forms"; + +let stubCompany: IdbCompany = getNewIdbCompany('123'); +stubCompany.guid = '123'; + +let companyIdbService: Partial = { + companies: new BehaviorSubject>([stubCompany]), + selectedCompany: new BehaviorSubject(stubCompany), + getByGUID: () => { return stubCompany } +}; + +let stubFacility: IdbFacility = getNewIdbFacility('123', '123'); +stubFacility.guid = '123'; + +let facilityIdbService: Partial = { + facilities: new BehaviorSubject>([stubFacility]), + selectedFacility: new BehaviorSubject(stubFacility), + getByGUID: () => { return stubFacility }, + getByOtherGuid: () => { return [stubFacility] } +}; + +let stubUser: IdbUser = getNewIdbUser(); +stubUser.guid = '123'; +let userIdbService: Partial = { + user: new BehaviorSubject(stubUser) +}; + + +let stubEnergyOpp: IdbEnergyOpportunity = getNewIdbEnergyOpportunity('123', '123', '123', '123', []); +stubEnergyOpp.guid = '123'; +let energyOpportunityIdbService: Partial = { + energyOpportunities: new BehaviorSubject>([stubEnergyOpp]), + getByGuid: () => { return stubEnergyOpp }, + getByOtherGuid: () => { return [stubEnergyOpp] } +}; + +let stubAssessment: IdbAssessment = getNewIdbAssessment('123', '123', '123', getDefaultUnitSettings()); +stubAssessment.guid = '123'; +let assessmentIdbService: Partial = { + assessments: new BehaviorSubject>([stubAssessment]), + selectedAssessment: new BehaviorSubject(stubAssessment), + getByGuid: () => { return stubAssessment }, + getByOtherGuid: () => { return [stubAssessment] } +}; + +let stubContact: IdbContact = getNewIdbContact('123', '123'); +stubContact.guid = '123'; +let contactIdbService: Partial = { + contacts: new BehaviorSubject>([stubContact]), + getContactByGuid: () => { return stubContact } +}; + +let stubNeb: IdbNonEnergyBenefit = getNewIdbNonEnergyBenefit('123', '123', '123', '123', '123', undefined, false); +stubNeb.guid = '123'; +let nonEnergyBenefitsIdbService: Partial = { + nonEnergyBenefits: new BehaviorSubject>([stubNeb]), + getEnergyOpportunityNonEnergyBenefits: () => { return [stubNeb] } +}; + +let stubOnSiteVisit: IdbOnSiteVisit = getNewIdbOnSiteVisit('123', '123', '123'); +stubOnSiteVisit.guid = '123'; +let onSiteVisitIdbService: Partial = { + onSiteVisits: new BehaviorSubject>([stubOnSiteVisit]), + selectedVisit: new BehaviorSubject(stubOnSiteVisit) +}; + +let setupWizardService: Partial = { + sidebarOpen: new BehaviorSubject(true) +}; + +let option: KeyPerformanceIndicatorOption = +{ + primaryKPI: 'Operations', + label: 'Expense Cost', + htmlLabel: 'Expense Cost', + optionValue: 'reduceExpenseCost' +} +let stubKpi: IdbKeyPerformanceIndicator = getNewKeyPerformanceIndicator('123', '123', option, false); +stubKpi.guid = '123'; +let keyPerformanceIndicatorService: Partial = { + keyPerformanceIndicators: new BehaviorSubject>([stubKpi]), + getByCompanyGuid: () => { return [stubKpi] }, + getByGuid: () => { return stubKpi }, + getCompanyKeyPerformanceMetrics: () => { return [] } +} + +let stubEnergyEquipment: IdbEnergyEquipment = getNewIdbEnergyEquipment('123', '123', '123', getDefaultUnitSettings()); +stubEnergyEquipment.guid = '123'; +let energyEquipmentIdbService: Partial = { + energyEquipments: new BehaviorSubject>([stubEnergyEquipment]), + getByOtherGuid: () => { return [stubEnergyEquipment] }, + getByGuid: () => { return stubEnergyEquipment } +}; + +let stubProcessEquipment: IdbProcessEquipment = getNewIdbProcessEquipment('123', '123', '123'); +stubProcessEquipment.guid = '123'; +let processEquipmentIdbService: Partial = { + processEquipments: new BehaviorSubject>([stubProcessEquipment]), + getByGuid: () => { return stubProcessEquipment } +} + +let stubKpiImpact: IdbKeyPerformanceMetricImpact = getNewIdbKeyPerformanceMetricImpact('123', '123', '123', '123', '123', 'TRIR', '123', '123', '123'); +stubKpiImpact.guid = '123'; +let keyPerformanceMetricImpactIdbService: Partial = { + keyPerformanceMetricImpacts: new BehaviorSubject>([stubKpiImpact]) +} + +let sharedDataService: Partial = { + createAssessmentModalOpen: new BehaviorSubject(false), + sidebarOpen: new BehaviorSubject(false), + displayAddNebsModal: new BehaviorSubject<{ assessmentId: string, energyOpportunityId: string }>(undefined), + displayContactModal: new BehaviorSubject<{ context: ContactContext, viewContact: IdbContact, contextGuid: string, companyId: string }>(undefined) +} + +let companyContactsFormService: Partial = { + getFormFromIdbContact: () => { + return new FormGroup({ + 'firstname': new FormControl(), + 'lastname': new FormControl(), + 'phone': new FormControl(), + 'ext': new FormControl(), + 'email': new FormControl(), + 'role': new FormControl(), + 'team': new FormControl(), + 'notes': new FormControl() + }) + } +} + +export const stubServiceProviders: Array<{ provide: any, useValue: any }> = [ + { provide: CompanyIdbService, useValue: companyIdbService }, + { provide: FacilityIdbService, useValue: facilityIdbService }, + { provide: UserIdbService, useValue: userIdbService }, + { provide: EnergyOpportunityIdbService, useValue: energyOpportunityIdbService }, + { provide: AssessmentIdbService, useValue: assessmentIdbService }, + { provide: ContactIdbService, useValue: contactIdbService }, + { provide: NonEnergyBenefitsIdbService, useValue: nonEnergyBenefitsIdbService }, + { provide: OnSiteVisitIdbService, useValue: onSiteVisitIdbService }, + { provide: SetupWizardService, useValue: setupWizardService }, + { provide: KeyPerformanceIndicatorsIdbService, useValue: keyPerformanceIndicatorService }, + { provide: EnergyEquipmentIdbService, useValue: energyEquipmentIdbService }, + { provide: ProcessEquipmentIdbService, useValue: processEquipmentIdbService }, + { provide: KeyPerformanceMetricImpactsIdbService, useValue: keyPerformanceMetricImpactIdbService }, + { provide: LocalStorageDataService, useValue: {} }, + { provide: SharedDataService, useValue: sharedDataService }, + { provide: CompanyContactsFormService, useValue: companyContactsFormService }, + { + provide: ActivatedRoute, + useValue: { + params: new BehaviorSubject({ 'id': '123' }) + } + } +] \ No newline at end of file diff --git a/src/app/user-dashboard/explore-nebs/explore-nebs.component.css b/src/app/user-dashboard/explore-nebs/explore-nebs.component.css deleted file mode 100644 index 6b5baf4b..00000000 --- a/src/app/user-dashboard/explore-nebs/explore-nebs.component.css +++ /dev/null @@ -1,3 +0,0 @@ -.card-header, .card-footer{ - background-color: white; -} \ No newline at end of file diff --git a/src/app/user-dashboard/explore-nebs/explore-nebs.component.html b/src/app/user-dashboard/explore-nebs/explore-nebs.component.html deleted file mode 100644 index a9fdc1d4..00000000 --- a/src/app/user-dashboard/explore-nebs/explore-nebs.component.html +++ /dev/null @@ -1,47 +0,0 @@ -
-
- -
-
-
-
-
-
-
-
- - -
-
-
-
-
-
- - -
-
- - -
-
-
- -
-
-
-
\ No newline at end of file diff --git a/src/app/user-dashboard/explore-nebs/explore-nebs.component.spec.ts b/src/app/user-dashboard/explore-nebs/explore-nebs.component.spec.ts deleted file mode 100644 index df857f7f..00000000 --- a/src/app/user-dashboard/explore-nebs/explore-nebs.component.spec.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ExploreNEBsComponent } from './explore-nebs.component'; -import { HelperPipesModule } from 'src/app/shared/helper-pipes/helper-pipes.module'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { FormsModule } from '@angular/forms'; -import { PrimaryKpiBadgeModule } from 'src/app/shared/primary-kpi-badge/primary-kpi-badge.module'; -import { KeyPerformanceIndicatorsIdbService } from 'src/app/indexed-db/key-performance-indicators-idb.service'; - -describe('ExploreNEBsComponent', () => { - let component: ExploreNEBsComponent; - let fixture: ComponentFixture; - let keyPerformanceIndicatorIdbService: Partial = {}; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [HelperPipesModule, FontAwesomeModule, FormsModule, PrimaryKpiBadgeModule], - declarations: [ExploreNEBsComponent], - providers: [ - { provide: KeyPerformanceIndicatorsIdbService, useValue: keyPerformanceIndicatorIdbService }, - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(ExploreNEBsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/user-dashboard/explore-nebs/explore-nebs.component.ts b/src/app/user-dashboard/explore-nebs/explore-nebs.component.ts deleted file mode 100644 index 5a67993d..00000000 --- a/src/app/user-dashboard/explore-nebs/explore-nebs.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Component } from '@angular/core'; -import { IconDefinition, faBullseye, faMagnifyingGlass, faMagnifyingGlassPlus, faScaleUnbalancedFlip, faWeightHanging } from '@fortawesome/free-solid-svg-icons'; -import { KeyPerformanceIndicatorOption, KeyPerformanceIndicatorOptions, PrimaryKPI, PrimaryKPIs } from 'src/app/shared/constants/keyPerformanceIndicatorOptions'; -import { KeyPerformanceMetricOption, KeyPerformanceMetricOptions } from 'src/app/shared/constants/keyPerformanceMetrics'; - -@Component({ - selector: 'app-explore-nebs', - templateUrl: './explore-nebs.component.html', - styleUrl: './explore-nebs.component.css' -}) -export class ExploreNEBsComponent { - - keyPerformanceIndicatorOptions: Array = KeyPerformanceIndicatorOptions; - keyPerformanceMetrics: Array = KeyPerformanceMetricOptions; - faBullseye: IconDefinition = faBullseye; - faScaleUnbalancedFlip: IconDefinition = faScaleUnbalancedFlip; - faWeightHanging: IconDefinition = faWeightHanging; - faMagnifyingGlassPlus: IconDefinition = faMagnifyingGlassPlus; - faMagnifyingGlass: IconDefinition = faMagnifyingGlass; - kpiSearchStr: string = ''; - kpiCategorySearch: PrimaryKPI | undefined = undefined; - - primaryKPIs: Array = PrimaryKPIs; -} diff --git a/src/app/user-dashboard/user-dashboard-help/user-dashboard-help.component.html b/src/app/user-dashboard/user-dashboard-help/user-dashboard-help.component.html deleted file mode 100644 index bcb3a061..00000000 --- a/src/app/user-dashboard/user-dashboard-help/user-dashboard-help.component.html +++ /dev/null @@ -1,7 +0,0 @@ -
-
-
- Tutorials and other help here..? -
-
-
\ No newline at end of file diff --git a/src/app/user-dashboard/user-dashboard-help/user-dashboard-help.component.spec.ts b/src/app/user-dashboard/user-dashboard-help/user-dashboard-help.component.spec.ts deleted file mode 100644 index 184634c0..00000000 --- a/src/app/user-dashboard/user-dashboard-help/user-dashboard-help.component.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { UserDashboardHelpComponent } from './user-dashboard-help.component'; - -describe('UserDashboardHelpComponent', () => { - let component: UserDashboardHelpComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [UserDashboardHelpComponent] - }) - .compileComponents(); - - fixture = TestBed.createComponent(UserDashboardHelpComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/user-dashboard/user-dashboard-help/user-dashboard-help.component.ts b/src/app/user-dashboard/user-dashboard-help/user-dashboard-help.component.ts deleted file mode 100644 index f40f455a..00000000 --- a/src/app/user-dashboard/user-dashboard-help/user-dashboard-help.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-user-dashboard-help', - templateUrl: './user-dashboard-help.component.html', - styleUrl: './user-dashboard-help.component.css' -}) -export class UserDashboardHelpComponent { - -} diff --git a/src/app/user-dashboard/user-dashboard-home/assessments-table/assessments-table.component.html b/src/app/user-dashboard/user-dashboard-home/assessments-table/assessments-table.component.html deleted file mode 100644 index d379eb00..00000000 --- a/src/app/user-dashboard/user-dashboard-home/assessments-table/assessments-table.component.html +++ /dev/null @@ -1,61 +0,0 @@ -
-
- - - Assessments - - -
-
- - - - - - - - - - - - - - - - - - - - -
- Name - - Company - - Facility - - Visit Date -
- - {{assessment.name}} - - - {{assessment.companyId | companyName:companies}} - - {{assessment.facilityId | facilityName:facilities}} - - - {{assessment.visitDate | date:'shortDate'}} - -
-
- - -
- No assessments found. Please use the "Setup Wizard" to get started. -
-
-
-
\ No newline at end of file diff --git a/src/app/user-dashboard/user-dashboard-home/assessments-table/assessments-table.component.spec.ts b/src/app/user-dashboard/user-dashboard-home/assessments-table/assessments-table.component.spec.ts deleted file mode 100644 index 77b6d701..00000000 --- a/src/app/user-dashboard/user-dashboard-home/assessments-table/assessments-table.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AssessmentsTableComponent } from './assessments-table.component'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { IdbAssessment, getNewIdbAssessment } from 'src/app/models/assessment'; -import { BehaviorSubject } from 'rxjs'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { IdbFacility, getNewIdbFacility } from 'src/app/models/facility'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { SetupWizardService } from 'src/app/setup-wizard/setup-wizard.service'; -import { HelperPipesModule } from 'src/app/shared/helper-pipes/helper-pipes.module'; -import { IdbCompany, getNewIdbCompany } from 'src/app/models/company'; -import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; -import { IdbOnSiteVisit } from 'src/app/models/onSiteVisit'; -import { getDefaultUnitSettings } from 'src/app/models/unitSettings'; - -describe('AssessmentsTableComponent', () => { - let component: AssessmentsTableComponent; - let fixture: ComponentFixture; - - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(getNewIdbAssessment('', '', '', getDefaultUnitSettings())), - assessments: new BehaviorSubject>([]) - }; - let facilityIdbService: Partial = { - selectedFacility: new BehaviorSubject(getNewIdbFacility('', '')), - facilities: new BehaviorSubject>([]) - }; - let companyIdbService: Partial = { - selectedCompany: new BehaviorSubject(getNewIdbCompany('')), - companies: new BehaviorSubject>([]) - }; - let setupWizardService: Partial = {}; - let onSiteVisitIdbService: Partial = { - onSiteVisits: new BehaviorSubject>([]) - }; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [FontAwesomeModule, HelperPipesModule], - declarations: [AssessmentsTableComponent], - providers: [ - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - { provide: FacilityIdbService, useValue: facilityIdbService }, - { provide: CompanyIdbService, useValue: companyIdbService }, - { provide: SetupWizardService, useValue: setupWizardService }, - { provide: OnSiteVisitIdbService, useValue: onSiteVisitIdbService }, - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(AssessmentsTableComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/user-dashboard/user-dashboard-home/assessments-table/assessments-table.component.ts b/src/app/user-dashboard/user-dashboard-home/assessments-table/assessments-table.component.ts deleted file mode 100644 index 44c717cd..00000000 --- a/src/app/user-dashboard/user-dashboard-home/assessments-table/assessments-table.component.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { Component } from '@angular/core'; -import { Router } from '@angular/router'; -import { IconDefinition, faFileLines, faWandMagicSparkles } from '@fortawesome/free-solid-svg-icons'; -import { Subscription } from 'rxjs'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; -import { IdbAssessment } from 'src/app/models/assessment'; -import { IdbCompany } from 'src/app/models/company'; -import { IdbFacility } from 'src/app/models/facility'; -import { SharedDataService } from 'src/app/shared/shared-services/shared-data.service'; - -@Component({ - selector: 'app-assessments-table', - templateUrl: './assessments-table.component.html', - styleUrl: './assessments-table.component.css' -}) -export class AssessmentsTableComponent { - - faWandMagicSparkles: IconDefinition = faWandMagicSparkles; - faFileLines: IconDefinition = faFileLines; - - companies: Array; - companiesSub: Subscription; - - facilities: Array; - facilitiesSub: Subscription; - - assessments: Array; - assessmentsSub: Subscription; - - constructor(private companyIdbService: CompanyIdbService, - private facilityIdbService: FacilityIdbService, - private assessmentIdbService: AssessmentIdbService, - private sharedDataService: SharedDataService, - private onSiteVisitIdbService: OnSiteVisitIdbService) { - } - - ngOnInit() { - this.companiesSub = this.companyIdbService.companies.subscribe(_companies => { - this.companies = _companies; - }); - - this.facilitiesSub = this.facilityIdbService.facilities.subscribe(_facilities => { - this.facilities = _facilities; - }); - this.assessmentsSub = this.assessmentIdbService.assessments.subscribe(_assessments => { - this.assessments = _assessments; - }) - } - - ngOnDestroy() { - this.companiesSub.unsubscribe(); - this.facilitiesSub.unsubscribe(); - this.assessmentsSub.unsubscribe(); - } - - openAddNewModal() { - this.companyIdbService.selectedCompany.next(undefined); - this.facilityIdbService.selectedFacility.next(undefined); - this.onSiteVisitIdbService.selectedVisit.next(undefined); - this.sharedDataService.createAssessmentModalOpen.next(true); - } - - goToVisit(assessment: IdbAssessment) { - this.companyIdbService.setSelectedFromGUID(assessment.companyId); - this.facilityIdbService.setSelectedFromGUID(assessment.facilityId); - this.onSiteVisitIdbService.setSelectedFromAssessmentGUID(assessment.guid); - this.sharedDataService.createAssessmentModalOpen.next(true); - } -} diff --git a/src/app/user-dashboard/user-dashboard-home/companies-table/companies-table.component.html b/src/app/user-dashboard/user-dashboard-home/companies-table/companies-table.component.html deleted file mode 100644 index 88ad56ca..00000000 --- a/src/app/user-dashboard/user-dashboard-home/companies-table/companies-table.component.html +++ /dev/null @@ -1,70 +0,0 @@ -
-
- - - Companies - - -
-
- - - - - - - - - - - - - - - - - -
- Name - - Location - - Assessments -
- - {{company.generalInformation.name}} - - - {{company.generalInformation | addressDisplay}} - - {{(company.guid | assessmentsList: assessments :true).length}} -
-
- - -
- No companies found. Please click "Add New" to get started. -
-
-
-
- -
- \ No newline at end of file diff --git a/src/app/user-dashboard/user-dashboard-home/companies-table/companies-table.component.spec.ts b/src/app/user-dashboard/user-dashboard-home/companies-table/companies-table.component.spec.ts deleted file mode 100644 index 60b164af..00000000 --- a/src/app/user-dashboard/user-dashboard-home/companies-table/companies-table.component.spec.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CompaniesTableComponent } from './companies-table.component'; -import { UserIdbService } from 'src/app/indexed-db/user-idb.service'; -import { IdbUser, getNewIdbUser } from 'src/app/models/user'; -import { BehaviorSubject } from 'rxjs'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { IdbCompany } from 'src/app/models/company'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { IdbFacility } from 'src/app/models/facility'; -import { RouterTestingModule } from '@angular/router/testing'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { IdbAssessment, getNewIdbAssessment } from 'src/app/models/assessment'; -import { getDefaultUnitSettings } from 'src/app/models/unitSettings'; - -describe('CompaniesTableComponent', () => { - let component: CompaniesTableComponent; - let fixture: ComponentFixture; - let userIdbService: Partial = { - user: new BehaviorSubject(getNewIdbUser()) - } - let companyIdbService: Partial = { - companies: new BehaviorSubject>([]) - }; - let facilityIdbService: Partial = { - facilities: new BehaviorSubject>([]) - }; - - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(getNewIdbAssessment('', '', '', getDefaultUnitSettings())), - assessments: new BehaviorSubject>([]) - }; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [RouterTestingModule, FontAwesomeModule], - declarations: [CompaniesTableComponent], - providers: [ - { provide: UserIdbService, useValue: userIdbService }, - { provide: CompanyIdbService, useValue: companyIdbService }, - { provide: FacilityIdbService, useValue: facilityIdbService }, - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(CompaniesTableComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/user-dashboard/user-dashboard-home/companies-table/companies-table.component.ts b/src/app/user-dashboard/user-dashboard-home/companies-table/companies-table.component.ts deleted file mode 100644 index b6d8e18f..00000000 --- a/src/app/user-dashboard/user-dashboard-home/companies-table/companies-table.component.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { Component } from '@angular/core'; -import { Router } from '@angular/router'; -import { IconDefinition, faBuilding, faPlus } from '@fortawesome/free-solid-svg-icons'; -import { Subscription, firstValueFrom } from 'rxjs'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { UserIdbService } from 'src/app/indexed-db/user-idb.service'; -import { IdbAssessment } from 'src/app/models/assessment'; -import { IdbCompany, getNewIdbCompany } from 'src/app/models/company'; -import { IdbFacility } from 'src/app/models/facility'; -import { IdbUser } from 'src/app/models/user'; - -@Component({ - selector: 'app-companies-table', - templateUrl: './companies-table.component.html', - styleUrl: './companies-table.component.css' -}) -export class CompaniesTableComponent { - - faPlus: IconDefinition = faPlus; - faBuilding: IconDefinition = faBuilding; - - companies: Array; - companiesSub: Subscription; - - facilities: Array; - facilitiesSub: Subscription; - - assessments: Array; - assessmentsSub: Subscription; - - displayAddNewModal: boolean; - constructor(private companyIdbService: CompanyIdbService, - private facilityIdbService: FacilityIdbService, - private assessmentIdbService: AssessmentIdbService, - private router: Router, - private userIdbService: UserIdbService) { - } - - ngOnInit() { - this.companiesSub = this.companyIdbService.companies.subscribe(_companies => { - this.companies = _companies; - }); - - this.facilitiesSub = this.facilityIdbService.facilities.subscribe(_facilities => { - this.facilities = _facilities; - }); - this.assessmentsSub = this.assessmentIdbService.assessments.subscribe(_assessments => { - this.assessments = _assessments; - }); - } - - ngOnDestroy() { - this.companiesSub.unsubscribe(); - this.facilitiesSub.unsubscribe(); - this.assessmentsSub.unsubscribe(); - } - - openAddNewModal() { - this.displayAddNewModal = true; - } - - closeAddNewModal() { - this.displayAddNewModal = false; - } - - async confirmCreate() { - let user: IdbUser = this.userIdbService.user.getValue(); - let newCompany: IdbCompany = getNewIdbCompany(user.guid); - newCompany = await firstValueFrom(this.companyIdbService.addWithObservable(newCompany)); - await this.companyIdbService.setCompanies(); - this.router.navigateByUrl('/company/' + newCompany.guid + '/settings'); - } -} diff --git a/src/app/user-dashboard/user-dashboard-home/facilities-table/facilities-table.component.html b/src/app/user-dashboard/user-dashboard-home/facilities-table/facilities-table.component.html deleted file mode 100644 index fec981bc..00000000 --- a/src/app/user-dashboard/user-dashboard-home/facilities-table/facilities-table.component.html +++ /dev/null @@ -1,84 +0,0 @@ -
-
- - - Facilities - - -
-
- - - - - - - - - - - - - - - - - - - -
- Name - - Location - - Contact - - Assessments -
- - {{facility.generalInformation.name}} - - - {{facility.generalInformation | addressDisplay}} - - - - {{(facility.guid | assessmentsList: assessments).length}} -
-
- - -
- No facilities found. Please click "Add New" to get started. -
-
-
-
- -
- \ No newline at end of file diff --git a/src/app/user-dashboard/user-dashboard-home/facilities-table/facilities-table.component.spec.ts b/src/app/user-dashboard/user-dashboard-home/facilities-table/facilities-table.component.spec.ts deleted file mode 100644 index 2575368c..00000000 --- a/src/app/user-dashboard/user-dashboard-home/facilities-table/facilities-table.component.spec.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { FacilitiesTableComponent } from './facilities-table.component'; -import { UserIdbService } from 'src/app/indexed-db/user-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbUser, getNewIdbUser } from 'src/app/models/user'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { IdbCompany } from 'src/app/models/company'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { IdbFacility } from 'src/app/models/facility'; -import { RouterTestingModule } from '@angular/router/testing'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { FormsModule } from '@angular/forms'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { IdbAssessment, getNewIdbAssessment } from 'src/app/models/assessment'; -import { getDefaultUnitSettings } from 'src/app/models/unitSettings'; - -describe('FacilitiesTableComponent', () => { - let component: FacilitiesTableComponent; - let fixture: ComponentFixture; - let userIdbService: Partial = { - user: new BehaviorSubject(getNewIdbUser()) - } - let companyIdbService: Partial = { - companies: new BehaviorSubject>([]) - }; - let facilityIdbService: Partial = { - facilities: new BehaviorSubject>([]) - }; - - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(getNewIdbAssessment('', '', '', getDefaultUnitSettings())), - assessments: new BehaviorSubject>([]) - }; - - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [RouterTestingModule, FontAwesomeModule, FormsModule], - declarations: [FacilitiesTableComponent], - providers: [ - { provide: UserIdbService, useValue: userIdbService }, - { provide: CompanyIdbService, useValue: companyIdbService }, - { provide: FacilityIdbService, useValue: facilityIdbService }, - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(FacilitiesTableComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/user-dashboard/user-dashboard-home/facilities-table/facilities-table.component.ts b/src/app/user-dashboard/user-dashboard-home/facilities-table/facilities-table.component.ts deleted file mode 100644 index 9dc6aeb7..00000000 --- a/src/app/user-dashboard/user-dashboard-home/facilities-table/facilities-table.component.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { Component } from '@angular/core'; -import { Router } from '@angular/router'; -import { IconDefinition, faIndustry, faPlus } from '@fortawesome/free-solid-svg-icons'; -import { Subscription, firstValueFrom } from 'rxjs'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { UserIdbService } from 'src/app/indexed-db/user-idb.service'; -import { IdbAssessment } from 'src/app/models/assessment'; -import { IdbCompany } from 'src/app/models/company'; -import { IdbFacility, getNewIdbFacility } from 'src/app/models/facility'; -import { IdbUser } from 'src/app/models/user'; - -@Component({ - selector: 'app-facilities-table', - templateUrl: './facilities-table.component.html', - styleUrl: './facilities-table.component.css' -}) -export class FacilitiesTableComponent { - - faPlus: IconDefinition = faPlus; - faIndustry: IconDefinition = faIndustry; - - companies: Array; - companiesSub: Subscription; - - facilities: Array; - facilitiesSub: Subscription; - - assessments: Array; - assessmentsSub: Subscription; - - displayAddNewModal: boolean = false; - selectedNewCompanyGuid: string; - constructor(private companyIdbService: CompanyIdbService, - private facilityIdbService: FacilityIdbService, - private assessmentIdbService: AssessmentIdbService, - private router: Router, - private userIdbService: UserIdbService) { - } - - ngOnInit() { - this.companiesSub = this.companyIdbService.companies.subscribe(_companies => { - this.companies = _companies; - }); - - this.facilitiesSub = this.facilityIdbService.facilities.subscribe(_facilities => { - this.facilities = _facilities; - }); - this.assessmentsSub = this.assessmentIdbService.assessments.subscribe(_assessments => { - this.assessments = _assessments; - }); - } - - ngOnDestroy() { - this.companiesSub.unsubscribe(); - this.facilitiesSub.unsubscribe(); - this.assessmentsSub.unsubscribe(); - } - - - openAddNewModal() { - this.displayAddNewModal = true; - } - - closeAddNewModal() { - this.displayAddNewModal = false; - } - - async confirmCreate() { - let user: IdbUser = this.userIdbService.user.getValue(); - let newFacility: IdbFacility = getNewIdbFacility(user.guid, this.selectedNewCompanyGuid); - newFacility = await firstValueFrom(this.facilityIdbService.addWithObservable(newFacility)); - await this.facilityIdbService.setFacilities(); - this.router.navigateByUrl('/facility/' + newFacility.guid + '/settings'); - } -} diff --git a/src/app/user-dashboard/user-dashboard-home/user-dashboard-home.component.html b/src/app/user-dashboard/user-dashboard-home/user-dashboard-home.component.html deleted file mode 100644 index 8da60ca4..00000000 --- a/src/app/user-dashboard/user-dashboard-home/user-dashboard-home.component.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
- -
-
- -
-
- -
-
\ No newline at end of file diff --git a/src/app/user-dashboard/user-dashboard-home/user-dashboard-home.component.spec.ts b/src/app/user-dashboard/user-dashboard-home/user-dashboard-home.component.spec.ts deleted file mode 100644 index 660681b9..00000000 --- a/src/app/user-dashboard/user-dashboard-home/user-dashboard-home.component.spec.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { UserDashboardHomeComponent } from './user-dashboard-home.component'; -import { RouterTestingModule } from '@angular/router/testing'; -import { UserIdbService } from 'src/app/indexed-db/user-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbUser, getNewIdbUser } from 'src/app/models/user'; -import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; -import { IdbFacility } from 'src/app/models/facility'; -import { FormsModule } from '@angular/forms'; -import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; -import { IdbCompany } from 'src/app/models/company'; -import { CompaniesTableComponent } from './companies-table/companies-table.component'; -import { FacilitiesTableComponent } from './facilities-table/facilities-table.component'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { AssessmentsTableComponent } from './assessments-table/assessments-table.component'; -import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; -import { IdbAssessment } from 'src/app/models/assessment'; -import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; -import { IdbOnSiteVisit } from 'src/app/models/onSiteVisit'; - -describe('UserDashboardHomeComponent', () => { - let component: UserDashboardHomeComponent; - let fixture: ComponentFixture; - let userIdbService: Partial = { - user: new BehaviorSubject(getNewIdbUser()) - } - let companyIdbService: Partial = { - companies: new BehaviorSubject>([]) - }; - let facilityIdbService: Partial = { - facilities: new BehaviorSubject>([]) - }; - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(undefined), - assessments: new BehaviorSubject>([]) - }; - let onSiteVisitIdbService: Partial = { - onSiteVisits: new BehaviorSubject>([]) - }; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [RouterTestingModule, FormsModule, FontAwesomeModule], - declarations: [UserDashboardHomeComponent, CompaniesTableComponent, FacilitiesTableComponent, AssessmentsTableComponent], - providers: [ - { provide: UserIdbService, useValue: userIdbService }, - { provide: CompanyIdbService, useValue: companyIdbService }, - { provide: FacilityIdbService, useValue: facilityIdbService }, - { provide: AssessmentIdbService, useValue: assessmentIdbService }, - { provide: OnSiteVisitIdbService, useValue: onSiteVisitIdbService }, - ] - }); - fixture = TestBed.createComponent(UserDashboardHomeComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/user-dashboard/user-dashboard-home/user-dashboard-home.component.ts b/src/app/user-dashboard/user-dashboard-home/user-dashboard-home.component.ts deleted file mode 100644 index 12b4a998..00000000 --- a/src/app/user-dashboard/user-dashboard-home/user-dashboard-home.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-user-dashboard-home', - templateUrl: './user-dashboard-home.component.html', - styleUrls: ['./user-dashboard-home.component.css'] -}) -export class UserDashboardHomeComponent { - -} diff --git a/src/app/user-dashboard/user-dashboard-tabs/user-dashboard-tabs.component.html b/src/app/user-dashboard/user-dashboard-tabs/user-dashboard-tabs.component.html deleted file mode 100644 index 3164e754..00000000 --- a/src/app/user-dashboard/user-dashboard-tabs/user-dashboard-tabs.component.html +++ /dev/null @@ -1,28 +0,0 @@ - \ No newline at end of file diff --git a/src/app/user-dashboard/user-dashboard-tabs/user-dashboard-tabs.component.ts b/src/app/user-dashboard/user-dashboard-tabs/user-dashboard-tabs.component.ts deleted file mode 100644 index 8b61c73a..00000000 --- a/src/app/user-dashboard/user-dashboard-tabs/user-dashboard-tabs.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component } from '@angular/core'; -import { IconDefinition, faDatabase, faFolderOpen, faGears, faQuestion } from '@fortawesome/free-solid-svg-icons'; - -@Component({ - selector: 'app-user-dashboard-tabs', - templateUrl: './user-dashboard-tabs.component.html', - styleUrl: './user-dashboard-tabs.component.css' -}) -export class UserDashboardTabsComponent { - - faFolderOpen: IconDefinition = faFolderOpen; - faGears: IconDefinition = faGears; - faDatabase: IconDefinition = faDatabase; - faQuestion: IconDefinition = faQuestion; -} diff --git a/src/app/user-dashboard/user-dashboard.component.html b/src/app/user-dashboard/user-dashboard.component.html deleted file mode 100644 index 4cc37cb0..00000000 --- a/src/app/user-dashboard/user-dashboard.component.html +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
\ No newline at end of file diff --git a/src/app/user-dashboard/user-dashboard.component.spec.ts b/src/app/user-dashboard/user-dashboard.component.spec.ts deleted file mode 100644 index 63b6b2b9..00000000 --- a/src/app/user-dashboard/user-dashboard.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { UserDashboardComponent } from './user-dashboard.component'; -import { RouterTestingModule } from '@angular/router/testing'; -import { UserDashboardTabsComponent } from './user-dashboard-tabs/user-dashboard-tabs.component'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; - -describe('UserDashboardComponent', () => { - let component: UserDashboardComponent; - let fixture: ComponentFixture; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [RouterTestingModule, FontAwesomeModule], - declarations: [UserDashboardComponent, UserDashboardTabsComponent] - }); - fixture = TestBed.createComponent(UserDashboardComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/user-dashboard/user-dashboard.component.ts b/src/app/user-dashboard/user-dashboard.component.ts deleted file mode 100644 index 695ece4d..00000000 --- a/src/app/user-dashboard/user-dashboard.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-user-dashboard', - templateUrl: './user-dashboard.component.html', - styleUrls: ['./user-dashboard.component.css'] -}) -export class UserDashboardComponent { - -} diff --git a/src/app/user-dashboard/user-dashboard.module.ts b/src/app/user-dashboard/user-dashboard.module.ts deleted file mode 100644 index 8af907df..00000000 --- a/src/app/user-dashboard/user-dashboard.module.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { UserDashboardComponent } from './user-dashboard.component'; -import { UserDashboardHomeComponent } from './user-dashboard-home/user-dashboard-home.component'; -import { RouterModule } from '@angular/router'; -import { FormsModule } from '@angular/forms'; -import { HelperPipesModule } from '../shared/helper-pipes/helper-pipes.module'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { CompaniesTableComponent } from './user-dashboard-home/companies-table/companies-table.component'; -import { FacilitiesTableComponent } from './user-dashboard-home/facilities-table/facilities-table.component'; -import { UserDashboardTabsComponent } from './user-dashboard-tabs/user-dashboard-tabs.component'; -import { UserSettingsComponent } from './user-settings/user-settings.component'; -import { UserDashboardHelpComponent } from './user-dashboard-help/user-dashboard-help.component'; -import { ExploreNEBsComponent } from './explore-nebs/explore-nebs.component'; -import { AssessmentsTableComponent } from './user-dashboard-home/assessments-table/assessments-table.component'; -import { PrimaryKpiBadgeModule } from '../shared/primary-kpi-badge/primary-kpi-badge.module'; - -@NgModule({ - declarations: [ - UserDashboardComponent, - UserDashboardHomeComponent, - CompaniesTableComponent, - FacilitiesTableComponent, - UserDashboardTabsComponent, - UserSettingsComponent, - UserDashboardHelpComponent, - ExploreNEBsComponent, - AssessmentsTableComponent - ], - imports: [ - CommonModule, - RouterModule, - FormsModule, - HelperPipesModule, - FontAwesomeModule, - PrimaryKpiBadgeModule - ] -}) -export class UserDashboardModule { } diff --git a/src/app/user-dashboard/user-settings/user-settings.component.html b/src/app/user-dashboard/user-settings/user-settings.component.html deleted file mode 100644 index 9b838ccb..00000000 --- a/src/app/user-dashboard/user-settings/user-settings.component.html +++ /dev/null @@ -1,7 +0,0 @@ -
-
-
- App wide settings here..? -
-
-
\ No newline at end of file diff --git a/src/app/user-dashboard/user-settings/user-settings.component.spec.ts b/src/app/user-dashboard/user-settings/user-settings.component.spec.ts deleted file mode 100644 index 48b61f41..00000000 --- a/src/app/user-dashboard/user-settings/user-settings.component.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { UserSettingsComponent } from './user-settings.component'; - -describe('UserSettingsComponent', () => { - let component: UserSettingsComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [UserSettingsComponent] - }) - .compileComponents(); - - fixture = TestBed.createComponent(UserSettingsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/user-dashboard/user-settings/user-settings.component.ts b/src/app/user-dashboard/user-settings/user-settings.component.ts deleted file mode 100644 index 10901714..00000000 --- a/src/app/user-dashboard/user-settings/user-settings.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-user-settings', - templateUrl: './user-settings.component.html', - styleUrl: './user-settings.component.css' -}) -export class UserSettingsComponent { - -} diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.css b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.css new file mode 100644 index 00000000..8d89b424 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.css @@ -0,0 +1,3 @@ +th{ + width: 30%; +} \ No newline at end of file diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.html b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.html new file mode 100644 index 00000000..6aa0372a --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.html @@ -0,0 +1,18 @@ +
+
+
+
+ + {{assessment.name}} +
+
+ +
+
+
+ +
+
\ No newline at end of file diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.spec.ts b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.spec.ts new file mode 100644 index 00000000..7027b8af --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.spec.ts @@ -0,0 +1,29 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AssessmentDashboardHomeComponent } from './assessment-dashboard-home.component'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { AssessmentListItemComponent } from '../../portfolio-items-list/assessment-list-item/assessment-list-item.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; + +describe('AssessmentDashboardHomeComponent', () => { + let component: AssessmentDashboardHomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, HelperPipesModule], + declarations: [AssessmentDashboardHomeComponent, AssessmentListItemComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(AssessmentDashboardHomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.ts b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.ts new file mode 100644 index 00000000..8f908305 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.ts @@ -0,0 +1,58 @@ +import { Component } from '@angular/core'; +import { faFileLines, faWandMagicSparkles, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; +import { IdbAssessment } from 'src/app/models/assessment'; +import { IdbEnergyOpportunity } from 'src/app/models/energyOpportunity'; +import { SharedDataService } from 'src/app/shared/shared-services/shared-data.service'; + +@Component({ + selector: 'app-assessment-dashboard-home', + templateUrl: './assessment-dashboard-home.component.html', + styleUrl: './assessment-dashboard-home.component.css' +}) +export class AssessmentDashboardHomeComponent { + + faFileLines: IconDefinition = faFileLines; + faWandMagicSparkles: IconDefinition = faWandMagicSparkles; + + assessment: IdbAssessment; + assessmentSub: Subscription; + energyOpportunitiesSub: Subscription; + energyOpportunities: Array; + constructor(private assessmentIdbService: AssessmentIdbService, + private companyIdbService: CompanyIdbService, + private facilityIdbService: FacilityIdbService, + private onSiteVisitIdbService: OnSiteVisitIdbService, + private sharedDataService: SharedDataService, + private energyOpportunityIdbService: EnergyOpportunityIdbService + ) { } + + ngOnInit() { + this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(assessment => { + this.assessment = assessment; + }); + this.energyOpportunitiesSub = this.energyOpportunityIdbService.energyOpportunities.subscribe(opportunities => { + this.energyOpportunities = opportunities.filter(opp => { + return opp.assessmentId == this.assessment.guid + }); + }); + } + + ngOnDestroy() { + this.assessmentSub.unsubscribe(); + this.energyOpportunitiesSub.unsubscribe(); + } + + goToVisit() { + this.companyIdbService.setSelectedFromGUID(this.assessment.companyId); + this.facilityIdbService.setSelectedFromGUID(this.assessment.facilityId); + this.onSiteVisitIdbService.setSelectedFromAssessmentGUID(this.assessment.guid); + this.sharedDataService.createAssessmentModalOpen.next(true); + } + +} diff --git a/src/app/assessment-dashboard/assessment-settings/manage-assessment/manage-assessment.component.css b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component.css similarity index 100% rename from src/app/assessment-dashboard/assessment-settings/manage-assessment/manage-assessment.component.css rename to src/app/user-portfolio/assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component.css diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component.html b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component.html new file mode 100644 index 00000000..8afbc2dd --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component.html @@ -0,0 +1,36 @@ + + \ No newline at end of file diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component.spec.ts b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component.spec.ts new file mode 100644 index 00000000..846f8002 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component.spec.ts @@ -0,0 +1,28 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AssessmentDashboardNavComponent } from './assessment-dashboard-nav.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { RouterTestingModule } from '@angular/router/testing'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('AssessmentDashboardNavComponent', () => { + let component: AssessmentDashboardNavComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, RouterTestingModule], + declarations: [AssessmentDashboardNavComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(AssessmentDashboardNavComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component.ts b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component.ts new file mode 100644 index 00000000..db787a3c --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component.ts @@ -0,0 +1,32 @@ +import { Component } from '@angular/core'; +import { faFile, faFileLines, faGears, faWeightHanging, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; +import { IdbAssessment } from 'src/app/models/assessment'; + +@Component({ + selector: 'app-assessment-dashboard-nav', + templateUrl: './assessment-dashboard-nav.component.html', + styleUrl: './assessment-dashboard-nav.component.css' +}) +export class AssessmentDashboardNavComponent { + + faGears: IconDefinition = faGears; + faFile: IconDefinition = faFile; + faWeightHanging: IconDefinition = faWeightHanging; + faFileLines: IconDefinition = faFileLines; + + assessment: IdbAssessment; + assessmentSub: Subscription; + constructor(private assessmentIdbService: AssessmentIdbService) { } + + ngOnInit() { + this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(assessment => { + this.assessment = assessment; + }); + } + + ngOnDestroy() { + this.assessmentSub.unsubscribe(); + } +} diff --git a/src/app/company-dashboard/company-dashboard-home/assessments-table/assessments-table.component.css b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard.component.css similarity index 100% rename from src/app/company-dashboard/company-dashboard-home/assessments-table/assessments-table.component.css rename to src/app/user-portfolio/assessment-dashboard/assessment-dashboard.component.css diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-dashboard.component.html b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard.component.html new file mode 100644 index 00000000..a528b642 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard.component.html @@ -0,0 +1,6 @@ +
+ +
+
+ +
\ No newline at end of file diff --git a/src/app/assessment-dashboard/assessment-dashboard.component.spec.ts b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard.component.spec.ts similarity index 54% rename from src/app/assessment-dashboard/assessment-dashboard.component.spec.ts rename to src/app/user-portfolio/assessment-dashboard/assessment-dashboard.component.spec.ts index fafb4006..62b54e1d 100644 --- a/src/app/assessment-dashboard/assessment-dashboard.component.spec.ts +++ b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard.component.spec.ts @@ -1,31 +1,22 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AssessmentDashboardComponent } from './assessment-dashboard.component'; -import { AssessmentDashboardTabsComponent } from './assessment-dashboard-tabs/assessment-dashboard-tabs.component'; +import { AssessmentDashboardNavComponent } from './assessment-dashboard-nav/assessment-dashboard-nav.component'; import { RouterTestingModule } from '@angular/router/testing'; -import { AssessmentIdbService } from '../indexed-db/assessment-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbAssessment, getNewIdbAssessment } from '../models/assessment'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { getDefaultUnitSettings } from '../models/unitSettings'; describe('AssessmentDashboardComponent', () => { let component: AssessmentDashboardComponent; let fixture: ComponentFixture; - let assessmentIdbService: Partial = { - selectedAssessment: new BehaviorSubject(getNewIdbAssessment('', '', '', getDefaultUnitSettings())) - } + beforeEach(async () => { await TestBed.configureTestingModule({ imports: [RouterTestingModule, FontAwesomeModule], - declarations: [AssessmentDashboardComponent, AssessmentDashboardTabsComponent], - providers:[ - { - provide: AssessmentIdbService, useValue: assessmentIdbService - } - ] + declarations: [AssessmentDashboardComponent, AssessmentDashboardNavComponent], + providers: stubServiceProviders }) - .compileComponents(); + .compileComponents(); fixture = TestBed.createComponent(AssessmentDashboardComponent); component = fixture.componentInstance; diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-dashboard.component.ts b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard.component.ts new file mode 100644 index 00000000..36f4de1d --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-dashboard.component.ts @@ -0,0 +1,36 @@ +import { Component } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { IdbAssessment } from 'src/app/models/assessment'; +import { IdbCompany } from 'src/app/models/company'; +import { IdbFacility } from 'src/app/models/facility'; + +@Component({ + selector: 'app-assessment-dashboard', + templateUrl: './assessment-dashboard.component.html', + styleUrl: './assessment-dashboard.component.css' +}) +export class AssessmentDashboardComponent { + + constructor(private activatedRoute: ActivatedRoute, + private companyIdbService: CompanyIdbService, + private facilityIdbService: FacilityIdbService, + private assessmentIdbService: AssessmentIdbService + ) { + } + + ngOnInit() { + this.activatedRoute.params.subscribe(params => { + let guid: string = params['id']; + let assessment: IdbAssessment = this.assessmentIdbService.getByGuid(guid); + this.assessmentIdbService.selectedAssessment.next(assessment); + let facility: IdbFacility = this.facilityIdbService.getByGUID(assessment.facilityId); + this.facilityIdbService.selectedFacility.next(facility); + let company: IdbCompany = this.companyIdbService.getByGUID(assessment.companyId); + this.companyIdbService.selectedCompany.next(company); + }); + } + +} diff --git a/src/app/company-dashboard/company-dashboard-home/company-dashboard-home.component.css b/src/app/user-portfolio/assessment-dashboard/assessment-details/assessment-details.component.css similarity index 100% rename from src/app/company-dashboard/company-dashboard-home/company-dashboard-home.component.css rename to src/app/user-portfolio/assessment-dashboard/assessment-details/assessment-details.component.css diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-details/assessment-details.component.html b/src/app/user-portfolio/assessment-dashboard/assessment-details/assessment-details.component.html new file mode 100644 index 00000000..3f4bd6ec --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-details/assessment-details.component.html @@ -0,0 +1,56 @@ +
+
+
+
+ + {{assessment.name}} Details +
+
+ + + + + + + +
+
+ +
+
+ +
+ \ No newline at end of file diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-details/assessment-details.component.spec.ts b/src/app/user-portfolio/assessment-dashboard/assessment-details/assessment-details.component.spec.ts new file mode 100644 index 00000000..4a09bf8e --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-details/assessment-details.component.spec.ts @@ -0,0 +1,28 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AssessmentDetailsComponent } from './assessment-details.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { SharedAssessmentFormsModule } from 'src/app/shared/shared-assessment-forms/shared-assessment-forms.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('AssessmentDetailsComponent', () => { + let component: AssessmentDetailsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, SharedAssessmentFormsModule], + declarations: [AssessmentDetailsComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(AssessmentDetailsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.ts b/src/app/user-portfolio/assessment-dashboard/assessment-details/assessment-details.component.ts similarity index 65% rename from src/app/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.ts rename to src/app/user-portfolio/assessment-dashboard/assessment-details/assessment-details.component.ts index 50ad99f4..6420d602 100644 --- a/src/app/assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component.ts +++ b/src/app/user-portfolio/assessment-dashboard/assessment-details/assessment-details.component.ts @@ -1,38 +1,40 @@ import { Component } from '@angular/core'; -import { IconDefinition, faWandMagicSparkles } from '@fortawesome/free-solid-svg-icons'; +import { faLock, faUnlock, faWandMagicSparkles, IconDefinition } from '@fortawesome/free-solid-svg-icons'; import { Subscription } from 'rxjs'; import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; import { IdbAssessment } from 'src/app/models/assessment'; -import { SetupWizardService } from 'src/app/setup-wizard/setup-wizard.service'; import { SharedDataService } from 'src/app/shared/shared-services/shared-data.service'; @Component({ - selector: 'app-assessment-dashboard-home', - templateUrl: './assessment-dashboard-home.component.html', - styleUrl: './assessment-dashboard-home.component.css' + selector: 'app-assessment-details', + templateUrl: './assessment-details.component.html', + styleUrl: './assessment-details.component.css' }) -export class AssessmentDashboardHomeComponent { +export class AssessmentDetailsComponent { + faLock: IconDefinition = faLock; + faUnlock: IconDefinition = faUnlock; faWandMagicSparkles: IconDefinition = faWandMagicSparkles; + isDisabled: boolean = true; + + displayUnlockModal: boolean = false; + assessment: IdbAssessment; assessmentSub: Subscription; - constructor(private assessmentIdbService: AssessmentIdbService, - private facilityIdbService: FacilityIdbService, private companyIdbService: CompanyIdbService, + private facilityIdbService: FacilityIdbService, private onSiteVisitIdbService: OnSiteVisitIdbService, private sharedDataService: SharedDataService - ) { - - } + ) { } ngOnInit() { - this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(_selectedAssessment => { - this.assessment = _selectedAssessment; + this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(assessment => { + this.assessment = assessment; }); } @@ -40,10 +42,25 @@ export class AssessmentDashboardHomeComponent { this.assessmentSub.unsubscribe(); } - openEditModal() { - this.facilityIdbService.setSelectedFromGUID(this.assessment.facilityId); + goToVisit() { this.companyIdbService.setSelectedFromGUID(this.assessment.companyId); + this.facilityIdbService.setSelectedFromGUID(this.assessment.facilityId); this.onSiteVisitIdbService.setSelectedFromAssessmentGUID(this.assessment.guid); this.sharedDataService.createAssessmentModalOpen.next(true); } + + openUnlockModal() { + this.displayUnlockModal = true; + } + + closeUnlockModal() { + this.displayUnlockModal = false; + } + + toggleDisabled() { + this.isDisabled = !this.isDisabled; + this.closeUnlockModal(); + } + + } diff --git a/src/app/company-dashboard/company-dashboard-home/facilities-table/facilities-table.component.css b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component.css similarity index 100% rename from src/app/company-dashboard/company-dashboard-home/facilities-table/facilities-table.component.css rename to src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component.css diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component.html b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component.html new file mode 100644 index 00000000..cdbe4c14 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component.html @@ -0,0 +1,64 @@ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
+ Opportunity Name + + NEBs + + Implementation Cost + + Savings +
+ {{energyOpportunity.name}} + + @let associatedNebs = energyOpportunity.guid | nebList:'energyOpportunity': nonEnergyBenefits; + + + + {{neb.name}}
+
+
+ + — + +
+ + +
+
+
+ + +
+ No energy efficiency opportunities found for this assessment. Use the " + Add Energy Efficiency Opportunity" button to add an opportunity this assessment. +
+
\ No newline at end of file diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component.spec.ts b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component.spec.ts new file mode 100644 index 00000000..4a49e03b --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component.spec.ts @@ -0,0 +1,30 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AssessmentEnergyOpportunitiesHomeComponent } from './assessment-energy-opportunities-home.component'; +import { RouterTestingModule } from '@angular/router/testing'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { TableEntriesModule } from 'src/app/shared/table-entries/table-entries.module'; + +describe('AssessmentEnergyOpportunitiesHomeComponent', () => { + let component: AssessmentEnergyOpportunitiesHomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [RouterTestingModule, FontAwesomeModule, HelperPipesModule, TableEntriesModule], + declarations: [AssessmentEnergyOpportunitiesHomeComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(AssessmentEnergyOpportunitiesHomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component.ts b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component.ts new file mode 100644 index 00000000..400a4ff1 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component.ts @@ -0,0 +1,74 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; +import { faPlus, faWeightHanging, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { firstValueFrom, Subscription } from 'rxjs'; +import { ToastNotificationsService } from 'src/app/core-components/toast-notifications/toast-notifications.service'; +import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; +import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service'; +import { NonEnergyBenefitsIdbService } from 'src/app/indexed-db/non-energy-benefits-idb.service'; +import { IdbAssessment } from 'src/app/models/assessment'; +import { getNewIdbEnergyOpportunity, IdbEnergyOpportunity } from 'src/app/models/energyOpportunity'; +import { IdbNonEnergyBenefit } from 'src/app/models/nonEnergyBenefit'; + +@Component({ + selector: 'app-assessment-energy-opportunities-home', + templateUrl: './assessment-energy-opportunities-home.component.html', + styleUrl: './assessment-energy-opportunities-home.component.css' +}) +export class AssessmentEnergyOpportunitiesHomeComponent { + + faPlus: IconDefinition = faPlus; + faWeightHanging: IconDefinition = faWeightHanging; + + assessment: IdbAssessment; + assessmentSub: Subscription; + + energyOpportunities: Array; + energyOpportunitiesSub: Subscription; + + nonEnergyBenefits: Array; + nonEnergyBenefitsSub: Subscription; + + constructor(private assessmentIdbService: AssessmentIdbService, + private energyOpportunityIdbService: EnergyOpportunityIdbService, + private nonEnergyBenefitsIdbService: NonEnergyBenefitsIdbService, + private router: Router, + private toastNotificationsService: ToastNotificationsService + ) { } + + ngOnInit() { + this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(assessment => { + this.assessment = assessment; + }); + + this.energyOpportunitiesSub = this.energyOpportunityIdbService.energyOpportunities.subscribe(energyOpportunities => { + this.energyOpportunities = energyOpportunities.filter(opp => { + return opp.assessmentId == this.assessment.guid; + }); + }); + + this.nonEnergyBenefitsSub = this.nonEnergyBenefitsIdbService.nonEnergyBenefits.subscribe(nebs => { + this.nonEnergyBenefits = nebs; + }); + } + + ngOnDestroy() { + this.assessmentSub.unsubscribe(); + this.energyOpportunitiesSub.unsubscribe(); + this.nonEnergyBenefitsSub.unsubscribe(); + } + + + async addEnergyOpportunity() { + let newOpportunity: IdbEnergyOpportunity = getNewIdbEnergyOpportunity(this.assessment.userId, this.assessment.companyId, + this.assessment.facilityId, this.assessment.guid, this.assessment.utilityEnergyUses); + let assessmentEnergyOpportunities: Array = this.energyOpportunities.filter(prj => { + return prj.assessmentId == this.assessment.guid; + }); + newOpportunity.name = 'Opportunity #' + (assessmentEnergyOpportunities.length + 1); + await firstValueFrom(this.energyOpportunityIdbService.addWithObservable(newOpportunity)); + await this.energyOpportunityIdbService.setEnergyOpportunities(); + this.toastNotificationsService.showToast('Opportunity Added!', 'A new energy efficiency opportunity was added to the assessment.', 'bg-success', true, false); + this.router.navigateByUrl('/portfolio/assessment/' + newOpportunity.assessmentId + '/energy-opportunities/' + newOpportunity.guid) + } +} diff --git a/src/app/company-dashboard/company-dashboard-tabs/company-dashboard-tabs.component.css b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component.css similarity index 100% rename from src/app/company-dashboard/company-dashboard-tabs/company-dashboard-tabs.component.css rename to src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component.css diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component.html b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component.html new file mode 100644 index 00000000..03bad81e --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component.html @@ -0,0 +1,42 @@ + \ No newline at end of file diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component.spec.ts b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component.spec.ts new file mode 100644 index 00000000..4f89c8c0 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component.spec.ts @@ -0,0 +1,28 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AssessmentEnergyOpportunitiesComponent } from './assessment-energy-opportunities.component'; +import { RouterTestingModule } from '@angular/router/testing'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('AssessmentEnergyOpportunitiesComponent', () => { + let component: AssessmentEnergyOpportunitiesComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [RouterTestingModule, FontAwesomeModule], + declarations: [AssessmentEnergyOpportunitiesComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(AssessmentEnergyOpportunitiesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component.ts b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component.ts new file mode 100644 index 00000000..0f4e55e8 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component.ts @@ -0,0 +1,44 @@ +import { Component } from '@angular/core'; +import { faChevronRight, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; +import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service'; +import { IdbAssessment } from 'src/app/models/assessment'; +import { IdbEnergyOpportunity } from 'src/app/models/energyOpportunity'; + +@Component({ + selector: 'app-assessment-energy-opportunities', + templateUrl: './assessment-energy-opportunities.component.html', + styleUrl: './assessment-energy-opportunities.component.css' +}) +export class AssessmentEnergyOpportunitiesComponent { + + faChevronRight: IconDefinition = faChevronRight; + + assessment: IdbAssessment; + assessmentSub: Subscription; + + energyOpportunities: Array; + energyOpportunitiesSub: Subscription; + constructor(private assessmentIdbService: AssessmentIdbService, + private energyOpportunityIdbService: EnergyOpportunityIdbService + ) { } + + ngOnInit() { + this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(assessment => { + this.assessment = assessment; + }); + + this.energyOpportunitiesSub = this.energyOpportunityIdbService.energyOpportunities.subscribe(energyOpportunities => { + this.energyOpportunities = energyOpportunities.filter(opp => { + return opp.assessmentId == this.assessment.guid; + }); + }) + } + + ngOnDestroy() { + this.assessmentSub.unsubscribe(); + this.energyOpportunitiesSub.unsubscribe(); + } + +} diff --git a/src/app/company-dashboard/company-dashboard.component.css b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component.css similarity index 100% rename from src/app/company-dashboard/company-dashboard.component.css rename to src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component.css diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component.html b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component.html new file mode 100644 index 00000000..80200034 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component.html @@ -0,0 +1,193 @@ +
+
+
Assessment Non-Energy Benefits
+
+
+ +
+
+
+ + + +

+ Use the " Add NEB" dropdown to add Non-Energy Benefits + () that + are not associated with any specific energy efficiency opportunity to this + assessment. +

+ + + + + + + + + + + + + + + + + +
+ Non-Energy Benefit + + Key Performance
Metric Impacts +
+ Stakeholders + + Total Savings
+ + ($/yr) + +
+ + {{nonEnergyBenefit.name}} + + @let kpmImpacts = nonEnergyBenefit.guid | associatedPerformanceMetricImpacts: + keyPerformanceMetricImpacts; + + + +
+
+
+ + — + +
+ @let associatedContacts = nonEnergyBenefit.guid | associatedContacts:'nonEnergyBenefit': + contacts; + + + {{contact | contactNameDisplay}}
+
+
+ + — + +
+ +
+
+ +
+ No non energy benefits found for this assessment. Use the " + Add NEB" dropdown to either add a custom NEB or search our NEBs database for new NEBs to be added to this + assessment. +
+
+ + +
+
Energy Opportunity Non-Energy Benefits
+

+ The below are Non-Energy Benefits () that + are associated with a specific energy efficiency opportunity within this + assessment. + To modify these NEBs navigate to the "Energy Efficiency Opportunities" tab. +

+ + + + + + + + + + + + + + + + + + + +
+ Non-Energy Benefit + + Key Performance
Metric Impacts +
+ Stakeholders + Energy Efficiency
Opportunity
+ Total Savings
+ + ($/yr) + +
+ + {{nonEnergyBenefit.name}} + + @let kpmImpacts = nonEnergyBenefit.guid | associatedPerformanceMetricImpacts: + keyPerformanceMetricImpacts; + + + +
+
+
+ + — + +
+ @let associatedContacts = nonEnergyBenefit.guid | associatedContacts:'nonEnergyBenefit': + contacts; + + + {{contact | contactNameDisplay}}
+
+
+ + — + +
+ + {{nonEnergyBenefit.energyOpportunityId | energyOpportunityDisplay: energyOpportunities}} + + + +
+
+ + + + +
+ + +
+ No non energy benefits found for this assessment. Use the " + Add NEB" dropdown to either add a custom NEB or search our NEBs database for new NEBs to be added to this + assessment. +
+
\ No newline at end of file diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component.spec.ts b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component.spec.ts new file mode 100644 index 00000000..d48ee907 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component.spec.ts @@ -0,0 +1,30 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AssessmentNebsHomeComponent } from './assessment-nebs-home.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { TableEntriesModule } from 'src/app/shared/table-entries/table-entries.module'; +import { RouterTestingModule } from '@angular/router/testing'; + +describe('AssessmentNebsHomeComponent', () => { + let component: AssessmentNebsHomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, HelperPipesModule, TableEntriesModule, RouterTestingModule], + declarations: [AssessmentNebsHomeComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(AssessmentNebsHomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component.ts b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component.ts new file mode 100644 index 00000000..df205e7a --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component.ts @@ -0,0 +1,123 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; +import { faPlus, faSearchPlus, faWeightHanging, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { firstValueFrom, Subscription } from 'rxjs'; +import { ToastNotificationsService } from 'src/app/core-components/toast-notifications/toast-notifications.service'; +import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; +import { ContactIdbService } from 'src/app/indexed-db/contact-idb.service'; +import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service'; +import { KeyPerformanceIndicatorsIdbService } from 'src/app/indexed-db/key-performance-indicators-idb.service'; +import { KeyPerformanceMetricImpactsIdbService } from 'src/app/indexed-db/key-performance-metric-impacts-idb.service'; +import { NonEnergyBenefitsIdbService } from 'src/app/indexed-db/non-energy-benefits-idb.service'; +import { IdbAssessment } from 'src/app/models/assessment'; +import { IdbContact } from 'src/app/models/contact'; +import { IdbEnergyOpportunity } from 'src/app/models/energyOpportunity'; +import { IdbKeyPerformanceMetricImpact } from 'src/app/models/keyPerformanceMetricImpact'; +import { getNewIdbNonEnergyBenefit, IdbNonEnergyBenefit } from 'src/app/models/nonEnergyBenefit'; +import { KeyPerformanceMetric } from 'src/app/shared/constants/keyPerformanceMetrics'; +import { SharedDataService } from 'src/app/shared/shared-services/shared-data.service'; + +@Component({ + selector: 'app-assessment-nebs-home', + templateUrl: './assessment-nebs-home.component.html', + styleUrl: './assessment-nebs-home.component.css' +}) +export class AssessmentNebsHomeComponent { + + faPlus: IconDefinition = faPlus; + faWeightHanging: IconDefinition = faWeightHanging; + faSearchPlus: IconDefinition = faSearchPlus; + + assessment: IdbAssessment; + assessmentSub: Subscription; + + energyOppNonEnergyBenefits: Array; + assessmentNonEnergyBenefits: Array; + + keyPerformanceMetricImpacts: Array; + keyPerformanceMetricImpactsSub: Subscription; + + contacts: Array; + contactsSub: Subscription; + + nonEnergyBenefitsSub: Subscription; + showAddNebDropdown: boolean = false; + keyPerformanceMetrics: Array; + keyPerformanceIndicatorsSub: Subscription; + + energyOpportunities: Array; + energyOpportunitiesSub: Subscription; + constructor(private assessmentIdbService: AssessmentIdbService, + private nonEnergyBenefitsIdbService: NonEnergyBenefitsIdbService, + private router: Router, + private toastNotificationsService: ToastNotificationsService, + private sharedDataService: SharedDataService, + private keyPerformanceMetricImpactsIdbService: KeyPerformanceMetricImpactsIdbService, + private contactIdbService: ContactIdbService, + private keyPerformanceIndicatorsIdbService: KeyPerformanceIndicatorsIdbService, + private energyOpportunityIdbService: EnergyOpportunityIdbService + + ) { } + + ngOnInit() { + this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(assessment => { + this.assessment = assessment; + }); + + this.nonEnergyBenefitsSub = this.nonEnergyBenefitsIdbService.nonEnergyBenefits.subscribe(nebs => { + this.assessmentNonEnergyBenefits = nebs.filter(neb => { + return neb.assessmentId == this.assessment.guid && neb.energyOpportunityId == undefined; + }); + this.energyOppNonEnergyBenefits = nebs.filter(neb => { + return neb.assessmentId == this.assessment.guid && neb.energyOpportunityId; + }); + }); + + this.keyPerformanceMetricImpactsSub = this.keyPerformanceMetricImpactsIdbService.keyPerformanceMetricImpacts.subscribe(kpmImpacts => { + this.keyPerformanceMetricImpacts = kpmImpacts; + }); + + this.contactsSub = this.contactIdbService.contacts.subscribe(contacts => { + this.contacts = contacts; + }); + + this.keyPerformanceIndicatorsSub = this.keyPerformanceIndicatorsIdbService.keyPerformanceIndicators.subscribe(kpis => { + this.keyPerformanceMetrics = kpis.flatMap(kpi => { + return kpi.performanceMetrics; + }) + }); + + this.energyOpportunitiesSub = this.energyOpportunityIdbService.energyOpportunities.subscribe(energyOpportunities => { + this.energyOpportunities = energyOpportunities + }); + + } + + ngOnDestroy() { + this.assessmentSub.unsubscribe(); + this.nonEnergyBenefitsSub.unsubscribe(); + this.keyPerformanceMetricImpactsSub.unsubscribe(); + this.contactsSub.unsubscribe(); + this.keyPerformanceIndicatorsSub.unsubscribe(); + this.energyOpportunitiesSub.unsubscribe(); + } + + showSuggestedNEBs() { + this.showAddNebDropdown = false; + this.sharedDataService.displayAddNebsModal.next({ + assessmentId: this.assessment.guid, + energyOpportunityId: undefined + }); + } + + async addNEB() { + this.showAddNebDropdown = false; + let newNonEnergyBenefit: IdbNonEnergyBenefit = getNewIdbNonEnergyBenefit(this.assessment.userId, this.assessment.companyId, this.assessment.facilityId, this.assessment.guid, undefined, undefined, true); + await firstValueFrom(this.nonEnergyBenefitsIdbService.addWithObservable(newNonEnergyBenefit)); + await this.nonEnergyBenefitsIdbService.setNonEnergyBenefits(); + } + + toggleAddNebDropdown() { + this.showAddNebDropdown = !this.showAddNebDropdown; + } +} diff --git a/src/app/company-dashboard/company-goals/company-goals.component.css b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs.component.css similarity index 100% rename from src/app/company-dashboard/company-goals/company-goals.component.css rename to src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs.component.css diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs.component.html b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs.component.html new file mode 100644 index 00000000..bbfb42b9 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs.component.html @@ -0,0 +1,42 @@ + \ No newline at end of file diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs.component.spec.ts b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs.component.spec.ts new file mode 100644 index 00000000..f6f3517b --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs.component.spec.ts @@ -0,0 +1,28 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AssessmentNebsComponent } from './assessment-nebs.component'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { RouterTestingModule } from '@angular/router/testing'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; + +describe('AssessmentNebsComponent', () => { + let component: AssessmentNebsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [RouterTestingModule, FontAwesomeModule], + declarations: [AssessmentNebsComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(AssessmentNebsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs.component.ts b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs.component.ts new file mode 100644 index 00000000..0a101fa6 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-nebs/assessment-nebs.component.ts @@ -0,0 +1,44 @@ +import { Component } from '@angular/core'; +import { faChevronRight, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; +import { NonEnergyBenefitsIdbService } from 'src/app/indexed-db/non-energy-benefits-idb.service'; +import { IdbAssessment } from 'src/app/models/assessment'; +import { IdbNonEnergyBenefit } from 'src/app/models/nonEnergyBenefit'; + +@Component({ + selector: 'app-assessment-nebs', + templateUrl: './assessment-nebs.component.html', + styleUrl: './assessment-nebs.component.css' +}) +export class AssessmentNebsComponent { + + faChevronRight: IconDefinition = faChevronRight; + + nonEnergyBenefits: Array; + nonEnergyBenefitsSub: Subscription; + + assessment: IdbAssessment; + assessmentSub: Subscription; + + constructor(private assessmentIdbService: AssessmentIdbService, + private nonEnergyBenefitsIdbService: NonEnergyBenefitsIdbService + ) { } + + ngOnInit() { + this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(assessment => { + this.assessment = assessment; + }); + + this.nonEnergyBenefitsSub = this.nonEnergyBenefitsIdbService.nonEnergyBenefits.subscribe(nonEnergyBenefits => { + this.nonEnergyBenefits = nonEnergyBenefits.filter(neb => { + return neb.assessmentId == this.assessment.guid && neb.energyOpportunityId == undefined; + }); + }) + } + + ngOnDestroy() { + this.assessmentSub.unsubscribe(); + this.nonEnergyBenefitsSub.unsubscribe(); + } +} diff --git a/src/app/company-dashboard/company-reports/company-reports.component.css b/src/app/user-portfolio/assessment-dashboard/assessment-reports/assessment-reports.component.css similarity index 100% rename from src/app/company-dashboard/company-reports/company-reports.component.css rename to src/app/user-portfolio/assessment-dashboard/assessment-reports/assessment-reports.component.css diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-reports/assessment-reports.component.html b/src/app/user-portfolio/assessment-dashboard/assessment-reports/assessment-reports.component.html new file mode 100644 index 00000000..650b9838 --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-reports/assessment-reports.component.html @@ -0,0 +1,6 @@ +
+
+ + +
+
\ No newline at end of file diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-reports/assessment-reports.component.spec.ts b/src/app/user-portfolio/assessment-dashboard/assessment-reports/assessment-reports.component.spec.ts new file mode 100644 index 00000000..3fd5e83f --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-reports/assessment-reports.component.spec.ts @@ -0,0 +1,27 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AssessmentReportsComponent } from './assessment-reports.component'; +import { ReportsModule } from 'src/app/shared/reports/reports.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('AssessmentReportsComponent', () => { + let component: AssessmentReportsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ReportsModule], + declarations: [AssessmentReportsComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(AssessmentReportsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/assessment-dashboard/assessment-reports/assessment-reports.component.ts b/src/app/user-portfolio/assessment-dashboard/assessment-reports/assessment-reports.component.ts new file mode 100644 index 00000000..4322b7cb --- /dev/null +++ b/src/app/user-portfolio/assessment-dashboard/assessment-reports/assessment-reports.component.ts @@ -0,0 +1,54 @@ +import { Component } from '@angular/core'; +import { Subscription } from 'rxjs'; +import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; +import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service'; +import { KeyPerformanceIndicatorsIdbService } from 'src/app/indexed-db/key-performance-indicators-idb.service'; +import { KeyPerformanceMetricImpactsIdbService } from 'src/app/indexed-db/key-performance-metric-impacts-idb.service'; +import { NonEnergyBenefitsIdbService } from 'src/app/indexed-db/non-energy-benefits-idb.service'; +import { IdbAssessment } from 'src/app/models/assessment'; +import { IdbEnergyOpportunity } from 'src/app/models/energyOpportunity'; +import { IdbKeyPerformanceMetricImpact } from 'src/app/models/keyPerformanceMetricImpact'; +import { IdbNonEnergyBenefit } from 'src/app/models/nonEnergyBenefit'; +import { KeyPerformanceMetric } from 'src/app/shared/constants/keyPerformanceMetrics'; +import { AssessmentReport, getAssessmentReport } from 'src/app/shared/reports/calculations/assessmentReport'; + +@Component({ + selector: 'app-assessment-reports', + templateUrl: './assessment-reports.component.html', + styleUrl: './assessment-reports.component.css' +}) +export class AssessmentReportsComponent { + + assessmentSub: Subscription; + assessment: IdbAssessment; + + assessmentReport: AssessmentReport; + constructor(private assessmentIdbService: AssessmentIdbService, + private energyOpportunityIdbService: EnergyOpportunityIdbService, + private nonEnergyBenefitIdbService: NonEnergyBenefitsIdbService, + private keyPerformanceIndicatorIdbService: KeyPerformanceIndicatorsIdbService, + private keyPerformanceMetricImpactsIdbService: KeyPerformanceMetricImpactsIdbService + + ) { + + } + + ngOnInit() { + this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(_assessment => { + this.assessment = _assessment; + this.setAssessmentReport(); + }); + } + + ngOnDestroy() { + this.assessmentSub.unsubscribe(); + } + + setAssessmentReport() { + let allEnergyOpportunities: Array = this.energyOpportunityIdbService.energyOpportunities.getValue(); + let allNonEnergyBenefits: Array = this.nonEnergyBenefitIdbService.nonEnergyBenefits.getValue(); + let companyPerformanceMetrics: Array = this.keyPerformanceIndicatorIdbService.getCompanyKeyPerformanceMetrics(this.assessment.companyId); + let keyPerformanceMetricImpacts: Array = this.keyPerformanceMetricImpactsIdbService.keyPerformanceMetricImpacts.getValue(); + this.assessmentReport = getAssessmentReport(this.assessment, allEnergyOpportunities, allNonEnergyBenefits, companyPerformanceMetrics, keyPerformanceMetricImpacts); + } +} diff --git a/src/app/facility-dashboard/facility-dashboard-home/assessments-table/assessments-table.component.css b/src/app/user-portfolio/company-dashboard/company-dashboard-home/company-dashboard-home.component.css similarity index 100% rename from src/app/facility-dashboard/facility-dashboard-home/assessments-table/assessments-table.component.css rename to src/app/user-portfolio/company-dashboard/company-dashboard-home/company-dashboard-home.component.css diff --git a/src/app/user-portfolio/company-dashboard/company-dashboard-home/company-dashboard-home.component.html b/src/app/user-portfolio/company-dashboard/company-dashboard-home/company-dashboard-home.component.html new file mode 100644 index 00000000..ebb545f8 --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-dashboard-home/company-dashboard-home.component.html @@ -0,0 +1,11 @@ +
+
+
+
+ + {{company.generalInformation.name}} +
+
+ +
+
\ No newline at end of file diff --git a/src/app/user-portfolio/company-dashboard/company-dashboard-home/company-dashboard-home.component.spec.ts b/src/app/user-portfolio/company-dashboard/company-dashboard-home/company-dashboard-home.component.spec.ts new file mode 100644 index 00000000..580987ae --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-dashboard-home/company-dashboard-home.component.spec.ts @@ -0,0 +1,32 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CompanyDashboardHomeComponent } from './company-dashboard-home.component'; +import { CompanyListItemComponent } from '../../portfolio-items-list/company-list-item/company-list-item.component'; +import { RouterTestingModule } from '@angular/router/testing'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { FacilityListItemComponent } from '../../portfolio-items-list/facility-list-item/facility-list-item.component'; +import { AssessmentListItemComponent } from '../../portfolio-items-list/assessment-list-item/assessment-list-item.component'; + +describe('CompanyDashboardHomeComponent', () => { + let component: CompanyDashboardHomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [RouterTestingModule, FontAwesomeModule, HelperPipesModule], + declarations: [CompanyDashboardHomeComponent, CompanyListItemComponent, FacilityListItemComponent, AssessmentListItemComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(CompanyDashboardHomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/company-dashboard/company-dashboard-home/company-dashboard-home.component.ts b/src/app/user-portfolio/company-dashboard/company-dashboard-home/company-dashboard-home.component.ts new file mode 100644 index 00000000..d426f95c --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-dashboard-home/company-dashboard-home.component.ts @@ -0,0 +1,39 @@ +import { Component } from '@angular/core'; +import { faBuilding, faCopy, faTrash, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { IdbCompany } from 'src/app/models/company'; + +@Component({ + selector: 'app-company-dashboard-home', + templateUrl: './company-dashboard-home.component.html', + styleUrl: './company-dashboard-home.component.css' +}) +export class CompanyDashboardHomeComponent { + + faBuilding: IconDefinition = faBuilding; + faTrash: IconDefinition = faTrash; + faCopy: IconDefinition = faCopy; + company: IdbCompany; + companySub: Subscription; + constructor(private companyIdbService: CompanyIdbService) { + } + + ngOnInit() { + this.companySub = this.companyIdbService.selectedCompany.subscribe(company => { + this.company = company; + }) + } + + ngOnDestroy() { + this.companySub.unsubscribe(); + } + + openCreateCopyModal(){ + + } + + openDeleteCompanyModal(){ + + } +} diff --git a/src/app/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.css b/src/app/user-portfolio/company-dashboard/company-dashboard-nav/company-dashboard-nav.component.css similarity index 100% rename from src/app/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.css rename to src/app/user-portfolio/company-dashboard/company-dashboard-nav/company-dashboard-nav.component.css diff --git a/src/app/user-portfolio/company-dashboard/company-dashboard-nav/company-dashboard-nav.component.html b/src/app/user-portfolio/company-dashboard/company-dashboard-nav/company-dashboard-nav.component.html new file mode 100644 index 00000000..84f70005 --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-dashboard-nav/company-dashboard-nav.component.html @@ -0,0 +1,34 @@ + \ No newline at end of file diff --git a/src/app/user-dashboard/user-dashboard-tabs/user-dashboard-tabs.component.spec.ts b/src/app/user-portfolio/company-dashboard/company-dashboard-nav/company-dashboard-nav.component.spec.ts similarity index 51% rename from src/app/user-dashboard/user-dashboard-tabs/user-dashboard-tabs.component.spec.ts rename to src/app/user-portfolio/company-dashboard/company-dashboard-nav/company-dashboard-nav.component.spec.ts index 4c0d0da4..e4081cd3 100644 --- a/src/app/user-dashboard/user-dashboard-tabs/user-dashboard-tabs.component.spec.ts +++ b/src/app/user-portfolio/company-dashboard/company-dashboard-nav/company-dashboard-nav.component.spec.ts @@ -1,21 +1,23 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { UserDashboardTabsComponent } from './user-dashboard-tabs.component'; +import { CompanyDashboardNavComponent } from './company-dashboard-nav.component'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { RouterTestingModule } from '@angular/router/testing'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; -describe('UserDashboardTabsComponent', () => { - let component: UserDashboardTabsComponent; - let fixture: ComponentFixture; +describe('CompanyDashboardNavComponent', () => { + let component: CompanyDashboardNavComponent; + let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ imports: [FontAwesomeModule, RouterTestingModule], - declarations: [UserDashboardTabsComponent] + declarations: [CompanyDashboardNavComponent], + providers: stubServiceProviders }) .compileComponents(); - - fixture = TestBed.createComponent(UserDashboardTabsComponent); + + fixture = TestBed.createComponent(CompanyDashboardNavComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/src/app/user-portfolio/company-dashboard/company-dashboard-nav/company-dashboard-nav.component.ts b/src/app/user-portfolio/company-dashboard/company-dashboard-nav/company-dashboard-nav.component.ts new file mode 100644 index 00000000..10b6bc9b --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-dashboard-nav/company-dashboard-nav.component.ts @@ -0,0 +1,33 @@ +import { Component } from '@angular/core'; +import { faAddressBook, faBullseye, faFile, faGears, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { IdbCompany } from 'src/app/models/company'; + +@Component({ + selector: 'app-company-dashboard-nav', + templateUrl: './company-dashboard-nav.component.html', + styleUrl: './company-dashboard-nav.component.css' +}) +export class CompanyDashboardNavComponent { + + faFile: IconDefinition = faFile; + faGears: IconDefinition = faGears; + faAddressBook: IconDefinition = faAddressBook; + faBullseye: IconDefinition = faBullseye; + + company: IdbCompany; + companySub: Subscription; + constructor(private companyIdbService: CompanyIdbService) { + } + + ngOnInit() { + this.companySub = this.companyIdbService.selectedCompany.subscribe(company => { + this.company = company; + }) + } + + ngOnDestroy() { + this.companySub.unsubscribe(); + } +} diff --git a/src/app/facility-dashboard/facility-dashboard-home/facility-production-details/facility-production-details.component.css b/src/app/user-portfolio/company-dashboard/company-dashboard.component.css similarity index 100% rename from src/app/facility-dashboard/facility-dashboard-home/facility-production-details/facility-production-details.component.css rename to src/app/user-portfolio/company-dashboard/company-dashboard.component.css diff --git a/src/app/user-portfolio/company-dashboard/company-dashboard.component.html b/src/app/user-portfolio/company-dashboard/company-dashboard.component.html new file mode 100644 index 00000000..5f537bdd --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-dashboard.component.html @@ -0,0 +1,6 @@ +
+ +
+
+ +
\ No newline at end of file diff --git a/src/app/company-dashboard/company-dashboard.component.spec.ts b/src/app/user-portfolio/company-dashboard/company-dashboard.component.spec.ts similarity index 54% rename from src/app/company-dashboard/company-dashboard.component.spec.ts rename to src/app/user-portfolio/company-dashboard/company-dashboard.component.spec.ts index e912710d..65c731b2 100644 --- a/src/app/company-dashboard/company-dashboard.component.spec.ts +++ b/src/app/user-portfolio/company-dashboard/company-dashboard.component.spec.ts @@ -1,27 +1,23 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CompanyDashboardComponent } from './company-dashboard.component'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; import { RouterTestingModule } from '@angular/router/testing'; -import { CompanyIdbService } from '../indexed-db/company-idb.service'; -import { BehaviorSubject } from 'rxjs'; -import { IdbCompany, getNewIdbCompany } from '../models/company'; -import { CompanyDashboardTabsComponent } from './company-dashboard-tabs/company-dashboard-tabs.component'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { CompanyDashboardNavComponent } from './company-dashboard-nav/company-dashboard-nav.component'; describe('CompanyDashboardComponent', () => { let component: CompanyDashboardComponent; let fixture: ComponentFixture; - beforeEach(() => { - let companyDbServiceStub: Partial = { - companies: new BehaviorSubject>([]), - selectedCompany: new BehaviorSubject(getNewIdbCompany('')) - } - TestBed.configureTestingModule({ + beforeEach(async () => { + await TestBed.configureTestingModule({ imports: [RouterTestingModule, FontAwesomeModule], - declarations: [CompanyDashboardComponent, CompanyDashboardTabsComponent], - providers: [{ provide: CompanyIdbService, useValue: companyDbServiceStub }], - }); + declarations: [CompanyDashboardComponent, CompanyDashboardNavComponent], + providers: stubServiceProviders + }) + .compileComponents(); + fixture = TestBed.createComponent(CompanyDashboardComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/app/user-portfolio/company-dashboard/company-dashboard.component.ts b/src/app/user-portfolio/company-dashboard/company-dashboard.component.ts new file mode 100644 index 00000000..3052ba14 --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-dashboard.component.ts @@ -0,0 +1,29 @@ +import { Component } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { faBuilding, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { IdbCompany } from 'src/app/models/company'; + +@Component({ + selector: 'app-company-dashboard', + templateUrl: './company-dashboard.component.html', + styleUrl: './company-dashboard.component.css' +}) +export class CompanyDashboardComponent { + + faBuilding: IconDefinition = faBuilding; + company: IdbCompany; + constructor(private activatedRoute: ActivatedRoute, + private companyIdbService: CompanyIdbService + ) { + + } + + ngOnInit() { + this.activatedRoute.params.subscribe(params => { + let guid: string = params['id']; + this.company = this.companyIdbService.getByGUID(guid); + this.companyIdbService.selectedCompany.next(this.company); + }); + } +} diff --git a/src/app/facility-dashboard/facility-dashboard-tabs/facility-dashboard-tabs.component.css b/src/app/user-portfolio/company-dashboard/company-performance-indicators/company-performance-indicators.component.css similarity index 100% rename from src/app/facility-dashboard/facility-dashboard-tabs/facility-dashboard-tabs.component.css rename to src/app/user-portfolio/company-dashboard/company-performance-indicators/company-performance-indicators.component.css diff --git a/src/app/user-portfolio/company-dashboard/company-performance-indicators/company-performance-indicators.component.html b/src/app/user-portfolio/company-dashboard/company-performance-indicators/company-performance-indicators.component.html new file mode 100644 index 00000000..6d8eddc4 --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-performance-indicators/company-performance-indicators.component.html @@ -0,0 +1,42 @@ + \ No newline at end of file diff --git a/src/app/user-portfolio/company-dashboard/company-performance-indicators/company-performance-indicators.component.spec.ts b/src/app/user-portfolio/company-dashboard/company-performance-indicators/company-performance-indicators.component.spec.ts new file mode 100644 index 00000000..c7a8398f --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-performance-indicators/company-performance-indicators.component.spec.ts @@ -0,0 +1,29 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CompanyPerformanceIndicatorsComponent } from './company-performance-indicators.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { SharedCompanyFormsModule } from 'src/app/shared/shared-company-forms/shared-company-forms.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { RouterModule } from '@angular/router'; + +describe('CompanyPerformanceIndicatorsComponent', () => { + let component: CompanyPerformanceIndicatorsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, SharedCompanyFormsModule, RouterModule], + declarations: [CompanyPerformanceIndicatorsComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(CompanyPerformanceIndicatorsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/company-dashboard/company-performance-indicators/company-performance-indicators.component.ts b/src/app/user-portfolio/company-dashboard/company-performance-indicators/company-performance-indicators.component.ts new file mode 100644 index 00000000..90aedbe8 --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-performance-indicators/company-performance-indicators.component.ts @@ -0,0 +1,45 @@ +import { Component } from '@angular/core'; +import { faBullseye, faChevronRight, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { KeyPerformanceIndicatorsIdbService } from 'src/app/indexed-db/key-performance-indicators-idb.service'; +import { IdbCompany } from 'src/app/models/company'; +import { IdbKeyPerformanceIndicator } from 'src/app/models/keyPerformanceIndicator'; + +@Component({ + selector: 'app-company-performance-indicators', + templateUrl: './company-performance-indicators.component.html', + styleUrl: './company-performance-indicators.component.css' +}) +export class CompanyPerformanceIndicatorsComponent { + + faBullseye: IconDefinition = faBullseye; + faChevronRight: IconDefinition = faChevronRight; + + keyPerformanceIndicators: Array; + keyPerformanceIndicatorsSub: Subscription; + + company: IdbCompany; + companySub: Subscription; + constructor(private keyPerformanceIndicatorIdbService: KeyPerformanceIndicatorsIdbService, + private companyIdbService: CompanyIdbService + ) { + } + + ngOnInit() { + this.companySub = this.companyIdbService.selectedCompany.subscribe(company => { + this.company = company; + }) + + this.keyPerformanceIndicatorsSub = this.keyPerformanceIndicatorIdbService.keyPerformanceIndicators.subscribe(kpis => { + this.keyPerformanceIndicators = kpis.filter(kpi => { + return kpi.companyId == this.company.guid + }); + }); + } + + ngOnDestroy() { + this.companySub.unsubscribe(); + this.keyPerformanceIndicatorsSub.unsubscribe(); + } +} diff --git a/src/app/facility-dashboard/facility-dashboard.component.css b/src/app/user-portfolio/company-dashboard/company-reports/company-reports.component.css similarity index 100% rename from src/app/facility-dashboard/facility-dashboard.component.css rename to src/app/user-portfolio/company-dashboard/company-reports/company-reports.component.css diff --git a/src/app/user-portfolio/company-dashboard/company-reports/company-reports.component.html b/src/app/user-portfolio/company-dashboard/company-reports/company-reports.component.html new file mode 100644 index 00000000..b2ad590b --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-reports/company-reports.component.html @@ -0,0 +1,7 @@ +
+
+
+ Company level reports coming soon. +
+
+
\ No newline at end of file diff --git a/src/app/company-dashboard/company-reports/company-reports.component.spec.ts b/src/app/user-portfolio/company-dashboard/company-reports/company-reports.component.spec.ts similarity index 99% rename from src/app/company-dashboard/company-reports/company-reports.component.spec.ts rename to src/app/user-portfolio/company-dashboard/company-reports/company-reports.component.spec.ts index 91d1a98b..952e9430 100644 --- a/src/app/company-dashboard/company-reports/company-reports.component.spec.ts +++ b/src/app/user-portfolio/company-dashboard/company-reports/company-reports.component.spec.ts @@ -11,7 +11,7 @@ describe('CompanyReportsComponent', () => { declarations: [CompanyReportsComponent] }) .compileComponents(); - + fixture = TestBed.createComponent(CompanyReportsComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/app/company-dashboard/company-reports/company-reports.component.ts b/src/app/user-portfolio/company-dashboard/company-reports/company-reports.component.ts similarity index 100% rename from src/app/company-dashboard/company-reports/company-reports.component.ts rename to src/app/user-portfolio/company-dashboard/company-reports/company-reports.component.ts diff --git a/src/app/facility-dashboard/facility-goals/facility-goals.component.css b/src/app/user-portfolio/company-dashboard/company-settings/company-settings.component.css similarity index 100% rename from src/app/facility-dashboard/facility-goals/facility-goals.component.css rename to src/app/user-portfolio/company-dashboard/company-settings/company-settings.component.css diff --git a/src/app/user-portfolio/company-dashboard/company-settings/company-settings.component.html b/src/app/user-portfolio/company-dashboard/company-settings/company-settings.component.html new file mode 100644 index 00000000..bedf20ef --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-settings/company-settings.component.html @@ -0,0 +1,89 @@ +
+
+ +
+
+
+
+ Create Company Copy +
+

+ Use the button below to create a copy of this company. A copy of this company will be added to your + JUSTIFI portfolio. +

+ +
+
+
+ Delete Company +
+

+ Use the button below to delete this company and all of its corresponding data. This action cannot be + undone. +

+ +
+
+
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/src/app/user-portfolio/company-dashboard/company-settings/company-settings.component.spec.ts b/src/app/user-portfolio/company-dashboard/company-settings/company-settings.component.spec.ts new file mode 100644 index 00000000..ded4c974 --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-settings/company-settings.component.spec.ts @@ -0,0 +1,28 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CompanySettingsComponent } from './company-settings.component'; +import { SharedCompanyFormsModule } from 'src/app/shared/shared-company-forms/shared-company-forms.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; + +describe('CompanySettingsComponent', () => { + let component: CompanySettingsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [SharedCompanyFormsModule, FontAwesomeModule], + declarations: [CompanySettingsComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(CompanySettingsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/company-dashboard/company-settings/company-settings.component.ts b/src/app/user-portfolio/company-dashboard/company-settings/company-settings.component.ts new file mode 100644 index 00000000..38a16fdd --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-settings/company-settings.component.ts @@ -0,0 +1,101 @@ +import { Component } from '@angular/core'; +import { FormControl, Validators } from '@angular/forms'; +import { Router } from '@angular/router'; +import { faCopy, faTrash, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Observable, of, Subscription } from 'rxjs'; +import { LoadingService } from 'src/app/core-components/loading/loading.service'; +import { ToastNotificationsService } from 'src/app/core-components/toast-notifications/toast-notifications.service'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { DbChangesService } from 'src/app/indexed-db/db-changes.service'; +import { IdbCompany } from 'src/app/models/company'; + +@Component({ + selector: 'app-company-settings', + templateUrl: './company-settings.component.html', + styleUrl: './company-settings.component.css' +}) +export class CompanySettingsComponent { + + faTrash: IconDefinition = faTrash; + faCopy: IconDefinition = faCopy; + + showDeleteCompanyModal: boolean = false; + showCreateCopyModal: boolean = false; + + + company: IdbCompany; + companySub: Subscription; + name: FormControl; + routeGuardWarningModal: boolean = false; + + hasAssessments: boolean = false; + constructor( + private companyIdbService: CompanyIdbService, + private dbChangesService: DbChangesService, + private loadingService: LoadingService, + private toastNotificationService: ToastNotificationsService, + private router: Router + ) { + + } + + ngOnInit() { + this.companySub = this.companyIdbService.selectedCompany.subscribe(_company => { + this.company = _company; + if (this.company) { + this.name = new FormControl(this.company.generalInformation.name, [Validators.required]); + } + }); + } + + canDeactivate(): Observable { + if (this.name && this.name.getError('required')) { + this.name.markAsTouched(); + this.displayWarningModal(); + return of(false); + } + return of(true); + } + + ngOnDestroy() { + this.companySub.unsubscribe(); + } + + + displayWarningModal() { + this.routeGuardWarningModal = true; + } + closeWarningModal() { + this.routeGuardWarningModal = false; + } + + openDeleteCompanyModal() { + this.showDeleteCompanyModal = true; + } + + closeDeleteCompanyModal() { + this.showDeleteCompanyModal = false; + } + + openCreateCopyModal() { + this.showCreateCopyModal = true; + } + + closeCreateCopyModal() { + this.showCreateCopyModal = false; + } + + confirmCreateCopy() { + //TODO... + } + + async confirmDelete() { + this.showDeleteCompanyModal = false; + this.loadingService.setLoadingMessage('Deleting ' + this.company.generalInformation.name + '...'); + this.loadingService.setLoadingStatus(true); + await this.dbChangesService.deleteCompany(this.company); + this.loadingService.setLoadingStatus(false); + this.toastNotificationService.showToast('Company Deleted!', undefined, 'bg-success', true, false); + this.router.navigateByUrl('/portfolio'); + } +} diff --git a/src/app/facility-dashboard/facility-reports/facility-reports.component.css b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component.css similarity index 100% rename from src/app/facility-dashboard/facility-reports/facility-reports.component.css rename to src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component.css diff --git a/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component.html b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component.html new file mode 100644 index 00000000..7a4e2871 --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component.html @@ -0,0 +1,53 @@ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
+ Name + + Title + + Team + + Notes +
+ {{contact | contactNameDisplay}} + + + + + + +
+
+ + +
+ No stakeholders found for this company. Use the " + Add New Stakeholder" button to add a stakeholder to this company. +
+
\ No newline at end of file diff --git a/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component.spec.ts b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component.spec.ts new file mode 100644 index 00000000..0133fad5 --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component.spec.ts @@ -0,0 +1,30 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CompanyStakeholdersHomeComponent } from './company-stakeholders-home.component'; +import { SharedCompanyFormsModule } from 'src/app/shared/shared-company-forms/shared-company-forms.module'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { TableEntriesModule } from 'src/app/shared/table-entries/table-entries.module'; + +describe('CompanyStakeholdersHomeComponent', () => { + let component: CompanyStakeholdersHomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [SharedCompanyFormsModule, FontAwesomeModule, HelperPipesModule, TableEntriesModule], + declarations: [CompanyStakeholdersHomeComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(CompanyStakeholdersHomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component.ts b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component.ts new file mode 100644 index 00000000..0dc9fa91 --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component.ts @@ -0,0 +1,56 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; +import { faPlus, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { firstValueFrom, Subscription } from 'rxjs'; +import { ToastNotificationsService } from 'src/app/core-components/toast-notifications/toast-notifications.service'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { ContactIdbService } from 'src/app/indexed-db/contact-idb.service'; +import { IdbCompany } from 'src/app/models/company'; +import { getNewIdbContact, IdbContact } from 'src/app/models/contact'; + +@Component({ + selector: 'app-company-stakeholders-home', + templateUrl: './company-stakeholders-home.component.html', + styleUrl: './company-stakeholders-home.component.css' +}) +export class CompanyStakeholdersHomeComponent { + + faPlus: IconDefinition = faPlus; + companyContacts: Array; + contactsSub: Subscription; + + company: IdbCompany; + selectedCompanySub: Subscription; + constructor( + private companyIdbService: CompanyIdbService, + private contactIdbService: ContactIdbService, + private toastNotificationService: ToastNotificationsService, + private router: Router + ) { + } + + ngOnInit() { + this.selectedCompanySub = this.companyIdbService.selectedCompany.subscribe(_company => { + this.company = _company; + }); + + this.contactsSub = this.contactIdbService.contacts.subscribe(_contacts => { + this.companyContacts = _contacts.filter(contact => { + return contact.companyId == this.company.guid + }); + }); + } + + ngOnDestroy() { + this.selectedCompanySub.unsubscribe(); + this.contactsSub.unsubscribe(); + } + + async addContact() { + let newContact: IdbContact = getNewIdbContact(this.company.userId, this.company.guid); + newContact = await firstValueFrom(this.contactIdbService.addWithObservable(newContact)); + await this.contactIdbService.setContacts(); + this.toastNotificationService.showToast('Stakeholder Added!', 'A new stakeholder has been added to ' + this.company.generalInformation.name, 'bg-success', true, false); + this.router.navigateByUrl('/portfolio/company/' + newContact.companyId + '/stakeholders/' + newContact.guid); + } +} diff --git a/src/app/user-dashboard/user-dashboard-help/user-dashboard-help.component.css b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders.component.css similarity index 100% rename from src/app/user-dashboard/user-dashboard-help/user-dashboard-help.component.css rename to src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders.component.css diff --git a/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders.component.html b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders.component.html new file mode 100644 index 00000000..b1074248 --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders.component.html @@ -0,0 +1,41 @@ + \ No newline at end of file diff --git a/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders.component.spec.ts b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders.component.spec.ts new file mode 100644 index 00000000..cab1b876 --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders.component.spec.ts @@ -0,0 +1,29 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CompanyStakeholdersComponent } from './company-stakeholders.component'; +import { RouterTestingModule } from '@angular/router/testing'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; + +describe('CompanyStakeholdersComponent', () => { + let component: CompanyStakeholdersComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [RouterTestingModule, FontAwesomeModule, HelperPipesModule], + declarations: [CompanyStakeholdersComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(CompanyStakeholdersComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders.component.ts b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders.component.ts new file mode 100644 index 00000000..3a78d61f --- /dev/null +++ b/src/app/user-portfolio/company-dashboard/company-stakeholders/company-stakeholders.component.ts @@ -0,0 +1,46 @@ +import { Component } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { faChevronRight, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Observable, of, Subscription } from 'rxjs'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { ContactIdbService } from 'src/app/indexed-db/contact-idb.service'; +import { IdbCompany } from 'src/app/models/company'; +import { IdbContact } from 'src/app/models/contact'; +import { CompanyContactsFormService } from 'src/app/shared/shared-company-forms/company-contacts-form/company-contacts-form.service'; + +@Component({ + selector: 'app-company-stakeholders', + templateUrl: './company-stakeholders.component.html', + styleUrl: './company-stakeholders.component.css' +}) +export class CompanyStakeholdersComponent { + faChevronRight: IconDefinition = faChevronRight; + + companyContacts: Array; + contactsSub: Subscription; + + company: IdbCompany; + selectedCompanySub: Subscription; + constructor( + private companyIdbService: CompanyIdbService, + private contactIdbService: ContactIdbService + ) { + } + + ngOnInit() { + this.selectedCompanySub = this.companyIdbService.selectedCompany.subscribe(_company => { + this.company = _company; + }); + + this.contactsSub = this.contactIdbService.contacts.subscribe(_contacts => { + this.companyContacts = _contacts.filter(contact => { + return contact.companyId == this.company.guid + }); + }); + } + + ngOnDestroy() { + this.selectedCompanySub.unsubscribe(); + this.contactsSub.unsubscribe(); + } +} diff --git a/src/app/user-dashboard/user-dashboard-home/assessments-table/assessments-table.component.css b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component.css similarity index 100% rename from src/app/user-dashboard/user-dashboard-home/assessments-table/assessments-table.component.css rename to src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component.css diff --git a/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component.html b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component.html new file mode 100644 index 00000000..68ad1145 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component.html @@ -0,0 +1,55 @@ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + +
+ Name + + Notes + + Stakeholders +
+ {{processEquipment.equipmentName}} + + + + @let associatedContacts = processEquipment.guid | associatedContacts:'processEquipment': contacts; + + + {{contact | contactNameDisplay}}
+
+
+ + — + +
+
+ + +
+ No end use inventory items found for this facility. Use the " + Add End Use" button to add an end use item to this facility. +
+
\ No newline at end of file diff --git a/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component.spec.ts b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component.spec.ts new file mode 100644 index 00000000..d90a8a6f --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component.spec.ts @@ -0,0 +1,30 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EndUseInventoryHomeComponent } from './end-use-inventory-home.component'; +import { TableEntriesModule } from 'src/app/shared/table-entries/table-entries.module'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { SharedCompanyFormsModule } from 'src/app/shared/shared-company-forms/shared-company-forms.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('EndUseInventoryHomeComponent', () => { + let component: EndUseInventoryHomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [SharedCompanyFormsModule, FontAwesomeModule, HelperPipesModule, TableEntriesModule], + declarations: [EndUseInventoryHomeComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(EndUseInventoryHomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component.ts b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component.ts new file mode 100644 index 00000000..453f2388 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component.ts @@ -0,0 +1,62 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; +import { faPlus, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { firstValueFrom, Subscription } from 'rxjs'; +import { ToastNotificationsService } from 'src/app/core-components/toast-notifications/toast-notifications.service'; +import { ContactIdbService } from 'src/app/indexed-db/contact-idb.service'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { ProcessEquipmentIdbService } from 'src/app/indexed-db/process-equipment-idb.service'; +import { IdbContact } from 'src/app/models/contact'; +import { IdbFacility } from 'src/app/models/facility'; +import { getNewIdbProcessEquipment, IdbProcessEquipment } from 'src/app/models/processEquipment'; + +@Component({ + selector: 'app-end-use-inventory-home', + templateUrl: './end-use-inventory-home.component.html', + styleUrl: './end-use-inventory-home.component.css' +}) +export class EndUseInventoryHomeComponent { + + faPlus: IconDefinition = faPlus; + facility: IdbFacility; + facilitySub: Subscription; + processEquipmentSub: Subscription + processEquipments: Array; + contacts: Array; + contactsSub: Subscription; + constructor(private facilityIdbService: FacilityIdbService, + private processEquipmentIdbService: ProcessEquipmentIdbService, + private contactIdbService: ContactIdbService, + private toastNotificationService: ToastNotificationsService, + private router: Router + ) { } + + ngOnInit() { + this.facilitySub = this.facilityIdbService.selectedFacility.subscribe(facility => { + this.facility = facility; + }); + + this.processEquipmentSub = this.processEquipmentIdbService.processEquipments.subscribe(processEquipments => { + this.processEquipments = processEquipments.filter(equipment => { + return equipment.facilityId == this.facility.guid; + }); + }); + this.contactsSub = this.contactIdbService.contacts.subscribe(contacts => { + this.contacts = contacts; + }); + } + + ngOnDestroy() { + this.processEquipmentSub.unsubscribe(); + this.facilitySub.unsubscribe(); + this.contactsSub.unsubscribe(); + } + + async addEquipment() { + let newProcessEquipment: IdbProcessEquipment = getNewIdbProcessEquipment(this.facility.userId, this.facility.companyId, this.facility.guid); + await firstValueFrom(this.processEquipmentIdbService.addWithObservable(newProcessEquipment)); + await this.processEquipmentIdbService.setProcessEquipments(); + this.toastNotificationService.showToast('End Use Added!', 'New end use item has been added to the inventory for ' + this.facility.generalInformation.name + '!', 'bg-success', true, false); + this.router.navigateByUrl('/portfolio/facility/' + newProcessEquipment.facilityId + '/end-use-inventory/' + newProcessEquipment.guid); + } +} diff --git a/src/app/user-dashboard/user-dashboard-home/companies-table/companies-table.component.css b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory.component.css similarity index 100% rename from src/app/user-dashboard/user-dashboard-home/companies-table/companies-table.component.css rename to src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory.component.css diff --git a/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory.component.html b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory.component.html new file mode 100644 index 00000000..08f844b0 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory.component.html @@ -0,0 +1,42 @@ + \ No newline at end of file diff --git a/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory.component.spec.ts b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory.component.spec.ts new file mode 100644 index 00000000..edfdc4d8 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory.component.spec.ts @@ -0,0 +1,28 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EndUseInventoryComponent } from './end-use-inventory.component'; +import { RouterTestingModule } from '@angular/router/testing'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('EndUseInventoryComponent', () => { + let component: EndUseInventoryComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [RouterTestingModule, FontAwesomeModule], + declarations: [EndUseInventoryComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(EndUseInventoryComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory.component.ts b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory.component.ts new file mode 100644 index 00000000..1994e3bd --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/end-use-inventory/end-use-inventory.component.ts @@ -0,0 +1,43 @@ +import { Component } from '@angular/core'; +import { faChevronRight, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { ProcessEquipmentIdbService } from 'src/app/indexed-db/process-equipment-idb.service'; +import { IdbFacility } from 'src/app/models/facility'; +import { IdbProcessEquipment } from 'src/app/models/processEquipment'; + +@Component({ + selector: 'app-end-use-inventory', + templateUrl: './end-use-inventory.component.html', + styleUrl: './end-use-inventory.component.css' +}) +export class EndUseInventoryComponent { + + faChevronRight: IconDefinition = faChevronRight; + + facility: IdbFacility; + facilitySub: Subscription; + processEquipmentSub: Subscription + processEquipments: Array; + + constructor(private facilityIdbService: FacilityIdbService, + private processEquipmentIdbService: ProcessEquipmentIdbService + ) { } + + ngOnInit() { + this.facilitySub = this.facilityIdbService.selectedFacility.subscribe(facility => { + this.facility = facility; + }); + + this.processEquipmentSub = this.processEquipmentIdbService.processEquipments.subscribe(processEquipments => { + this.processEquipments = processEquipments.filter(equipment => { + return equipment.facilityId == this.facility.guid; + }); + }); + } + + ngOnDestroy() { + this.processEquipmentSub.unsubscribe(); + this.facilitySub.unsubscribe(); + } +} diff --git a/src/app/user-dashboard/user-dashboard-home/facilities-table/facilities-table.component.css b/src/app/user-portfolio/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.css similarity index 100% rename from src/app/user-dashboard/user-dashboard-home/facilities-table/facilities-table.component.css rename to src/app/user-portfolio/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.css diff --git a/src/app/user-portfolio/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.html b/src/app/user-portfolio/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.html new file mode 100644 index 00000000..52c58e04 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.html @@ -0,0 +1,11 @@ +
+
+
+
+ + {{facility.generalInformation.name}} +
+
+ +
+
\ No newline at end of file diff --git a/src/app/user-portfolio/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.spec.ts b/src/app/user-portfolio/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.spec.ts new file mode 100644 index 00000000..e8ddd47c --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.spec.ts @@ -0,0 +1,30 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FacilityDashboardHomeComponent } from './facility-dashboard-home.component'; +import { FacilityListItemComponent } from '../../portfolio-items-list/facility-list-item/facility-list-item.component'; +import { AssessmentListItemComponent } from '../../portfolio-items-list/assessment-list-item/assessment-list-item.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('FacilityDashboardHomeComponent', () => { + let component: FacilityDashboardHomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, HelperPipesModule], + declarations: [FacilityDashboardHomeComponent, FacilityListItemComponent, AssessmentListItemComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(FacilityDashboardHomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.ts b/src/app/user-portfolio/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.ts new file mode 100644 index 00000000..fdcf9ee8 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-dashboard-home/facility-dashboard-home.component.ts @@ -0,0 +1,29 @@ +import { Component } from '@angular/core'; +import { faIndustry, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { IdbFacility } from 'src/app/models/facility'; + +@Component({ + selector: 'app-facility-dashboard-home', + templateUrl: './facility-dashboard-home.component.html', + styleUrl: './facility-dashboard-home.component.css' +}) +export class FacilityDashboardHomeComponent { + + faIndustry: IconDefinition = faIndustry; + + facility: IdbFacility; + facilitySub: Subscription; + constructor(private facilityIdbService: FacilityIdbService) { } + + ngOnInit(){ + this.facilitySub = this.facilityIdbService.selectedFacility.subscribe(facility => { + this.facility = facility; + }) + } + + ngOnDestroy(){ + this.facilitySub.unsubscribe(); + } +} diff --git a/src/app/user-dashboard/user-dashboard-home/user-dashboard-home.component.css b/src/app/user-portfolio/facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component.css similarity index 100% rename from src/app/user-dashboard/user-dashboard-home/user-dashboard-home.component.css rename to src/app/user-portfolio/facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component.css diff --git a/src/app/user-portfolio/facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component.html b/src/app/user-portfolio/facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component.html new file mode 100644 index 00000000..f974d962 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component.html @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/src/app/user-portfolio/facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component.spec.ts b/src/app/user-portfolio/facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component.spec.ts new file mode 100644 index 00000000..94f995db --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component.spec.ts @@ -0,0 +1,28 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FacilityDashboardNavComponent } from './facility-dashboard-nav.component'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { RouterTestingModule } from '@angular/router/testing'; + +describe('FacilityDashboardNavComponent', () => { + let component: FacilityDashboardNavComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, RouterTestingModule], + declarations: [FacilityDashboardNavComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(FacilityDashboardNavComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component.ts b/src/app/user-portfolio/facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component.ts new file mode 100644 index 00000000..7aec86d1 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component.ts @@ -0,0 +1,32 @@ +import { Component } from '@angular/core'; +import { faDiagramProject, faFile, faGears, faList, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { IdbFacility } from 'src/app/models/facility'; + +@Component({ + selector: 'app-facility-dashboard-nav', + templateUrl: './facility-dashboard-nav.component.html', + styleUrl: './facility-dashboard-nav.component.css' +}) +export class FacilityDashboardNavComponent { + + faGears: IconDefinition = faGears; + faFile: IconDefinition = faFile; + faList: IconDefinition = faList; + faDiagramProject: IconDefinition = faDiagramProject; + + facility: IdbFacility; + facilitySub: Subscription; + constructor(private facilityIdbService: FacilityIdbService) { } + + ngOnInit(){ + this.facilitySub = this.facilityIdbService.selectedFacility.subscribe(facility => { + this.facility = facility; + }) + } + + ngOnDestroy(){ + this.facilitySub.unsubscribe(); + } +} diff --git a/src/app/user-dashboard/user-dashboard-tabs/user-dashboard-tabs.component.css b/src/app/user-portfolio/facility-dashboard/facility-dashboard.component.css similarity index 100% rename from src/app/user-dashboard/user-dashboard-tabs/user-dashboard-tabs.component.css rename to src/app/user-portfolio/facility-dashboard/facility-dashboard.component.css diff --git a/src/app/user-portfolio/facility-dashboard/facility-dashboard.component.html b/src/app/user-portfolio/facility-dashboard/facility-dashboard.component.html new file mode 100644 index 00000000..334f094a --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-dashboard.component.html @@ -0,0 +1,6 @@ +
+ +
+
+ +
\ No newline at end of file diff --git a/src/app/facility-dashboard/facility-dashboard.component.spec.ts b/src/app/user-portfolio/facility-dashboard/facility-dashboard.component.spec.ts similarity index 53% rename from src/app/facility-dashboard/facility-dashboard.component.spec.ts rename to src/app/user-portfolio/facility-dashboard/facility-dashboard.component.spec.ts index b4687a4c..65f9626a 100644 --- a/src/app/facility-dashboard/facility-dashboard.component.spec.ts +++ b/src/app/user-portfolio/facility-dashboard/facility-dashboard.component.spec.ts @@ -1,27 +1,23 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FacilityDashboardComponent } from './facility-dashboard.component'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; import { RouterTestingModule } from '@angular/router/testing'; -import { FacilityIdbService } from '../indexed-db/facility-idb.service'; -import { FacilityDashboardTabsComponent } from './facility-dashboard-tabs/facility-dashboard-tabs.component'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { BehaviorSubject } from 'rxjs'; -import { IdbFacility, getNewIdbFacility } from '../models/facility'; +import { FacilityDashboardNavComponent } from './facility-dashboard-nav/facility-dashboard-nav.component'; describe('FacilityDashboardComponent', () => { let component: FacilityDashboardComponent; let fixture: ComponentFixture; - beforeEach(() => { - let facilityIdbService: Partial = { - facilities: new BehaviorSubject>([]), - selectedFacility: new BehaviorSubject(getNewIdbFacility('', '')) - }; - TestBed.configureTestingModule({ + beforeEach(async () => { + await TestBed.configureTestingModule({ imports: [RouterTestingModule, FontAwesomeModule], - declarations: [FacilityDashboardComponent, FacilityDashboardTabsComponent], - providers: [{ provide: FacilityIdbService, useValue: facilityIdbService }] - }); + declarations: [FacilityDashboardComponent, FacilityDashboardNavComponent], + providers: stubServiceProviders + }) + .compileComponents(); + fixture = TestBed.createComponent(FacilityDashboardComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/app/user-portfolio/facility-dashboard/facility-dashboard.component.ts b/src/app/user-portfolio/facility-dashboard/facility-dashboard.component.ts new file mode 100644 index 00000000..cb1992d0 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-dashboard.component.ts @@ -0,0 +1,31 @@ +import { Component } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { IdbCompany } from 'src/app/models/company'; +import { IdbFacility } from 'src/app/models/facility'; + +@Component({ + selector: 'app-facility-dashboard', + templateUrl: './facility-dashboard.component.html', + styleUrl: './facility-dashboard.component.css' +}) +export class FacilityDashboardComponent { + + constructor(private activatedRoute: ActivatedRoute, + private companyIdbService: CompanyIdbService, + private facilityIdbService: FacilityIdbService + ) { + + } + + ngOnInit() { + this.activatedRoute.params.subscribe(params => { + let guid: string = params['id']; + let facility: IdbFacility = this.facilityIdbService.getByGUID(guid); + this.facilityIdbService.selectedFacility.next(facility); + let company: IdbCompany = this.companyIdbService.getByGUID(facility.companyId); + this.companyIdbService.selectedCompany.next(company); + }); + } +} diff --git a/src/app/user-dashboard/user-dashboard.component.css b/src/app/user-portfolio/facility-dashboard/facility-reports/facility-reports.component.css similarity index 100% rename from src/app/user-dashboard/user-dashboard.component.css rename to src/app/user-portfolio/facility-dashboard/facility-reports/facility-reports.component.css diff --git a/src/app/user-portfolio/facility-dashboard/facility-reports/facility-reports.component.html b/src/app/user-portfolio/facility-dashboard/facility-reports/facility-reports.component.html new file mode 100644 index 00000000..645f3d08 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-reports/facility-reports.component.html @@ -0,0 +1,7 @@ +
+
+
+ Facility level reports coming soon. +
+
+
\ No newline at end of file diff --git a/src/app/facility-dashboard/facility-reports/facility-reports.component.spec.ts b/src/app/user-portfolio/facility-dashboard/facility-reports/facility-reports.component.spec.ts similarity index 99% rename from src/app/facility-dashboard/facility-reports/facility-reports.component.spec.ts rename to src/app/user-portfolio/facility-dashboard/facility-reports/facility-reports.component.spec.ts index 9cdc9210..c6c02a7b 100644 --- a/src/app/facility-dashboard/facility-reports/facility-reports.component.spec.ts +++ b/src/app/user-portfolio/facility-dashboard/facility-reports/facility-reports.component.spec.ts @@ -11,7 +11,7 @@ describe('FacilityReportsComponent', () => { declarations: [FacilityReportsComponent] }) .compileComponents(); - + fixture = TestBed.createComponent(FacilityReportsComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/app/facility-dashboard/facility-reports/facility-reports.component.ts b/src/app/user-portfolio/facility-dashboard/facility-reports/facility-reports.component.ts similarity index 100% rename from src/app/facility-dashboard/facility-reports/facility-reports.component.ts rename to src/app/user-portfolio/facility-dashboard/facility-reports/facility-reports.component.ts diff --git a/src/app/user-dashboard/user-settings/user-settings.component.css b/src/app/user-portfolio/facility-dashboard/facility-settings/facility-settings.component.css similarity index 100% rename from src/app/user-dashboard/user-settings/user-settings.component.css rename to src/app/user-portfolio/facility-dashboard/facility-settings/facility-settings.component.css diff --git a/src/app/user-portfolio/facility-dashboard/facility-settings/facility-settings.component.html b/src/app/user-portfolio/facility-dashboard/facility-settings/facility-settings.component.html new file mode 100644 index 00000000..e3359fa1 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-settings/facility-settings.component.html @@ -0,0 +1,90 @@ +
+
+ +
+
+
+
+ Create Facility Copy +
+

+ Use the button below to create a copy of this facility. A copy of this facility will be added to + your + JUSTIFI portfolio. +

+ +
+
+
+ Delete Facility +
+

+ Use the button below to delete this facility and all of its corresponding data. This action cannot + be + undone. +

+ +
+
+
+
+ + +
+ + + + + \ No newline at end of file diff --git a/src/app/user-portfolio/facility-dashboard/facility-settings/facility-settings.component.spec.ts b/src/app/user-portfolio/facility-dashboard/facility-settings/facility-settings.component.spec.ts new file mode 100644 index 00000000..0b43881e --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-settings/facility-settings.component.spec.ts @@ -0,0 +1,28 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FacilitySettingsComponent } from './facility-settings.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { SharedFacilityFormsModule } from 'src/app/shared/shared-facility-forms/shared-facility-forms.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('FacilitySettingsComponent', () => { + let component: FacilitySettingsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, SharedFacilityFormsModule], + declarations: [FacilitySettingsComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(FacilitySettingsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/facility-dashboard/facility-settings/facility-settings.component.ts b/src/app/user-portfolio/facility-dashboard/facility-settings/facility-settings.component.ts new file mode 100644 index 00000000..d55bac2c --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/facility-settings/facility-settings.component.ts @@ -0,0 +1,103 @@ +import { Component } from '@angular/core'; +import { FormControl, Validators } from '@angular/forms'; +import { Router } from '@angular/router'; +import { faCopy, faTrash, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Observable, of, Subscription } from 'rxjs'; +import { LoadingService } from 'src/app/core-components/loading/loading.service'; +import { ToastNotificationsService } from 'src/app/core-components/toast-notifications/toast-notifications.service'; +import { DbChangesService } from 'src/app/indexed-db/db-changes.service'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { IdbFacility } from 'src/app/models/facility'; + +@Component({ + selector: 'app-facility-settings', + templateUrl: './facility-settings.component.html', + styleUrl: './facility-settings.component.css' +}) +export class FacilitySettingsComponent { + + + faTrash: IconDefinition = faTrash; + faCopy: IconDefinition = faCopy; + + showDeleteFacilityModal: boolean = false; + showCreateCopyModal: boolean = false; + + + name: FormControl; + facilityName: string; + facilitySub: Subscription; + facility: IdbFacility; + routeGuardWarningModal: boolean = false; + + constructor(private facilityIdbService: FacilityIdbService, + private loadingService: LoadingService, + private toastNotificationService: ToastNotificationsService, + private dbChangesService: DbChangesService, + private router: Router + ) { + + } + + ngOnInit() { + this.facilitySub = this.facilityIdbService.selectedFacility.subscribe(facility => { + this.facility = facility; + this.name = new FormControl(this.facility.generalInformation.name, [Validators.required]); + }); + } + + ngOnDestroy() { + this.facilitySub.unsubscribe(); + } + + async saveChanges() { + let facility: IdbFacility = this.facilityIdbService.selectedFacility.getValue(); + facility.generalInformation.name = this.name.value; + await this.facilityIdbService.asyncUpdate(facility); + } + + canDeactivate(): Observable { + if (this.name && this.name.getError('required')) { + this.displayWarningModal(); + return of(false); + } + return of(true); + } + + displayWarningModal() { + this.routeGuardWarningModal = true; + } + closeWarningModal() { + this.routeGuardWarningModal = false; + } + + openDeleteFacilityModal() { + this.showDeleteFacilityModal = true; + } + + closeDeleteFacilityModal() { + this.showDeleteFacilityModal = false; + } + + openCreateCopyModal() { + this.showCreateCopyModal = true; + } + + closeCreateCopyModal() { + this.showCreateCopyModal = false; + } + + confirmCreateCopy() { + //TODO... + } + + async confirmDelete() { + this.showDeleteFacilityModal = false; + this.loadingService.setLoadingMessage('Deleting ' + this.facility.generalInformation.name + '...'); + this.loadingService.setLoadingStatus(true); + await this.dbChangesService.deleteFacility(this.facility); + this.loadingService.setLoadingStatus(false); + this.toastNotificationService.showToast('Facility Deleted!', undefined, 'bg-success', true, false); + this.router.navigateByUrl('/portfolio'); + } +} \ No newline at end of file diff --git a/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.css b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.css new file mode 100644 index 00000000..8bbc53cc --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.css @@ -0,0 +1,3 @@ +th{ + width: 20%; +} \ No newline at end of file diff --git a/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.html b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.html new file mode 100644 index 00000000..b652b0ec --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.html @@ -0,0 +1,71 @@ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Name + + Industrial System + + Utility Type + + Energy Use
+ + (/yr) + +
+ Stakeholders +
+ {{energyEquipment.equipmentName}} + + + + + + + + @let associatedContacts = energyEquipment.guid | associatedContacts:'energyEquipment': contacts; + + + {{contact | contactNameDisplay}}
+
+
+ + — + +
+
+ + +
+ No industrial system equipment found for this facility. Use the " + Add New Equipment" button to add equipment to this facility. +
+
\ No newline at end of file diff --git a/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.spec.ts b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.spec.ts new file mode 100644 index 00000000..009b2d48 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.spec.ts @@ -0,0 +1,30 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { IndustrialSystemInventoryHomeComponent } from './industrial-system-inventory-home.component'; +import { SharedCompanyFormsModule } from 'src/app/shared/shared-company-forms/shared-company-forms.module'; +import { TableEntriesModule } from 'src/app/shared/table-entries/table-entries.module'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('IndustrialSystemInventoryHomeComponent', () => { + let component: IndustrialSystemInventoryHomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [SharedCompanyFormsModule, FontAwesomeModule, HelperPipesModule, TableEntriesModule], + declarations: [IndustrialSystemInventoryHomeComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(IndustrialSystemInventoryHomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.ts b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.ts new file mode 100644 index 00000000..782021f7 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component.ts @@ -0,0 +1,80 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; +import { faPlus, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { firstValueFrom, Subscription } from 'rxjs'; +import { ToastNotificationsService } from 'src/app/core-components/toast-notifications/toast-notifications.service'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { ContactIdbService } from 'src/app/indexed-db/contact-idb.service'; +import { EnergyEquipmentIdbService } from 'src/app/indexed-db/energy-equipment-idb.service'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { IdbContact } from 'src/app/models/contact'; +import { getNewIdbEnergyEquipment, IdbEnergyEquipment } from 'src/app/models/energyEquipment'; +import { IdbFacility } from 'src/app/models/facility'; + +@Component({ + selector: 'app-industrial-system-inventory-home', + templateUrl: './industrial-system-inventory-home.component.html', + styleUrl: './industrial-system-inventory-home.component.css' +}) +export class IndustrialSystemInventoryHomeComponent { + + faPlus: IconDefinition = faPlus; + + facility: IdbFacility; + facilitySub: Subscription; + energyEquipmentsSub: Subscription + energyEquipments: Array; + + companyEnergyUnit: string; + companySub: Subscription; + + contacts: Array; + contactsSub: Subscription; + constructor(private facilityIdbService: FacilityIdbService, + private energyEquipmentIdbService: EnergyEquipmentIdbService, + private companyIdbService: CompanyIdbService, + private contactIdbService: ContactIdbService, + private toastNotificationService: ToastNotificationsService, + private router: Router + ) { } + + ngOnInit() { + this.companySub = this.companyIdbService.selectedCompany.subscribe(company => { + this.companyEnergyUnit = company.companyEnergyUnit; + }); + + this.facilitySub = this.facilityIdbService.selectedFacility.subscribe(facility => { + this.facility = facility; + }); + + this.energyEquipmentsSub = this.energyEquipmentIdbService.energyEquipments.subscribe(energyEquipments => { + this.energyEquipments = energyEquipments.filter(equipment => { + return equipment.facilityId == this.facility.guid; + }); + }); + + this.contactsSub = this.contactIdbService.contacts.subscribe(contacts => { + this.contacts = contacts; + }); + } + + ngOnDestroy() { + this.energyEquipmentsSub.unsubscribe(); + this.facilitySub.unsubscribe(); + this.companySub.unsubscribe(); + this.contactsSub.unsubscribe(); + } + + async addEquipment() { + let newEnergyEquipment: IdbEnergyEquipment = getNewIdbEnergyEquipment( + this.facility.userId, + this.facility.companyId, + this.facility.guid, + this.facility.unitSettings); + await firstValueFrom(this.energyEquipmentIdbService.addWithObservable(newEnergyEquipment)); + await this.energyEquipmentIdbService.setEnergyEquipments(); + this.toastNotificationService.showToast('Equipment Added!', 'New industrial system equipment has been added to the inventory for ' + this.facility.generalInformation.name + '!', 'bg-success', true, false); + this.router.navigateByUrl('/portfolio/facility/' + newEnergyEquipment.facilityId + '/system-inventory/' + newEnergyEquipment.guid); + } + +} diff --git a/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory.component.css b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory.component.css new file mode 100644 index 00000000..e69de29b diff --git a/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory.component.html b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory.component.html new file mode 100644 index 00000000..b2fc7d63 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory.component.html @@ -0,0 +1,42 @@ + \ No newline at end of file diff --git a/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory.component.spec.ts b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory.component.spec.ts new file mode 100644 index 00000000..9c7e1c05 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory.component.spec.ts @@ -0,0 +1,28 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { IndustrialSystemInventoryComponent } from './industrial-system-inventory.component'; +import { RouterTestingModule } from '@angular/router/testing'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('IndustrialSystemInventoryComponent', () => { + let component: IndustrialSystemInventoryComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [RouterTestingModule, FontAwesomeModule], + declarations: [IndustrialSystemInventoryComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(IndustrialSystemInventoryComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory.component.ts b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory.component.ts new file mode 100644 index 00000000..466c1c03 --- /dev/null +++ b/src/app/user-portfolio/facility-dashboard/industrial-system-inventory/industrial-system-inventory.component.ts @@ -0,0 +1,45 @@ +import { Component } from '@angular/core'; +import { faChevronRight, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { EnergyEquipmentIdbService } from 'src/app/indexed-db/energy-equipment-idb.service'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { IdbEnergyEquipment } from 'src/app/models/energyEquipment'; +import { IdbFacility } from 'src/app/models/facility'; + +@Component({ + selector: 'app-industrial-system-inventory', + templateUrl: './industrial-system-inventory.component.html', + styleUrl: './industrial-system-inventory.component.css' +}) +export class IndustrialSystemInventoryComponent { + + faChevronRight: IconDefinition = faChevronRight; + + facility: IdbFacility; + facilitySub: Subscription; + + + energyEquipmentsSub: Subscription + energyEquipments: Array; + + constructor(private facilityIdbService: FacilityIdbService, + private energyEquipmentIdbService: EnergyEquipmentIdbService + ) { } + + ngOnInit() { + this.facilitySub = this.facilityIdbService.selectedFacility.subscribe(facility => { + this.facility = facility; + }); + + this.energyEquipmentsSub = this.energyEquipmentIdbService.energyEquipments.subscribe(energyEquipments => { + this.energyEquipments = energyEquipments.filter(equipment => { + return equipment.facilityId == this.facility.guid; + }); + }); + } + + ngOnDestroy() { + this.energyEquipmentsSub.unsubscribe(); + this.facilitySub.unsubscribe(); + } +} diff --git a/src/app/user-portfolio/latest-visits-table/latest-visits-table.component.css b/src/app/user-portfolio/latest-visits-table/latest-visits-table.component.css new file mode 100644 index 00000000..e69de29b diff --git a/src/app/user-portfolio/latest-visits-table/latest-visits-table.component.html b/src/app/user-portfolio/latest-visits-table/latest-visits-table.component.html new file mode 100644 index 00000000..adf80722 --- /dev/null +++ b/src/app/user-portfolio/latest-visits-table/latest-visits-table.component.html @@ -0,0 +1,95 @@ +
+
+
+
+ + On-Site Visits +
+
+ +
+
+

+ Below is a list of the on-site visits conducted in JUSTIFI so you can jump back in. + Just click the "" button. +

+ + + + + + + + + + + + + + + + + + + + + + +
+ Company + + Facility + + Assessments + + Visit Date + + Last Modified + + +
+ + {{visit.companyId | companyName: companies}} + + + + {{visit.facilityId | facilityName: facilities}} + + + + + + + {{assessmentId | assessmentNameDisplay: assessments}} + +
+
+
+ + — + +
+ {{visit.visitDate | date}} + + {{visit.modifiedDate | date}} + + +
+
+ +
+
+ +
+ No visits found. Use the setup wizard to add your first on site visit. +
+
+
+
\ No newline at end of file diff --git a/src/app/user-portfolio/latest-visits-table/latest-visits-table.component.spec.ts b/src/app/user-portfolio/latest-visits-table/latest-visits-table.component.spec.ts new file mode 100644 index 00000000..e39e81b3 --- /dev/null +++ b/src/app/user-portfolio/latest-visits-table/latest-visits-table.component.spec.ts @@ -0,0 +1,30 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LatestVisitsTableComponent } from './latest-visits-table.component'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { TablePaginationModule } from 'src/app/shared/table-pagination/table-pagination.module'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { RouterTestingModule } from '@angular/router/testing'; + +describe('LatestVisitsTableComponent', () => { + let component: LatestVisitsTableComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, TablePaginationModule, HelperPipesModule, RouterTestingModule], + declarations: [LatestVisitsTableComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(LatestVisitsTableComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/latest-visits-table/latest-visits-table.component.ts b/src/app/user-portfolio/latest-visits-table/latest-visits-table.component.ts new file mode 100644 index 00000000..4a400e79 --- /dev/null +++ b/src/app/user-portfolio/latest-visits-table/latest-visits-table.component.ts @@ -0,0 +1,86 @@ +import { Component } from '@angular/core'; +import { faStopwatch, faWandMagicSparkles, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; +import { IdbAssessment } from 'src/app/models/assessment'; +import { IdbCompany } from 'src/app/models/company'; +import { IdbFacility } from 'src/app/models/facility'; +import { IdbOnSiteVisit } from 'src/app/models/onSiteVisit'; +import { SharedDataService } from 'src/app/shared/shared-services/shared-data.service'; + +@Component({ + selector: 'app-latest-visits-table', + templateUrl: './latest-visits-table.component.html', + styleUrl: './latest-visits-table.component.css' +}) +export class LatestVisitsTableComponent { + + faWandMagicSparkles: IconDefinition = faWandMagicSparkles; + faStopwatch: IconDefinition = faStopwatch; + + onSiteVisits: Array; + onSiteVisitSub: Subscription; + + facilities: Array; + facilitiesSub: Subscription; + + companies: Array; + companiesSub: Subscription; + + assessments: Array; + assessmentSub: Subscription; + + currentPageNumber: number = 1; + constructor( + private onSiteVisitIdbService: OnSiteVisitIdbService, + private facilityIdbService: FacilityIdbService, + private companyIdbService: CompanyIdbService, + private sharedDataService: SharedDataService, + private assessmentIdbService: AssessmentIdbService + ) { + + } + + ngOnInit() { + this.onSiteVisitSub = this.onSiteVisitIdbService.onSiteVisits.subscribe(visits => { + this.onSiteVisits = visits; + }); + + this.facilitiesSub = this.facilityIdbService.facilities.subscribe(facilities => { + this.facilities = facilities; + }); + + this.companiesSub = this.companyIdbService.companies.subscribe(companies => { + this.companies = companies; + }); + this.assessmentSub = this.assessmentIdbService.assessments.subscribe(assessments => { + this.assessments = assessments; + }) + } + + ngOnDestroy() { + this.onSiteVisitSub.unsubscribe(); + this.facilitiesSub.unsubscribe(); + this.companiesSub.unsubscribe(); + this.assessmentSub.unsubscribe(); + } + + + goToVisit(visit: IdbOnSiteVisit) { + this.companyIdbService.setSelectedFromGUID(visit.companyId); + this.facilityIdbService.setSelectedFromGUID(visit.facilityId); + this.onSiteVisitIdbService.setSelectedFromAssessmentGUID(visit.assessmentIds[0]); + this.sharedDataService.createAssessmentModalOpen.next(true); + } + + openWizardModal() { + this.sharedDataService.createAssessmentModalOpen.next(true); + } + + setPageCurrentPageNumber(pageNumber: number) { + this.currentPageNumber = pageNumber; + } +} diff --git a/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.css b/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.css new file mode 100644 index 00000000..8d89b424 --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.css @@ -0,0 +1,3 @@ +th{ + width: 30%; +} \ No newline at end of file diff --git a/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.html b/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.html new file mode 100644 index 00000000..678292fd --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.html @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Assessment Type + + {{assessment.assessmentType}} +
+ Visit Date + + {{assessment.visitDate | date}} +
+ Utility Usage + + + + {{utilityType.utilityType}}: {{utilityType.energyUse | number}}
+
+
+
+ Annual Costs + + + {{assessment.cost | currency}} + + + — + +
+ Energy Opportunities + + + + {{opportunity.name}}
+
+
+ + — + +
+ NEBs + + @let assessmentNebs = assessment.guid | nebList:'assessment': nonEnergyBenefits; + + + + {{neb.name}}
+
+
+
\ No newline at end of file diff --git a/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.spec.ts b/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.spec.ts new file mode 100644 index 00000000..aa7229f1 --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.spec.ts @@ -0,0 +1,31 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AssessmentListItemComponent } from './assessment-list-item.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { getNewIdbAssessment } from 'src/app/models/assessment'; +import { getDefaultUnitSettings } from 'src/app/models/unitSettings'; + +describe('AssessmentListItemComponent', () => { + let component: AssessmentListItemComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, HelperPipesModule], + declarations: [AssessmentListItemComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(AssessmentListItemComponent); + component = fixture.componentInstance; + component.assessment = getNewIdbAssessment('123', '123', '123', getDefaultUnitSettings()); + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.ts b/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.ts new file mode 100644 index 00000000..c57032be --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/assessment-list-item/assessment-list-item.component.ts @@ -0,0 +1,48 @@ +import { Component, Input } from '@angular/core'; +import { faWeightHanging, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service'; +import { NonEnergyBenefitsIdbService } from 'src/app/indexed-db/non-energy-benefits-idb.service'; +import { IdbAssessment } from 'src/app/models/assessment'; +import { IdbEnergyOpportunity } from 'src/app/models/energyOpportunity'; +import { IdbNonEnergyBenefit } from 'src/app/models/nonEnergyBenefit'; + +@Component({ + selector: 'app-assessment-list-item', + templateUrl: './assessment-list-item.component.html', + styleUrl: './assessment-list-item.component.css' +}) +export class AssessmentListItemComponent { + @Input({ required: true }) + assessment: IdbAssessment; + @Input() + inAssessmentDashboard: boolean; + + faWeightHanging: IconDefinition = faWeightHanging; + energyOpportunitiesSub: Subscription; + energyOpportunities: Array; + + nonEnergyBenefitsSub: Subscription; + nonEnergyBenefits: Array; + constructor(private energyOpportunityIdbService: EnergyOpportunityIdbService, + private nonEnergyBenefitIdbService: NonEnergyBenefitsIdbService + ) { + } + + ngOnInit() { + this.energyOpportunitiesSub = this.energyOpportunityIdbService.energyOpportunities.subscribe(opportunities => { + this.energyOpportunities = opportunities.filter(opp => { + return opp.assessmentId == this.assessment.guid + }); + }); + + this.nonEnergyBenefitsSub = this.nonEnergyBenefitIdbService.nonEnergyBenefits.subscribe(nebs => { + this.nonEnergyBenefits = nebs; + }); + } + + ngOnDestroy() { + this.energyOpportunitiesSub.unsubscribe(); + this.nonEnergyBenefitsSub.unsubscribe(); + } +} diff --git a/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.css b/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.css new file mode 100644 index 00000000..9695f083 --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.css @@ -0,0 +1,4 @@ +.accordion-body{ + border-left: solid var(--facility-color) 5px; +} + diff --git a/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.html b/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.html new file mode 100644 index 00000000..0c8b9602 --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.html @@ -0,0 +1,74 @@ +@let companyAddress = company.generalInformation | addressDisplay; + +

+ {{companyAddress}} +

+
+
+
+
+
+ {{company.generalInformation.name}} Facilities +
+
+
+ +
+
+ +
+
+

+
+ + +
+

+
+
+ +
+
+
+
+
+ + +
+ No facilities found for this company. Use the " Add Facility" button to add a + facility to this company. +
+
+ +
+ \ No newline at end of file diff --git a/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.spec.ts b/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.spec.ts new file mode 100644 index 00000000..fd7e0561 --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.spec.ts @@ -0,0 +1,32 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CompanyListItemComponent } from './company-list-item.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { FacilityListItemComponent } from '../facility-list-item/facility-list-item.component'; +import { AssessmentListItemComponent } from '../assessment-list-item/assessment-list-item.component'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { getNewIdbCompany } from 'src/app/models/company'; + +describe('CompanyListItemComponent', () => { + let component: CompanyListItemComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, HelperPipesModule], + declarations: [CompanyListItemComponent, FacilityListItemComponent, AssessmentListItemComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(CompanyListItemComponent); + component = fixture.componentInstance; + component.company = getNewIdbCompany('123'); + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.ts b/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.ts new file mode 100644 index 00000000..18ca2d8d --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/company-list-item/company-list-item.component.ts @@ -0,0 +1,79 @@ +import { Component, Input } from '@angular/core'; +import { Router } from '@angular/router'; +import { faArrowRight, faIndustry, faPlus, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { ToastNotificationsService } from 'src/app/core-components/toast-notifications/toast-notifications.service'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { IdbCompany } from 'src/app/models/company'; +import { IdbFacility } from 'src/app/models/facility'; +import { BootstrapService } from 'src/app/shared/shared-services/bootstrap.service'; + +@Component({ + selector: 'app-company-list-item', + templateUrl: './company-list-item.component.html', + styleUrl: './company-list-item.component.css' +}) +export class CompanyListItemComponent { + @Input({ required: true }) + company: IdbCompany; + @Input() + inCompanyDashboard: boolean; + + faIndustry: IconDefinition = faIndustry; + faArrowRight: IconDefinition = faArrowRight; + faPlus: IconDefinition = faPlus; + + facilities: Array; + facilitiesSub: Subscription; + accordionGuid: string; + displayAddFacilityModal: boolean = false; + constructor(private facilityIdbService: FacilityIdbService, + private bootstrapService: BootstrapService, + private router: Router, + private companyIdbService: CompanyIdbService, + private toastNotificationService: ToastNotificationsService + ) { + + } + + ngOnInit() { + this.facilitiesSub = this.facilityIdbService.facilities.subscribe(facilities => { + this.facilities = facilities.filter(facility => { return facility.companyId == this.company.guid }); + }); + } + + ngOnDestroy() { + this.facilitiesSub.unsubscribe(); + } + + toggleBS(companyGuid: string) { + this.bootstrapService.bsCollapse('#' + companyGuid); + if (this.accordionGuid != companyGuid) { + this.accordionGuid = companyGuid; + } else { + this.accordionGuid = undefined; + } + } + + goToFacilityDashboard(facility: IdbFacility) { + this.router.navigateByUrl('/portfolio/facility/' + facility.guid); + } + + openAddFacilityModal() { + this.displayAddFacilityModal = true; + } + + closeAddFacilityModal() { + this.displayAddFacilityModal = false; + } + + async confirmCreate() { + this.closeAddFacilityModal(); + let company: IdbCompany = this.companyIdbService.selectedCompany.getValue(); + let newFacilityGuid: string = await this.facilityIdbService.addNewFacility(company.userId, company.guid); + let newFacility: IdbFacility = this.facilityIdbService.getByGUID(newFacilityGuid) + this.router.navigateByUrl('/portfolio/facility/' + newFacility.guid + '/manage'); + this.toastNotificationService.showToast('New Facility Added!', undefined, 'bg-success', true, false); + } +} diff --git a/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.css b/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.css new file mode 100644 index 00000000..b0116dcb --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.css @@ -0,0 +1,3 @@ +.accordion-body{ + border-left: solid var(--assessment-color) 5px; +} \ No newline at end of file diff --git a/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.html b/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.html new file mode 100644 index 00000000..5acc4bd2 --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.html @@ -0,0 +1,54 @@ +@let facilityAddress = facility.generalInformation | addressDisplay; + +

+ {{facilityAddress}} +

+
+
+
+
+
+ {{facility.generalInformation.name}} Assessments +
+
+
+ +
+
+ +
+
+

+
+ + + +
+

+
+
+ +
+
+
+
+
+ +
+ No assessments found for this facility. +
+
\ No newline at end of file diff --git a/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.spec.ts b/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.spec.ts new file mode 100644 index 00000000..a788e185 --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.spec.ts @@ -0,0 +1,31 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FacilityListItemComponent } from './facility-list-item.component'; +import { AssessmentListItemComponent } from '../assessment-list-item/assessment-list-item.component'; +import { getNewIdbFacility } from 'src/app/models/facility'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; + +describe('FacilityListItemComponent', () => { + let component: FacilityListItemComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, HelperPipesModule], + declarations: [FacilityListItemComponent, AssessmentListItemComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(FacilityListItemComponent); + component = fixture.componentInstance; + component.facility = getNewIdbFacility('123', '123'); + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.ts b/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.ts new file mode 100644 index 00000000..1010f40c --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/facility-list-item/facility-list-item.component.ts @@ -0,0 +1,80 @@ +import { Component, Input } from '@angular/core'; +import { Router } from '@angular/router'; +import { faArrowRight, faScrewdriverWrench, faWandMagicSparkles, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { FacilityIdbService } from 'src/app/indexed-db/facility-idb.service'; +import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service'; +import { IdbAssessment } from 'src/app/models/assessment'; +import { IdbFacility } from 'src/app/models/facility'; +import { BootstrapService } from 'src/app/shared/shared-services/bootstrap.service'; +import { SharedDataService } from 'src/app/shared/shared-services/shared-data.service'; + +@Component({ + selector: 'app-facility-list-item', + templateUrl: './facility-list-item.component.html', + styleUrl: './facility-list-item.component.css' +}) +export class FacilityListItemComponent { + @Input({ required: true }) + facility: IdbFacility; + @Input() + inFacilityDashboard: boolean; + + + faScrewdriverWrench: IconDefinition = faScrewdriverWrench; + faArrowRight: IconDefinition = faArrowRight; + faWandMagicSparkles: IconDefinition = faWandMagicSparkles; + + assessments: Array; + assessmentsSub: Subscription; + accordionGuid: string; + constructor(private assessmentIdbService: AssessmentIdbService, + private bootstrapService: BootstrapService, + private router: Router, + private companyIdbService: CompanyIdbService, + private facilityIdbService: FacilityIdbService, + private onSiteVisitIdbService: OnSiteVisitIdbService, + private sharedDataService: SharedDataService + ) { + + } + + ngOnInit() { + this.assessmentsSub = this.assessmentIdbService.assessments.subscribe(assessments => { + this.assessments = assessments.filter(assessment => { + return assessment.facilityId == this.facility.guid; + }) + }); + } + + ngOnDestroy() { + this.assessmentsSub.unsubscribe(); + } + + toggleBS(assessmentGuid: string) { + this.bootstrapService.bsCollapse('#' + assessmentGuid); + if (this.accordionGuid != assessmentGuid) { + this.accordionGuid = assessmentGuid; + } else { + this.accordionGuid = undefined; + } + } + + goToAssessmentDashboard(assessment: IdbAssessment) { + this.router.navigateByUrl('/portfolio/assessment/' + assessment.guid); + } + + goToVisit(assessment: IdbAssessment) { + this.companyIdbService.setSelectedFromGUID(this.facility.companyId); + this.facilityIdbService.setSelectedFromGUID(this.facility.guid); + if (assessment) { + this.onSiteVisitIdbService.setSelectedFromAssessmentGUID(assessment.guid); + } else { + this.onSiteVisitIdbService.selectedVisit.next(undefined); + } + this.sharedDataService.createAssessmentModalOpen.next(true); + } + +} diff --git a/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.css b/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.css new file mode 100644 index 00000000..d05eb2ec --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.css @@ -0,0 +1,5 @@ + + +.accordion-body{ + border-left: solid var(--company-color) 5px; +} \ No newline at end of file diff --git a/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.html b/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.html new file mode 100644 index 00000000..e7b1df69 --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.html @@ -0,0 +1,70 @@ +
+
+
+
+ + Companies, Facilities, and Assessments +
+
+ +
+
+ +
+
+

+ +
+ + +
+

+
+
+ +
+
+
+
+
+ +
+ No companies found in your portfolio. Use the " + Add Company" button to add your first company. +
+
+
+
+ +
+ \ No newline at end of file diff --git a/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.spec.ts b/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.spec.ts new file mode 100644 index 00000000..82e4b75f --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.spec.ts @@ -0,0 +1,31 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PortfolioItemsListComponent } from './portfolio-items-list.component'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { CompanyListItemComponent } from './company-list-item/company-list-item.component'; +import { AssessmentListItemComponent } from './assessment-list-item/assessment-list-item.component'; +import { FacilityListItemComponent } from './facility-list-item/facility-list-item.component'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; + +describe('PortfolioItemsListComponent', () => { + let component: PortfolioItemsListComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, HelperPipesModule], + declarations: [PortfolioItemsListComponent, CompanyListItemComponent, AssessmentListItemComponent, FacilityListItemComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(PortfolioItemsListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.ts b/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.ts new file mode 100644 index 00000000..3e8c575c --- /dev/null +++ b/src/app/user-portfolio/portfolio-items-list/portfolio-items-list.component.ts @@ -0,0 +1,75 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; +import { faArrowRight, faBuilding, faFolderTree, faPlus, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; +import { ToastNotificationsService } from 'src/app/core-components/toast-notifications/toast-notifications.service'; +import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service'; +import { UserIdbService } from 'src/app/indexed-db/user-idb.service'; +import { IdbCompany } from 'src/app/models/company'; +import { IdbUser } from 'src/app/models/user'; +import { BootstrapService } from 'src/app/shared/shared-services/bootstrap.service'; + +@Component({ + selector: 'app-portfolio-items-list', + templateUrl: './portfolio-items-list.component.html', + styleUrl: './portfolio-items-list.component.css' +}) +export class PortfolioItemsListComponent { + + faFolderTree: IconDefinition = faFolderTree; + faBuilding: IconDefinition = faBuilding; + faPlus: IconDefinition = faPlus; + faArrowRight: IconDefinition = faArrowRight; + + companies: Array + companiesSub: Subscription + accordionGuid: string; + + displayAddCompanyModal: boolean = false; + constructor(private companyIdbService: CompanyIdbService, + private bootstrapService: BootstrapService, + private router: Router, + private userIdbService: UserIdbService, + private toastNotificationService: ToastNotificationsService + ) { } + + ngOnInit() { + this.companiesSub = this.companyIdbService.companies.subscribe(companies => { + this.companies = companies; + }); + } + + ngOnDestroy() { + this.companiesSub.unsubscribe(); + } + + toggleBS(companyGuid: string) { + this.bootstrapService.bsCollapse('#' + companyGuid); + if (this.accordionGuid != companyGuid) { + this.accordionGuid = companyGuid; + } else { + this.accordionGuid = undefined; + } + } + + goToCompanyDashboard(company: IdbCompany) { + this.router.navigateByUrl('/portfolio/company/' + company.guid); + } + + openAddCompanyModal() { + this.displayAddCompanyModal = true; + } + + closeAddCompanyModal() { + this.displayAddCompanyModal = false; + } + + async confirmCreate() { + this.closeAddCompanyModal(); + let user: IdbUser = this.userIdbService.user.getValue(); + let newCompanyGuid: string = await this.companyIdbService.addNewCompany(user.guid) + let newCompany: IdbCompany = this.companyIdbService.getByGUID(newCompanyGuid); + this.router.navigateByUrl('/portfolio/company/' + newCompany.guid + '/manage'); + this.toastNotificationService.showToast('New Company Added!', undefined, 'bg-success', true, false); + } +} diff --git a/src/app/user-portfolio/user-portfolio-home/user-portfolio-home.component.css b/src/app/user-portfolio/user-portfolio-home/user-portfolio-home.component.css new file mode 100644 index 00000000..e69de29b diff --git a/src/app/user-portfolio/user-portfolio-home/user-portfolio-home.component.html b/src/app/user-portfolio/user-portfolio-home/user-portfolio-home.component.html new file mode 100644 index 00000000..31126763 --- /dev/null +++ b/src/app/user-portfolio/user-portfolio-home/user-portfolio-home.component.html @@ -0,0 +1,8 @@ +
+ +
+
+
+ +
+
\ No newline at end of file diff --git a/src/app/user-portfolio/user-portfolio-home/user-portfolio-home.component.spec.ts b/src/app/user-portfolio/user-portfolio-home/user-portfolio-home.component.spec.ts new file mode 100644 index 00000000..1ebbe374 --- /dev/null +++ b/src/app/user-portfolio/user-portfolio-home/user-portfolio-home.component.spec.ts @@ -0,0 +1,35 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UserPortfolioHomeComponent } from './user-portfolio-home.component'; +import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub'; +import { PortfolioItemsListComponent } from '../portfolio-items-list/portfolio-items-list.component'; +import { LatestVisitsTableComponent } from '../latest-visits-table/latest-visits-table.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { RouterTestingModule } from '@angular/router/testing'; +import { CompanyListItemComponent } from '../portfolio-items-list/company-list-item/company-list-item.component'; +import { FacilityListItemComponent } from '../portfolio-items-list/facility-list-item/facility-list-item.component'; +import { AssessmentListItemComponent } from '../portfolio-items-list/assessment-list-item/assessment-list-item.component'; +import { HelperPipesModule } from 'src/app/shared/helper-pipes/_helper-pipes.module'; +import { TablePaginationModule } from 'src/app/shared/table-pagination/table-pagination.module'; + +describe('UserPortfolioHomeComponent', () => { + let component: UserPortfolioHomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FontAwesomeModule, RouterTestingModule, HelperPipesModule, TablePaginationModule], + declarations: [UserPortfolioHomeComponent, PortfolioItemsListComponent, LatestVisitsTableComponent, CompanyListItemComponent, AssessmentListItemComponent, FacilityListItemComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(UserPortfolioHomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/user-portfolio-home/user-portfolio-home.component.ts b/src/app/user-portfolio/user-portfolio-home/user-portfolio-home.component.ts new file mode 100644 index 00000000..f1d33287 --- /dev/null +++ b/src/app/user-portfolio/user-portfolio-home/user-portfolio-home.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-user-portfolio-home', + templateUrl: './user-portfolio-home.component.html', + styleUrl: './user-portfolio-home.component.css' +}) +export class UserPortfolioHomeComponent { + +} diff --git a/src/app/user-portfolio/user-portfolio.component.css b/src/app/user-portfolio/user-portfolio.component.css new file mode 100644 index 00000000..6bfdbf50 --- /dev/null +++ b/src/app/user-portfolio/user-portfolio.component.css @@ -0,0 +1,15 @@ +.card{ + border-radius: 0; +} + +/* .card-title{ + font-size: 26px; +} */ + +/* .card-title.secondary{ + font-size: 20px; +} */ + +.card-text{ + font-size: 14px; +} \ No newline at end of file diff --git a/src/app/user-portfolio/user-portfolio.component.html b/src/app/user-portfolio/user-portfolio.component.html new file mode 100644 index 00000000..f5fe992b --- /dev/null +++ b/src/app/user-portfolio/user-portfolio.component.html @@ -0,0 +1,44 @@ + + + + + + diff --git a/src/app/user-portfolio/user-portfolio.component.spec.ts b/src/app/user-portfolio/user-portfolio.component.spec.ts new file mode 100644 index 00000000..4bae191c --- /dev/null +++ b/src/app/user-portfolio/user-portfolio.component.spec.ts @@ -0,0 +1,31 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UserPortfolioComponent } from './user-portfolio.component'; +import { SharedAssessmentFormsModule } from '../shared/shared-assessment-forms/shared-assessment-forms.module'; +import { ContactModalModule } from '../shared/contact-modal/contact-modal.module'; +import { RouterTestingModule } from '@angular/router/testing'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { stubServiceProviders } from '../spec-helpers/spec-test-service-stub'; + +describe('UserPortfolioComponent', () => { + let component: UserPortfolioComponent; + let fixture: ComponentFixture; + + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [SharedAssessmentFormsModule, ContactModalModule, RouterTestingModule, FontAwesomeModule], + declarations: [UserPortfolioComponent], + providers: stubServiceProviders + }) + .compileComponents(); + + fixture = TestBed.createComponent(UserPortfolioComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user-portfolio/user-portfolio.component.ts b/src/app/user-portfolio/user-portfolio.component.ts new file mode 100644 index 00000000..27a693c5 --- /dev/null +++ b/src/app/user-portfolio/user-portfolio.component.ts @@ -0,0 +1,126 @@ +import { ChangeDetectorRef, Component } from '@angular/core'; +import { NavigationEnd, Router } from '@angular/router'; +import { faBuilding, faFolderOpen, faIndustry, faScrewdriverWrench, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { CompanyIdbService } from '../indexed-db/company-idb.service'; +import { FacilityIdbService } from '../indexed-db/facility-idb.service'; +import { AssessmentIdbService } from '../indexed-db/assessment-idb.service'; +import { IdbCompany } from '../models/company'; +import { IdbFacility } from '../models/facility'; +import { IdbAssessment } from '../models/assessment'; +import { Subscription } from 'rxjs'; +import { SharedDataService } from '../shared/shared-services/shared-data.service'; +import { ContactContext, IdbContact } from '../models/contact'; + +@Component({ + selector: 'app-user-portfolio', + templateUrl: './user-portfolio.component.html', + styleUrl: './user-portfolio.component.css' +}) +export class UserPortfolioComponent { + + faFolderOpen: IconDefinition = faFolderOpen; + faBuilding: IconDefinition = faBuilding; + faIndustry: IconDefinition = faIndustry; + faScrewdriverWrench: IconDefinition = faScrewdriverWrench; + + context: 'home' | 'company' | 'facility' | 'assessment'; + company: IdbCompany; + companySub: Subscription; + facility: IdbFacility; + facilitySub: Subscription; + assessment: IdbAssessment; + assessmentSub: Subscription; + routerSub: Subscription; + displayAddNebsModal: { + assessmentId: string, + energyOpportunityId: string + }; + displayAddNebsModalSub: Subscription; + displayContactModal: { context: ContactContext, viewContact: IdbContact, contextGuid: string, companyId: string }; + displayContactModalSub: Subscription; + constructor( + private router: Router, + private companyIdbService: CompanyIdbService, + private facilityIdbService: FacilityIdbService, + private assessmentIdbService: AssessmentIdbService, + private cd: ChangeDetectorRef, + private sharedDataService: SharedDataService + ) { + } + + ngOnInit() { + this.routerSub = this.router.events.subscribe(event => { + if (event instanceof NavigationEnd) { + this.setContext(event.urlAfterRedirects); + } + }); + this.setContext(this.router.url); + this.companySub = this.companyIdbService.selectedCompany.subscribe(selectedCompany => { + this.company = selectedCompany; + this.cd.detectChanges(); + }); + this.facilitySub = this.facilityIdbService.selectedFacility.subscribe(selectedFacility => { + this.facility = selectedFacility; + this.cd.detectChanges(); + }); + this.assessmentSub = this.assessmentIdbService.selectedAssessment.subscribe(selectedAssessment => { + this.assessment = selectedAssessment; + this.cd.detectChanges(); + }) + this.displayAddNebsModalSub = this.sharedDataService.displayAddNebsModal.subscribe(val => { + this.displayAddNebsModal = val; + }); + this.displayContactModalSub = this.sharedDataService.displayContactModal.subscribe(val => { + this.displayContactModal = val; + }) + } + + ngOnDestroy() { + this.displayAddNebsModalSub.unsubscribe(); + this.displayContactModalSub.unsubscribe(); + this.companySub.unsubscribe(); + this.facilitySub.unsubscribe(); + this.assessmentSub.unsubscribe(); + this.routerSub.unsubscribe(); + } + + setContext(url: string) { + if (url.includes('company')) { + this.context = 'company'; + this.facilityIdbService.selectedFacility.next(undefined); + this.assessmentIdbService.selectedAssessment.next(undefined); + } else if (url.includes('facility')) { + this.context = 'facility'; + this.assessmentIdbService.selectedAssessment.next(undefined); + } else if (url.includes('assessment')) { + this.context = 'assessment'; + } else { + this.context = 'home'; + this.facilityIdbService.selectedFacility.next(undefined); + this.assessmentIdbService.selectedAssessment.next(undefined); + this.companyIdbService.selectedCompany.next(undefined); + } + } + + setValues(guid: string) { + if (this.context != 'home') { + if (this.context == 'company') { + this.assessment = undefined; + this.facility = undefined; + this.company = this.companyIdbService.getByGUID(guid); + } else if (this.context == 'facility') { + this.assessment = undefined; + this.facility = this.facilityIdbService.getByGUID(guid); + this.company = this.companyIdbService.getByGUID(this.facility.companyId); + } else if (this.context == 'assessment') { + this.assessment = this.assessmentIdbService.getByGuid(guid); + this.facility = this.facilityIdbService.getByGUID(this.assessment.facilityId); + this.company = this.companyIdbService.getByGUID(this.assessment.companyId); + } + } + } + + closeContactModal() { + this.sharedDataService.displayContactModal.next(undefined); + } +} diff --git a/src/app/user-portfolio/user-portfolio.module.ts b/src/app/user-portfolio/user-portfolio.module.ts new file mode 100644 index 00000000..22fcc0d6 --- /dev/null +++ b/src/app/user-portfolio/user-portfolio.module.ts @@ -0,0 +1,98 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { UserPortfolioComponent } from './user-portfolio.component'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { LatestVisitsTableComponent } from './latest-visits-table/latest-visits-table.component'; +import { HelperPipesModule } from '../shared/helper-pipes/_helper-pipes.module'; +import { PortfolioItemsListComponent } from './portfolio-items-list/portfolio-items-list.component'; +import { CompanyListItemComponent } from './portfolio-items-list/company-list-item/company-list-item.component'; +import { FacilityListItemComponent } from './portfolio-items-list/facility-list-item/facility-list-item.component'; +import { AssessmentListItemComponent } from './portfolio-items-list/assessment-list-item/assessment-list-item.component'; +import { TablePaginationModule } from '../shared/table-pagination/table-pagination.module'; +import { UserPortfolioHomeComponent } from './user-portfolio-home/user-portfolio-home.component'; +import { RouterModule } from '@angular/router'; +import { CompanyDashboardComponent } from './company-dashboard/company-dashboard.component'; +import { FacilityDashboardComponent } from './facility-dashboard/facility-dashboard.component'; +import { AssessmentDashboardComponent } from './assessment-dashboard/assessment-dashboard.component'; +import { CompanyDashboardNavComponent } from './company-dashboard/company-dashboard-nav/company-dashboard-nav.component'; +import { CompanyDashboardHomeComponent } from './company-dashboard/company-dashboard-home/company-dashboard-home.component'; +import { CompanyPerformanceIndicatorsComponent } from './company-dashboard/company-performance-indicators/company-performance-indicators.component'; +import { CompanyStakeholdersComponent } from './company-dashboard/company-stakeholders/company-stakeholders.component'; +import { CompanyReportsComponent } from './company-dashboard/company-reports/company-reports.component'; +import { CompanySettingsComponent } from './company-dashboard/company-settings/company-settings.component'; +import { FacilityDashboardNavComponent } from './facility-dashboard/facility-dashboard-nav/facility-dashboard-nav.component'; +import { FacilityDashboardHomeComponent } from './facility-dashboard/facility-dashboard-home/facility-dashboard-home.component'; +import { IndustrialSystemInventoryComponent } from './facility-dashboard/industrial-system-inventory/industrial-system-inventory.component'; +import { EndUseInventoryComponent } from './facility-dashboard/end-use-inventory/end-use-inventory.component'; +import { FacilityReportsComponent } from './facility-dashboard/facility-reports/facility-reports.component'; +import { FacilitySettingsComponent } from './facility-dashboard/facility-settings/facility-settings.component'; +import { AssessmentDashboardHomeComponent } from './assessment-dashboard/assessment-dashboard-home/assessment-dashboard-home.component'; +import { AssessmentDashboardNavComponent } from './assessment-dashboard/assessment-dashboard-nav/assessment-dashboard-nav.component'; +import { AssessmentReportsComponent } from './assessment-dashboard/assessment-reports/assessment-reports.component'; +import { SharedAssessmentFormsModule } from "../shared/shared-assessment-forms/shared-assessment-forms.module"; +import { AssessmentDetailsComponent } from './assessment-dashboard/assessment-details/assessment-details.component'; +import { AssessmentEnergyOpportunitiesComponent } from './assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities.component'; +import { ReportsModule } from '../shared/reports/reports.module'; +import { SharedCompanyFormsModule } from "../shared/shared-company-forms/shared-company-forms.module"; +import { SharedFacilityFormsModule } from '../shared/shared-facility-forms/shared-facility-forms.module'; +import { AssessmentEnergyOpportunitiesHomeComponent } from './assessment-dashboard/assessment-energy-opportunities/assessment-energy-opportunities-home/assessment-energy-opportunities-home.component'; +import { AssessmentNebsComponent } from './assessment-dashboard/assessment-nebs/assessment-nebs.component'; +import { AssessmentNebsHomeComponent } from './assessment-dashboard/assessment-nebs/assessment-nebs-home/assessment-nebs-home.component'; +import { ContactModalModule } from '../shared/contact-modal/contact-modal.module'; +import { IndustrialSystemInventoryHomeComponent } from './facility-dashboard/industrial-system-inventory/industrial-system-inventory-home/industrial-system-inventory-home.component'; +import { EndUseInventoryHomeComponent } from './facility-dashboard/end-use-inventory/end-use-inventory-home/end-use-inventory-home.component'; +import { CompanyStakeholdersHomeComponent } from './company-dashboard/company-stakeholders/company-stakeholders-home/company-stakeholders-home.component'; +import { TableEntriesModule } from "../shared/table-entries/table-entries.module"; + +@NgModule({ + declarations: [ + UserPortfolioComponent, + LatestVisitsTableComponent, + PortfolioItemsListComponent, + CompanyListItemComponent, + FacilityListItemComponent, + AssessmentListItemComponent, + UserPortfolioHomeComponent, + CompanyDashboardComponent, + FacilityDashboardComponent, + AssessmentDashboardComponent, + CompanyDashboardNavComponent, + CompanyDashboardHomeComponent, + CompanyPerformanceIndicatorsComponent, + CompanyStakeholdersComponent, + CompanyReportsComponent, + CompanySettingsComponent, + FacilityDashboardNavComponent, + FacilityDashboardHomeComponent, + IndustrialSystemInventoryComponent, + EndUseInventoryComponent, + FacilityReportsComponent, + FacilitySettingsComponent, + AssessmentDashboardHomeComponent, + AssessmentDashboardNavComponent, + AssessmentReportsComponent, + AssessmentDetailsComponent, + AssessmentEnergyOpportunitiesComponent, + AssessmentEnergyOpportunitiesHomeComponent, + AssessmentNebsComponent, + AssessmentNebsHomeComponent, + IndustrialSystemInventoryHomeComponent, + EndUseInventoryHomeComponent, + CompanyStakeholdersHomeComponent + ], + imports: [ + CommonModule, + FontAwesomeModule, + HelperPipesModule, + TablePaginationModule, + RouterModule, + SharedAssessmentFormsModule, + ReportsModule, + SharedCompanyFormsModule, + SharedFacilityFormsModule, + ContactModalModule, + TableEntriesModule, + TableEntriesModule +] +}) +export class UserPortfolioModule { } diff --git a/src/assets/styles/accordion.css b/src/assets/styles/accordion.css index 6597ca17..931b78b7 100644 --- a/src/assets/styles/accordion.css +++ b/src/assets/styles/accordion.css @@ -17,4 +17,16 @@ .accordion-button{ padding: .25rem; +} + +.portfolio .accordion .accordion-button{ + font-size: 18px; +} + +.accordion-button, .accordion-item:first-of-type>.accordion-header .accordion-button, .accordion-item:last-of-type>.accordion-header .accordion-button.collapsed { + border-radius: 0; + padding-top: .25rem; + padding-bottom: .25rem; + padding-left: .5rem; + padding-right: .5rem; } \ No newline at end of file diff --git a/src/assets/styles/dashboards.css b/src/assets/styles/dashboards.css new file mode 100644 index 00000000..e6f62aef --- /dev/null +++ b/src/assets/styles/dashboards.css @@ -0,0 +1,45 @@ +.card{ + border-radius: 0; +} + +.portfolio .primary-nav{ + font-size: 20px; + margin-bottom: 0px; +} + +.portfolio .card-title{ + font-size: 18px; + margin-bottom: 0px; +} +.portfolio .card-body { + padding: .5rem .5rem; +} + + +.portfolio .card-text{ + font-size: 14px; +} + +.portfolio th.actions,.portfolio td.actions, .dashboard th.actions,.dashboard td.actions{ + width: 15px; +} + +.portfolio table th,.portfolio table td, .dashboard table th,.dashboard table td{ + padding: .2rem; + vertical-align: middle; +} + + +.container-fluid.portfolio{ + margin-bottom: 1rem; +} + +.portfolio .btn:hover .d-none{ + display: inline !important; +} + + + +.portfolio .table { + margin-bottom: 0px; +} \ No newline at end of file diff --git a/src/assets/styles/modals.css b/src/assets/styles/modals.css index e3f78a5c..99b6d9ca 100644 --- a/src/assets/styles/modals.css +++ b/src/assets/styles/modals.css @@ -57,4 +57,8 @@ .lg-popup.popup .popup-body{ height: calc(98vh - 125px); overflow-y: auto; +} + +.toast .toast-body{ + background-color: white; } \ No newline at end of file diff --git a/src/assets/styles/setup-wizard.css b/src/assets/styles/setup-wizard.css index ae741f77..f128d311 100644 --- a/src/assets/styles/setup-wizard.css +++ b/src/assets/styles/setup-wizard.css @@ -1,5 +1,5 @@ .setup-wizard-content{ - height: calc(100% - 4rem); + height: calc(100% - 3rem); /* background-color: red; */ overflow-y: auto; } @@ -11,10 +11,19 @@ } .setup-wizard-footer.navbar{ - height: 4rem; - background-color: #0079c2 !important; + height: 3rem; + padding: .25rem; + background-color: #5e6c75 !important; } +.setup-wizard-footer.navbar .nav-btn{ + background-color: var(--portfolio-nav-color); + color: white; +} +.setup-wizard-footer.navbar .btn.nav-btn:hover { + background-color: #8DABBE; + color: black; +} .add-neb-btn{ background-color: #186A3B; diff --git a/src/assets/styles/tabs.css b/src/assets/styles/tabs.css index 19cd5a72..85136db6 100644 --- a/src/assets/styles/tabs.css +++ b/src/assets/styles/tabs.css @@ -10,3 +10,109 @@ border-left: 1px solid; border-right: 1px solid; } + + +.nav-link:hover { + cursor: pointer; +} + +/* +PORTFOLIO TABS +*/ + +.portfolio .navbar { + overflow-y: auto; + /* flex-wrap: nowrap; */ +} + +.portfolio .breadcrumb .breadcrumb-item a { + color: var(--portfolio-nav-color); +} + +.portfolio .navbar .nav-item { + width: 100%; +} + +.portfolio .navbar .nav-item .nav-link { + padding: .25rem; + text-wrap-mode: nowrap; + border-bottom: solid 1px; + /* border-color: black; */ + /* border-top-left-radius: 0px; + border-bottom-right-radius: .5rem; + border-bottom-right-radius: .5rem; */ +} + +.portfolio .nav-item .nav-link { + padding: .25rem; + /* text-wrap-mode: nowrap; */ + /* border-bottom: solid 1px; */ + border-color: var(--portfolio-nav-color); + color: var(--portfolio-nav-color); +} + +a { + color: var(--portfolio-nav-color); +} + +.btn.nav-btn{ + background-color: var(--portfolio-nav-color); + color: white; +} + +.portfolio .nav-item .nav-link.active { + background-color: var(--portfolio-nav-color); + color: white; + border-bottom-color: black; +} + +.portfolio .nav-item .nav-link:hover, .btn.nav-btn:hover { + background-color: #8DABBE; + color: black; +} + +.portfolio .navbar .text-end { + text-align: right; +} + +.portfolio .nav-flex { + height: fit-content; +} + +.portfolio .navbar .nav-item .nav-link .chevron.float-right { + color: white; + float: right; + padding-left: .25rem; +} + +.portfolio .btn-outline-primary { + --bs-btn-color: var(--portfolio-nav-color); + --bs-btn-border-color: var(--portfolio-nav-color); + --bs-btn-hover-color: #fff; + --bs-btn-hover-bg: var(--portfolio-nav-color); + --bs-btn-hover-border-color: var(--portfolio-nav-color); + --bs-btn-focus-shadow-rgb: 13, 110, 253; + --bs-btn-active-color: #fff; + --bs-btn-active-bg: var(--portfolio-nav-color); + --bs-btn-active-border-color: var(--portfolio-nav-color); + --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); + --bs-btn-disabled-color: var(--portfolio-nav-color); + --bs-btn-disabled-bg: transparent; + --bs-btn-disabled-border-color: var(--portfolio-nav-color); + --bs-gradient: none; +} + +.portfolio .nav-tabs .nav-link{ + /* border-top-left-radius: 0px; + border-top-right-radius: 0px; */ + padding: .25rem .5rem; +} + +.portfolio .breadcrumb .breadcrumb-item.active { + color: black; +} + +.portfolio .breadcrumb .breadcrumb-item.active a { + text-decoration: none; + color: black; +} diff --git a/src/styles.css b/src/styles.css index 9fb01ac9..0c12ab6a 100644 --- a/src/styles.css +++ b/src/styles.css @@ -5,6 +5,10 @@ --energy-opp-color: #2e4053; --metric-color: #1f618d; --neb-color: #085646; + --company-color: #5b2c6f; + --facility-color: #212f3c; + --assessment-color: #196f3d; + --portfolio-nav-color: #006aaa; }