controller change, views working and db for paper and journals

This commit is contained in:
Harry Bomrah 2012-05-03 21:30:12 +08:00
parent 1fce99c96f
commit a3a1e4b92e
11 changed files with 248 additions and 123 deletions

View File

@ -794,9 +794,8 @@ var orbitDesktop = function(dom){
saveaccount("","",type,what);
}
})
break;
break;
}
})
var $conlist = $('.s_form'),
@ -812,19 +811,19 @@ var orbitDesktop = function(dom){
}
var saveaccount = function(usernm,pwd,type,what){
$.post("/desktop/save_account_info",{email:usernm,password:pwd,account:type,dowhat:what},function(result){
if(what!="delete"){
if(result[0].success=="true")
o.notify(type+" account connected!!","success",2);
else
o.notify(type+" account connection failed!!","imp",2);
}else{
if(result[0].success=="true")
o.notify(type+" account removed!!","success",2);
else
o.notify(type+" account removal failed!!","imp",2);
}
})
$.post("/desktop/save_account_info",{email:usernm,password:pwd,account:type,dowhat:what},function(result){
if(what!="delete"){
if(result[0].success=="true")
o.notify(type+" account connected!!","success",2);
else
o.notify(type+" account connection failed!!","imp",2);
}else{
if(result[0].success=="true")
o.notify(type+" account removed!!","success",2);
else
o.notify(type+" account removal failed!!","imp",2);
}
})
}
$("div#settings div#panel_r").load("/desktop/settingconnection",function(){
$.getJSON("desktop/getaccounts",function(accounts){
@ -882,6 +881,7 @@ var orbitDesktop = function(dom){
}
var list = function(){ // to open list part in journal papers page
var journalData;
var bindHandlers = function(){ // to bind handlers for list page
o.simple_drop_down();
@ -892,16 +892,138 @@ var orbitDesktop = function(dom){
e.parents('.overview').width( baseWidth * count );
$('.tinycanvas')
.tinyscrollbar({ axis: 'x'})
.find('.scrollbar')
.delay(1500)
.addClass('op00', 500);
$("#journal_p div.toolbar ul#journal_selection_options a").click(function(){
switch($(this).attr("href")){
case "all":
$("#journal_p div#paper_list a.item_check_status").addClass("checked");
break;
case "none":
$("#journal_p div#paper_list a.item_check_status").removeClass("checked");
break;
}
return false;
})
$("#journal_p div.toolbar ul#journal_view_selection a").click(function(){
switch($(this).attr("href")){
case "journal":
journalview();
break;
case "keywords":
keywordsview();
break;
case "title":
titleview();
break;
case "abstract":
abstractview();
break;
}
return false;
})
}
var bindSecondaryHandlers = function(){
$("#journal_p div#paper_list a").click(function(){
if($(this).hasClass("item_check_status")){
$(this).toggleClass("checked");
}else if($(this).hasClass("icon-star")){
$(this).removeClass("icon-star").addClass("icon-star-empty");
}else if($(this).hasClass("icon-star-empty")){
$(this).removeClass("icon-star-empty").addClass("icon-star");
}
return false;
})
}
var journalview = function(){
$("#journal_p div#paper_list div.overview").empty();
var column = $('<div class="g_col list_t"><ul></ul></div>'),
counter = 1,
li;
$.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){
li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+journal.title+'</div><div class="list_t_des">'+paper.title+'</div></li>');
column.find("ul").append(li);
if(counter%5==0){
$("#journal_p div#paper_list div.overview").append(column);
column = $('<div class="g_col list_t"><ul></ul></div>');
}
counter++;
})
})
$("#journal_p div#paper_list div.overview").append(column);
bindSecondaryHandlers();
}
var keywordsview = function(){
$("#journal_p div#paper_list div.overview").empty();
var column = $('<div class="g_col list_t"><ul></ul></div>'),
counter = 1,
li;
$.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){
li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><div class="list_t_des">'+paper.keywords+'</div></li>');
column.find("ul").append(li);
if(counter%5==0){
$("#journal_p div#paper_list div.overview").append(column);
column = $('<div class="g_col list_t"><ul></ul></div>');
}
counter++;
})
})
$("#journal_p div#paper_list div.overview").append(column);
bindSecondaryHandlers();
}
var titleview = function(){
$("#journal_p div#paper_list div.overview").empty();
var column = $('<div class="g_col list_t"><ul></ul></div>'),
counter = 1,
li;
$.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){
li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div></li>');
column.find("ul").append(li);
if(counter%5==0){
$("#journal_p div#paper_list div.overview").append(column);
column = $('<div class="g_col list_t"><ul></ul></div>');
}
counter++;
})
})
$("#journal_p div#paper_list div.overview").append(column);
bindSecondaryHandlers();
}
var abstractview = function(){
$("#journal_p div#paper_list div.overview").empty();
var column = $('<div class="g_col list_t"><ul></ul></div>'),
li;
$.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){
li = $('<li class="list_t_item" style="height:auto;"><div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><div class="list_t_des" style="text-align:justify;">'+paper.abstract+paper.abstract+'</div></li>');
column.find("ul").append(li);
$("#journal_p div#paper_list div.overview").append(column);
column = $('<div class="g_col list_t"><ul></ul></div>');
})
})
$("#journal_p div#paper_list div.overview").append(column);
bindSecondaryHandlers();
}
$("div#settings div#panel_r").load("/desktop/journal_p_list",function(){
bindHandlers();
$.getJSON("/desktop_publications/getjournals",function(journals){
journalData = eval(journals);
journalview();
bindHandlers();
})
})
}

