82 lines
2.3 KiB
Plaintext
82 lines
2.3 KiB
Plaintext
<div>
|
|
<h3>Channel and feeds</h3>
|
|
</div>
|
|
<div class="accordion" id="feedAccordion">
|
|
<% @school_urls.each_with_index do |url,index| %>
|
|
<div class="accordion-group">
|
|
<div class="accordion-heading">
|
|
<a class="accordion-toggle" data-toggle="collapse" data-parent="#feedAccordion" href="#channel_<%= index.to_s %>">
|
|
<%= (index + 1).to_s %>. <%= url %>
|
|
</a>
|
|
</div>
|
|
<div id="channel_<%= index.to_s %>" class="accordion-body collapse">
|
|
<div class="accordion-inner">
|
|
<% channels = @site_feeds[url].group_by(&:channel_name)
|
|
channel_names = channels.keys
|
|
channel_names.each do |name|
|
|
%>
|
|
<ul>
|
|
<li>
|
|
<%= name %>
|
|
<% channels[name].each do |channel| %>
|
|
<ul>
|
|
<li><%= channel.feed_name %> <button class="btn <%= channel.disabled ? "btn-info" : "btn-warning" %> disable-feed-btn" data-feed-id="<%= channel.id.to_s %>"><%= channel.disabled ? "Enable" : "Disable" %></button> <button class="btn btn-danger unsubscribe-btn" data-feed-uid="<%= channel.feed_uid %>" data-feed-name="<%= channel.feed_name %>">Unsubscribe</button></li>
|
|
</ul>
|
|
<% end %>
|
|
</li>
|
|
</ul>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
$(".disable-feed-btn").on("click",function(){
|
|
var disable = null,
|
|
el = $(this),
|
|
feed_id = $(this).data("feed-id");
|
|
if(el.hasClass("btn-warning")){
|
|
el.removeClass("btn-warning");
|
|
el.text("Disabling...");
|
|
disable = true;
|
|
}else{
|
|
el.removeClass("btn-info");
|
|
el.text("Enabling...");
|
|
disable = false;
|
|
}
|
|
|
|
$.ajax({
|
|
url : "/admin/feeds/disable",
|
|
data : {"feed_id" : feed_id, "disable" : disable},
|
|
dataType : "json",
|
|
type : "post"
|
|
}).done(function(){
|
|
if(disable){
|
|
setTimeout(function(){el.addClass("btn-info");el.text("Enable")},800);
|
|
}else{
|
|
setTimeout(function(){el.addClass("btn-warning");el.text("Disable")},800);
|
|
}
|
|
})
|
|
})
|
|
|
|
$(".unsubscribe-btn").on("click",function(){
|
|
var el = $(this);
|
|
if(confirm("Are you sure, you want to unsubscribe from " + el.data("feed-name"))){
|
|
$.ajax({
|
|
url : "/admin/feeds/unsubscribe",
|
|
data : {"feed_uid": el.data("feed-uid")},
|
|
dataType : "json",
|
|
type : "post"
|
|
}).done(function(){
|
|
el.parent().remove();
|
|
})
|
|
}
|
|
})
|
|
</script>
|
|
|
|
|
|
|
|
|