Skip to content

Commit

Permalink
spam2 stable issues, UI update and modals added (#8034)
Browse files Browse the repository at this point in the history
* ui-update

* if-cache

* travis

* before action spam2

* system test issue

* delete node test

* string issue

* node path issue

* margin added if cached

* spam 2 ui update

* ui spam2 issues

* specific coloumn search

* formatting

* menu btn changed

* tests and alerts in spam2

* stable error

* spam2 ui update
  • Loading branch information
keshavsethi committed Jun 23, 2020
1 parent 734bff3 commit 9559d6e
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 277 deletions.
11 changes: 11 additions & 0 deletions app/assets/javascripts/spam2.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,22 @@ function table_main(id) {
$('#selectall').click(function () {
$('.selectedId').prop('checked', this.checked);
$('#select-count').text($('.selectedId').filter(":checked").length);
disable_buttons('#selectall');
});
$('.selectedId').change(function () {
var check = ($('.selectedId').filter(":checked").length === $('.selectedId').length);
$('#select-count').text($('.selectedId').filter(":checked").length);
$('#selectall').prop("checked", check);
disable_buttons('.selectedId');
});
return table;
}

function disable_buttons(id){
if ($(id).is(":checked")){
$("#batch-spam, #batch-publish, #delete-batch, #batch-ban, #batch-unban").removeClass("disabled");
}
else {
$("#batch-spam, #batch-publish, #delete-batch, #batch-ban, #batch-unban").addClass("disabled");
}
}
141 changes: 36 additions & 105 deletions app/assets/stylesheets/spam2.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,152 +2,83 @@
*= require datatables/dataTables.bootstrap4
*/
.nav_top {
position: fixed;
top: 60px;
left: 0px;
z-index: 5;
height: 50px;
width: 100%;
overflow-y: hidden;
border-bottom: 1px solid #e1e4e8;
}

#sidebar-wrapper {
margin-left: -15%;
transition: all .4s ease 0s;
position: fixed;
top: 50px;
right: 0;
left: 0;
width: 15%;
height: 100vh;
z-index: 4;
}

#page-content-wrapper {
margin-top: 8vh;
width: 85vw;
}

#wrapper.active #sidebar-wrapper {
left: 15%;
}

#batch-spam:hover {
border-bottom: 2px solid red;
color: grey;
font-weight: bold;
color: red !important;
cursor: pointer;
}

#batch-publish:hover {
border-bottom: 2px solid green;
color: grey;
font-weight: bold;
color: green !important;
cursor: pointer;
}

#delete-batch:hover {
border-bottom: 2px solid maroon;
color: grey;
font-weight: bold;
color: red !important;
cursor: pointer;
}

#all:hover {
border-bottom: 2px solid blue;
color: grey;
font-weight: bold;
color: blue !important;
cursor: pointer;
}

#batch-ban:hover {
border-bottom: 2px solid orange;
color: grey;
font-weight: bold;
color: orange !important;
cursor: pointer;
}

#batch-unban:hover {
border-bottom: 2px solid green;
color: grey;
font-weight: bold;
}

.alert {
z-index: 6;
}

#wrapper.active #card-top {
margin-left: 10%;
color: green !important;
cursor: pointer;
}

#wrapper.active #table-card {
margin-left: 10%;
#node-hover:hover{
color:blue !important;
}

#table-card {
margin-top: 8vh;
transition: all .4s ease 0s;
width: 100%;
}

#card-top {
transition: all .4s ease 0s;
margin-top:2vh;
}

.sidenav {
font-size: 0.9rem;
padding-top: 3.625rem;
border-right: 1px solid #e1e4e8;
#bulk-nav{
margin-top: 2%;
margin-bottom: 1%;
width:100%;
}

.sidenav .sidenav-menu .nav .sidenav-menu-heading {
padding: 1.1rem 1.4rem 0.7rem;
font-size: 0.9rem;
.active .drop{
color:white !important;
}

.sidenav .sidenav-menu .nav .nav-link {
display: flex;
align-items: center;
padding-top: 0.70rem;
padding-bottom: 0.70rem;
position: relative;
color: black;
#col-search{
cursor: text;
text-align:left !important;
margin-top:2px;
}

.sidenav .sidenav-menu .nav .nav-link.active {
font-weight: bold;
color: #007bff!important
#col-select{
margin-top:2px;
}

@media (max-width: 750px) {
#sidebar-wrapper {
margin-left: -45%;
width: 45%;
}
#wrapper.active #sidebar-wrapper {
left: 45%;
}
.nav_top {
font-size: small;
}
#table-card,
#table-card, #bulk-nav, .nav_top,
#card-top {
margin-left: 10%;
width:85vw;
}
#wrapper.active #page-content-wrapper {
opacity: 0.2;
}
}

