diff --git a/Gemfile.lock b/Gemfile.lock index c96a64f0..6bba0c34 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -127,12 +127,12 @@ GEM activemodel (~> 3.1) mongo (~> 1.3) tzinfo (~> 0.3.22) - mongoid-tree (0.7.0) - mongoid (~> 2.0) mongoid-encryptor (0.0.5) activesupport (~> 3.0) encrypted_strings (~> 0.3.3) mongoid (~> 2) + mongoid-tree (0.7.0) + mongoid (~> 2.0) multi_json (1.1.0) nokogiri (1.5.2) nokogiri (1.5.2-x86-mingw32) @@ -293,8 +293,8 @@ DEPENDENCIES mini_magick mongo_session_store-rails3 mongoid - mongoid-tree mongoid-encryptor + mongoid-tree nokogiri radius rails (>= 3.1.0, < 3.2.0) diff --git a/app/assets/javascripts/orbitTimeline.js b/app/assets/javascripts/orbitTimeline.js index 4fc04109..fd412139 100644 --- a/app/assets/javascripts/orbitTimeline.js +++ b/app/assets/javascripts/orbitTimeline.js @@ -18,7 +18,7 @@ var orbitTimeline = function(dom){ $("div.scrollbar").hide(); t.constructTimeScale(function(timelineScale){ $("#timeline_scale").html(timelineScale); - var totalyearwidth =timelineScale.find(".year").length * 100; + var totalyearwidth =timelineScale.find(".year").length * 200; var totalul = 0; $(".t_scale").css({"min-width":$(".tinycanvas .viewport").width()+200 + "px"}) for(eve in t.events){ @@ -51,24 +51,26 @@ var orbitTimeline = function(dom){ this.constructTimeScale = function(callbackFn){ var mon ="",year="",formname; var scale = $("
"); - $.getJSON("desktop_orbit/getevents",{"event":"papers","from":t.fromdate},function(papers){ - $.each(papers,function(i,paper){ - var dt = new Date(paper.created_at); - var cur_mon = paper.created_at.substr(5,2); - var cur_year = dt.getFullYear(); - var cdt = paper.created_at.substr(0,7).replace("-",""); - formname = (cur_mon.charAt(0) == "0"?cur_mon.charAt(1) : cur_mon) - var bubbleData = {"fulldate" : t.monthList[parseInt(formname)] +", " + dt.getDate() + ", " + cur_year,"title":paper.title,"jtitle":"Harry","coauthors":paper.coauthors,"abstract":paper.abstract,"timestamp":cdt} - t.events.push(bubbleData); - if(cur_year != year){ - year = cur_year; - scale.append($("
"+(year+1)+"
")); - } - if(cur_mon != mon){ - mon = cur_mon; - var yr = scale.find("div[data-content="+year+"]"); - yr.append($("
"+t.monthList[parseInt(formname)]+"
")) - } + $.getJSON("desktop_orbit/eventajaxload",{"event":"papers","from":t.fromdate},function(papersArray){ + $.each(papersArray,function(i,pa){ + $.each(pa.papers,function(i,paper){ + var dt = new Date(paper.created_at); + var cur_mon = paper.created_at.substr(5,2); + var cur_year = dt.getFullYear(); + var cdt = paper.created_at.substr(0,7).replace("-",""); + formname = (cur_mon.charAt(0) == "0"?cur_mon.charAt(1) : cur_mon) + var bubbleData = {"fulldate" : t.monthList[parseInt(formname)] +", " + dt.getDate() + ", " + cur_year,"title":paper.title,"jtitle":"Harry","coauthors":paper.coauthors,"abstract":paper.abstract,"timestamp":cdt} + t.events.push(bubbleData); + if(cur_year != year){ + year = cur_year; + scale.append($("
"+(year+1)+"
")); + } + if(cur_mon != mon){ + mon = cur_mon; + var yr = scale.find("div[data-content="+year+"]"); + yr.append($("
"+t.monthList[parseInt(formname)]+"
")) + } + }); }); scale.append($("
"+year+"
")); t.fromdate = [year,formname-1]; @@ -137,9 +139,9 @@ var orbitTimeline = function(dom){ }); }); if(papersArray.length != 0){ - scale.append($("
"+year+"
")); + if(scale.find("div[data-content="+(year-1)+"]").length == 0) + scale.append($("
"+year+"
")); t.ajaxload = true; - console.log(year); t.fromdate = [year,formname-1]; } if(typeof callbackFn == "function"){ diff --git a/app/controllers/desktop_orbit_controller.rb b/app/controllers/desktop_orbit_controller.rb index b3b35daf..29761bfb 100644 --- a/app/controllers/desktop_orbit_controller.rb +++ b/app/controllers/desktop_orbit_controller.rb @@ -16,14 +16,16 @@ class DesktopOrbitController< ApplicationController end def eventajaxload + @limit = 15 @fromdate = params["from"] @fromdate[0] = Integer(@fromdate[0]) @fromdate[1] = Integer(@fromdate[1]) @totalpapers = 0 @lastpaper = current_user.papers.all.desc(:created_at).last + @date = Date.new(Integer(@lastpaper.created_at.strftime("%Y")),Integer(@lastpaper.created_at.strftime("%m"))) @data = Array.new - while @totalpapers < 15 - if @lastpaper.created_at > Date.new(@fromdate[0],@fromdate[1]) + while @totalpapers < @limit + if Date.new(@date.year,@date.month-1) > Date.new(@fromdate[0],@fromdate[1]) break end if(@fromdate[1] == 12) diff --git a/app/controllers/desktop_publications_controller.rb b/app/controllers/desktop_publications_controller.rb index 8e3d3a5f..ea24af97 100644 --- a/app/controllers/desktop_publications_controller.rb +++ b/app/controllers/desktop_publications_controller.rb @@ -12,7 +12,7 @@ class DesktopPublicationsController< ApplicationController end def create_journal - Journal.create(user_id: current_user.id, title: "Google") + Journal.create(user_id: current_user.id, title: "Ice Cream Sandwich") b = Array.new b << {"success"=>"true"} render :json=>b.to_json @@ -35,4 +35,15 @@ class DesktopPublicationsController< ApplicationController b << {"success"=>"true"} render :json=>b.to_json end + + def update_journal + @journal = Journal.find("4ff2d6ebbd98eb02b9000017") + @papers = @journal.papers + @papers.each do |paper| + paper.update_attributes(:user_id => current_user.id) + end + b = Array.new + b << {"success"=>"true"} + render :json=>b.to_json + end end diff --git a/app/models/journal.rb b/app/models/journal.rb index 88497f61..b1a65284 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -11,7 +11,7 @@ class Journal before_create :initialize_paper def initialize_paper - for i in 0..5 + for i in 0..11 self.papers.build end end diff --git a/app/models/paper.rb b/app/models/paper.rb index d42e1d53..a92dde1f 100644 --- a/app/models/paper.rb +++ b/app/models/paper.rb @@ -7,9 +7,8 @@ class Paper field :abstract, default: "The concept of microstructure engineering has gained increasingly attention with the goal to quantitatively link the operational parameters of an industrial process to the properties of its product. The key component of this concept is to accurately model the microstructure evolution along the processing path. Modelling of recrystallization in Cuinterconnects will be presented as an example of a conventional process model. Further, the potential of developing next generation process models will be discussed by using models across different length and time scale. The multi-scale modelling approach will be illustrated with a case study for phase transformation in Fe-Mn alloys." field :level, default: "SCI" field :coauthors, default: "Allen, Shelly, Eric, Manson, Chris, Clara, Anna, Albee, Vincent, Devin, Chunchi, Ika, Jaoshua, Ray, Matt, Lin, Spen" - field :created_at, type: Date, default: ->{12.months.ago} - - belongs_to :user + field :created_at, type: Date + belongs_to :journal diff --git a/config/routes.rb b/config/routes.rb index 43d6ee87..25fa8101 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -199,8 +199,9 @@ Orbit::Application.routes.draw do match '/desktop_orbit/orbit' => 'desktop_orbit#orbit' match '/desktop_orbit/eventajaxload'=> 'desktop_orbit#eventajaxload' match '/desktop_orbit/getevents' => 'desktop_orbit#getevents' - #match '/desktop_orbit/getevents' => 'desktop_publications#create_journal' - #match '/desktop_orbit/getevents' => 'desktop_publications#delete_journal' + #match '/desktop_orbit/eventajaxload' => 'desktop_publications#create_journal' + #match '/desktop_orbit/eventajaxload' => 'desktop_publications#delete_journal' + # match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal' match '/desktop/temp_func/'=>'desktop#temp_func'