View File

@ -42,17 +42,7 @@ class DesktopController< ApplicationController
render "desktop/settings/connections", :layout => false
end
def journal_p
render :layout => false
end
def journal_p_list
render "desktop/journal_pages/list", :layout => false
end
def journal_p_add
render "desktop/journal_pages/add", :layout => false
end
#ajax data load....
def save_desktop_settings

View File

@ -0,0 +1,30 @@
class DesktopPublicationsController< ApplicationController
def journal_p
render "desktop/journal_p", :layout => false
end
def journal_p_list
render "desktop/journal_pages/list", :layout => false
end
def journal_p_add
render "desktop/journal_pages/add", :layout => false
end
def create_journal
Journal.create(user_id: current_user.id, title: "2012, Material Chemistry and Physics Journal")
b = Array.new
b << {"success"=>"true"}
render :json=>b.to_json
end
def getjournals
@journals = Journal.all
data = Array.new
@journals.each do |journal|
@papers = journal.papers.all
data << {"title" => journal.title, "papers" => @papers}
end
render :json=>data.to_json
end
end

View File

@ -49,8 +49,12 @@ class OtheraccountsController< ApplicationController
end
end
def twitter
end
def getaccounts
@accounts = OtherAccount.where(:user_id.all => [current_user.id])
@accounts = OtherAccount.where(:user_id.all => [current_user.id]).without(:encrypted_password)
render :json => @accounts.to_json
end
end

View File

@ -2,7 +2,7 @@ class Desktop
include Mongoid::Document
include Mongoid::Timestamps
field :theme, default: "default"
field :theme, default: "4f8d3f493b67fcd05f086359"
field :customtheme
field :wallpaper

19
app/models/journal.rb Normal file
View File

@ -0,0 +1,19 @@
class Journal
include Mongoid::Document
include Mongoid::Timestamps
field :user_id
field :title
belongs_to :user
has_many :papers, :autosave => true, :dependent => :destroy
before_create :initialize_paper
def initialize_paper
for i in 0..25
self.papers.build
end
end
end

14
app/models/paper.rb Normal file
View File

@ -0,0 +1,14 @@
class Paper
include Mongoid::Document
include Mongoid::Timestamps
field :keywords, default: "Material, Fracture Mechanism, Reliability Test, Solder Joints, Nano-material"
field :title, default: "The performance and fracture mechanism of solder joints under mechanical reliability test"
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"
belongs_to :journal
end

View File

@ -18,6 +18,7 @@ class User
has_many :managing_apps,:class_name => "AppManager"
has_one :desktop, :autosave => true, :dependent => :destroy
has_many :other_accounts, :autosave => true, :dependent => :destroy
has_many :journals, :autosave => true, :dependent => :destroy
belongs_to :role
has_and_belongs_to_many :sub_roles
accepts_nested_attributes_for :attribute_values, :allow_destroy => true

