Discussion:
[oae-dev] 3akai-ux and hilary connection
Jacqueline Ramos
2014-03-31 17:25:15 UTC
Permalink
Hi, I am trying to understand how the widget "creatediscussion" connects
with the module in Hilary "oae-discussion" to create a new discussion and
insert into cassandra

I see that this code does it.
oae.api.discussion.createDiscussion(displayName, discussionTopic,
visibility, [], members, function (err, data) {
// If the creation succeeded, redirect to the discussion
profile
if (!err) {
window.location = data.profilePath;
} else {
oae.api.util.notification(

oae.api.i18n.translate('__MSG__DISCUSSION_NOT_CREATED__',
'creatediscussion'),

oae.api.i18n.translate('__MSG__DISCUSSION_COULD_NOT_BE_CREATED__',
'creatediscussion'),
'error');
}
});

and there is a oae.api.discussion.js in 3akai-ux/shared/oae/api that I
assume is the file that connects with Hilary. Am I wrong?
Also I am trying to create a "oae.api.meeting.js" and place it in the
oae.api,js file. It says there that the file is a plugin so I guess I have
to do something else for it work, right?

Could you please help me?

Jacqueline
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/oae-dev/attachments/20140331/68da6376/attachment.html
Simon Gaeremynck
2014-03-31 18:21:00 UTC
Permalink
Hi Jacqueline,

The frontend (3akai-ux) and the backend (Hilary) talk to each other over REST (more specifically, HTTP).
This means that if the frontend needs some data (e.g.: discussion profile data) it will perform a GET request to an api that is provided by Hilary.

Have a look in the network tab of your browser?s developer tools when loading a page.
You?ll see a lot of requests fly by. Among those, there should be a couple of requests to `/api/?`

In the frontend, we use jQuery?s excellent ajax function [1] to achieve this. As you said, this logic is located
in the `oae.api.discussion.js` [2] file under `/shared/oae/api`.
If you?re writing your own widget however, it?s probably not necessary to add your own API, you can place that logic in your own
widget and use jQuery?s ajax method directly.

On the backend we expose a set of REST endpoints (all under `/api`) that the UI can consume via jQuery?s ajax method.
Each `oae-*` module will have a `/lib/rest.js` file that plugs the endpoint in the expressjs [3] webserver.
Have a look at the discussion rest endpoints [4] for how this might work.

Hope that helps,

Simon

[1] http://api.jquery.com/jQuery.ajax/
[2] https://github.com/oaeproject/3akai-ux/blob/master/shared/oae/api/oae.api.discussion.js#L32
[3] http://expressjs.com/3x/api.html
[4] https://github.com/oaeproject/Hilary/blob/master/node_modules/oae-discussions/lib/rest.js#L114
Hi, I am trying to understand how the widget "creatediscussion" connects with the module in Hilary "oae-discussion" to create a new discussion and insert into cassandra
I see that this code does it.
oae.api.discussion.createDiscussion(displayName, discussionTopic, visibility, [], members, function (err, data) {
// If the creation succeeded, redirect to the discussion profile
if (!err) {
window.location = data.profilePath;
} else {
oae.api.util.notification(
oae.api.i18n.translate('__MSG__DISCUSSION_NOT_CREATED__', 'creatediscussion'),
oae.api.i18n.translate('__MSG__DISCUSSION_COULD_NOT_BE_CREATED__', 'creatediscussion'),
'error');
}
});
and there is a oae.api.discussion.js in 3akai-ux/shared/oae/api that I assume is the file that connects with Hilary. Am I wrong?
Also I am trying to create a "oae.api.meeting.js" and place it in the oae.api,js file. It says there that the file is a plugin so I guess I have to do something else for it work, right?
Could you please help me?
Jacqueline
_______________________________________________
oae-dev mailing list
oae-dev at collab.sakaiproject.org
http://collab.sakaiproject.org/mailman/listinfo/oae-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/oae-dev/attachments/20140331/9a8e449a/attachment-0001.html
Jacqueline Ramos
2014-03-31 19:07:47 UTC
Permalink
Hi Simon.
I wanted to do all the logic in my own widget, but I have to write in a
columnfamily I created in cassandra. I see that the module is in the Hilary
side. So my question is: how can I do this if I don't have the files that
for example "creatediscussion" has?

Hope you can help me
Jacqueline
Post by Simon Gaeremynck
Hi Jacqueline,
The frontend (3akai-ux) and the backend (Hilary) talk to each other over
REST (more specifically, HTTP).
This means that if the frontend needs some data (e.g.: discussion profile
data) it will perform a GET request to an api that is provided by Hilary.
Have a look in the network tab of your browser's developer tools when
loading a page.
You'll see a lot of requests fly by. Among those, there should be a couple
of requests to `/api/...`
In the frontend, we use jQuery's excellent ajax function [1] to achieve
this. As you said, this logic is located
in the `oae.api.discussion.js` [2] file under `/shared/oae/api`.
If you're writing your own widget however, it's probably not necessary to
add your own API, you can place that logic in your own
widget and use jQuery's ajax method directly.
On the backend we expose a set of REST endpoints (all under `/api`) that
the UI can consume via jQuery's ajax method.
Each `oae-*` module will have a `/lib/rest.js` file that plugs the
endpoint in the expressjs [3] webserver.
Have a look at the discussion rest endpoints [4] for how this might work.
Hope that helps,
Simon
[1] http://api.jquery.com/jQuery.ajax/
[2]
https://github.com/oaeproject/3akai-ux/blob/master/shared/oae/api/oae.api.discussion.js#L32
[3] http://expressjs.com/3x/api.html
[4]
https://github.com/oaeproject/Hilary/blob/master/node_modules/oae-discussions/lib/rest.js#L114
Hi, I am trying to understand how the widget "creatediscussion" connects
with the module in Hilary "oae-discussion" to create a new discussion and
insert into cassandra
I see that this code does it.
oae.api.discussion.createDiscussion(displayName, discussionTopic,
visibility, [], members, function (err, data) {
// If the creation succeeded, redirect to the discussion profile
if (!err) {
window.location = data.profilePath;
} else {
oae.api.util.notification(
oae.api.i18n.translate('__MSG__DISCUSSION_NOT_CREATED__',
'creatediscussion'),
oae.api.i18n.translate('__MSG__DISCUSSION_COULD_NOT_BE_CREATED__', 'creatediscussion'),
'error');
}
});
and there is a oae.api.discussion.js in 3akai-ux/shared/oae/api that I
assume is the file that connects with Hilary. Am I wrong?
Also I am trying to create a "oae.api.meeting.js" and place it in the
oae.api,js file. It says there that the file is a plugin so I guess I have
to do something else for it work, right?
Could you please help me?
Jacqueline
_______________________________________________
oae-dev mailing list
oae-dev at collab.sakaiproject.org
http://collab.sakaiproject.org/mailman/listinfo/oae-dev
--
Liliana Ramos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/oae-dev/attachments/20140331/51970123/attachment.html
Simon Gaeremynck
2014-03-31 20:23:28 UTC
Permalink
Hi Jacqueline,

You will have to create a backend module which will take care of persisting/retrieving data to/from Cassandra.
I've started a document on our wiki [1] which outlines the anatomy of an OAE backend module and where what code should go.
I will be expanding on it in the following days, but it should get you started.

I would suggest you go through the document first and then go through the code that is creating a discussion. Start in the node_modules/oae-discussions/lib/rest.js file with the create discussion endpoint and work your way down from there. You can add `console.log("My text");` if you want debug output, or if you're feeling adventurous, you could use something like node-inspector [2] to step through the code.

I suspect that what you will have to do is very similar to content/discussions?
i.e.:
1. Create an endpoint in your oae-meetings/lib/rest.js file at /api/meetings/create which responds to POST requests
2. Export a function in your oae-meetings/lib/api.js file `createMeeting`
3. Export a function in your oae-meetings/lib/internal/dao.js file `createMeeting` which persists the data to cassandra


When you have all of the above you can wire it up in your widget through jQuery's ajax function like so:

