diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 6c75e0e6fdd5be37ba1ea880bc0b7a1ee2159880..0000000000000000000000000000000000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,421 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - abstract_type (0.0.7) - actionmailer (4.2.0) - actionpack (= 4.2.0) - actionview (= 4.2.0) - activejob (= 4.2.0) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.0) - actionview (= 4.2.0) - activesupport (= 4.2.0) - rack (~> 1.6.0) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - actionview (4.2.0) - activesupport (= 4.2.0) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - activejob (4.2.0) - activesupport (= 4.2.0) - globalid (>= 0.3.0) - activemodel (4.2.0) - activesupport (= 4.2.0) - builder (~> 3.1) - activerecord (4.2.0) - activemodel (= 4.2.0) - activesupport (= 4.2.0) - arel (~> 6.0) - activesupport (4.2.0) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - adamantium (0.2.0) - ice_nine (~> 0.11.0) - memoizable (~> 0.4.0) - arel (6.0.3) - ast (2.1.0) - autoprefixer-rails (6.0.3) - execjs - json - axiom-types (0.1.1) - descendants_tracker (~> 0.0.4) - ice_nine (~> 0.11.0) - thread_safe (~> 0.3, >= 0.3.1) - bcrypt (3.1.10) - better_errors (2.1.1) - coderay (>= 1.0.0) - erubis (>= 2.6.6) - rack (>= 0.9.0) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) - bootstrap-sass (3.3.5.1) - autoprefixer-rails (>= 5.0.0.1) - sass (>= 3.3.0) - builder (3.2.2) - bullet (4.14.7) - activesupport (>= 3.0.0) - uniform_notifier (~> 1.9.0) - byebug (6.0.2) - celluloid (0.17.1.2) - bundler - celluloid-essentials - celluloid-extras - celluloid-fsm - celluloid-pool - celluloid-supervision - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - celluloid-essentials (0.20.2.1) - bundler - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - celluloid-extras (0.20.1) - bundler - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - celluloid-fsm (0.20.1) - bundler - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - celluloid-pool (0.20.1) - bundler - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - celluloid-supervision (0.20.1.1) - bundler - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - chart-js-rails (0.0.9) - railties (> 3.1) - chronic (0.10.2) - climate_control (0.0.3) - activesupport (>= 3.0) - cocaine (0.5.7) - climate_control (>= 0.0.3, < 1.0) - coderay (1.1.0) - coercible (1.0.0) - descendants_tracker (~> 0.0.1) - coffee-rails (4.1.0) - coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.9.1.1) - concord (0.1.5) - adamantium (~> 0.2.0) - equalizer (~> 0.0.9) - connection_pool (2.2.0) - curb (0.8.8) - dalli (2.7.4) - debug_inspector (0.0.2) - descendants_tracker (0.0.4) - thread_safe (~> 0.3, >= 0.3.1) - devise (3.5.1) - bcrypt (~> 3.0) - orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) - responders - thread_safe (~> 0.1) - warden (~> 1.2.3) - devise_token_auth (0.1.34) - devise (= 3.5.1) - rails (~> 4.2) - diff-lcs (1.2.5) - domain_name (0.5.24) - unf (>= 0.0.5, < 1.0.0) - dotenv (2.0.2) - dspace_rest_client (1.1.2) - curb (~> 0.8.6) - rest-client (>= 1.7, < 2) - equalizer (0.0.11) - erubis (2.7.0) - execjs (2.6.0) - fast_stack (0.1.0) - rake - rake-compiler - flamegraph (0.1.0) - fast_stack - flay (2.4.0) - ruby_parser (~> 3.0) - sexp_processor (~> 4.0) - flog (4.2.1) - ruby_parser (~> 3.1, > 3.1.0) - sexp_processor (~> 4.4) - globalid (0.3.6) - activesupport (>= 4.1.0) - hitimes (1.2.3) - http-cookie (1.0.2) - domain_name (~> 0.5) - i18n (0.7.0) - ice_nine (0.11.1) - jbuilder (2.3.1) - activesupport (>= 3.0.0, < 5) - multi_json (~> 1.2) - jquery-rails (4.0.5) - rails-dom-testing (~> 1.0) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - jquery-turbolinks (2.1.0) - railties (>= 3.1.0) - turbolinks - json (1.8.3) - kaminari (0.16.3) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) - libv8 (3.16.14.11) - locastyle (0.0.1) - loofah (2.0.3) - nokogiri (>= 1.5.9) - mail (2.6.3) - mime-types (>= 1.16, < 3) - memoizable (0.4.2) - thread_safe (~> 0.3, >= 0.3.1) - mime-types (2.6.2) - mimemagic (0.3.0) - mina (0.3.7) - open4 (~> 1.3.4) - rake - mini_portile (0.6.2) - minitest (5.8.1) - multi_json (1.11.2) - nenv (0.2.0) - netrc (0.10.3) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) - open4 (1.3.4) - orientdb4r (0.5.1) - rest-client (~> 1.7) - orm_adapter (0.5.0) - paperclip (4.3.1) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - cocaine (~> 0.5.5) - mime-types - mimemagic (= 0.3.0) - parser (2.2.2.6) - ast (>= 1.1, < 3.0) - procto (0.0.2) - puma (2.14.0) - rack (1.6.4) - rack-cors (0.4.0) - rack-mini-profiler (0.9.7) - rack (>= 1.1.3) - rack-protection (1.5.3) - rack - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.0) - actionmailer (= 4.2.0) - actionpack (= 4.2.0) - actionview (= 4.2.0) - activejob (= 4.2.0) - activemodel (= 4.2.0) - activerecord (= 4.2.0) - activesupport (= 4.2.0) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.0) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) - loofah (~> 2.0) - railties (4.2.0) - actionpack (= 4.2.0) - activesupport (= 4.2.0) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rainbow (2.0.0) - rake (10.4.2) - rake-compiler (0.9.5) - rake - rdoc (4.2.0) - redis (3.2.1) - redis-namespace (1.5.2) - redis (~> 3.0, >= 3.0.4) - reek (1.6.5) - parser (~> 2.2.0.pre.7) - rainbow (>= 1.99, < 3.0) - unparser (~> 0.2.2) - ref (2.0.0) - responders (2.1.0) - railties (>= 4.2.0, < 5) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - rsolr (1.0.12) - builder (>= 2.1.2) - rspec-logsplit (0.1.3) - ruby_parser (3.7.1) - sexp_processor (~> 4.1) - rubycritic (1.4.0) - flay (= 2.4.0) - flog (= 4.2.1) - parser (>= 2.2.0, < 3.0) - reek (= 1.6.5) - virtus (~> 1.0) - sass (3.4.18) - sass-rails (5.0.4) - railties (>= 4.0.0, < 5.0) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) - sdoc (0.4.1) - json (~> 1.7, >= 1.7.7) - rdoc (~> 4.0) - select2-rails (4.0.0) - thor (~> 0.14) - sexp_processor (4.6.0) - shoulda (3.5.0) - shoulda-context (~> 1.0, >= 1.0.1) - shoulda-matchers (>= 1.4.1, < 3.0) - shoulda-callback-matchers (1.1.3) - activesupport (>= 3) - shoulda-context (1.2.1) - shoulda-matchers (2.8.0) - activesupport (>= 3.0.0) - sidekiq (3.5.0) - celluloid (~> 0.17.0) - connection_pool (~> 2.2, >= 2.2.0) - json (~> 1.0) - redis (~> 3.2, >= 3.2.1) - redis-namespace (~> 1.5, >= 1.5.2) - sinatra (1.4.6) - rack (~> 1.4) - rack-protection (~> 1.4) - tilt (>= 1.3, < 3) - slim (3.0.6) - temple (~> 0.7.3) - tilt (>= 1.3.3, < 2.1) - spring (1.4.0) - sprockets (3.3.5) - rack (> 1, < 3) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) - sqlite3 (1.3.10) - stackprof (0.2.7) - streamio-ffmpeg (1.0.0) - temple (0.7.6) - therubyracer (0.12.2) - libv8 (~> 3.16.14.0) - ref - thor (0.19.1) - thread_safe (0.3.5) - tilt (2.0.1) - timers (4.1.1) - hitimes - turbolinks (2.5.3) - coffee-rails - tzinfo (1.2.2) - thread_safe (~> 0.1) - uglifier (2.7.2) - execjs (>= 0.3.0) - json (>= 1.8.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.1) - uniform_notifier (1.9.0) - unparser (0.2.4) - abstract_type (~> 0.0.7) - adamantium (~> 0.2.0) - concord (~> 0.1.5) - diff-lcs (~> 1.2.5) - equalizer (~> 0.0.9) - parser (~> 2.2.2) - procto (~> 0.0.2) - virtus (1.0.5) - axiom-types (~> 0.1) - coercible (~> 1.0) - descendants_tracker (~> 0.0, >= 0.0.3) - equalizer (~> 0.0, >= 0.0.9) - warden (1.2.3) - rack (>= 1.0) - web-console (2.2.1) - activemodel (>= 4.0) - binding_of_caller (>= 0.7.2) - railties (>= 4.0) - sprockets-rails (>= 2.0, < 4.0) - whenever (0.9.4) - chronic (>= 0.6.3) - -PLATFORMS - ruby - -DEPENDENCIES - bcrypt (~> 3.1.7) - better_errors - bootstrap-sass - bullet - byebug - chart-js-rails - coffee-rails (~> 4.1.0) - curb (~> 0.8.8) - dalli - devise - devise_token_auth - dspace_rest_client (~> 1.1.0) - execjs - flamegraph - jbuilder (~> 2.0) - jquery-rails - jquery-turbolinks - kaminari - locastyle - mina - orientdb4r - paperclip - puma - rack-cors - rack-mini-profiler - rails (= 4.2.0) - rdoc - rsolr (~> 1.0.12) - rubycritic - sass-rails (~> 5.0) - sdoc (~> 0.4.0) - select2-rails - shoulda - shoulda-callback-matchers (~> 1.1.1) - sidekiq - sinatra - slim - spring - sqlite3 - stackprof - streamio-ffmpeg (~> 1.0.0) - therubyracer - turbolinks - uglifier (>= 1.3.0) - web-console (~> 2.0) - whenever - -BUNDLED WITH - 1.10.6 diff --git a/app/assets/javascripts/management.js b/app/assets/javascripts/management.js index 6d8a234891f222388410291be9226e0d884f7f4d..2d3b06881e852c5fa40034fb4d8a6911e844d9d7 100644 --- a/app/assets/javascripts/management.js +++ b/app/assets/javascripts/management.js @@ -21,9 +21,15 @@ //mais infos: www.chartjs.org/docs/ +var visualised,non_visualised; $(document).ready(function(){ -//adicionar no array o nome do gráfico e criar um case para ele -var charts = ["colections","users","downloads","accesses"]; + +visualised = document.getElementById("lobject").value; +non_visualised = document.getElementById("lobject_non").value; + +var data_learning_objects = dataLearningObjects(visualised,non_visualised); + +var charts = ["colections","users","learning_objects","accesses"]; for(i=0;i<charts.length;i++) { if ( document.getElementById(charts[i]) ) { @@ -37,9 +43,9 @@ for(i=0;i<charts.length;i++) { new Chart(ctx).Bar(data_users,bar_options); var users_chart = new Chart(ctx).Bar(data_users); break; - case "downloads": - new Chart(ctx).Line(data_downloads,line_options); - var downloads_chart = new Chart(ctx).Line(data_downloads); + case "learning_objects": + new Chart(ctx).Pie(data_learning_objects,pie_options); + var learning_objects_chart = new Chart(ctx).Pie(data_learnin_objects); break; case "accesses": new Chart(ctx).Line(data_accesses,line_options); @@ -49,14 +55,10 @@ for(i=0;i<charts.length;i++) { default: null; break; } - } } }); - - - Chart.defaults.global = { // Boolean - Whether to animate the chart animation: true, diff --git a/app/assets/javascripts/management/accesses.js b/app/assets/javascripts/management/accesses.js index c19a2393d02fefaf7f436b1bb431fa850b030786..ba738f9bbf092f9b1efb85b7ca359d8ea9388690 100644 --- a/app/assets/javascripts/management/accesses.js +++ b/app/assets/javascripts/management/accesses.js @@ -19,3 +19,53 @@ var data_accesses = { } ] }; + + +var line_options = { + + ///Boolean - Whether grid lines are shown across the chart + scaleShowGridLines : true, + + //String - Colour of the grid lines + scaleGridLineColor : "rgba(0,0,0,.05)", + + //Number - Width of the grid lines + scaleGridLineWidth : 1, + + //Boolean - Whether to show horizontal lines (except X axis) + scaleShowHorizontalLines: true, + + //Boolean - Whether to show vertical lines (except Y axis) + scaleShowVerticalLines: true, + + //Boolean - Whether the line is curved between points + bezierCurve : true, + + //Number - Tension of the bezier curve between points + bezierCurveTension : 0.4, + + //Boolean - Whether to show a dot for each point + pointDot : true, + + //Number - Radius of each point dot in pixels + pointDotRadius : 4, + + //Number - Pixel width of point dot stroke + pointDotStrokeWidth : 1, + + //Number - amount extra to add to the radius to cater for hit detection outside the drawn point + pointHitDetectionRadius : 20, + + //Boolean - Whether to show a stroke for datasets + datasetStroke : true, + + //Number - Pixel width of dataset stroke + datasetStrokeWidth : 2, + + //Boolean - Whether to fill the dataset with a colour + datasetFill : true, + + //String - A legend template + legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].strokeColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>" + +}; diff --git a/app/assets/javascripts/management/downloads.js b/app/assets/javascripts/management/downloads.js deleted file mode 100644 index 397c29b5d7fceeec9a5d08a4f6cdc78f6b214eab..0000000000000000000000000000000000000000 --- a/app/assets/javascripts/management/downloads.js +++ /dev/null @@ -1,71 +0,0 @@ -//confurações dos gráficos de linha -//mais infos: www.chartjs.org/docs/ - - -var data_downloads = { - labels: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho"], - datasets: [ - - { - label: "Downloads", - fillColor: "rgba(151,187,205,0.2)", - strokeColor: "rgba(151,187,205,1)", - pointColor: "rgba(151,187,205,1)", - pointStrokeColor: "#fff", - pointHighlightFill: "#fff", - pointHighlightStroke: "rgba(151,187,205,1)", - data: [15, 28, 17, 58, 32, 91,99 ] - } - ] -}; - - - -var line_options = { - - ///Boolean - Whether grid lines are shown across the chart - scaleShowGridLines : true, - - //String - Colour of the grid lines - scaleGridLineColor : "rgba(0,0,0,.05)", - - //Number - Width of the grid lines - scaleGridLineWidth : 1, - - //Boolean - Whether to show horizontal lines (except X axis) - scaleShowHorizontalLines: true, - - //Boolean - Whether to show vertical lines (except Y axis) - scaleShowVerticalLines: true, - - //Boolean - Whether the line is curved between points - bezierCurve : true, - - //Number - Tension of the bezier curve between points - bezierCurveTension : 0.4, - - //Boolean - Whether to show a dot for each point - pointDot : true, - - //Number - Radius of each point dot in pixels - pointDotRadius : 4, - - //Number - Pixel width of point dot stroke - pointDotStrokeWidth : 1, - - //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - pointHitDetectionRadius : 20, - - //Boolean - Whether to show a stroke for datasets - datasetStroke : true, - - //Number - Pixel width of dataset stroke - datasetStrokeWidth : 2, - - //Boolean - Whether to fill the dataset with a colour - datasetFill : true, - - //String - A legend template - legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].strokeColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>" - -}; diff --git a/app/assets/javascripts/management/learning_objects.js b/app/assets/javascripts/management/learning_objects.js new file mode 100644 index 0000000000000000000000000000000000000000..783f2af0fb2c832f27732000b9b83e1999b1fb6d --- /dev/null +++ b/app/assets/javascripts/management/learning_objects.js @@ -0,0 +1,55 @@ +//confurações dos gráficos de linha +//mais infos: www.chartjs.org/docs/ + + + +//var visual = document.getElementById("object").value; +//alert(visual); +function dataLearningObjects(visualised,non_visualised) { + var data = [ + { + value: visualised, + color:"#F7464A", + highlight: "#FF5A5E", + label: "Visualizados" + }, + { + value: non_visualised, + color: "#46BFBD", + highlight: "#5AD3D1", + label: "Não Visualizados" + } + + ]; + return data; +} + +var pie_options = { + //Boolean - Whether we should show a stroke on each segment + segmentShowStroke : true, + + //String - The colour of each segment stroke + segmentStrokeColor : "#fff", + + //Number - The width of each segment stroke + segmentStrokeWidth : 2, + + //Number - The percentage of the chart that we cut out of the middle + percentageInnerCutout : 0, // This is 0 for Pie charts + + //Number - Amount of animation steps + animationSteps : 100, + + //String - Animation easing effect + animationEasing : "easeOutBounce", + + //Boolean - Whether we animate the rotation of the Doughnut + animateRotate : true, + + //Boolean - Whether we animate scaling the Doughnut from the centre + animateScale : false, + + //String - A legend template + legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>" + +}; diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 971c9ef3ffb61a4160c39265edfc67b7b44a773d..42a0c5a2d2771ccbec3af0fada5056cbc83c1013 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -66,13 +66,6 @@ a, a:focus, a:hover { top: 45%; } -.popover { - display: none; - z-index: 999; - max-width: 600px; - width: auto; -} - .radio { margin-left: 20px; } @@ -266,6 +259,35 @@ header { } } +//form complaint +.submit_button { + color: #FFFFFF; + background: #2178F5; + border-radius : 5px 5px 20px 20px ; + moz-border-radius : 5px 5px 20px 20px ; + +} + +.close_button { + color: #FFFFFF; + background: #2178F5; + border-radius : 5px 5px 20px 20px ; + moz-border-radius : 5px 5px 20px 20px ; +} + + +.popover { + display: none; + z-index: 999; + max-width: 600px; + width: auto; +} + +.popover-title{ + background: #2178F5; + color: #FFFFFF; +} + //// FOOTER footer { width: 100%; diff --git a/app/controllers/complaints_controller.rb b/app/controllers/complaints_controller.rb index 26f48b71b69f57068c1b3993cd63448285fb726d..747badc133766d7834ac9ca16497704b1c18d2c9 100644 --- a/app/controllers/complaints_controller.rb +++ b/app/controllers/complaints_controller.rb @@ -6,13 +6,13 @@ class ComplaintsController < ApplicationController def create @complaint = Complaint.new(complaint_params) @complaint.user = current_user - @complaint.object = params[:object] - + @complaint.object = params[:complaint][:object_rid] + respond_to do |format| if complaint_repository.report @complaint - format.html { redirect_to @complaint, notice: 'complaint was successfully created.' } + format.html { redirect_to :back, notice: 'Denúncia realizada com sucesso.' } else - format.html { render :new } + format.html { redirect_to :back, alert: 'Objeto já foi denunciado por você.' } end end end diff --git a/app/controllers/management/statistics_controller.rb b/app/controllers/management/statistics_controller.rb index 9681d7966d07cb57c0a8860ace3b0cc102028aa7..761e080cf8cdd2505852223a2af780b4c67fc8d8 100644 --- a/app/controllers/management/statistics_controller.rb +++ b/app/controllers/management/statistics_controller.rb @@ -1,25 +1,39 @@ class Management::StatisticsController < ManagementController - def index - + include RepositoriesProxy + def index + @n_collections = collection_repository.get_number_of_collections + @n_views = main_page_repository.get_number_of("Views") + @n_users = subject_repository.get_number_of("User") + @n_learning_objects = learning_object_repository.get_number_of("learningObject") + @n_non_visualised = learning_object_repository.get_number_of_non_visualised end - def usuarios - + def users + #missing roles + @n_users = subject_repository.get_number_of("User") end def downloads - + #Decidir se mantém end def accesses + #usar o logstash e kibana end - def highlights + def collections + @n_collections = collection_repository.get_number_of_collections end - def collections + def learning_objects + @n_learning_objects = learning_object_repository.get_number_of("learningObject") + @n_non_visualised = learning_object_repository.get_number_of_non_visualised + @most_visualised = learning_object_repository.get_most_visualised + end + def views + @n_views = main_page_repository.get_number_of("Views") end end diff --git a/app/controllers/management_controller.rb b/app/controllers/management_controller.rb index ef890daa346304084f5f8b2fea71edf2ad7aa555..8dc0ebe813704f2d64d17d4ee60fa381e0d314ca 100644 --- a/app/controllers/management_controller.rb +++ b/app/controllers/management_controller.rb @@ -1,5 +1,7 @@ class ManagementController < ApplicationController + include RepositoriesProxy before_action :authenticate_user! + layout 'management' end diff --git a/app/repositories/orient_db/collection_repository.rb b/app/repositories/orient_db/collection_repository.rb index 6a725450a4c5f54cb0936dd50c913ba14762a770..39f8ed020c806e281fba8c59fc294a7fa4fac9f2 100644 --- a/app/repositories/orient_db/collection_repository.rb +++ b/app/repositories/orient_db/collection_repository.rb @@ -1,6 +1,7 @@ module OrientDb class CollectionRepository < Base include OrientDb::Methods::EdgeMethods + include OrientDb::Methods::GenericMethods def build_object(args={}) Collection.new(map_object_hash(args)) @@ -13,6 +14,11 @@ module OrientDb end end + def get_number_of_collections + result = get_number_of("Collection") + result + end + def create_bookmarks_collection(user) bookmarks = Bookmarks.new(owner: user) create bookmarks diff --git a/app/repositories/orient_db/complaint_repository.rb b/app/repositories/orient_db/complaint_repository.rb index 58dd7de100e440ee002d33805c1ca8eef726d650..b2454f176d9afefb29a4411e005948ea9ab29cf5 100644 --- a/app/repositories/orient_db/complaint_repository.rb +++ b/app/repositories/orient_db/complaint_repository.rb @@ -4,19 +4,19 @@ module OrientDb include RepositoriesProxy def report(complaint) - if edge_exists?(odb_class, complaint.user.id, complaint.object.id) - raise "The user has already been reported" + if edge_exists?(odb_class, complaint.user.rid, complaint.object) + false + else + connection.command "CREATE EDGE Complaint FROM #{complaint.user.rid} TO #{complaint.object} SET message = '#{complaint.message}', description = '#{complaint.description}'" end - - connection.command "CREATE EDGE Complaint FROM #{complaint.user.id} TO #{complaint.object.id} SET message = #{complaint.message}, description = #{complaint.description}" end def destroy(object) - if !edge_exists?(odb_class, complaint.user.id, complaint.object.id) - raise "The user has not already been reported" + if !edge_exists?(odb_class, complaint.user.rid, complaint.object) + raise "The object has not been reported by you yet." end - connection.command "DELETE EDGE Complaint FROM #{complaint.user.id} TO #{complaint.object.id}" + connection.command "DELETE EDGE Complaint FROM #{complaint.user.rid} TO #{complaint.object}" end def build_object(args={}) diff --git a/app/repositories/orient_db/learning_object_repository.rb b/app/repositories/orient_db/learning_object_repository.rb index 77a56e3d1be7150deffd5e156cd6ac5df2b16dfb..5ef66dd790d2affc4d0236cad4ee354c1aab4680 100644 --- a/app/repositories/orient_db/learning_object_repository.rb +++ b/app/repositories/orient_db/learning_object_repository.rb @@ -73,6 +73,21 @@ module OrientDb raise 'The user hasn`t likes this object.' end + #it could perhaps be in the GenericMethods, if we'd like to extend to User counting. + def get_number_of_non_visualised() + (connection.query("SELECT COUNT(*) FROM LearningObject WHERE in('Views').size() = 0"))[0]["COUNT"] + end + + #get the ten most visualised. It's probably making too many useless accesses to orientDB... + def get_most_visualised() + result = connection.query("SELECT FROM (SELECT @rid,in('Views').size() AS views FROM LearningObject) ORDER BY views DESC LIMIT 10") + @most_visualised = [] + result.each do |result| + (@most_visualised ||= []).push(get_by_rid(result["rid"])) + end + build_objects @most_visualised + end + def get_by_dspace_id(id_dspace) result = select_by_property(odb_class, "id_dspace", id_dspace) build_object result.first diff --git a/app/repositories/orient_db/user_repository.rb b/app/repositories/orient_db/user_repository.rb index cb6a97b4b815333bf7d2e0e4790941d160b4a9e7..7a904ba1cb44a3d9391054b95662d31878103d9a 100644 --- a/app/repositories/orient_db/user_repository.rb +++ b/app/repositories/orient_db/user_repository.rb @@ -1,5 +1,6 @@ module OrientDb class UserRepository < Base + include RepositoriesProxy def create_graph_node(user) begin diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb index 14e792bfd6badfaa19f88d1db3fbaa7212f1bafd..8e1d227d64e893b5d5fe48618740671b40d866c6 100644 --- a/app/views/collections/show.html.erb +++ b/app/views/collections/show.html.erb @@ -1,37 +1,3 @@ -<!-- - -<div class="row"> - <%#= render 'users/header', user: @user %> - - <div class="user-files"> - <div class="row user-page-subtitle"> - <div class="col-md-6"> - <div class="media"> - <div class="media-body"> - <h2 class="media-heading">Objetos do usuário</h2> - <h4>x items</h4> - </div> - </div> - </div> - <div class="col-md-6 right-column align-right"> - <%# if current_user_page? user %> - <button type="button" class="btn btn-primary">Adicionar novo objeto</button> - <%# end %> - </div> - </div> - - <div class="row learning-object-columns"> - - <%#= render @objects[0], orientation: "vertical" %> -<%#= render @objects[1], orientation: "vertical" %> -<%#= render @objects[2], orientation: "vertical" %> - </div> - - <div style="clear: both;"></div> - </div> -</div> - ---> <nav class="navigation navbar-default "><br/> @@ -64,4 +30,4 @@ <div class="row mainpage-subjects"> <br/> <%= render_collection_objects @collection.learning_objects %> -</div> \ No newline at end of file +</div> diff --git a/app/views/complaints/_complaints_button.html.erb b/app/views/complaints/_complaints_button.html.erb index 25d6f5669caa9eb37975e096cc1741bdb0268730..a9708241b5322149106f65ec0b3c0f4a7fb09fc5 100644 --- a/app/views/complaints/_complaints_button.html.erb +++ b/app/views/complaints/_complaints_button.html.erb @@ -1,4 +1,4 @@ -<button type="button" class="btn btn-default btn-xs add_to_complaint " data-toggle="button" data-trigger="click" aria-pressed="false" autocomplete="off" title="Denunciar Objeto" border-style: "none" > +<button type="button" class="btn btn-default btn-xs add_to_complaint " data-toggle="button" data-trigger="click" aria-pressed="false" autocomplete="off" title="Denunciar Objeto" border-style: "none" > <%= image_tag "icons/report-circle.png", alt: "Denunciar objeto" %> </button> diff --git a/app/views/complaints/_form.html.erb b/app/views/complaints/_form.html.erb index 6abcde32db89ce3e4cf52d80d6ec781500893bef..0d62529c40323fb99fe7a870550a1ce1ed487f62 100644 --- a/app/views/complaints/_form.html.erb +++ b/app/views/complaints/_form.html.erb @@ -4,8 +4,6 @@ <div class="ls-label " > - <h4 class="ls-title-4"><p><b>Escolha a razão da denúncia:</b></p></h4> - <br><br> <%= f.collection_radio_buttons :message, @messages, :message, :message do |m| %> <div class="radio" > @@ -21,12 +19,15 @@ </div> - <%= f.hidden_field :object, value: @learning_object %> + <%= f.hidden_field :object_rid, value: @learning_object.id %> </fieldset> - <div align="center" class="ls-btn-primary"> - <%= f.submit "Salvar" %> - <%= link_to "Fechar", class:"btn-success" %> + + + <div align="center" > + <%= f.submit "Salvar", class:"submit_button" %> + <%#= link_to "Fechar",{}, class:"close_button" %> + <!--<button id="btn-fechar" class="btn btn-danger" data-dismiss="clickover">Fechar</button>--> </div> <%end%> diff --git a/app/views/management/statistics/downloads.html.erb b/app/views/management/statistics/downloads.html.erb deleted file mode 100644 index 59a8bd26d09d52ed4b4b1c62238f436a23c4782d..0000000000000000000000000000000000000000 --- a/app/views/management/statistics/downloads.html.erb +++ /dev/null @@ -1,27 +0,0 @@ -<ol class="ls-breadcrumb"> - <li><%= link_to "InÃcio", management_root_path %></li> - <li><%= link_to "EstatÃsticas", management_statistics_path %></li> - <li> Downloads </li> -</ol> -<br><br> - - -<div class="ls-box ls-board-box"> - <header class="ls-info-header"> - <h2 class="ls-title-3">Downloads</h2> - <p class="ls-float-right ls-float-none-xs ls-small-info">Apurado em <strong><%= Date.today.to_s %></strong></p> - </header> - - <div id="sending-stats" class="row"> - <div class="col-sm-6 col-md-12"> - <div class="ls-box"> - <h6 class="ls-title-6">Total</h6> - <strong class="ls-color-theme">340</strong> - </div> - </div> - </div> -</div> - -<div align="center"> - <canvas id="downloads" width="400" height="350"></canvas> -</div> diff --git a/app/views/management/statistics/index.html.erb b/app/views/management/statistics/index.html.erb index fb8d9e581c4b783df3de7b01d8655b8207b3aeb5..3868c0e0af441262ecd2c9017d2feb581e13ecfa 100644 --- a/app/views/management/statistics/index.html.erb +++ b/app/views/management/statistics/index.html.erb @@ -17,7 +17,7 @@ <div class="col-sm-6 col-md-3"> <div class="ls-box"> <h6 class="ls-title-4">Total de usuários</h6> - <strong class="ls-color-theme">60</strong> + <strong class="ls-color-theme"><%= @n_users %></strong> <!--<small>envios por mês</small>--> <%= link_to "Mais detalhes" , users_management_statistics_path, class: "ls-btn ls-btn-sm" %> </div> @@ -25,21 +25,22 @@ <div class="col-sm-6 col-md-3"> <div class="ls-box"> <h6 class="ls-title-4">Total de coleções</h6> - <strong class="ls-color-theme">348</strong> + <strong class="ls-color-theme"><%= @n_collections %></strong> <%= link_to "Mais detalhes" , collections_management_statistics_path, class: "ls-btn ls-btn-sm" %> </div> </div> - <div class="col-sm-6 col-md-3"> - <div class="ls-box"> - <h6 class="ls-title-4">Total de downloads</h6> - <strong class="ls-color-theme">340</strong> - <%= link_to "Mais detalhes" , downloads_management_statistics_path, class: "ls-btn ls-btn-sm" %> - </div> + + <div class="col-sm-6 col-md-3"> + <div class="ls-box"> + <h6 class="ls-title-4">Total de objetos</h6> + <strong class="ls-color-theme"><%= @n_learning_objects %></strong> + <%= link_to "Mais detalhes" , learning_objects_management_statistics_path, class: "ls-btn ls-btn-sm" %> </div> + </div> <div class="col-sm-6 col-md-3"> <div class="ls-box"> - <h6 class="ls-title-4 ">Total de acessos</h6> - <strong class="ls-color-theme">2091</strong> + <h6 class="ls-title-4 ">Objetos não visualizados</h6> + <strong class="ls-color-theme"><%= @n_non_visualised %></strong> <%= link_to "Mais detalhes" , accesses_management_statistics_path, class: "ls-btn ls-btn-sm" %> </div> diff --git a/app/views/management/statistics/learning_objects.html.erb b/app/views/management/statistics/learning_objects.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..dfdbe98e489d0912f280a2c8cb6e09a6c0f028d7 --- /dev/null +++ b/app/views/management/statistics/learning_objects.html.erb @@ -0,0 +1,56 @@ +<ol class="ls-breadcrumb"> + <li><%= link_to "InÃcio", management_root_path %></li> + <li><%= link_to "EstatÃsticas", management_statistics_path %></li> + <li> Objetos </li> +</ol> +<br><br> + + +<div class="ls-box ls-board-box"> + <header class="ls-info-header"> + <h2 class="ls-title-3">Objetos</h2> + <p class="ls-float-right ls-float-none-xs ls-small-info">Apurado em <strong><%= Date.today.to_s %></strong></p> + </header> + + <div id="sending-stats" class="row"> + <div class="col-sm-6 col-md-12"> + <div class="ls-box"> + <h6 class="ls-title-6">Total</h6> + <strong class="ls-color-theme"><%= @n_learning_objects %></strong> + </div> + </div> + + <div class="col-sm-6 col-md-6"> + <div class="ls-box"> + <h6 class="ls-title-6">Visualizados</h6> + <strong class="ls-color-theme"><%= @n_learning_objects - @n_non_visualised %></strong> + </div> + </div> + + <div class="col-sm-6 col-md-6"> + <div class="ls-box"> + <h6 class="ls-title-6">Não Visualizados</h6> + <strong class="ls-color-theme"><%= @n_non_visualised %></strong> + </div> + </div> +</div> +</div> + +<input type="hidden" id="lobject" value="<%= @n_learning_objects - @n_non_visualised %>"/> +<input type="hidden" id="lobject_non" value="<%= @n_non_visualised %>"/> + + +<div> + <div style="float: left; margin-left: 85px; margin-top: 100px"> + <canvas id="learning_objects" width="700" height="600"></canvas> + </div> + + <div style="margin-left: 900px"> + <h3><th><b> 10 mais visualisados </b></th></h3><br> + <div class="row learning-object-columns"> + <% @most_visualised.each do |most| %> + <%= render_learning_object("vertical", most) %> + <% end %> + </div> + </div> +</div> diff --git a/app/views/shared/management/_nav_menu.html.erb b/app/views/shared/management/_nav_menu.html.erb index d0d4771c0081723c44365d60045adc66b0270470..e86d2e3e0a9865996ce9720b9f482ef1dd3884cd 100644 --- a/app/views/shared/management/_nav_menu.html.erb +++ b/app/views/shared/management/_nav_menu.html.erb @@ -10,7 +10,7 @@ <li><%= link_to "Geral", management_statistics_path, class: 'ls-submenu-item' %></li> <li><%= link_to "Usuários", users_management_statistics_path, class: 'ls-submenu-item' %></li> <li><%= link_to "Coleções", collections_management_statistics_path, class: 'ls-submenu-item' %></li> - <li><%= link_to "Downloads", downloads_management_statistics_path, class: 'ls-submenu-item' %></li> + <li><%= link_to "Objetos", learning_objects_management_statistics_path, class: 'ls-submenu-item' %></li> <li><%= link_to "Acessos", accesses_management_statistics_path, class: 'ls-submenu-item' %></li> </ul> </li> diff --git a/config/routes.rb b/config/routes.rb index 5292a63702076f8050acd4b7514fbe7d55e03e48..118160414832893ea341c10d3bf15c27a37235b7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,7 +15,7 @@ Rails.application.routes.draw do get :users get :collections get :accesses - get :downloads + get :learning_objects end end diff --git a/lib/orient_db/methods/finder_methods.rb b/lib/orient_db/methods/finder_methods.rb index 95449325dfd6f98ab97a1bdbef3f1f82e63f4820..93af468623d5dfb0fca172dd65e3d9e262c9dfc3 100644 --- a/lib/orient_db/methods/finder_methods.rb +++ b/lib/orient_db/methods/finder_methods.rb @@ -10,6 +10,11 @@ module OrientDb connection.query sprintf("SELECT FROM %s WHERE %s = '%s'", from, prop_name, prop_value) end + def get_number_of(element) + result = (connection.query sprintf("SELECT COUNT(@rid) FROM %s", element))[0]["COUNT"] + result + end + end end -end \ No newline at end of file +end