orbit-basic/app/controllers/desktop_controller.rb

97 lines
2.1 KiB
Ruby

class DesktopController< ApplicationController
layout 'desktop'
before_filter :authenticate_user!
#to load pages...
def index
@desktop = current_user.desktop
@section = @desktop.sections.first
end
def desktop
render :layout => false
end
def app_manager
render :layout => false
end
def sections
render :layout => false
end
def settings
render :layout => false
end
def settingthemes
render "desktop/settings/themes", :layout => false
end
def settingsections
render "desktop/settings/sections", :layout => false
end
#ajax data load....
def save_desktop_settings
@desktop = Desktop.find(params["id"])
@desktop.update_attributes(:theme => params["theme"])
a = Array.new
a << {"success"=>"true"}
render :json=>a.to_json
end
def get_desktop_settings
@desktop = Desktop.find(params["id"])
render :json => @desktop.to_json
end
def getgroups
@section = Section.find(params["sectionid"])
@groups = @section.groups
a = Array.new
@groups.each do |group|
a << group.tiles
end
render :json =>a.to_json
end
def getsectionlist
@desktop = Desktop.find(params["desktopid"])
@sections = @desktop.sections
render :json => @sections.to_json
end
def temp_func
@section = Section.find(params["sectionid"])
@groups = @section.groups
@groups.each do |group|
a = 1;
@tiles = group.tiles
@tiles.each do |tile|
tile.update_attributes({:data_category => "widget",:data_content => "temp", :position => a})
a = a+1;
end
end
b = Array.new
b << {"success"=>"true"}
render :json=>b.to_json
end
def getapplist
@desktop = Desktop.find(params["desktopid"])
@sections = @desktop.sections
a = Array.new
@sections.each do |section|
@groups = section.groups
@groups.each do |group|
@tiles = group.tiles.where(:data_category.all => ["app"])
a << @tiles
end
end
render :json=>a.to_json
end
end