niedziela, 1 grudnia 2013

Another thing we will add to MotoAds demo application is a feature which allows us to comment each advert. A good idea would be to realize this as AngularJS directive. It will look like in the picture below. We can see all added comment to advert, click on Comment link activate the comment form with Preview, Send and Cancel buttons.

The comment form we will realize as AngularJS directive. Before we start let's look at changed adverts.json, there is the additional comments field (array of comments):
Step 1
We create commenForm.html template which we use in directive:
Step 2
We in directives.js we create AngularJS directive:
Step 3
We add simple CommentController into controllers.js:
Step 4
We add simple newlines filter into filters.js:
Step 5
We comment-form directive into adverts.html and some additional code to list comments and activate the comment form:
If you want to run this example on your computer, you can download sources from GitHub.

czwartek, 28 listopada 2013

I would like to show simple Java program which use XML-RPC interface to do some freeswitch commands.
We should on freeswitch console load mod_xml_rpc:
Worth checking out if it works, in web browser type:
If you see "FreeSWITCH help" it works.

sobota, 23 listopada 2013

I built MotoAds demo application in AngularJS but it did not have any server layer. Data was read directly from the json files. So I was decided to build the server side services. I know pretty well JEE and relational database, so I could use it. But I want to know something new so I chose NodeJS nad MongoDB. Thanks to this decision I got a full stack JavaScript application. It's incredible to use JavaScript to build the complete application.

Now MotoAds demo application consists of:

User interface in AngularJS and Bootstrap with full CRUD operations: add, read, edit and remove adverts.

Server service layer was built in NodeJS with RESTful serrvices. To simplify the use of a NodeJS I used ExpressJS.

Database: all data except the pictures are stored in MongoDB.

So let's see how to add the CRUD operations in AngularJS with services in NodeJS with MongoDB.

Step 1
We write in services.js access to our RESTful services:
Step 2
Inject services in app.js:
We use the angularjs services in controllers.js:
Step 3
In server.js we create the HTTP server with the RESTful service in NodeJS and ExpressJS. It is also used to host angularjs app:
Step 4
In adverts.js we write some code in NodeJS which allows us to use MongoDB:
We run MongoDB and start our HTTP server (node server.js). Now we are typing in web browser URL http://localhost:3000/#/. In web browser we should see the MotoAds application and we can use CRUD operations.

If you want to run this example on your computer, you can download sources from GitHub.

O mnie

Manager and programmer in one, in the IT industry since 2000. Passionate about new technologies and advocate of pragmatic solutions. He has been involved in many projects and the integrations of information systems, from concept to implementation. He likes to teach others and learn from others. Always open to new challenges.
English is not my native language and I make mistakes, probably a lot of them so if you notice something wrong, please just send me an e-mail.