mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 14:47:12 -04:00
add listGroups to API
fix wrong link in tests.html
This commit is contained in:
parent
8e6b451459
commit
7ec4100f0f
4 changed files with 41 additions and 1 deletions
|
@ -35,6 +35,7 @@ var cleanText = require("./Pad").cleanText;
|
||||||
/**GROUP FUNCTIONS*****/
|
/**GROUP FUNCTIONS*****/
|
||||||
/**********************/
|
/**********************/
|
||||||
|
|
||||||
|
exports.listGroups = groupManager.listGroups;
|
||||||
exports.createGroup = groupManager.createGroup;
|
exports.createGroup = groupManager.createGroup;
|
||||||
exports.createGroupIfNotExistsFor = groupManager.createGroupIfNotExistsFor;
|
exports.createGroupIfNotExistsFor = groupManager.createGroupIfNotExistsFor;
|
||||||
exports.deleteGroup = groupManager.deleteGroup;
|
exports.deleteGroup = groupManager.deleteGroup;
|
||||||
|
|
|
@ -111,6 +111,16 @@ exports.deleteGroup = function(groupID, callback)
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.listGroups = function(callback)
|
||||||
|
{
|
||||||
|
//try to get the groups entry
|
||||||
|
db.get("groups", function (err, groups)
|
||||||
|
{
|
||||||
|
if(ERR(err, callback)) return;
|
||||||
|
callback(null, groups);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
exports.doesGroupExist = function(groupID, callback)
|
exports.doesGroupExist = function(groupID, callback)
|
||||||
{
|
{
|
||||||
|
@ -124,9 +134,36 @@ exports.doesGroupExist = function(groupID, callback)
|
||||||
|
|
||||||
exports.createGroup = function(callback)
|
exports.createGroup = function(callback)
|
||||||
{
|
{
|
||||||
|
// load all existing groups from db
|
||||||
|
existingGroups = [];
|
||||||
|
|
||||||
|
exports.listGroups(function(err, responseGroups)
|
||||||
|
{
|
||||||
|
if(ERR(err, callback)) return;
|
||||||
|
if(responseGroups != undefined)
|
||||||
|
{
|
||||||
|
for(var key in responseGroups['groups'])
|
||||||
|
{
|
||||||
|
existingGroups.push(responseGroups['groups'][key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//search for non existing groupID
|
//search for non existing groupID
|
||||||
var groupID = "g." + randomString(16);
|
var groupID = "g." + randomString(16);
|
||||||
|
|
||||||
|
// check if group already exisits
|
||||||
|
exports.doesGroupExist(groupID, function(err, groupExist)
|
||||||
|
{
|
||||||
|
if(groupExist) return;
|
||||||
|
});
|
||||||
|
|
||||||
|
// add the new group to the array
|
||||||
|
existingGroups.push(groupID);
|
||||||
|
|
||||||
|
// update the entry to the db, which hold all groups
|
||||||
|
db.set("groups", {groups: existingGroups});
|
||||||
|
|
||||||
//create the group
|
//create the group
|
||||||
db.set("group:" + groupID, {pads: {}});
|
db.set("group:" + groupID, {pads: {}});
|
||||||
callback(null, {groupID: groupID});
|
callback(null, {groupID: groupID});
|
||||||
|
|
|
@ -38,6 +38,7 @@ catch(e)
|
||||||
|
|
||||||
//a list of all functions
|
//a list of all functions
|
||||||
var functions = {
|
var functions = {
|
||||||
|
"listGroups" : [],
|
||||||
"createGroup" : [],
|
"createGroup" : [],
|
||||||
"createGroupIfNotExistsFor" : ["groupMapper"],
|
"createGroupIfNotExistsFor" : ["groupMapper"],
|
||||||
"deleteGroup" : ["groupID"],
|
"deleteGroup" : ["groupID"],
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>API Test and Examples Page</title>
|
<title>API Test and Examples Page</title>
|
||||||
<script type="text/javascript" src="js/jquery.min.js"></script>
|
<script type="text/javascript" src="js/jquery.js"></script>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body {
|
body {
|
||||||
font-size:9pt;
|
font-size:9pt;
|
||||||
|
@ -139,6 +139,7 @@
|
||||||
</table>
|
</table>
|
||||||
<div class="results"/>
|
<div class="results"/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="define">listGroups()</div>
|
||||||
<div class="define">createGroup()</div>
|
<div class="define">createGroup()</div>
|
||||||
<div class="define">deleteGroup(groupID)</div>
|
<div class="define">deleteGroup(groupID)</div>
|
||||||
<div class="define">createGroupIfNotExistsFor(groupMapper)</div>
|
<div class="define">createGroupIfNotExistsFor(groupMapper)</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue