summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authormr <mr@mrautenberg.de>2011-10-17 10:04:44 +0200
committermr <mr@mrautenberg.de>2011-10-17 10:04:44 +0200
commit5147b37a3285a231d8c938c3baf2f216a3b7f197 (patch)
treea1b15847651c4968cdd3ae7b1bfbc81f25c825b7 /views
parentab78958d59f7d7d2526ea7a9e997f9afd2a61cc0 (diff)
model sorting for endpoints| pager for models
Diffstat (limited to 'views')
-rw-r--r--views/models.haml1
-rw-r--r--views/models_navigation.haml36
-rw-r--r--views/models_navigation_bottom.haml47
-rw-r--r--views/predict.haml5
-rw-r--r--views/style.sass24
5 files changed, 92 insertions, 21 deletions
diff --git a/views/models.haml b/views/models.haml
index 1419e37..af11a32 100644
--- a/views/models.haml
+++ b/views/models.haml
@@ -26,3 +26,4 @@
= haml :model, :locals=>{:model=>model}, :layout => false
-if @models.size == 0
.notice There are currently no models. You have to create a model first.
+= models_navigation_bottom if @models.size > 1 \ No newline at end of file
diff --git a/views/models_navigation.haml b/views/models_navigation.haml
index 0dc1f63..6bf05bd 100644
--- a/views/models_navigation.haml
+++ b/views/models_navigation.haml
@@ -1,12 +1,12 @@
.models_navigation
-
+ - js = ""
%form{:name => "nav", :action => url_for('/models'), :method => "get", :id => "nav"}
%input{:type => :hidden, :name => :sort_by, :id => "sort_by", :value => params[:sort_by]}
%input{:type => :hidden, :name => :order, :id => "order", :value => params[:order]}
%input{:type => :hidden, :name => :page, :id => "page", :value => params[:page]}
Sort by:
- - ["created_at","name","type"].each do |s|
+ - ["created_at","name","type","endpoint"].each do |s|
- idname = s == "created_at" ? "date" : s
- if params[:sort_by] == s
%div{:id => idname, :class => "active"}
@@ -22,27 +22,37 @@
- if @models.size > 5
|
Models:
- = "#{@models.size}"
- - unless @page.to_i == 0
- #prev
- %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/
- -else
- %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/
-
- if @models.size < 5*@page+5
- last = @models.size
- else
- last = 5*@page+5
- = "(#{5*@page+1}-#{last}/#{@models.size})"
+ = "#{5*@page+1}-#{last} / #{@models.size}"
+
+ | Page:
+ - unless @page.to_i == 0
+ #prev{:class => "link"}
+ %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/
+ -else
+ %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/
+
+ - (0..(@models.size/5).to_f.ceil-1).each do |p|
+ -if p != @page.to_f
+ %a{:href => '#', :id => "page_link_#{p}", :class => "page page_link"} #{p+1}
+ - js += "$('#page_link_#{p}').click(function() \{ \n "
+ - js += " $('#page').val('#{p}');\n "
+ - js += " $('#nav').submit();\n "
+ - js += "});\n "
+ -else
+ %span{:class => "page page_active"} #{p+1}
+
- unless 5*@page.to_i+5 >= @models.size
- #next
+ #next{:class => "link"}
%img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/
-else
%img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/
- - js = ""
- - ["created_at","name","type"].each do |s|
+ - ["created_at","name","type","endpoint"].each do |s|
- idname = s == "created_at" ? "date" : s
- js += "$('##{idname}').click(function() \{ \n "
- js += " $('#sort_by').val('#{s}');\n "
diff --git a/views/models_navigation_bottom.haml b/views/models_navigation_bottom.haml
new file mode 100644
index 0000000..abea2d4
--- /dev/null
+++ b/views/models_navigation_bottom.haml
@@ -0,0 +1,47 @@
+.models_navigation
+ - js = ""
+ %form{:name => "nav_bottom", :action => url_for('/models'), :method => "get", :id => "nav"}
+ %input{:type => :hidden, :name => :sort_by, :id => "sort_by", :value => params[:sort_by]}
+ %input{:type => :hidden, :name => :order, :id => "order", :value => params[:order]}
+ %input{:type => :hidden, :name => :page, :id => "page", :value => params[:page]}
+
+ - if @models.size > 5
+ Models:
+ - if @models.size < 5*@page+5
+ - last = @models.size
+ - else
+ - last = 5*@page+5
+ = "#{5*@page+1}-#{last} / #{@models.size}"
+ | Page:
+ - unless @page.to_i == 0
+ #prevbot{:class => "link"}
+ %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/
+ -else
+ %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/
+
+ - (0..(@models.size/5).to_f.ceil-1).each do |p|
+ -if p != @page.to_f
+ %a{:href => '#', :id => "page_linkbot_#{p}", :class => "page page_link"} #{p+1}
+ - js += "$('#page_linkbot_#{p}').click(function() \{ \n"
+ - js += " $('#page').val('#{p}');\n"
+ - js += " $('#nav').submit();\n"
+ - js += "});\n"
+ -else
+ %span{:class => "page page_active"} #{p+1}
+
+ - unless 5*@page.to_i+5 >= @models.size
+ #nextbot{:class => "link"}
+ %img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/
+ -else
+ %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/
+
+ :javascript
+ $("#prevbot").click(function() {
+ $("#page").val(#{@page-1});
+ $("#nav").submit();
+ });
+ $("#nextbot").click(function() {
+ $("#page").val(#{@page+1});
+ $("#nav").submit();
+ });
+ #{js} \ No newline at end of file
diff --git a/views/predict.haml b/views/predict.haml
index 670ca44..c6097ac 100644
--- a/views/predict.haml
+++ b/views/predict.haml
@@ -30,7 +30,12 @@
%legend
Choose one or more prediction models
%br
+ - endpoint = ''
- @models.each do |model|
+ -if model.endpoint != endpoint
+ -endpoint = model.endpoint
+ %b #{endpoint}:
+ %br
%input{:type => 'checkbox', :name => "selection[#{model.id}]", :value => true, :id => "model#{model.id}", :disabled => false}
%label{:for => "model#{model.id}"}
= model.name
diff --git a/views/style.sass b/views/style.sass
index 0c1f48c..c14f164 100644
--- a/views/style.sass
+++ b/views/style.sass
@@ -270,14 +270,7 @@ dl
float: left
.models_navigation
- #prev
- @extend a
- display: inline
- cursor: pointer
- #next
- @extend a
- display: inline
- cursor: pointer
+ margin-top: 4px
.link
@extend a
display: inline
@@ -288,6 +281,21 @@ dl
font-weight: bold
.thin
font-weight: 100
+ .page
+ border: solid 1px #999
+ background-color: #FFF
+ padding: 0px 3px
+ font-size: 94%
+ foont-weight: normal
+ .page_link:hover
+ border-color: #000
+ color: #000
+ .page_active
+ background-color: #ccd2dc
+ color: #000
+ font-weight: bold
+ border-right-color: #000
+ border-bottom-color: #000
ul.endpoint
list-style-type: none