mirror of https://github.com/calzoneman/sync.git
Add 'My Channels' to prevent silly people from forgetting which rooms they own
This commit is contained in:
parent
6d37c63a3d
commit
b53ac91a61
26
api.js
26
api.js
|
@ -356,9 +356,6 @@ module.exports = function (Server) {
|
|||
var session = params.session || "";
|
||||
var img = params.profile_image || "";
|
||||
var text = params.profile_text || "";
|
||||
console.log(name);
|
||||
console.log(img);
|
||||
console.log(text);
|
||||
|
||||
var row = Auth.login(name, pw, session);
|
||||
if(!row) {
|
||||
|
@ -501,6 +498,28 @@ module.exports = function (Server) {
|
|||
}
|
||||
},
|
||||
|
||||
handleListUserChannels: function (params, req, res) {
|
||||
var name = params.name || "";
|
||||
var pw = params.pw || "";
|
||||
var session = params.session || "";
|
||||
|
||||
var row = Auth.login(name, pw, session);
|
||||
if(!row) {
|
||||
this.sendJSON(res, {
|
||||
success: false,
|
||||
error: "Invalid login"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var channels = Server.db.listUserChannels(name);
|
||||
|
||||
this.sendJSON(res, {
|
||||
success: true,
|
||||
channels: channels
|
||||
});
|
||||
},
|
||||
|
||||
handleAdmReports: function (params, req, res) {
|
||||
this.sendJSON(res, {
|
||||
error: "Not implemented"
|
||||
|
@ -590,6 +609,7 @@ module.exports = function (Server) {
|
|||
"recoverpw" : api.handlePasswordRecover.bind(api),
|
||||
"setprofile" : api.handleProfileChange.bind(api),
|
||||
"getprofile" : api.handleProfileGet.bind(api),
|
||||
"listuserchannels": api.handleListUserChannels.bind(api),
|
||||
"setemail" : api.handleEmailChange.bind(api),
|
||||
"admreports" : api.handleAdmReports.bind(api),
|
||||
"readactionlog" : api.handleReadActionLog.bind(api)
|
||||
|
|
21
database.js
21
database.js
|
@ -943,6 +943,26 @@ function deleteUserPlaylist(user, name) {
|
|||
return results;
|
||||
}
|
||||
|
||||
function listUserChannels(user) {
|
||||
var db = getConnection();
|
||||
if(!db) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var query = createQuery(
|
||||
"SELECT * FROM channels WHERE owner=? ORDER BY id ASC",
|
||||
[user]
|
||||
);
|
||||
|
||||
var results = db.querySync(query);
|
||||
if(!results) {
|
||||
Logger.errlog.log("! Failed to list user channels");
|
||||
return [];
|
||||
}
|
||||
|
||||
return results.fetchAllSync();
|
||||
}
|
||||
|
||||
/* User Aliases */
|
||||
|
||||
function recordVisit(ip, name) {
|
||||
|
@ -1058,6 +1078,7 @@ exports.getUserPlaylists = getUserPlaylists;
|
|||
exports.loadUserPlaylist = loadUserPlaylist;
|
||||
exports.saveUserPlaylist = saveUserPlaylist;
|
||||
exports.deleteUserPlaylist = deleteUserPlaylist;
|
||||
exports.listUserChannels = listUserChannels;
|
||||
exports.recordVisit = recordVisit;
|
||||
exports.getAliases = getAliases;
|
||||
exports.ipForName = ipForName;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
<li><a href="javascript:void(0)" id="pwreset">Reset Password</a></li>
|
||||
<li><a href="javascript:void(0)" id="profile">Edit Profile</a></li>
|
||||
<li><a href="javascript:void(0)" id="email">Change Email</a></li>
|
||||
<li><a href="javascript:void(0)" id="channels">My Channels</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="span7">
|
||||
|
@ -208,6 +209,16 @@
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="span7" id="channelspane" style="display: none">
|
||||
<h1>My Channels</h1>
|
||||
<table id="channellist" class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /container -->
|
||||
<div class="push"></div>
|
||||
|
|
|
@ -70,6 +70,33 @@ $("#profile").click(function() {
|
|||
});
|
||||
}
|
||||
});
|
||||
$("#channels").click(makeTabCallback("#channels", "#channelspane"));
|
||||
$("#channels").click(function () {
|
||||
if(!loggedin) {
|
||||
var error = $("<div/>").addClass("alert alert-error")
|
||||
.text("You must be logged in to view this page")
|
||||
.insertBefore($("#channellist"));
|
||||
$("<button/>").addClass("close pull-right").click(function () {
|
||||
error.remove();
|
||||
}).html("×").prependTo(error);
|
||||
return;
|
||||
}
|
||||
|
||||
$.getJSON(api + "listuserchannels?name=" + encodeURIComponent(uname) +
|
||||
"&session=" + session + "&callback=?", function(data) {
|
||||
$("#channellist tbody").remove();
|
||||
data.channels.forEach(function (chan) {
|
||||
var tr = $("<tr/>").appendTo($("#channellist"));
|
||||
var td = $("<td/>").appendTo(tr);
|
||||
$("<a/>").attr("href", "./r/" + chan.name)
|
||||
.attr("target", "_blank")
|
||||
.text(chan.name)
|
||||
.appendTo(td);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
$("#registerbtn").click(function() {
|
||||
$("#registerpane").find(".alert-error").remove();
|
||||
|
|
Loading…
Reference in New Issue