Skip to content

shashank1shukla/App42-To-do-List

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

App42-Todo-List

App42 Client SDK sample for HTML5.

Create upcoming event or task and make your to-do list and share with your friends using [App42CloudAPI] (http://api.shephertz.com/apis) javascript SDK.

Feature List :

  1. User Authentication
  2. Session Storage
  3. Hosting your own task or event in an usual location
  4. Removable List Items
  5. Share with your friends who has use this app
  6. Support all mobile browsers and desktop browsers

Running Sample:

  1. [Register] (https://apphq.shephertz.com/register) with App42 platform
  2. Go to dashboard and click on the App Create .
  3. Fill all the mandatory fields and and checked the ACL true to get your APIKey and SecretKey.

Initialize App42 :

Edit index.html file and put your APIKey and SecretKey overhere.

App42.initialize("Your APIKey","Your SecretKey");

#Design Details:

App42 User:

Initialize App42User

var user  = new App42User();

Sign up for a new account.

var userName = ("#userName").val(),
password = ("#pwd").val(),
email = ("#email").val();
user.createUser(userName, password, email,{
success: function(object) {
// callbacl response when user is successfully created.
},
error: function(error) {
// callback when user already created or email already existes.
}
});

Authenticate existing account.

var userName = ("#loginName").val(),
password = ("#loginPassword").val();
user.authenticate(userName, password,{
success: function(object) {
// get userName and sessionId from authenticate user response
var userObj = JSON.parse(object)
var name = userObj.app42.response.users.user.userName;
var sId =  userObj.app42.response.users.user.sessionId;
// save logged in user with sessionId to browser local storage.
$.session.set('login', name);
$.session.set('sessionId', sId);
},
error: function(error) {
// callback when user not found.
}
});

Get all app users.

user.getAllUsers({
success: function(object) {
// create your app users list.
},
error: function(error) {
// when app has no user yet.
}
});

Get detail info of user.

var myProfile = ("#myProfile").val();
user.getUser(myProfile,{
success: function(object) {
// view user detail info.
},
error: function(error) {
// call when user not exists.
}
});

App42 Storage:

Initialize App42Storage

var storage  = new App42Storage(),
dbName = "Your db",
collectionName = "Your Collection";
// Get logged in user session id from authenticate response and set in to storage object.
var getSession = $.session.get('sessionId');
storage.setSessionId(getSession);

Save To-do using jsonData with storage

var todoName = $("#tName").val(),
startDate = $("#sDate").val(),
endDate = $("#eDate").val(),
time = $("#time").val(),
location = $("#location").val(),
json = "{\"task\":'"+todoName+"',\"startDate\":'"+startDate+"',\"endDate\":'"+endDate+"',\"time\":'"+time+"',\"location\":'"+location+"'}";
storage.insertJSONDocument(dbName, collectionName, json,{
success: function(object) {
// Add To-do in to list 
// When to create any To-do this will accessible to every one
// To remove accessibility from other user call revokeAccessOnDoc method in storage object
},
error: function(error) {
// callback when error occurred.
}
}); 

Remove Access from other users to view your To-do

var docId = "get from insertJSONDocument response"
var aclList = new Array();
var point={
user:"PUBLIC",
permission:Permission.READ
};
aclList.push(point)
storage.revokeAccessOnDoc(dbName, collectionName,docId, aclList,{
success: function(object) {
// callback for success 

},
error: function(error) {
// callback when error occurred.
}
});  

Get all To-do List created by you or shared with you

storage.findAllDocuments(dbName, collectionName,{
success: function(object) {
// Add all To-do to list view
},
error: function(error) {
// No To-do found.
}

Remove your To-do

storage.deleteDocumentById(dbName,collectionName,docId,{
success: function(object) {
// delete To-do successfully.
},
error: function(error) {
  // To-do not found.
}
})

Get detail of To-do

storage.findDocumentById(dbName,collectionName,docId,{
success: function(object) {
},
error: function(error) {
 
}
})

Share your To-do with your selected user or type his/her name.

var friendName = "your selected user from list"
var aclList = new Array();
var point1={
user:friendName,
permission:Permission.READ
};
aclList.push(point1)
// get documentId from local storage.
var tId = $.session.get('documentId');

storage.grantAccessOnDoc(dbName, collectionName,tId, aclList,{
success: function(object) {

},
error: function(error) {


}
});

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published