Skip to content

Commit

Permalink
add unreviewed + list of posts
Browse files Browse the repository at this point in the history
  • Loading branch information
SteakOverCooked authored and SteakOverCooked committed Feb 2, 2018
1 parent d8674b4 commit e6aedd9
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 24 deletions.
85 changes: 83 additions & 2 deletions js/utopian.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,67 @@ const logit = (msg) => {
dom.val(s + "\n" + n + ": " + msg);
}

function updateUnreviewed(api) {
logit("calling " + api);
$.ajax({
type: "GET",
url: api,
success: function(result) {
let data = [];
let categories = result.posts.pending.categories;
let total = result.posts.pending._total;
let s = "<h5>Total: <B>" + total + "</B></h5>";
data.push({"name": "development", "category": "Development", "posts":categories.development});
data.push({"name": "bug-hunting", "category": "Bug Hunting", "posts":categories.bug_hunting});
data.push({"name": "sub-projects", "category": "Sub Projects", "posts":categories.sub_projects});
data.push({"name": "documentation", "category": "Documentation", "posts":categories.documentation});
data.push({"name": "translations", "category": "Translations", "posts":categories.translations});
data.push({"name": "analysis", "category": "Analysis", "posts":categories.analysis});
data.push({"name": "ideas", "category": "Suggestions", "posts":categories.ideas});
data.push({"name": "graphics", "category": "Graphics", "posts":categories.graphics});
data.push({"name": "tutorials", "category": "Tutorials", "posts":categories.tutorials});
data.push({"name": "video-tutorials", "category": "Video Tutorials", "posts":categories.video_tutorials});
data.push({"name": "blog", "category": "Blog", "posts":categories.blog});
data.push({"name": "tasks", "category": "Task Requests", "posts":categories.tasks});
data.push({"name": "social", "category": "Visibility", "posts":categories.social});
data.push({"name": "copywriting", "category": "Copywriting", "posts":categories.copywriting});
let datalen = data.length;
data.sort(function(a, b) {
return b['posts'] - a['posts'];
})
s += "<ul>";
for (let i = 0; i < datalen; ++ i) {
s += "<li><a target=_blank href='https://utopian.io/" + data[i]['name'] + "/review'>" + data[i]['category'] + ' (' + data[i]['posts'] + ')</a></li>';
}
s += "</ul>";
$('div#unreviewed_cnt').html(s);
let chart = AmCharts.makeChart( "chart_unreviewed", {
"type": "pie",
"theme": "light",
"dataProvider": data,
"startDuration": 0,
"valueField": "posts",
"titleField": "category",
"balloon":{
"fixedPosition": true
},
"export": {
"enabled": false
}
});
},
error: function(request, status, error) {
logit('Response: ' + request.responseText);
logit('Error: ' + error );
logit('Status: ' + status);
},
complete: function(data) {
logit("API Finished: unreviewed.");
$('img#loading-unreviewed').hide();
}
});
}

