module ClientManagement
  class Engine < ::Rails::Engine
    initializer "client_management" do 
      OrbitApp.registration "client_management", :type => "ModuleApp" do
        module_label "client_management.client_management"
        base_url File.expand_path File.dirname(__FILE__)
        categorizable
        authorizable
        taggable "SiteServer"
        # frontend_enabled
        # data_count 1..30
        require File.expand_path('../../../app/models/server_ability', __FILE__)
        require File.expand_path('../../../app/models/plow_setting', __FILE__)
        if ServerAbility.count==0
          ServerAbility.create()
        end
        if PlowSetting.count==0
          PlowSetting.create()
        end
        set_keyword_contstraints ["/cpanel/"]
        side_bar do
          head_label_i18n 'client_management.client_management', icon_class: "icons-users"
          available_for "admin"
          active_for_controllers (['admin/site_panels'])
          head_link_path "admin_site_panel_server_manager_path"

          context_link 'client_management.new_requests',
                :link_path=>"admin_client_managements_path" ,
                :priority=>1,
                :active_for_action=>{'admin/client_managements'=>"index"},
                :available_for => 'admin'

          context_link 'client_management.completed_requests',
                :link_path=>"completed_requests_admin_client_managements_path" ,
                :priority=>1,
                :active_for_action=>{'admin/client_managements'=>"completed_requests"},
                :available_for => 'admin'

          context_link 'client_management.contracts',
                :link_path=>"contracts_admin_client_managements_path" ,
                :priority=>1,
                :active_for_action=>{'admin/client_managements'=>"contracts"},
                :available_for => 'admin'

          context_link 'client_management.setting',
                :link_path=>"admin_site_panel_setting_path" ,
                :priority=>1,
                :active_for_action=>{'admin/site_panel'=>"setting"},
                :available_for => 'admin'
          context_link 'client_management.cert_management',
                :link_path=>"cert_management_admin_site_panel_index_path" ,
                :priority=>1,
                :active_for_action=>{'admin/site_panel'=>"cert_management"},
                :available_for => 'admin'
          context_link 'client_management.create_site',
                :link_path=>"admin_site_panel_path" ,
                :priority=>1,
                :active_for_action=>{'admin/site_panel'=>"index"},
                :available_for => 'admin'

          context_link 'client_management.sites_list',
                :link_path=>"admin_site_panel_sites_list_path" ,
                :priority=>1,
                :active_for_action=>{'admin/site_panel'=>"sites_list"},
                :available_for => 'admin'

          context_link 'client_management.server_manager',
                :link_path=>"admin_site_panel_server_manager_path" ,
                :priority=>1,
                :active_for_action=>{'admin/site_panel'=>"server_manager"},
                :available_for => 'admin'

          context_link 'client_management.stress_test',
                :link_path=>"admin_plow_setting_path" ,
                :priority=>1,
                :active_for_action=>{'admin/plow'=>"setting"},
                :available_for => 'admin'
        end
      end
    end
  end
end
