Add Tautulli news to settings page

This commit is contained in:
JonnyWong16 2020-05-10 14:18:36 -07:00
parent cbcad30a6c
commit b57065d6ee
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 83 additions and 0 deletions

View file

@ -2994,6 +2994,9 @@ a .home-platforms-list-cover-face:hover
.accordion li .link i.fa {
color: #999;
}
.accordion li .link span.toggle-left {
padding-right: 5px;
}
.accordion li .link span.toggle-right {
float: right;
padding-left: 10px;
@ -4301,3 +4304,36 @@ a[data-tab-destination] {
#browse-path-list > li > span > i.fa {
color: #999;
}
#tautulli-news .open .news-title,
#tautulli-news .open .news-date,
#tautulli-news .accordion li.open .link i.fa {
color: #eee;
}
.news-title,
.news-date {
color: #999;
padding-left: 5px;
}
.news-subtitle {
display: block;
color: #aaa;
font-weight: bold;
margin-bottom: 10px;
}
.news-body {
display: block;
color: #aaa;
}
.news-body p:last-of-type {
margin-bottom: 0;
}
.news-body a {
display: inline !important;
background: none !important;
padding: 0 !important;
color: #fff;
}
.news-body a:hover {
color: #f9be03;
}

View file

@ -71,6 +71,13 @@
<h3>Version ${common.RELEASE} <small><a id="changelog-modal-link" href="#"><i class="fa fa-info-circle"></i> Changelog</a></small></h3>
</div>
% endif
<div class="padded-header">
<h3>Tautulli News</h3>
</div>
<div id="tautulli-news">
<div class='text-muted'><i class="fa fa-refresh fa-spin"></i> Loading news...</div>
<br>
</div>
<div class="padded-header">
<h3>Tautulli Configuration</h3>
</div>
@ -2990,6 +2997,46 @@ $(document).ready(function() {
$('#resources-xml').on('tripleclick', function () {
openPlexXML('/api/resources', true, {includeHttps: 1});
});
var tautulli_news = $('#tautulli-news')
$.ajax({
url: 'https://tautulli.com/news/tautulli-news.json',
type: 'GET',
dataType: 'json',
cache: false,
async: true,
success: function (data) {
if (data) {
var news = $('<ul/>').addClass('accordion list-unstyled')
$.each(data, function (index, news_item) {
if (index >= 5) { return false; }
var header = $('<div/>').addClass('link').html(
'<span class="toggle-left"><i class="fa fa-newspaper fa-fw"></i></span>' +
'<span class="news-title">' + news_item.title + '</span>' +
'<span class="toggle-right"><i class="fa fa-chevron-down fa-fw"></i></span>' +
'<span class="news-date toggle-right">' + moment(news_item.date, "YYYY-MM-DD").format($('#date_format').val()) + '</span>');
var subtitle = $('<span/>').addClass('news-subtitle').html(news_item.subtitle);
var body = $('<span/>').addClass('news-body').html(news_item.body);
var content = $('<div/>').addClass('submenu');
if (news_item.subtitle) { content.append(subtitle); }
content.append(body);
var li = $('<li/>').append(header).append(content)
if (index === 0) {
li.addClass('open');
content.css('display', 'block');
}
news.append(li)
});
tautulli_news.html(news);
var accordion_news = new Accordion(news, false);
} else {
tautulli_news.html('<p class="help-block"><i class="fa fa-check"></i>&nbsp; No news available.</p>')
}
},
error: function () {
tautulli_news.html('<p class="help-block"><i class="fa fa-exclamation-triangle"></i>&nbsp; Failed to retrieve news.</p>')
}
});
});
</script>
</%def>