@media (max-width: 1050px) and (min-width: 750px) {
#sidebar-wrapper {
margin-left: -25%;
width: 25%;
}
#wrapper.active #sidebar-wrapper {
left: 25%;
margin-left: 5vw;
width:90vw;
}
#wrapper.active #card-top {
margin-left: 25%;
.nav_title{
font-size: 18px;
margin-bottom : 10px;
}
#wrapper.active #table-card {
margin-left: 25%;
#card-top .card-header{
font-size: 18px;
}
}
15 changes: 8 additions & 7 deletions app/controllers/spam2_controller.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
class Spam2Controller < ApplicationController
before_action :require_user, only: %i(spam spam_revisions mark_comment_spam publish_comment spam_comments)
before_action :require_user, only: %i(_spam _spam_revisions _spam_comments)

def _spam
if logged_in_as(%w(moderator admin))
@nodes = Node
@nodes = Node.order('nid DESC')
@nodes = if params[:type] == 'wiki'
@nodes.where(type: 'page', status: 1)
else
@nodes.where(status: [0, 4])
end
@spam_count = @nodes.where(status: 0).length.to_s
@unmoderated_count = @nodes.where(status: 4).length.to_s
@page_count = @nodes.where(type: 'page').length.to_s
@note_count = @nodes.where(type: 'note').length.to_s
@spam_count = @nodes.where(status: 0).length
@unmoderated_count = @nodes.where(status: 4).length
@page_count = @nodes.where(type: 'page').length
@note_count = @nodes.where(type: 'note').length
else
flash[:error] = 'Only moderators can moderate posts.'
redirect_to '/dashboard'
Expand All @@ -32,7 +32,8 @@ def _spam_revisions

def _spam_comments
if logged_in_as(%w(moderator admin))
@comments = Comment.where(status: 0)
@comments = Comment.order('timestamp DESC')
.where(status: 0)
render template: 'spam2/_spam'
else
flash[:error] = 'Only moderators can moderate comments.'
Expand Down
38 changes: 29 additions & 9 deletions app/views/spam2/_comments.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ $(document).ready(function () {
<tbody>
<% @comments.each do |comment| %>
<tr id="n<%= comment.id %>">
<td><input class="selectedId" value="<%= comment.nid %>" type="checkbox" /></td>
<td><input class="selectedId" value="<%= comment.id %>" type="checkbox" /></td>
<td>
<% unless comment.node.nil? %>
<i class="fa fa-file"></i> <a href="<%= comment.node.path %>"><%= comment.node.title.truncate(40) %></a>
<% end %>
</td>
<i class="fa fa-file"></i> <a href="<%= comment.node.path %>" data-toggle="modal" data-target="#ninfo<%= comment.id %>"><%= comment.node.title.truncate(20) %></a>
<% end %>
</td>
<td style="width:200px;">
<%= comment.body.truncate(40) %>
</td>
<td>
<a href="/profile/<%= comment.author.name %>"><%= comment.author.name %></a>
<a href="/profile/<%= comment.author&.name %>"><%= comment.author&.name %></a>
</td>
<td>
<% unless comment.node.nil? %>
Expand All @@ -40,13 +40,33 @@ $(document).ready(function () {
</td>
<td>
<a class="badge badge-pill badge<% if comment.status == 0 %>-success<% else %>-secondary disabled<% end %> publish" href="/admin/publish_comment/<%= comment.id %>"><i class="fa fa-check-circle fa-white"></i> Publish</a>
<% if comment.author.status == 0 %>
<a class="badge badge-pill badge-danger a<%= comment.author.id %>" href="/ban/<%= comment.author.id %>">Ban</a>
<% elsif comment.author.status == 1 %>
<a class="badge badge-pill badge-secondary unban a-unban<%= comment.author.id %>" href="/unban/<%= comment.author.id %>">Unban</a>
<% if comment.author&.status == 0 %>
<a class="badge badge-pill badge-danger a<%= comment.author&.id %>" href="/ban/<%= comment.author&.id %>">Ban</a>
<% elsif comment.author&.status == 1 %>
<a class="badge badge-pill badge-secondary unban a-unban<%= comment.author&.id %>" href="/unban/<%= comment.author&.id %>">Unban</a>
<% end %>
</td>
</tr>
<div class="modal fade" id="ninfo<%= comment.id %>">
<div class="modal-dialog" >
<% unless comment.node.nil? %>
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><a href="<%= comment.node.path %>"><%= comment.node.title %></a></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span>&times;</span>
</button>
</div>
<div class="modal-body">
<%= comment.body %>
</div>
<div class="modal-footer">
<%= time_ago_in_words(comment.timestamp.seconds.ago) %> ago
</div>
</div>
<% end %>
</div>
</div>
<% end %>
</tbody>
</table>
Expand Down
Loading

0 comments on commit 9559d6e

Please sign in to comment.