/*
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

(function() {
  'use strict';

  /**
   * @ngdoc overview
   * @ngname horizon.cluster.clusters
   *
   * @description
   * Provides all of the services and widgets required
   * to support and display clusters related content.
   */
  angular
    .module('horizon.cluster.clusters', [
      'ngRoute',
      'horizon.cluster.clusters.actions',
      'horizon.cluster.clusters.details'
    ])
    .constant('horizon.app.core.clusters.resourceType', 'OS::Senlin::Cluster')
    .run(run)
    .config(config);

  run.$inject = [
    'horizon.framework.conf.resource-type-registry.service',
    'horizon.cluster.clusters.service',
    'horizon.app.core.clusters.basePath',
    'horizon.app.core.clusters.resourceType'
  ];

  function run(registry, clusterService, basePath, clusterResourceType) {
    registry.getResourceType(clusterResourceType)
      .setNames(gettext('Cluster'), gettext('Clusters'))
      .setSummaryTemplateUrl(basePath + 'details/drawer.html')
      .setProperties(clusterProperties())
      .setListFunction(clusterService.getClustersPromise)
      .tableColumns
      .append({
        id: 'name',
        priority: 1,
        sortDefault: true,
        urlFunction: clusterService.getDetailsClusterPath
      })
      .append({
        id: 'status',
        priority: 1
      })
      .append({
        id: 'status_reason',
        priority: 2
      })
      .append({
        id: 'profile_name',
        priority: 2,
        urlFunction: clusterService.getDetailsProfilePath
      })
      .append({
        id: 'created_at',
        priority: 2
      })
      .append({
        id: 'updated_at',
        priority: 1
      });
  }

  function clusterProperties() {
    return {
      id: { label: gettext('ID'), filters: ['noValue']},
      name: { label: gettext('Name'), filters: ['noName']},
      status: { label: gettext('Status'), filters: ['noValue']},
      status_reason: { label: gettext('Status Reason')},
      profile_name: { label: gettext('Profile Name')},
      created_at: { label: gettext('Created'), filters: ['simpleDate']},
      updated_at: { label: gettext('Updated'), filters: ['simpleDate']}
    };
  }

  config.$inject = [
    '$provide',
    '$windowProvider',
    '$routeProvider'
  ];

  /**
   * @name config
   * @param {Object} $provide
   * @param {Object} $windowProvider
   * @param {Object} $routeProvider
   * @description Routes used by this module.
   * @returns {undefined} Returns nothing
   */
  function config($provide, $windowProvider, $routeProvider) {
    var path = $windowProvider.$get().STATIC_URL + 'app/core/clusters/';
    $provide.constant('horizon.app.core.clusters.basePath', path);

    $routeProvider.when('/cluster', {
      templateUrl: path + 'panel.html'
    });
  }
})();

@@ -1027,16 +1027,467 @@
 uster')%0A
+    .constant('horizon.app.core.clusters.statuses', %7B%0A      INIT: gettext('INIT'),%0A      ACTIVE: gettext('ACTIVE'),%0A      ERROR: gettext('ERROR'),%0A      CRITICAL: gettext('CRITICAL'),%0A      WARNING: gettext('WARNING'),%0A      CREATING: gettext('CREATING'),%0A      UPDATING: gettext('UPDATING'),%0A      DELETING: gettext('DELETING'),%0A      RESIZING: gettext('RESIZING'),%0A      CHECKING: gettext('CHECKING'),%0A      RECOVERING: gettext('RECOVERING')%0A    %7D)%0A
     .run
@@ -1719,16 +1719,58 @@
 rceType'
+,%0A    'horizon.app.core.clusters.statuses'
 %0A  %5D;%0A%0A 
@@ -1838,16 +1838,26 @@
 urceType
+, statuses
 ) %7B%0A    
@@ -2061,16 +2061,24 @@
 perties(
+statuses
 ))%0A     
@@ -2751,16 +2751,24 @@
 perties(
+statuses
 ) %7B%0A    
@@ -2934,16 +2934,34 @@
 tatus'),
+ values: statuses,
  filters

Cluster status should be translatable