function updateStats(api) {
logit("calling " + api);
$.ajax({
Expand Down Expand Up @@ -178,12 +239,30 @@ function getModeratorStats(api) {
url: api_approved,
success: function(result) {
let approved_cnt = result.total;
let approved_s = "<h4>Latest Approved Posts</h4>";
approved_s += "<ul>";
let approved_len = result.results.length;
for (let i = 0; i < approved_len; ++ i) {
let post = result.results[i];
approved_s += "<li><a target=_blank href='https://utopian.io/utopian-io/@" + post['author'] + '/' + post['permlink'] + "'>" + post['title'] + "</a> by @" + post['author'] + "</li>";
}
approved_s += "</ul>";
$('div#moderators_approved').html(approved_s);
logit("calling " + api_rejected);
$.ajax({
type: "GET",
url: api_rejected,
success: function(result) {
let rejected_cnt = result.total;
let rejected_s = "<h4>Latest Rejected Posts</h4>";
rejected_s += "<ul>";
let rejected_len = result.results.length;
for (let i = 0; i < rejected_len; ++ i) {
let post = result.results[i];
rejected_s += "<li><a target=_blank href='https://utopian.io/utopian-io/@" + post['author'] + '/' + post['permlink'] + "'>" + post['title'] + "</a> by @" + post['author'] + "</li>";
}
rejected_s += "</ul>";
$('div#moderators_rejected').html(rejected_s);
let rejected_cnt = result.total;
let s = "<h4>Your Approved/Rejected Stats</h4>";
s += "<ul>";
s += "<li>Approved: <B>" + approved_cnt + "</B></li>";
Expand Down Expand Up @@ -292,7 +371,7 @@ document.addEventListener('DOMContentLoaded', function() {
if (validId(id)) {
getVP(id, $("div#account_vp"));
getRep(id, $("div#account_rep"));
getModeratorStats("https://api.utopian.io/api/posts?moderator=" + id + "&skip=0&limit=1");
getModeratorStats("https://api.utopian.io/api/posts?moderator=" + id + "&skip=0&limit=8");
}
}
if (utopian["steemit_website"]) {
Expand Down Expand Up @@ -340,4 +419,6 @@ document.addEventListener('DOMContentLoaded', function() {
updateStats("https://api.utopian.io/api/stats");
// load moderator data
updateModerators("https://api.utopian.io/api/moderators");
// load unreviewed contributions
updateUnreviewed("https://utopian.plus/unreviewedPosts.json");
}, false);
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Utopian Moderator & Supervisor",
"short_name": "Utopian-IO",
"default_locale": "en",
"version": "0.0.4",
"version": "0.0.5",
"browser_action": {
"default_icon": "icon.png",
"default_title": "Utopian Moderator & Supervisor",
Expand Down
32 changes: 11 additions & 21 deletions utopian-ext-main.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<link rel="stylesheet" href="css/jquery-ui.css" />
<script src="js/jquery-ui.js"></script>
<style>
.ext-window {width: 600px;}
.ext-window {width: 620px;}
textarea {width: 100%;}
img {max-width: 100%;}
.chart {width: 100%; height: 550px;}
.chart {width: 100%; height: 570px;}
.vpbar {width: 100%; background-color: grey;}
.vp {color: white;}
</style>
Expand All @@ -31,7 +31,7 @@
<div id="tabs" class='ext-window'>
<ul>
<li><a href="#tabs-general">General</a></li>
<li><a href="#tabs-shortcuts">Short Cuts</a></li>
<li><a href="#tabs-unreviewed">Unreviewed</a></li>
<li><a href="#tabs-moderators">Moderators</a></li>
<li><a href="#tabs-chart">Chart</a></li>
<li><a href="#tabs-setting">Setting</a></li>
Expand All @@ -47,28 +47,18 @@
<h4>Total Number by Categories</h4>
<div id='chartdiv' class="chart"> </div>
</div>
<div id="tabs-shortcuts">
<ul>
<li><a target=_blank href="https://utopian.io/all/review">All</a></li>
<li><a target=_blank href="https://utopian.io/translations/review">Translations</a></li>
<li><a target=_blank href="https://utopian.io/bug-hunting/review">Bug-Hunting</a></li>
<li><a target=_blank href="https://utopian.io/ideas/review">Suggestions</a></li>
<li><a target=_blank href="https://utopian.io/development/review">Development</a></li>
<li><a target=_blank href="https://utopian.io/social/review">Visibility</a></li>
<li><a target=_blank href="https://utopian.io/documentation/review">Documentation</a></li>
<li><a target=_blank href="https://utopian.io/tutorials/review">Tutorials</a></li>
<li><a target=_blank href="https://utopian.io/video-tutorials/review">Video Tutorials</a></li>
<li><a target=_blank href="https://utopian.io/copywriting/review">Copyright</a></li>
<li><a target=_blank href="https://utopian.io/graphics/review">Graphics</a></li>
<li><a target=_blank href="https://utopian.io/analysis/review">Analysis</a></li>
<li><a target=_blank href="https://utopian.io/blog/review">Blog</a></li>
<li><a target=_blank href="https://utopian.io/sub-projects/review">Sub Projects</a></li>
</ul>
</div>
<div id="tabs-unreviewed">
<h4>Unreviewed Contributions</h4>
<div id="unreviewed_cnt"> </div>
<img id='loading-unreviewed' src='images/loading.gif' />
<div id='chart_unreviewed' class="chart"> </div>
</div>
<div id="tabs-moderators">
<img id='loading-moderators' src='images/loading.gif' />
<div id="moderators"> </div>
<div id="moderators_stats"> </div>
<div id="moderators_approved"> </div>
<div id="moderators_rejected"> </div>
<div id='chart_moderators' class="chart"> </div>
</div>
<div id="tabs-chart">
Expand Down

0 comments on commit e6aedd9

Please sign in to comment.