View File

@ -7,25 +7,23 @@
</div>
</div>
<div id="holder">
<div id="panel_l" class="ph">
<div class="s_menu sm_v">
<ul id='setting_left_nav'>
<li><a href="list" class="hh2 w2 hp active thmc1 thmtxt" onclick='return false;'>List</a></li>
<li><a href="addpaper" class="admtxt hh2 w2 hp" onclick='return false;'>Add/Edit</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Journals</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Co-Authors</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Tags &amp; Keywords</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Analysis</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Import</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Export</a></li>
</ul>
</div>
</div>
<div id="panel_r" class="ph pw admbg hp">
</div>
<div class="clear"></div>
<div id="panel_l" class="ph">
<div class="s_menu sm_v">
<ul id='setting_left_nav'>
<li><a href="list" class="hh2 w2 hp active thmc1 thmtxt" onclick='return false;'>List</a></li>
<li><a href="addpaper" class="admtxt hh2 w2 hp" onclick='return false;'>Add/Edit</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Journals</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Co-Authors</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Tags &amp; Keywords</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Analysis</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Import</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Export</a></li>
</ul>
</div>
</div>
<div id="panel_r" class="ph pw admbg hp">
</div>
<div class="clear"></div>
</div>
</div>
</div>

View File

@ -2,16 +2,16 @@
<div class="hh2 hp sdm">
<div class="sdm_t hh2"><span class="icon-check"></span></div>
<div class="admbg sdm_o">
<ul id="section_list">
<li><a class="hp hh2 admtxt" href="">All</a></li>
<li><a class="hp hh2 admtxt" href="">None</a></li>
<ul id="journal_selection_options">
<li><a class="hp hh2 admtxt" href="all">All</a></li>
<li><a class="hp hh2 admtxt" href="none">None</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">More</div>
<div class="admbg sdm_o">
<ul id="section_list">
<ul>
<li><a class="hp hh2 admtxt" href="">Delete</a></li>
<li><a class="hp hh2 admtxt" href="">Tag</a></li>
</ul>
@ -20,7 +20,7 @@
<div class="hh2 hp sdm">
<div class="sdm_t hh2">Tag</div>
<div class="admbg sdm_o">
<ul id="section_list">
<ul
<li><a class="hp hh2 admtxt" href="">All</a></li>
<li><a class="hp hh2 admtxt" href="">Starred</a></li>
<li><a class="hp hh2 admtxt" href="">MIT</a></li>
@ -30,7 +30,7 @@
<div class="hh2 hp sdm">
<div class="sdm_t hh2">Status</div>
<div class="admbg sdm_o">
<ul id="section_list">
<ul>
<li><a class="hp hh2 admtxt" href="">All</a></li>
<li><a class="hp hh2 admtxt" href="">Published</a></li>
<li><a class="hp hh2 admtxt" href="">Pending</a></li>
@ -40,19 +40,19 @@
<div class="hh2 hp sdm">
<div class="sdm_t hh2">View</div>
<div class="admbg sdm_o">
<ul id="section_list">
<li><a class="hp hh2 admtxt" href="">Title</a></li>
<li><a class="hp hh2 admtxt" href="">File</a></li>
<li><a class="hp hh2 admtxt" href="">Journal</a></li>
<li><a class="hp hh2 admtxt" href="">Keywords</a></li>
<li><a class="hp hh2 admtxt" href="">Abstract</a></li>
<ul id="journal_view_selection">
<li><a class="hp hh2 admtxt" href="journal">Journal</a></li>
<li><a class="hp hh2 admtxt" href="title">Title</a></li>
<li><a class="hp hh2 admtxt" href="file">File</a></li>
<li><a class="hp hh2 admtxt" href="keywords">Keywords</a></li>
<li><a class="hp hh2 admtxt" href="abstract">Abstract</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">Share</div>
<div class="admbg sdm_o">
<ul id="section_list">
<ul>
<li><a class="hp hh2 admtxt" href="">Full</a></li>
<li><a class="hp hh2 admtxt" href="">Abstract</a></li>
<li><a class="hp hh2 admtxt" href="">Friends</a></li>
@ -66,64 +66,7 @@
<div class="scrollbar sb_h vp"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div>
<div class="viewport">
<div class="overview">
<div class="g_col list_t">
<ul>
<li class="list_t_item">
<div class="list_item_action"><a href="" class="item_check_status checked"><span class="icon-ok"></span></a><a href="" class="icon-star"></a></div>
<div class="list_t_title">2012, Material Chemistry and Physics Journal</div>
<div class="list_t_des">The performance and fracture mechanism of solder joints under mechanical reliability test</div>
</li>
<li class="list_t_item">
<div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star"></a></div>
<div class="list_t_title">2012, Material Chemistry and Physics Journal</div>
<div class="list_t_des">The performance and fracture mechanism of solder joints under mechanical reliability test</div>
</li>
<li class="list_t_item">
<div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div>
<div class="list_t_title">2012, Material Chemistry and Physics Journal</div>
<div class="list_t_des">The performance and fracture mechanism of solder joints under mechanical reliability test</div>
</li>
<li class="list_t_item">
<div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div>
<div class="list_t_title">2012, Material Chemistry and Physics Journal</div>
<div class="list_t_des">The performance and fracture mechanism of solder joints under mechanical reliability test</div>
</li>
<li class="list_t_item">
<div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div>
<div class="list_t_title">2012, Material Chemistry and Physics Journal</div>
<div class="list_t_des">The performance and fracture mechanism of solder joints under mechanical reliability test</div>
</li>
</ul>
</div>
<div class="g_col list_t">
<ul>
<li class="list_t_item">
<div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div>
<div class="list_t_title">2012, Material Chemistry and Physics Journal</div>
<div class="list_t_des">The performance and fracture mechanism of solder joints under mechanical reliability test</div>
</li>
<li class="list_t_item">
<div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div>
<div class="list_t_title">2012, Material Chemistry and Physics Journal</div>
<div class="list_t_des">The performance and fracture mechanism of solder joints under mechanical reliability test</div>
</li>
<li class="list_t_item">
<div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div>
<div class="list_t_title">2012, Material Chemistry and Physics Journal</div>
<div class="list_t_des">The performance and fracture mechanism of solder joints under mechanical reliability test</div>
</li>
<li class="list_t_item">
<div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div>
<div class="list_t_title">2012, Material Chemistry and Physics Journal</div>
<div class="list_t_des">The performance and fracture mechanism of solder joints under mechanical reliability test</div>
</li>
<li class="list_t_item">
<div class="list_item_action"><a href="" class="item_check_status"><span class="icon-ok"></span></a><a href="" class="icon-star-empty"></a></div>
<div class="list_t_title">2012, Material Chemistry and Physics Journal</div>
<div class="list_t_des">The performance and fracture mechanism of solder joints under mechanical reliability test</div>
</li>
</ul>
</div>
</div>
</div>
</div>

View File

@ -114,10 +114,14 @@ Orbit::Application.routes.draw do
match '/desktop/settingsections/'=>'desktop#settingsections'
match '/desktop/getapplist/'=>'desktop#getapplist'
match '/desktop/newpositions/'=>'desktop#newpositions'
match '/desktop/journal_p/'=>'desktop#journal_p'
match '/desktop/journal_p_list/'=>'desktop#journal_p_list'
match '/desktop/journal_p_add/'=>'desktop#journal_p_add'
match '/desktop/settingconnection/'=>'desktop#settingconnection'
match '/desktop/journal_p/'=>'desktop_publications#journal_p'
match '/desktop/journal_p_list/'=>'desktop_publications#journal_p_list'
match '/desktop/journal_p_add/'=>'desktop_publications#journal_p_add'
match '/desktop_publications/getjournals' => 'desktop_publications#getjournals'
match '/desktop/forgmail/'=>'otheraccounts#gmail'
match '/desktop/getaccounts'=>'otheraccounts#getaccounts'
match '/desktop/save_account_info/'=>'otheraccounts#saveaccountinfo'