diff --git a/app/assets/Archive/javascripts/orbitdesktop.js b/app/assets/Archive/javascripts/orbitdesktop.js index fbcf7489..06cf3c04 100755 --- a/app/assets/Archive/javascripts/orbitdesktop.js +++ b/app/assets/Archive/javascripts/orbitdesktop.js @@ -612,6 +612,7 @@ var orbitDesktop = function(dom){ } } this.sub_menu_item = function(dom,data){ + console.log(dom) var sub_data_method = dom.attr('callback-method'); if(sub_data_method){ o.lastlink = dom.attr("href"); @@ -818,7 +819,8 @@ var orbitDesktop = function(dom){ }; this.initializeAppManager = function(target,url,cache){ //this is application search ie is app manager initialization - var searchArray,allApps; + var searchArray, allApps; + var bindHandlers = function(){ // bind handler for app manager page // var gn = $('.g_col').length, // gw = $('.g_col').outerWidth(true); @@ -826,7 +828,12 @@ var orbitDesktop = function(dom){ // $("div#app_manager .group_search").css("width",$(window).width()-200); //for textbox search var $elements = $("#app_manager .element"), - $result = $("#app_manager .search_result"); + $result = $("#app_manager .search_result"), + $appinfo = $("#app_info"), + $apptitle = $("#app_info .app_info_name"), + $appicon = $("#app_info .app_info_icon") + $appinfolist = $("#app_info .app_info_list"); + $("#app_manager #searchbox") .focus(function(){ $(this).val(""); @@ -849,8 +856,8 @@ var orbitDesktop = function(dom){ if(i == 1){ $column = $('
'); } - var $newelement = $('
'+$(this).html()+'
'); - $column.append($newelement); + $column.append($(this)); + $(this).show(); if(i == 4){ $result.append($column); i = 0; @@ -859,6 +866,7 @@ var orbitDesktop = function(dom){ if(i != 0){ $result.append($column); } + elementSetting(); } else { $result.text("No Result Found."); } @@ -877,11 +885,11 @@ var orbitDesktop = function(dom){ switch ($(this).attr("href")){ case "ascending": $(this).attr("href","descending").find(".thmtxt").text("Alphabet [Z-A]"); - allApps = $("div#app_manager .group_search .element").sort(sortAscending); + allApps = $("div#app_manager .element").sort(sortAscending); break; case "descending": $(this).attr("href","ascending").find(".thmtxt").text("Alphabet [A-Z]"); - allApps = $("#app_manager .group_search .element").sort(sortDescending); + allApps = $("#app_manager .element").sort(sortDescending); break; } $("#app_manager #app_list").empty(); @@ -897,25 +905,85 @@ var orbitDesktop = function(dom){ $('.g_col.col'+ colindex).append(app); } }); + elementSetting(); return false; }); - $(window).on('keydown', function(){ - if($('#searchbox').val() == 'Search'){ - $('#searchbox').focus(); - } - }); + + + var elementSetting = function(){// for element setting load + $(".element").click(function(){ + $e = $(this); + $apptitle.text($e.data("title")); + $appicon.attr("src",$e.find("img").attr("src")); + $appinfolist.find("li:eq(2) div").text($e.data("version")); + var dt = new Date($e.data("update")); + $appinfolist.find("li:eq(3) div").text(dt.toUTCString()); + $appinfolist.find("li:eq(4) div").text($e.data("author")); + + var sections = elementSettingsData[$e.data("id")].sections; + + var sectionids = new Array(); + $.each(sections,function(i,sec){ + sectionids.push(sec.id); + }) + + $appinfolist.find("li:eq(0)").empty(); + $.each(o.sectionList,function(i,sec){ + + var present = $.inArray(sec._id,sectionids); + if(present == -1){ + $sectionswitch = $('
Off
'); + }else{ + $sectionswitch = $('
On
'); + } + $appinfolist.find("li:eq(0)").append($sectionswitch); + }) + $appinfo.show(); + o.simple_switch(function(dom){ + var options = { + "status" : dom.is(":checked"), + "widget_id" : dom.data("widget"), + "section_id" : dom.data("section") + } + var sectionDetails = o.sectionList.filter(function(o){return(o._id == dom.data("section"))})[0]; + $.ajax({ + url : "/desktop/appactivation", + type : "post", + datatype : "json", + data : options, + success : function(data){ + if(data.success == "true"){ + elementSettingsData[$e.data("id")].sections.push({"id" : dom.data("section"),"name":sectionDetails.name}); + if(dom.is(":checked")) + o.notify("Added to " + sectionDetails.name,"success"); + else + o.notify("Removed from " + sectionDetails.name,"success"); + } + } + }) + }); + }) + } + + $appinfo.find("a.panel_close").click(function(){ + $appinfo.hide(); + return false; + }) + elementSetting(); o.appname_substr('#group_wrapper .element'); - o.simple_switch(); + } - var loadApps = function(){ //this load apps for sorting and searching - $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){ + var elementSettingsData = {}; + var loadApps = function(){ //this load apps for sorting and searching + $('#app_list').empty(); + $.getJSON("/desktop/getapplistforManager",{desktopid:o.desktopId},function(apps){ var count = 0, colindex = 0; $('#app_list').append('
'); - $.each(appss,function(i,apps){ $.each(apps,function(i,app){ var $app; count++; - $app = $('

'+app.title+'

'); + elementSettingsData[app.id] = {"sections" : app.sections}; + $app = $('

'+app.title+'

'); if( count > 4 ){ count = 1, colindex+=1; $('#app_list').append('
'); @@ -924,16 +992,14 @@ var orbitDesktop = function(dom){ $('.g_col.col'+ colindex).append($app); } }); - }); - bindHandlers(); }); } - if(cache){ - bindHandlers(); - } else { + // if(cache){ + // bindHandlers(); + // } else { loadApps(); - } + // } }; this.initializeSectionsManager = function(target,url,cache){ // this is init function for section manager var elementParent,element,slabel; @@ -1579,7 +1645,8 @@ var orbitDesktop = function(dom){ }); }); }; - this.simple_switch = function(){ + + this.simple_switch = function(func){ $('.s_switch').each(function(){ var $switcher = $(this).find('.s_switch_switcher'), $checkbox = $(this).find('input[type=checkbox]'), @@ -1603,9 +1670,12 @@ var orbitDesktop = function(dom){ $status.text(status_off); break; } + if(typeof func == "function") + func.call(this,$(this)); }); }); }; + this.single_select = function(){ // single select $('.ssl .ssl_item').each(function(){ diff --git a/app/assets/Archive/stylesheets/desktop/desktop-main.css b/app/assets/Archive/stylesheets/desktop/desktop-main.css index f1d42a54..80a587e8 100644 --- a/app/assets/Archive/stylesheets/desktop/desktop-main.css +++ b/app/assets/Archive/stylesheets/desktop/desktop-main.css @@ -604,6 +604,7 @@ a.admtxt.admbg2:hover { width: 420px; height: 516px; margin-right: 36px; } + #app_info .app_info_header { height: 120px; margin: -12px -12px 12px -12px; diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index 882765f1..aedc752b 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -117,8 +117,8 @@ class DesktopController< ApplicationController jsfile = [] cssfile = "" shape = "w1 h1" - fullsize = false link = "" + fullsize = false if tile.data_category == "widget" widge = DesktopWidget.find(tile.desktop_widget_id.to_s) # data_content = widge.widget_layout.file @@ -128,9 +128,7 @@ class DesktopController< ApplicationController shape = widge.shape title = widge.name # binding.pry - if not widge.fullsize.nil? - fullsize = widge.fullsize - end + fullsize = widge.fullsize else data_content = tile.data_content title = tile.title @@ -194,6 +192,33 @@ class DesktopController< ApplicationController end render :json=>a.to_json end + + def getapplistforManager + @dwss = DesktopWidget.all + @tiles = Array.new + desktop = Desktop.find(params['desktopid']) + sections = desktop.sections + sections.each do |section| + groups = section.groups + groups.each do |group| + @tiles += group.tiles + end + end + @validtiles = Array.new + @allWidgets = Array.new + @dwss.each do |dw| + @id = dw.id + @validtiles = @tiles.select{|t| t.desktop_widget_id == @id} + @sections = Array.new + @validtiles.each do |vt| + grp = Group.find(vt.group_id) + sec = Section.find(grp.section_id); + @sections << {"id"=>sec.id,"name"=>sec.name} + end + @allWidgets << {"id"=>dw.id, "data_category"=> "widget","title" => dw.name, "version" => dw.version, "author"=>dw.author, "last_update"=>dw.updated_at, "icon"=>dw.images.where(:name=>dw.icon).first.file.url, "sections" => @sections} + end + render :json=>@allWidgets.to_json + end def newpositions @newpositions = params[:newpositions] @@ -236,5 +261,27 @@ class DesktopController< ApplicationController feed = Net::HTTP.get_response(URI.parse("https://mail.google.com/mail/feed/atom")).body render :xml=>feed end + + def appactivation + @group = Section.find(params[:section_id]).groups.first + @widget = DesktopWidget.find(params[:widget_id]) + status = params[:status] + + case status + when "true" + tile = Tile.new(data_category: "widget", position: 8, desktop_widget_id: @widget.id) + @group.tiles+=[tile] + @group.save + when "false" + tile = @group.tiles.where("desktop_widget_id"=>@widget.id).first + if tile != nil + tile.destroy + end + end + + b = Array.new + b = {"success"=>"true"} + render :json=>b.to_json + end end diff --git a/app/controllers/desktop_widgets_controller.rb b/app/controllers/desktop_widgets_controller.rb index 2605f367..f52a58c9 100644 --- a/app/controllers/desktop_widgets_controller.rb +++ b/app/controllers/desktop_widgets_controller.rb @@ -4,6 +4,7 @@ class DesktopWidgetsController < OrbitBackendController require 'zip/zip' def index + @desktopWidgets = DesktopWidget.all end def upload @@ -21,6 +22,19 @@ class DesktopWidgetsController < OrbitBackendController temp_file.close end end + def edit + @dw = DesktopWidget.find(params[:id]) + end + + def update + @dw = DesktopWidget.find(params[:id]) + if(params[:desktop_widget]) + @imagefile = params[:desktop_widget][:image] + @dw.images.build(:file => @imagefile) + @dw.save + end + redirect_to action: "index" + end def unzip_widget(file, zip_name) Zip::ZipFile.open(file) { |zip_file| diff --git a/app/models/desktop/desktop_widget.rb b/app/models/desktop/desktop_widget.rb index 879b40b6..ae2fd9b6 100644 --- a/app/models/desktop/desktop_widget.rb +++ b/app/models/desktop/desktop_widget.rb @@ -6,8 +6,11 @@ class DesktopWidget field :name field :author field :shape - field :fullsize, :type => Boolean + field :fullsize, :type => Boolean, default: false field :version, :type => String + field :text_color, :type => String, default: "#fff" + field :bg_color, :type => String, default: "#fff" + field :icon, default: "icon.png" has_one :css_default, as: :css, :autosave => true, :dependent => :destroy has_one :widget_layout, :autosave => true, :dependent => :destroy diff --git a/app/views/desktop/app_manager.html.erb b/app/views/desktop/app_manager.html.erb index 70831dde..44d199cc 100644 --- a/app/views/desktop/app_manager.html.erb +++ b/app/views/desktop/app_manager.html.erb @@ -13,7 +13,7 @@
-
+