$.ajax({
'url': '/api/meetings/create',
'data': { .. },
'succes': function() { alert('Meeting has been created!'); },
'error': function() { alert('Meeting has not been created! :('; }
});


Kind regards,

Simon

[1] https://github.com/oaeproject/Hilary/wiki/Anatomy-of-an-OAE-backend-module
[2] https://github.com/node-inspector/node-inspector
Post by Jacqueline Ramos
Hi Simon.
I wanted to do all the logic in my own widget, but I have to write in a columnfamily I created in cassandra. I see that the module is in the Hilary side. So my question is: how can I do this if I don't have the files that for example "creatediscussion" has?
Hope you can help me
Jacqueline
Hi Jacqueline,
The frontend (3akai-ux) and the backend (Hilary) talk to each other over REST (more specifically, HTTP).
This means that if the frontend needs some data (e.g.: discussion profile data) it will perform a GET request to an api that is provided by Hilary.
Have a look in the network tab of your browser?s developer tools when loading a page.
You?ll see a lot of requests fly by. Among those, there should be a couple of requests to `/api/?`
In the frontend, we use jQuery?s excellent ajax function [1] to achieve this. As you said, this logic is located
in the `oae.api.discussion.js` [2] file under `/shared/oae/api`.
If you?re writing your own widget however, it?s probably not necessary to add your own API, you can place that logic in your own
widget and use jQuery?s ajax method directly.
On the backend we expose a set of REST endpoints (all under `/api`) that the UI can consume via jQuery?s ajax method.
Each `oae-*` module will have a `/lib/rest.js` file that plugs the endpoint in the expressjs [3] webserver.
Have a look at the discussion rest endpoints [4] for how this might work.
Hope that helps,
Simon
[1] http://api.jquery.com/jQuery.ajax/
[2] https://github.com/oaeproject/3akai-ux/blob/master/shared/oae/api/oae.api.discussion.js#L32
[3] http://expressjs.com/3x/api.html
[4] https://github.com/oaeproject/Hilary/blob/master/node_modules/oae-discussions/lib/rest.js#L114
Hi, I am trying to understand how the widget "creatediscussion" connects with the module in Hilary "oae-discussion" to create a new discussion and insert into cassandra
I see that this code does it.
oae.api.discussion.createDiscussion(displayName, discussionTopic, visibility, [], members, function (err, data) {
// If the creation succeeded, redirect to the discussion profile
if (!err) {
window.location = data.profilePath;
} else {
oae.api.util.notification(
oae.api.i18n.translate('__MSG__DISCUSSION_NOT_CREATED__', 'creatediscussion'),
oae.api.i18n.translate('__MSG__DISCUSSION_COULD_NOT_BE_CREATED__', 'creatediscussion'),
'error');
}
});
and there is a oae.api.discussion.js in 3akai-ux/shared/oae/api that I assume is the file that connects with Hilary. Am I wrong?
Also I am trying to create a "oae.api.meeting.js" and place it in the oae.api,js file. It says there that the file is a plugin so I guess I have to do something else for it work, right?
Could you please help me?
Jacqueline
_______________________________________________
oae-dev mailing list
oae-dev at collab.sakaiproject.org
http://collab.sakaiproject.org/mailman/listinfo/oae-dev
--
Liliana Ramos
Jacqueline Ramos
2014-03-31 20:39:20 UTC
Permalink
Thanks Simon.
I am looking forward to see your wiki finished :)
Post by Simon Gaeremynck
Hi Jacqueline,
You will have to create a backend module which will take care of
persisting/retrieving data to/from Cassandra.
I've started a document on our wiki [1] which outlines the anatomy of an
OAE backend module and where what code should go.
I will be expanding on it in the following days, but it should get you started.
I would suggest you go through the document first and then go through the
code that is creating a discussion. Start in the
node_modules/oae-discussions/lib/rest.js file with the create discussion
endpoint and work your way down from there. You can add `console.log("My
text");` if you want debug output, or if you're feeling adventurous, you
could use something like node-inspector [2] to step through the code.
I suspect that what you will have to do is very similar to
content/discussions?
1. Create an endpoint in your oae-meetings/lib/rest.js file at
/api/meetings/create which responds to POST requests
2. Export a function in your oae-meetings/lib/api.js file `createMeeting`
3. Export a function in your oae-meetings/lib/internal/dao.js file
`createMeeting` which persists the data to cassandra
When you have all of the above you can wire it up in your widget through
$.ajax({
'url': '/api/meetings/create',
'data': { .. },
'succes': function() { alert('Meeting has been created!'); },
'error': function() { alert('Meeting has not been created! :('; }
});
Kind regards,
Simon
[1]
https://github.com/oaeproject/Hilary/wiki/Anatomy-of-an-OAE-backend-module
[2] https://github.com/node-inspector/node-inspector
Post by Jacqueline Ramos
Hi Simon.
I wanted to do all the logic in my own widget, but I have to write in a
columnfamily I created in cassandra. I see that the module is in the Hilary
side. So my question is: how can I do this if I don't have the files that
for example "creatediscussion" has?
Post by Jacqueline Ramos
Hope you can help me
Jacqueline
On Mon, Mar 31, 2014 at 1:21 PM, Simon Gaeremynck <gaeremyncks at gmail.com>
Hi Jacqueline,
The frontend (3akai-ux) and the backend (Hilary) talk to each other over
REST (more specifically, HTTP).
Post by Jacqueline Ramos
This means that if the frontend needs some data (e.g.: discussion
profile data) it will perform a GET request to an api that is provided by
Hilary.
Post by Jacqueline Ramos
Have a look in the network tab of your browser's developer tools when
loading a page.
Post by Jacqueline Ramos
You'll see a lot of requests fly by. Among those, there should be a
couple of requests to `/api/...`
Post by Jacqueline Ramos
In the frontend, we use jQuery's excellent ajax function [1] to achieve
this. As you said, this logic is located
Post by Jacqueline Ramos
in the `oae.api.discussion.js` [2] file under `/shared/oae/api`.
If you're writing your own widget however, it's probably not necessary
to add your own API, you can place that logic in your own
Post by Jacqueline Ramos
widget and use jQuery's ajax method directly.
On the backend we expose a set of REST endpoints (all under `/api`) that
the UI can consume via jQuery's ajax method.
Post by Jacqueline Ramos
Each `oae-*` module will have a `/lib/rest.js` file that plugs the
endpoint in the expressjs [3] webserver.
Post by Jacqueline Ramos
Have a look at the discussion rest endpoints [4] for how this might work.
Hope that helps,
Simon
[1] http://api.jquery.com/jQuery.ajax/
[2]
https://github.com/oaeproject/3akai-ux/blob/master/shared/oae/api/oae.api.discussion.js#L32
Post by Jacqueline Ramos
[3] http://expressjs.com/3x/api.html
[4]
https://github.com/oaeproject/Hilary/blob/master/node_modules/oae-discussions/lib/rest.js#L114
Post by Jacqueline Ramos
On 31 Mar 2014, at 18:25, Jacqueline Ramos <jackie.ljrm at gmail.com>
Post by Jacqueline Ramos
Hi, I am trying to understand how the widget "creatediscussion"
connects with the module in Hilary "oae-discussion" to create a new
discussion and insert into cassandra
Post by Jacqueline Ramos
Post by Jacqueline Ramos
I see that this code does it.
oae.api.discussion.createDiscussion(displayName, discussionTopic,
visibility, [], members, function (err, data) {
Post by Jacqueline Ramos
Post by Jacqueline Ramos
// If the creation succeeded, redirect to the
discussion profile
Post by Jacqueline Ramos
Post by Jacqueline Ramos
if (!err) {
window.location = data.profilePath;
} else {
oae.api.util.notification(
oae.api.i18n.translate('__MSG__DISCUSSION_NOT_CREATED__',
'creatediscussion'),
oae.api.i18n.translate('__MSG__DISCUSSION_COULD_NOT_BE_CREATED__', 'creatediscussion'),
Post by Jacqueline Ramos
Post by Jacqueline Ramos
'error');
}
});
and there is a oae.api.discussion.js in 3akai-ux/shared/oae/api that I
assume is the file that connects with Hilary. Am I wrong?
Post by Jacqueline Ramos
Post by Jacqueline Ramos
Also I am trying to create a "oae.api.meeting.js" and place it in the
oae.api,js file. It says there that the file is a plugin so I guess I have
to do something else for it work, right?
Post by Jacqueline Ramos
Post by Jacqueline Ramos
Could you please help me?
Jacqueline
_______________________________________________
oae-dev mailing list
oae-dev at collab.sakaiproject.org
http://collab.sakaiproject.org/mailman/listinfo/oae-dev
--
Liliana Ramos
--
Liliana Ramos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/oae-dev/attachments/20140331/b4236ba7/attachment-0001.html
Loading...