@ -1,23 +1,30 @@
/// <reference path="../../includes.ts"/>
/// <reference path="../../includes.ts"/>
module Developer {
module Developer {
/ *
var log = Logger . get ( 'developer-navigation' ) ;
function homeBreadcrumb() {
return {
export type LabelResolver = ( ) = > string ;
href : "/home" ,
label : "Home" ,
export interface BreadcrumbConfig {
title : "Go to the home page"
href? : string ;
}
label? : string | LabelResolver ;
title? : string ;
class ? : string ;
isValid ? : ( ) = > boolean ;
isActive ? : ( subTab , path ) = > boolean ;
}
}
* /
function developBreadcrumb() {
function developBreadcrumb ( ) : BreadcrumbConfig {
return {
return {
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" ) ,
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" ) ,
label : "Develop" ,
label : "Teams" ,
title : "View all the apps for a project"
title : "View all the available teams" ,
isActive : ( subTab , path ) = > false
} ;
} ;
}
}
function operateBreadcrumb() {
function operateBreadcrumb ( ) : BreadcrumbConfig {
return {
return {
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/namespaces" ) ,
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/namespaces" ) ,
label : "Manage" ,
label : "Manage" ,
@ -38,21 +45,8 @@ module Developer {
}
}
}
}
export function createWorkspacesBreadcrumbs ( developPerspective ) {
export function createWorkspacesBreadcrumbs ( developPerspective ? ) {
/ *
return [ developBreadcrumb ( ) ] ;
if ( developPerspective ) {
return [
//homeBreadcrumb(),
developBreadcrumb ( )
] ;
} else {
return [
//homeBreadcrumb(),
operateBreadcrumb ( )
] ;
}
* /
return [ ] ;
}
}
@ -64,10 +58,7 @@ module Developer {
}
}
export function createWorkspaceBreadcrumbs ( children = null , workspaceName = null ) {
export function createWorkspaceBreadcrumbs ( children = null , workspaceName = null ) {
var answer = [
var answer = createWorkspacesBreadcrumbs ( true ) ;
//homeBreadcrumb(),
developBreadcrumb ( )
] ;
if ( ! workspaceName ) {
if ( ! workspaceName ) {
workspaceName = Kubernetes . currentKubernetesNamespace ( ) ;
workspaceName = Kubernetes . currentKubernetesNamespace ( ) ;
}
}
@ -76,7 +67,8 @@ module Developer {
{
{
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces/" , workspaceName ) ,
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces/" , workspaceName ) ,
label : workspaceName ,
label : workspaceName ,
title : "View the project: " + workspaceName
title : "View the project: " + workspaceName ,
isActive : ( subTab , path ) = > false
}
}
) ;
) ;
return processChildren ( answer , children ) ;
return processChildren ( answer , children ) ;
@ -90,55 +82,64 @@ module Developer {
var namespacesLink = UrlHelpers . join ( HawtioCore . documentBase ( ) , "/kubernetes/namespace" ) ;
var namespacesLink = UrlHelpers . join ( HawtioCore . documentBase ( ) , "/kubernetes/namespace" ) ;
var workspaceName = $routeParams . workspace ;
var workspaceName = $routeParams . workspace ;
var project = $routeParams . project ;
var project = $routeParams . project ;
var environment = $routeParams . namespace ;
if ( workspaceName && project ) {
if ( workspaceName && project ) {
var projectLink = UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , project ) ;
var projectLink = UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , project ) ;
$scope . $projectLink = projectLink ;
$scope . $projectLink = projectLink ;
$scope . $projectNamespaceLink = UrlHelpers . join ( projectLink , "namespace" , ns ) ;
$scope . $projectNamespaceLink = UrlHelpers . join ( projectLink , "namespace" , ns ) ;
namespacesLink = UrlHelpers . join ( projectLink , "namespace" ) ;
namespacesLink = UrlHelpers . join ( projectLink , "namespace" ) ;
// TODO use the logical name?
var children : Array < BreadcrumbConfig > = [
var envName = ns ;
{
var buildConfig = null ;
href : UrlHelpers.join ( projectLink , "environments" ) ,
if ( $scope . model ) {
label : "Environments" ,
buildConfig = $scope . model . getProject ( project , workspaceName ) ;
title : "View the environments for this project"
if ( buildConfig ) {
} ,
// lets find the label for the namespace
var env = _ . find ( buildConfig . environments , { namespace : ns } ) ;
if ( env ) {
envName = env [ 'label' ] || envName ;
}
log . info ( "env found: " + env + " for nameppace " + ns + " on buildConfig: " + buildConfig ) ;
}
}
var children = [
{
href : UrlHelpers.join ( projectLink , "environments" ) ,
label : "Environments" ,
title : "View the environments for this project"
} ,
{
href : UrlHelpers.join ( namespacesLink , ns , "apps" ) ,
label : envName ,
title : "View the runtime of the workspace: " + ns
}
] ;
return createProjectBreadcrumbs ( project , children , workspaceName ) ;
} else {
if ( ! workspaceName ) {
workspaceName = Kubernetes . currentKubernetesNamespace ( ) ;
}
return activateCurrent ( [
//homeBreadcrumb(),
operateBreadcrumb ( ) ,
{
{
href : UrlHelpers.join ( namespacesLink , ns , "apps" ) ,
href : UrlHelpers.join ( namespacesLink , ns , "apps" ) ,
label : workspaceName ,
label : ( ) = > environmentName ( workspaceName , ns ) ,
title : "View the runtime of the workspace: " + ns
title : "View the runtime of the workspace: " + ns
}
}
] ) ;
] ;
return createProjectBreadcrumbs ( project , children , workspaceName ) ;
} else if ( workspaceName && environment && workspaceName != environment ) {
// find label for namespace environment
var children : Array < BreadcrumbConfig > = [
{
href : environmentsLink ( workspaceName ) ,
label : "Environments" ,
title : "View the environments for this project"
} ,
{
href : environmentLink ( workspaceName , environment ) ,
label : ( ) = > environmentName ( workspaceName , environment ) ,
title : "View this environment"
}
] ;
return createProjectBreadcrumbs ( project , children , workspaceName ) ;
} else if ( ! workspaceName ) {
workspaceName = Kubernetes . currentKubernetesNamespace ( ) ;
}
var answer = createWorkspaceBreadcrumbs ( workspaceName ) ;
answer . push ( {
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "workspaces" , workspaceName , "namespace" , ns , "apps" ) ,
label : 'Runtime' ,
title : "View the runtime of the workspace: " + ns
} ) ;
return activateCurrent ( answer ) ;
}
/ * *
* Returns the name of the given environment namespace
* /
function environmentName ( workspaceName , environment ) {
var model = Kubernetes . getKubernetesModel ( ) ;
if ( model ) {
return model . environmentName ( workspaceName , environment ) ;
}
}
return environment ;
}
}
export function createProjectBreadcrumbs ( projectName = null , children = null , workspaceName = null ) {
export function createProjectBreadcrumbs ( projectName = null , children : Array < BreadcrumbConfig > = null , workspaceName = null ) {
if ( ! workspaceName ) {
if ( ! workspaceName ) {
workspaceName = Kubernetes . currentKubernetesNamespace ( ) ;
workspaceName = Kubernetes . currentKubernetesNamespace ( ) ;
}
}
@ -168,12 +169,9 @@ module Developer {
export function createProjectSettingsBreadcrumbs ( projectName , workspaceName = null ) {
export function createProjectSettingsBreadcrumbs ( projectName , workspaceName = null ) {
var children = [ {
var children = [ ] ;
label : "Settings" ,
title : "View the settings of this app"
} ] ;
if ( ! projectName ) {
if ( ! projectName ) {
var children = [ {
children = [ {
label : "New App" ,
label : "New App" ,
title : "Lets make a new app"
title : "Lets make a new app"
} ] ;
} ] ;
@ -186,6 +184,12 @@ module Developer {
return activateCurrent ( [
return activateCurrent ( [
{
{
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName ) ,
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName ) ,
label : "Dashboard" ,
class : "fa fa-tachometer" ,
title : "View the dashboard for the apps, environments and pipelines in this project"
} ,
{
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "apps" ) ,
label : "Apps" ,
label : "Apps" ,
class : "fa fa-rocket" ,
class : "fa fa-rocket" ,
title : "View the apps in this project"
title : "View the apps in this project"
@ -198,25 +202,78 @@ module Developer {
title : "View the builds in this project"
title : "View the builds in this project"
} ,
} ,
{
{
href : UrlHelpers.join( HawtioCore . documentBase ( ) , "/kubernetes/namespace" , workspaceName , "apps" ) ,
href : environmentsLink( ) ,
label : " Runtime ",
label : " Environments ",
class : "fa fa- gear s",
class : "fa fa- cube s",
title : "View the runtime resources in this project"
title : "View the environments for this project"
} ,
} ,
{
href : namespaceRuntimeLink ( workspaceName ) ,
label : "Runtime" ,
class : "fa fa-cube" ,
title : "View the Runtime perspective for this project"
}
/ *
{
{
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "detail" ) ,
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "detail" ) ,
label : "Details" ,
label : "Details" ,
class : "fa fa-gear" ,
class : "fa fa-gear" ,
title : "View the project details"
title : "View the project details"
}
}
* /
] ) ;
] ) ;
}
}
export function namespaceRuntimeLink ( workspaceName = null ) {
if ( ! workspaceName ) {
workspaceName = Kubernetes . currentKubernetesNamespace ( ) ;
}
return UrlHelpers . join ( HawtioCore . documentBase ( ) , "workspaces" , workspaceName , "namespace" , workspaceName , "apps" ) ;
}
function createBuildsLink ( workspaceName , projectName , jenkinsJobId ) {
function createBuildsLink ( workspaceName , projectName , jenkinsJobId ) {
workspaceName = workspaceName || Kubernetes . currentKubernetesNamespace ( ) ;
workspaceName = workspaceName || Kubernetes . currentKubernetesNamespace ( ) ;
return UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , projectName , "jenkinsJob" , jenkinsJobId ) ;
return UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , projectName , "jenkinsJob" , jenkinsJobId ) ;
}
}
/ * *
* Creates a routing function that loads a template and inject the needed directives to properly
* display / update the Developer module managed tabs and bread crumbs for when the route is active .
*
* Example Usage :
*
* var route = Developer . createTabRoutingFunction ( "/app/somedir" ) ;
* $routeProvider . when ( '/profiles' , route ( 'view.html' , false , [ {
* label : "Profiles" ,
* title : "Browse the profiles of this project"
* } ]
* ) ) ;
*
* @param baseURL
* @returns { function ( string , boolean = , Array < Developer.BreadcrumbConfig > = ) : { template : string , reloadOnSearch : boolean , controller : string | string | ( function ( any , ng . route . IRouteParamsService ) : undefined ) [ ] } }
* /
export function createTabRoutingFunction ( baseURL :string ) {
return ( templateName :string , reloadOnSearch :boolean = true , children? : Array < Developer.BreadcrumbConfig > ) = > {
return {
template : "<div hawtio-breadcrumbs></div><div hawtio-tabs></div><ng-include src='contentTemplateUrl'></ng-include>" ,
reloadOnSearch : reloadOnSearch ,
controller : [ "$scope" , "$routeParams" , ( $scope , $routeParams :ng.route.IRouteParamsService ) = > {
if ( $routeParams [ "namespace" ] == null ) {
log . error ( "The :namespace route parameter was not defined for the route." ) ;
}
if ( $routeParams [ "projectId" ] == null ) {
log . error ( "The :projectId route parameter was not defined for the route." ) ;
}
$scope . namespace = $routeParams [ "namespace" ] ;
$scope . projectId = $routeParams [ "projectId" ] ;
$scope . contentTemplateUrl = UrlHelpers . join ( baseURL , templateName ) ;
$scope . breadcrumbConfig = Developer . createProjectBreadcrumbs ( $scope . projectId , children ) ;
$scope . subTabConfig = Developer . createProjectSubNavBars ( $scope . projectId ) ;
} ]
} ;
}
}
export function createProjectSubNavBars ( projectName , jenkinsJobId = null , $scope = null ) {
export function createProjectSubNavBars ( projectName , jenkinsJobId = null , $scope = null ) {
var workspaceName = Kubernetes . currentKubernetesNamespace ( ) ;
var workspaceName = Kubernetes . currentKubernetesNamespace ( ) ;
var projectLink = UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , projectName ) ;
var projectLink = UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , projectName ) ;
@ -243,6 +300,7 @@ module Developer {
}
}
var answer = [
var answer = [
/ *
{
{
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName ) ,
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName ) ,
label : "All Apps" ,
label : "All Apps" ,
@ -252,20 +310,22 @@ module Developer {
{
{
template : ` <div ng-include="'plugins/developer/html/projectSelector.html'"></div> `
template : ` <div ng-include="'plugins/developer/html/projectSelector.html'"></div> `
} ,
} ,
* /
{
{
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , projectName , "environments" ) ,
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , projectName , "environments" ) ,
isActive : ( subTab , path ) = > {
isActive : ( subTab , path ) = > {
var href = normalizeHref ( subTab . href ) ;
//console.log("subTab: ", subTab, " path: ", path);
//console.log("subTab: ", subTab, " path: ", path);
if ( path === subTab. href) {
if ( path === href) {
return true ;
return true ;
}
}
var rootPath = subTab. href. replace ( /\/environments/ , '' ) ;
var rootPath = href. replace ( /\/environments/ , '' ) ;
if ( path === rootPath ) {
if ( path === rootPath ) {
return true ;
return true ;
}
}
return false ;
return false ;
} ,
} ,
//href: UrlHelpers.join( "/workspaces", workspaceName, "projects", projectName),
//href: UrlHelpers.join( HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName),
label : "Dashboard" ,
label : "Dashboard" ,
class : "fa fa-tachometer" ,
class : "fa fa-tachometer" ,
title : "View the app dashboard for the activity, environments and pipelines"
title : "View the app dashboard for the activity, environments and pipelines"
@ -287,6 +347,15 @@ module Developer {
} ,
} ,
{
{
isValid : ( ) = > isJenkinsBuild ( ) ,
isValid : ( ) = > isJenkinsBuild ( ) ,
isActive : ( item , path ) = > {
if ( path . indexOf ( '/log/' ) > 0 ) {
return false ;
}
if ( path . indexOf ( '/jenkinsJob/' ) > 0 ) {
return true ;
}
return false ;
} ,
id : "builds" ,
id : "builds" ,
href : jenkinsBuildLink ,
href : jenkinsBuildLink ,
label : "Builds" ,
label : "Builds" ,
@ -302,7 +371,7 @@ module Developer {
} ,
} ,
/ *
/ *
{
{
href : UrlHelpers.join ( "/workspaces" , workspaceName , "projects" , projectName , "tools" ) ,
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , projectName , "tools" ) ,
label : "Tools" ,
label : "Tools" ,
title : "View the tools for this project"
title : "View the tools for this project"
} ,
} ,
@ -441,6 +510,23 @@ module Developer {
return UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , projectName , path ) ;
return UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , projectName , path ) ;
}
}
export function environmentsLink ( workspaceName = null ) {
if ( ! workspaceName ) {
workspaceName = Kubernetes . currentKubernetesNamespace ( ) ;
}
return UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "environments" )
}
export function environmentLink ( workspaceName , environmentNamespace , path = "" , ignoreBlankProject = true ) {
if ( ignoreBlankProject && ! environmentNamespace ) {
return "" ;
}
if ( ! workspaceName ) {
workspaceName = Kubernetes . currentKubernetesNamespace ( ) ;
}
return UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "namespace" , environmentNamespace , path ) ;
}
export var customProjectSubTabFactories = [ ] ;
export var customProjectSubTabFactories = [ ] ;
export function createJenkinsBreadcrumbs ( projectName , jobId , buildId ) {
export function createJenkinsBreadcrumbs ( projectName , jobId , buildId ) {
@ -467,7 +553,7 @@ module Developer {
export function createJenkinsSubNavBars ( projectName , jenkinsJobId , buildId , extraOption : any = null ) {
export function createJenkinsSubNavBars ( projectName , jenkinsJobId , buildId , extraOption : any = null ) {
var answer = createProjectSubNavBars ( projectName , jenkinsJobId ) ;
var answer = createProjectSubNavBars ( projectName , jenkinsJobId ) ;
if ( extraOption ) {
if ( extraOption ) {
extraOption . active = true ;
// extraOption.active = true;
answer . push ( extraOption ) ;
answer . push ( extraOption ) ;
}
}
return answer ;
return answer ;
@ -478,75 +564,53 @@ module Developer {
var ns = Kubernetes . currentKubernetesNamespace ( ) ;
var ns = Kubernetes . currentKubernetesNamespace ( ) ;
var workspaceName = $routeParams . workspace ;
var workspaceName = $routeParams . workspace ;
var project = $routeParams . project ;
var project = $routeParams . project ;
var environment = $routeParams . namespace ;
var projectLink = UrlHelpers . join ( HawtioCore . documentBase ( ) , "/kubernetes" ) ;
var projectLink = UrlHelpers . join ( HawtioCore . documentBase ( ) , "/kubernetes" ) ;
/ * c o n s o l e . l o g ( " = = = = = = = = = = = = = = = = = = = = = " )
console . log ( projectLink ) ;
if ( workspaceName && project ) {
if ( workspaceName && project ) {
projectLink = UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , workspaceName , "projects" , project ) ;
projectLink = UrlHelpers . join ( HawtioCore . documentBase ( ) , "/kubernetes" , workspaceName , "projects" , project ) ;
}
} else {
var namespacesLink = UrlHelpers . join ( projectLink , "namespace" ) ;
projectLink = UrlHelpers . join ( HawtioCore . documentBase ( ) , "/kubernetes" , workspaceName || ns ) ;
return activateCurrent ( [
} * /
{
var namespacesLink = UrlHelpers . join ( projectLink , "namespace" ) ;
href : UrlHelpers.join ( projectLink , "environments" ) ,
return activateCurrent ( [
label : "<< Back To App" ,
title : "Go back to the Dashboard for this App" ,
isValid : ( ) = > project
} ,
{
href : UrlHelpers.join ( namespacesLink , ns , "apps" ) ,
label : "Overview" ,
class : "fa fa-list" ,
title : "Overview of all the apps for this project"
} ,
{
href : UrlHelpers.join ( namespacesLink , ns , "services" ) ,
label : "Services" ,
class : "fa fa-plug" ,
title : "View the apps for this project"
} ,
{
{
href : UrlHelpers.join ( namespacesLink , ns , "replicationControllers" ) ,
href : UrlHelpers.join ( namespacesLink , ns , "replicationControllers" ) ,
label : " Controllers ",
label : "服务管理" ,
class : "fa fa-clone" ,
class : "fa fa-clone" ,
title : "View the Replication Controllers for this project"
title : "View the Replicas for this project"
} ,
} ,
{
href : UrlHelpers.join ( namespacesLink , ns , "pods" ) ,
label : "Pods" ,
class : "fa fa-puzzle-piece" ,
title : "View the pods for this project"
} ,
{
{
href : UrlHelpers.join ( namespacesLink , ns , "events" ) ,
href : UrlHelpers.join ( namespacesLink , ns , "events" ) ,
label : " Events ",
label : "日志信息" ,
class : "fa fa-newspaper-o" ,
class : "fa fa-newspaper-o" ,
title : "View the events for this project"
title : "View the events for this project"
} ,
} ,
{
{
href : UrlHelpers.join ( namespacesLink , ns , "secrets" ) ,
href : UrlHelpers.join ( projectLink , "hosts" ) ,
label : "Secrets" ,
label : "集群节点" ,
class : "fa fa-key" ,
title : "View the secrets for this project"
} ,
{
href : UrlHelpers.join ( HawtioCore . documentBase ( ) , "/kubernetes/hosts" ) ,
label : "Nodes" ,
class : "fa fa-server" ,
class : "fa fa-server" ,
title : "View the nodes for this project"
title : "View the nodes for this project"
} ,
}
{
href : UrlHelpers.join ( namespacesLink , ns , "overview" ) ,
label : "Diagram" ,
class : "fa fa-sitemap" ,
title : "View all the objects in this project and their relationship"
} ,
{
href : UrlHelpers.join ( namespacesLink , ns , "angryPods" ) ,
label : "Angry Pods" ,
class : "fa fa-gamepad" ,
title : "Try the Angry Pods game!"
} ,
] ) ;
] ) ;
}
}
export function environmentInstanceLink ( env , projectName = null ) {
if ( env ) {
var envNamespace = env [ "namespace" ] ;
if ( envNamespace ) {
if ( projectName ) {
return UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , Kubernetes . currentKubernetesNamespace ( ) , "projects" , projectName , "namespace" , envNamespace ) ;
} else {
return UrlHelpers . join ( HawtioCore . documentBase ( ) , "/workspaces" , Kubernetes . currentKubernetesNamespace ( ) , "namespace" , envNamespace ) ;
}
}
}
return "" ;
}
export function namespaceLink ( $scope , $routeParams , path = null ) {
export function namespaceLink ( $scope , $routeParams , path = null ) {
var ns = Kubernetes . currentKubernetesNamespace ( ) ;
var ns = Kubernetes . currentKubernetesNamespace ( ) ;
@ -572,32 +636,68 @@ module Developer {
return text ;
return text ;
}
}
// Cater for the app running at some weird document base
export function normalizeHref ( href :string ) {
if ( ! href ) {
return null ;
}
var regex = new RegExp ( '^' + HawtioCore . documentBase ( ) . replace ( '/' , '\\/' ) ) ;
return href . replace ( regex , '/' ) ;
}
function activateCurrent ( navBarItems ) {
function activateCurrent ( navBarItems ) {
navBarItems = _ . compact ( navBarItems ) ;
navBarItems = _ . compact ( navBarItems ) ;
var injector = HawtioCore . injector ;
var injector = HawtioCore . injector ;
var $location = injector ? injector . get < ng.ILocationService > ( "$location" ) : null ;
var $location = injector ? injector . get < ng.ILocationService > ( "$location" ) : null ;
if ( $location ) {
if ( $location ) {
var path = trimQuery ( $location . path ( ) ) ;
var path = normalizeHref( trimQuery( $location . path ( ) ) ) ;
var found = false ;
var found = false ;
function makeActive ( item ) {
function makeActive ( item ) {
item . active = true ;
item . active = true ;
found = true ;
found = true ;
}
}
function getHref ( item ) {
var href = item . href ;
var trimHref = trimQuery ( href ) ;
return normalizeHref ( trimHref ) ;
}
angular . forEach ( navBarItems , ( item ) = > {
angular . forEach ( navBarItems , ( item ) = > {
if ( item ) {
if ( ! found && item ) {
if ( angular . isFunction ( item . isActive ) ) {
if ( angular . isFunction ( item . isActive ) ) {
if ( ! found && item . isActive ( item , path ) ) {
if ( item . isActive ( item , path ) ) {
makeActive ( item ) ;
makeActive ( item ) ;
}
}
} else {
} else {
var href = item . href ;
var trimHref = getHref ( item ) ;
var trimHref = trimQuery ( href ) ;
if ( ! trimHref ) {
if ( ! found && trimHref && trimHref === path ) {
return ;
}
if ( trimHref === path ) {
makeActive ( item ) ;
makeActive ( item ) ;
}
}
}
}
}
}
} ) ;
} ) ;
// Maybe it's a sub-item of a tab, let's fall back to that maybe
if ( ! found ) {
angular . forEach ( navBarItems , ( item ) = > {
if ( ! found ) {
if ( ! angular . isFunction ( item . isActive ) ) {
var trimHref = getHref ( item ) ;
if ( ! trimHref ) {
return ;
}
if ( _ . startsWith ( path , trimHref ) ) {
makeActive ( item ) ;
}
}
}
} ) ;
}
// still not found, let's log it
if ( ! found ) {
log . debug ( "No navigation tab found for path:" , path ) ;
}
}
}
return navBarItems ;
return navBarItems ;
}
}