/// <reference path="../../includes.ts"/>
/// <reference path="systemHelpers.ts"/>
/// <reference path="../../configs/ts/configPlugin.ts"/>

module System{
	export var _module = angular.module(pluginName, ['hawtio-core', 'hawtio-ui', 'ui.codemirror', 'ui.validate', 'kubernetesUI', 'ngFileUpload', 'ngDialog']);
  	export var controller = PluginHelpers.createControllerFunction(_module, pluginName);
	export var route = PluginHelpers.createRoutingFunction(templatePath);

	/*
		页面路由配置
	*/
	_module.config(['$provide', '$routeProvider', ($provide, $routeProvider) =>{
		$routeProvider.when(UrlHelpers.join(context, '/'), route('systemList.html', false))
					  .when(UrlHelpers.join(context, 'system-list'), route('systemList.html', false))
					  .when(UrlHelpers.join(context, 'system-help'), route('regionalismCodeSearch.html', false))
					  .when(UrlHelpers.join(context, 'system-help', 'regionalism-search'), route('regionalismCodeSearch.html', false))
					  .when(UrlHelpers.join(context, 'system-help', 'system-search'), route('systemCodeSearch.html', false))
					  .when(UrlHelpers.join(context, 'system-verification'), route('systemVerification.html', false))
					  .when(UrlHelpers.join(context, 'system-sqlManagement'), route('systemSQLManagement.html', false))
					  .when(context, {redirectTo: UrlHelpers.join(context, 'system-list')});		   			  
	}]);

	/*
		模块加载后初始化配置
	*/
	_module.run(['viewRegistry', '$templateCache', 'HawtioNav', '$compile', (viewRegistry, $templateCache:ng.ITemplateCacheService, HawtioNav,  $compile:ng.ICompileService) => {
        viewRegistry['system'] = Configs.templatePath + "shareLayout.html"; 
        /*
        	信息系统一级菜单导航
        */
        var builder = HawtioNav.builder(); 
        var systemTab = builder.id('systemTab')
                     .rank(10)
                     .href(() => context)
                     .title(() => '信息系统')
                     //.isValid(() => !Core.isRemoteConnection())                         
                     .build();                     
         HawtioNav.add(systemTab);
    }]);

	// 加载模块 
	hawtioPluginLoader.addModule(pluginName); 
}