/// <reference path="../../includes.ts"/>
/// <reference path="developerHelpers.ts"/>

module Developer {

  export var _module = angular.module(pluginName, ['hawtio-core', 'hawtio-ui', 'ui.codemirror', 'nvd3', 'treeControl']);
  export var controller = PluginHelpers.createControllerFunction(_module, pluginName);
  export var route = PluginHelpers.createRoutingFunction(templatePath);

  _module.config(['$routeProvider', ($routeProvider:ng.route.IRouteProvider) => {    
    $routeProvider.when(context, route('workspaces.html', false))
                  .when("/data-manager", route('workspaces.html', false))
                  .when(UrlHelpers.join(context, 'Overview/:type/data-type/all'), route('workspaces.html', false))
                  .when(UrlHelpers.join(context, 'Overview/:type/data-type/financial'), route('workspaces.html', false))
                  .when(UrlHelpers.join(context, 'Overview/:type/data-type/social-security'), route('workspaces.html', false))
                  .when(UrlHelpers.join(context, 'task'), route('apps.html', false))
                  .otherwise(context);                       
}]);  

  _module.run(['viewRegistry', 'ServiceRegistry', 'HawtioNav', 'KubernetesModel', '$templateCache', (viewRegistry, ServiceRegistry, HawtioNav, KubernetesModel, $templateCache) => {
    log.debug("Running");
    viewRegistry['workspaces'] = Kubernetes.templatePath + 'layoutKubernetes.html';
    viewRegistry['namespaces'] = Kubernetes.templatePath + 'layoutKubernetes.html';

    var builder = HawtioNav.builder();

    var dmanagerTab = builder.id('dmanager')
                         .rank(200)
                         .href(() => context)
                         .title(() => '数据管理')
                         //.isValid(() => !Core.isRemoteConnection())                         
                         .build();

    HawtioNav.add(dmanagerTab);
  }]);

  _module.filter('asTrustedHtml', ['$sce', function ($sce) {
    return function (text) {
      return $sce.trustAsHtml(text);
    };
  }]);

  hawtioPluginLoader.addModule(pluginName);

  // for scroll-glue directive
  hawtioPluginLoader.addModule('luegg.directives');
}
