2012-03-28 10:53:30 +00:00
|
|
|
class DesktopController< ApplicationController
|
|
|
|
layout 'desktop'
|
2012-04-03 10:25:41 +00:00
|
|
|
before_filter :authenticate_user!
|
2012-04-12 06:44:08 +00:00
|
|
|
|
|
|
|
#to load pages...
|
|
|
|
|
2012-03-28 10:53:30 +00:00
|
|
|
def index
|
2012-04-05 12:32:56 +00:00
|
|
|
@desktop = current_user.desktop
|
2012-04-11 07:31:10 +00:00
|
|
|
@section = @desktop.sections.first
|
2012-03-28 10:53:30 +00:00
|
|
|
end
|
2012-03-29 07:23:48 +00:00
|
|
|
|
|
|
|
def desktop
|
|
|
|
render :layout => false
|
2012-03-29 11:50:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def app_manager
|
|
|
|
render :layout => false
|
|
|
|
end
|
|
|
|
|
|
|
|
def sections
|
|
|
|
render :layout => false
|
|
|
|
end
|
2012-04-12 06:44:08 +00:00
|
|
|
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....
|
2012-04-05 12:09:01 +00:00
|
|
|
|
2012-04-05 12:32:56 +00:00
|
|
|
def save_desktop_settings
|
2012-04-12 14:18:58 +00:00
|
|
|
@desktop = Desktop.find(params["desktopid"])
|
|
|
|
@savewhat = params["save"]
|
|
|
|
case @savewhat
|
|
|
|
when "theme"
|
|
|
|
@desktop.update_attributes(:theme => params["theme"])
|
|
|
|
when "desktopnames"
|
|
|
|
@sections = @desktop.sections
|
|
|
|
x = 0;
|
|
|
|
@sections.each do |section|
|
|
|
|
@desktopnewnames = params["desktopnms"]
|
|
|
|
section.update_attributes(:name => @desktopnewnames[x] )
|
|
|
|
x = x+1
|
|
|
|
end
|
2012-04-17 08:33:41 +00:00
|
|
|
when "appnewsection"
|
|
|
|
@section = Section.find(params["newsectionid"])
|
|
|
|
@groups = @section.groups
|
|
|
|
@app = Tile.find(params["appid"])
|
|
|
|
@groups.each do |group|
|
|
|
|
@tiles = group.tiles.where(:data_category.all => ["app"])
|
|
|
|
if @tiles.length < 12
|
|
|
|
@app.update_attributes(:group_id => group.id)
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-04-12 14:18:58 +00:00
|
|
|
end
|
2012-04-05 12:32:56 +00:00
|
|
|
a = Array.new
|
|
|
|
a << {"success"=>"true"}
|
|
|
|
render :json=>a.to_json
|
2012-04-03 10:25:41 +00:00
|
|
|
end
|
|
|
|
|
2012-04-05 12:32:56 +00:00
|
|
|
def get_desktop_settings
|
2012-04-12 14:18:58 +00:00
|
|
|
@desktop = Desktop.find(params["desktopid"])
|
|
|
|
@getwhat = params["get"]
|
|
|
|
case @getwhat
|
|
|
|
when "desktop"
|
|
|
|
render :json => @desktop.to_json
|
|
|
|
when "sectionnames"
|
|
|
|
secnames = Array.new
|
|
|
|
@sections = @desktop.sections
|
|
|
|
@sections.each do |section|
|
|
|
|
secnames << section.name
|
|
|
|
end
|
|
|
|
render :json => secnames.to_json
|
|
|
|
when "theme"
|
|
|
|
@theme = @desktop.theme
|
|
|
|
render :json => @theme.to_json
|
|
|
|
end
|
2012-04-03 10:25:41 +00:00
|
|
|
end
|
2012-04-11 09:26:25 +00:00
|
|
|
|
2012-04-11 07:31:10 +00:00
|
|
|
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
|
2012-04-12 06:44:08 +00:00
|
|
|
|
|
|
|
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
|
2012-04-17 08:33:41 +00:00
|
|
|
|
|
|
|
def newpositions
|
|
|
|
@newpositions = params["newpos"]
|
|
|
|
@section = Section.find(params["sectionid"])
|
|
|
|
@groupids = params["groupids"]
|
|
|
|
@groups = @section.groups
|
|
|
|
z = 0
|
|
|
|
@newpositions.each do |grp|
|
|
|
|
x = 1
|
|
|
|
grp.each do |tileid|
|
|
|
|
if x != 1
|
|
|
|
y = 1
|
|
|
|
tileid.each do |id|
|
|
|
|
@tile = Tile.find(id)
|
|
|
|
@tile.update_attributes({:position => y})
|
|
|
|
if @tile.group_id != @groupids[z]
|
|
|
|
@tile.update_attributes({:group_id => @groupids[z]})
|
|
|
|
end
|
|
|
|
y = y + 1
|
|
|
|
end
|
|
|
|
z = z + 1
|
|
|
|
end
|
|
|
|
x = x + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
b = Array.new
|
|
|
|
b << {"success"=>"true"}
|
|
|
|
render :json=>b.to_json
|
|
|
|
end
|
|
|
|
|
2012-03-28 10:53:30 +00:00
|
|
|
end
|