import { Injectable } from '@angular/core' ; import { NavigationEnd } from "@angular/router" ; import { Breadcrumb } from "./models/breadcrumb" ; import { Logger } from "angular2-logger/core" ; import { WsCacheService } from "../data-services/ws-cache.service" ; import { Subject , BehaviorSubject } from "rxjs" ; import { WebService } from "../api-services/models/web-service.interface" ; import { Organization } from "../api-services/models/organization.class" ; import { SslSupport } from "../api-services/models/ssl-support.class" ; @ Injectable ( ) export class WsBreadcrumbsService { private _currentBreadcrumbs : Breadcrumb [ ] ; public breadcrumbsChanged : Subject < Breadcrumb [ ] > = new BehaviorSubject < Breadcrumb [ ] > ( [ ] ) ; constructor ( private logger , private cacheService ) { } private getBreadcrumbForAccountSettings ( ) { return { url : '/account/settings' , label : 'Account Settings' , } ; } private getBreadcrumbForDomainReportsList ( orgUuid ) { return { url : '/topography/' + orgUuid + '/domain-names/' , label : 'Domain Names' , } ; } private getBreadcrumbForManageUsers ( ) { return { url : '/admin/manage-users' , label : 'Manage Users' , } ; } private getBreadcrumbForOrderCheckout ( organizationUuid , orderUuid ) { return { url : '/organizations/' + organizationUuid + '/check-out/' + orderUuid , label : 'Check Out' } ; } private getBreadcrumbForMyAccountHome ( ) { return { url : '/account/home' , label : 'Manage My Account' , } ; } private getBreadcrumbForMyOrganizations ( ) { return { url : '/organizations/mine' , label : 'Manage Organizations' } ; } private getBreadcrumbForOrderScanConfig ( organizationUuid , orderUuid ) { return { url : '/organizations/' + organizationUuid + '/configure-scan/' + orderUuid , label : 'Configure Scan' , } ; } private getBreadcrumbForOrganizationDetails ( organization ) { return { url : '/organizations/' + organization . uuid , label : organization . name } ; } private getBreadcrumbForSslSupportDetails ( orgUuid , sslSupport ) { return { url : '/topography/' + orgUuid + '/ssl-support/' + sslSupport . uuid , label : sslSupport . endpoint , } ; } private getBreadcrumbForSslSupportList ( orgUuid ) { return { url : '/topography/' + orgUuid + '/ssl-support' , label : 'SSL Support' , } ; } private getBreadcrumbForTopographyHome ( orgUuid ) { return { url : '/topography/' + orgUuid , label : 'Topography Home' , } ; } private getBreadcrumbForWebApplications ( orgUuid ) { return { url : '/topography/' + orgUuid + '/web-applications' , label : 'Web Applications' , } ; } private getBreadcrumbForWebAppDetails ( webService ) { return { url : '/topography/' + webService . org_uuid + '/web-app/' + webService . uuid , label : webService . url , } ; } private getBreadcrumbForWebAppsList ( orgUuid ) { return { url : '/topography/' + orgUuid + '/web-apps/' , label : 'Web Applications' , } ; } private getBreadcrumbForWebService ( orgUuid , appUuid , url ) { return { url : '/topography/' + orgUuid + '/web-application/' + appUuid , label : url , } ; } public setBreadcrumbsForAccountSettings ( ) { this . currentBreadcrumbs = [ this . getBreadcrumbForAccountSettings ( ) ] ; } public setBreadcrumbsForDomainReportsList ( orgUuid ) { this . currentBreadcrumbs = [ this . getBreadcrumbForTopographyHome ( orgUuid ) , this . getBreadcrumbForDomainReportsList ( orgUuid ) , ] ; } public setBreadcrumbsForManageUsers ( ) { this . currentBreadcrumbs = [ this . getBreadcrumbForManageUsers ( ) ] ; } public setBreadcrumbsForMyAccountHome ( ) { this . currentBreadcrumbs = [ this . getBreadcrumbForMyAccountHome ( ) ] ; } public setBreadcrumbsForMyOrganizations ( ) { this . currentBreadcrumbs = [ this . getBreadcrumbForMyOrganizations ( ) ] ; } public setBreadcrumbsForOrderCheckout ( organization , orderUuid ) { this . currentBreadcrumbs = [ this . getBreadcrumbForMyOrganizations ( ) , this . getBreadcrumbForOrganizationDetails ( organization ) , this . getBreadcrumbForOrderCheckout ( organization . uuid , orderUuid ) , ] ; } public setBreadcrumbsForOrganizationDetails ( organization ) { this . currentBreadcrumbs = [ this . getBreadcrumbForMyOrganizations ( ) , this . getBreadcrumbForOrganizationDetails ( organization ) , ] ; } public setBreadcrumbsForScanConfig ( organization , orderUuid ) { this . currentBreadcrumbs = [ this . getBreadcrumbForMyOrganizations ( ) , this . getBreadcrumbForOrganizationDetails ( organization ) , this . getBreadcrumbForOrderScanConfig ( organization . uuid , orderUuid ) , ] ; } public setBreadcrumbsForSslSupportList ( orgUuid ) { this . currentBreadcrumbs = [ this . getBreadcrumbForTopographyHome ( orgUuid ) , this . getBreadcrumbForSslSupportList ( orgUuid ) , ] ; } public setBreadcrumbsForSslSupportDetails ( orgUuid , sslSupport ) { this . currentBreadcrumbs = [ this . getBreadcrumbForTopographyHome ( orgUuid ) , this . getBreadcrumbForSslSupportList ( orgUuid ) , this . getBreadcrumbForSslSupportDetails ( orgUuid , sslSupport ) , ] ; } public setBreadcrumbsForTopographyHome ( orgUuid ) { this . currentBreadcrumbs = [ this . getBreadcrumbForTopographyHome ( orgUuid ) ] ; } public setBreadcrumbsForWebApplication ( orgUuid , appUuid , url ) { let breadcrumbs = [ this . getBreadcrumbForTopographyHome ( orgUuid ) , this . getBreadcrumbForWebApplications ( orgUuid ) , this . getBreadcrumbForWebService ( orgUuid , appUuid , url ) ] ; this . currentBreadcrumbs = breadcrumbs ; } public setBreadcrumbsForWebApplications ( orgUuid ) { let breadcrumbs = [ this . getBreadcrumbForTopographyHome ( orgUuid ) , this . getBreadcrumbForWebApplications ( orgUuid ) , ] ; this . currentBreadcrumbs = breadcrumbs ; } public setBreadcrumbsForWebAppDetails ( webService ) { this . currentBreadcrumbs = [ this . getBreadcrumbForTopographyHome ( webService . org_uuid ) , this . getBreadcrumbForWebAppsList ( webService . org_uuid ) , this . getBreadcrumbForWebAppDetails ( webService ) , ] ; } public setBreadcrumbsForWebAppsList ( orgUuid ) { this . currentBreadcrumbs = [ this . getBreadcrumbForTopographyHome ( orgUuid ) , this . getBreadcrumbForWebAppsList ( orgUuid ) , ] ; } get currentBreadcrumbs ( ) : Breadcrumb [ ] { return this . _currentBreadcrumbs ; } set currentBreadcrumbs ( newCrumbs ) { this . _currentBreadcrumbs = newCrumbs ; this . breadcrumbsChanged . next ( newCrumbs ) ; } }