<!DOCTYPE html>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<head>
  <title>Sensor</title>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>
</head>
<body>
<%
########## Loging ##############
	  UserLog.create(:user_id => session[:user_id], :action => request.path, :params => params, :ip => request.remote_ip, :action_type => 'PAGE')
%>	
	
	
	
<%= render "shared/colorlist" %>
<%




    @menus=Menu.includes(:sub_menus).order(:id).joins(:user_accesses).where('"user_accesses"."user_group_id" = ?',User.find(session[:user_id]).user_group_id)
	@locale=User.find(session[:user_id]).language
    @result_array=[]
       @menus.each do |menu|
             @submenu_array=[]
             menu.sub_menus.all.each do |sub_menu|
                @submenu_array.push({:name_rus => sub_menu[@locale], :name_eng => sub_menu[:name_eng], :visible => sub_menu[:visible]})
             end
             @result_array.push({:name_rus => menu[@locale], :name_eng => menu[:name_eng], :sub_menu => @submenu_array})
       end
%>
<%= render partial: "shared/menu", locals: {menu_structure: @result_array, calendar_action:1, calendar_use:1, filter_use:1} %> 
<div id="body" style="min-width:1280px;min-height:600px;width:100%;height:calc(100% - 50px);top:50px;left:0px;position:absolute;background:<%= $white %>">
	<%= render "shared/loading" %>
	<%= yield %>
</div>
<script>
var scroll_settings={cursorwidth:15,cursorborderradius:0,cursorborder:0,cursorcolor:"<%= $gray %>",autohidemode:true,horizrailenabled:false}
function second_to_hour_converter(seconds){
		if (parseInt(seconds*1000) == 0){
			return '<%= t(:js_less_milisecond) %>'
		}
		if(parseInt(seconds) > 3){
			seconds=parseInt(seconds)
			hour=Math.floor(seconds/3600)
			min=Math.floor((seconds-hour*3600)/60)
			sec=seconds-hour*3600-min*60
			output_time=hour.add_zero()+'<%= t(:js_hour) %> '+min.add_zero()+'<%= t(:js_minute) %> '+sec.add_zero()+'<%= t(:js_second) %>'
			return output_time
		}else{
			ms=seconds*1000
			output_time=parseInt(ms)+'<%= t(:js_milisecond) %>'
			return output_time
		}
}
<%
@common_links=[
	{:link_name => 'oper_map', :link => '/operations/map?operation_id=', :image => 'oper_link', :text => t(:js_map)},
	{:link_name => 'oper_activity', :link => '/operations/activity?operation_id=', :image => 'oper_link', :text => t(:js_activity)},
	{:link_name => 'login_map', :link => '/logins/map?login_id=', :image => 'login_link', :text => t(:js_map)}
]
%>

<%
@common_links.each do |link|
%>

function link_<%= link[:link_name] %>(id){
	return '<div onclick="link_<%= link[:link_name] %>_action('+id+')" class="link_container">'+
		   '<%= image_tag("links/#{link[:image]}.png", class: "link_image") %>'+
		   '<div class="link_text"><%= link[:text] %></div>'+
		'</div>'
}
function link_<%= link[:link_name] %>_action(id){
	if (id > 0){
		window.open('<%= link[:link] %>'+id,'_self');
	}else{
		return true
	}
}
<% end %>
</script>
</body>
</html>
