Skip to content

Instantly share code, notes, and snippets.

@langalex

langalex/app.js Secret

Created August 11, 2016 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save langalex/499dabb3c018aa85a9cbf86dfed014aa to your computer and use it in GitHub Desktop.
Save langalex/499dabb3c018aa85a9cbf86dfed014aa to your computer and use it in GitHub Desktop.
list all members bot
(function() {
'use strict';
var subdomain = window.cobot.subdomain;
var client = Cobot.Api(window.cobot.access_token);
var storage = Cobot.Storage(window.cobot.storage_token);
var template = Handlebars.compile($('#app-template').html());
client.get(subdomain, '/memberships', {all: true, attributes: 'name,canceled_to,user'}).done(function(memberships) {
$('#app').html(template({memberships: memberships}));
Cobot.iframeResize();
});
})();
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>List all Members</title>
<meta name="description" content="List all members, including canceled and not yet started.">
</head>
<body>
<div class="page-header">
<h1>All Members</h1>
</div>
<div id="app">Loading...</div>
<script id="app-template" type="x-handlebars/text">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Canceled to</th>
</tr>
</thead>
<tbody>
{{#each memberships}}
<tr>
<td>{{name}}</td>
<td>{{user.email}}</td>
<td>{{canceled_to}}</td>
</tr>
{{/each}}
</tbody>
</table>
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="/javascripts/cobot_api.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment