Tuesday 15 December 2015

How to Creating Azure Active Directory to provides identity services

To authenticate your applications, you need to register them in Microsoft Azure Active Directory (Azure AD). This is where Office 365 user account and application information is stored. To manage Azure AD through the Azure Management Portal, you need a Microsoft Azure subscription.

  1. Sign into the Azure Management Portal using your Office 365 business account credentials.
  2. Click the Active Directory node in the left column and select the directory linked to your Office 365 subscription.

    If Active Directory is not available on left go thought this step
    • Click New -> Search (Active Directory) -> Click on Active Directory
    • Click on Create Button it will navigate to Active Directory Page
    • Now if there is Popup Add directory. We can Close it
  3. Click First Small arrow in row.
  4. Click First Small arrow in row.
  5. Select the Applications tab and then Add at the bottom of the screen.
  6. On the pop-up, select Add an application my organization is developing. Then click the arrow to continue.
  7. Choose a name for the app, such as QualappsMail, and select Web application as its Type. Then click the arrow to continue.
  8. The value of Sign-on URL is the URL where the application will be hosted. Use https://QualappsRFP.azurewebsites.net.

    The value of App ID URI is a unique identifier for Azure AD to identify the app. You can use http://{your_subdomain}/SimpleMailApp, where {your_subdomain} is the subdomain of .onmicrosoft you specified while signing up for your Office 365 business account. Then click the check mark to provision the application.
  9. Once the application has been successfully added, you will be taken to the Quick Start page for the application. From here, select the Configure tab.
  10. Scroll down to the permissions to other applications section and click the Add application button.
  11. In this add the Office 365 Exchange Online application. Click the plus sign in the application's row and then click the check mark at the top right to add it. Then click the check mark at the bottom right to continue.
  12. In the Office 365 Exchange Online row, select Delegated Permissions, and in the selection list, choose Read user profiles, Send mail as a user, Read user mail.
  13. Click Save to save the app's configuration.
Configure the app to allow the OAuth 2.0 implicit grant flow

In order to get an access token for Office 365 API requests, the application will use the OAuth implicit grant flow. We need to update the application's manifest to allow the OAuth implicit grant flow because it is not allowed by default.

  1. Select the Configure tab of the application's entry in the Azure Management Portal.
  2. Using the Manage Manifest button in the drawer, download the manifest file for the application and save it to the computer.
  3. Open the manifest file with a text editor. Search for the oauth2AllowImplicitFlow property. By default it is set to false; change it to true and save the file.
  4. Using the Manage Manifest button, upload the updated manifest file.
  5. Browse and add Manifest file.
  6. Finally thing is. Now we are good with ClientId which is required to integrate it in our App.

Sunday 29 November 2015

Difference between ng-model and ng-bind

ng-bind has one-way data binding ($scope --> view). It has a shortcut {{ val }} which displays the scope value $scope.val inserted into html where val is a variable name.

ng-model is intended to be put inside of form elements and has two-way data binding ($scope --> view and view --> $scope) e.g. <input ng-model="val"/>.

7VhPb+I+EP00HCuRP6TtEbrt/i4/aaVK3bNJTGLhZLKOKdBP33E8SXAClG6p2q7KAezx2J6Z9/yCMwpu8s1Pxcrsf0i4HPnjZDMKfox8/+pqjN/GsLWGyRh7xpAqkViT1xnuxRMnI81LVyLhleOoAaQWpWuMoSh4rB0bUwrWrtsCpLtrydJmx85wHzM5tP4Wic4oLT/q7P9xkWbNzl50bUfmLF6mClYF7Tfyg0X9scM5a9aiRDdj2/U9KtCWDAEtWLLCCekJIHcMildd+Shd4VakYI9OX4pi6RZoDirhaiey4BbRVQC4kGnlmxsuDcINejb8uwOjbfkULyiU4xOimF+GXsiicTyPkmv/ggr9yOSKcrOGSm8bjHiCkFEXlM4ghYLJ2846q3HgZgss6izTucSmh81KK1i2yBoLL5Kp4Q125xLipTXdCYyydSCaeqZrozEhHMyYTBWsVExegzRD4jZTKadpA59JiweeNg4512pb4y6ZFo/u/oxgTVu/rujYoLqfiAEF52AQSQxztgBMcheM6M/KUKUeuLB8nKKDd1VuukFspfY3rGIoebMaBmYXbIZ7QHcwmsqvM6H5fcnqmq5RfXrQZiypYTSdVLLKVMTAP8Sc0uNKc9KtQygOq08TUBPo2Db6Red63amG15z1bEcxIrKdFbCaKe8A2IPg638QrBaEDwGLYvlqCndUzuiZdVTOmkf8CbidLHH1VMyOmVmNQwmi0NXOyr+MoaPDZNyjQ/8Z9Tp/bNgIOjq0qfwdQ6ia3/p7+EiHl59JfxtqfwvwaWh9rACjyn1uBV5IUT441X/5/+ZbRXSoepPeCetjYR8INOuYfPYWGoBqnxqDhV4t6/19XpL14/7nl/XmprfDuyK9mAu8Mvbph0fNnPEBq25AgrmtFVAYDi6QQj0TkyI1F8cY6WEudjNzcAVecKc0MAetzU1yr0IAei9kzdRMJAnHCTtEPyocRpuIxFhI6lNGl+f4E+cFDlzhHgmZ7JGQ4F0khGJ5g+Bj7nsEHwmR23cqp4n+VyXKGYkR9s7xOxIDu92rESsJ3Vuw4PYZ

DEMO

Talking between Controllers using $emit, $broadcast and $on in AngularJS

AngularJS provides $on, $emit, and $broadcast services for event-based communication between controllers.

7ZlRc6o6EMc/jY/tABG0j7XtaV/uzJ1x5pxzHyNEZIrEG7BqP303yQYIUFu97UV76oPDbmCT/PcHZMmA3Cy394KuFn/xiKUDz4m2A3I78Lzx2IF/6dhph++AJR2xSCLtcivHNHlm6MTr4nUSsdw6seA8LZKV7Qx5lrGwsHxUCL6xT5vz1O51RWPTY+WYhjRte38lUbHAaXlB5X9gSbwwPbvBlW6Z0fAxFnydYX8Dj8zVTzcvqYmFE906GMHX9s7YY9NTZo3omfOl5RAsr9TD2Sa2IBl9suw0yR5tfWZcREzUBkbuILmCcwgkj5bbG5bKBJvk6dH/eKW1VE+wDIey/wLPGxI/cD3HJZE/I+QCIzzRdI1zG3hDOZ5pyFdMN+bFzqQLogEZYEw2i6Rg0xUNZcsG2ATfolimYLlwqDLDZK/Syhc04hs04pTmUhVIwCQvBH8sMw9yTFZMJEtWMCFjJ1mMJ+IwmSgYot8xd+XCid8zDmHETqZetxKfYOrNraLNTcUdCKN9ixpz5hajmMq4jFwJDQeo9Tt1x7vU1j3/XzT/ACndK9QEpXRHfWqJabW1HHhBCp1Ocnlje0GsjrW+ugG6qbedg+y+kfQkZMcHqSV7W/MK67OV3XVs2YmRuBfZ8c349Wn3glOSffSnPmT6lR1XZ19f9uZDZtir7KY8sHRviphF17ICACuUWiShrR1MXOx+o0LK+MeSi0Wt0qAhFnTH10KlZs/ataAiZnhZ99qgLXpNVLMMrGtqfIKltEie7GF2CY09/M0TmEC14jS5wZyWVZcJoaeHV9WX7W8FIs7lyHWC0dh1x4E/HOFLwcTVkrTiKgxKFY4ko6tiOJaM0uiBDDXsbzI+kIyudfjRz4xL/5PYwFHuZUO97Ptiw2+klJg3w6FstAJ5/bEB7+wzYAMHtZcNVfb0xUYZ57+y0QrUIxtdheR5sqFE+2bjA9noqnZPjw0keC8bqpLpiw23UUsPTdxD2WgFGvXHRldtqOu/OVdjriAJ/l3LT+yq4UJ/x7+GE7zhals11j5ZzQSnUUhziFJWlDroaxXlGxDaH7qlZ56k6Q1Pud4NMJsX5sxai6N+uvyEEpfcqn2XA+DtCzrDgkGlWam+l7lGnCa6n4kYbjZ9BmJsCbtHJ0zXHD6RPOBjUh7/xMgnT50ppQx2AT6dD8auEYg04hzNHZjVjp8+vdrbJXcv

The key thing to remember when using $scope to fire your events, is that they will communicate only with immediate parent or child scopes only! Scopes aren’t always child and parent. We might have sibling scopes. Using $scope to fire an event will miss out sibling scopes, and just carry on up! They do not go sideways!

So to solve this problem we can use $broadcast and $emit.

$broadcast

We could fire an event down from ParentCtrl to SiblingOneCtrl using $broadcast:

$emit

If we wanted to communicate upwards, from SiblingOneCtrl to ParentCtrl, you guessed it, we can use $emit.

Sunday 8 November 2015

What is AngularJS ?

AngularJS is a JavaScript framework which simplifies binding JavaScript objects with HTML UI elements.

Let us understand this with a simple Example.

So if we analyze the above code (Control Binding In Plain Javascript) visually it looks something as shown below.

5Vlbc9o6EP41PKaDbS7mMdA0fTnTzuTMtH0UtrDVyBaVZS759ZGsFbZsTAzBzckJDyCt1quVvo+9wMBbJLt7jtbxPyzEdOAOw93A+zxwXd8fyncl2GvBeChnShBxEmqRUwoeyBMGITwX5STEmaUoGKOCrG1hwNIUB8KSIc7Z1lZbMWrvukaR2bEUPASINqU/SChiOJY7KeVfMYlis7MzmemVJQoeI87yFPYbuN6qeOnlBBlbcNDdUE89X8/3MB+NzE6p5dETY4kl4Dgrbw9OS+wLSdHG2pOS9NG+nyXjIeYVJe9OgssZk4bUKNktMFUAG/DGvjdbzoLVauIGsyme3mjTX7qqH+6X4xScfa1JAGCDaA7XoQWZ2BtUcShBhinjImYRSxG9K6XzAjmstpA4zGORUDl05BDviPgJYjX+pcafxmqWCr5XS4Wamui1qVrULqh9a7w6cW7QyVjOA3isoQNsEYhHuM1OcX64vHvMEixdU4zT6q4LFwbfUMebwtcHqBEdHjlY+c6I9Lq7CX0EeKqKZd2QVzPkj21D+pwNQ7ecI3Uko7ZWCllVQw4qhy9FBZk6EgsO1ROx+mIIOHmSIUU0azKEY4oE2dgOtdKiHYSOYLv6gjuTw9aXA+3B1fCGm7PwnlB5h/MVKxwrgZ/8yVWILBZudBy+lQruaL0rF+UoUp//7kSeYZ6iBBuD0jdtU2s0eFWyRlFlGxOBH9aowHwr867NpCxGIdvCJKIoU4Aotq0IpQtGmQ7wJh/JBwRnj7iyMixeB0c2mAsMKHSmZWvAqcM4hO/4tsyvjikb4mpuNWnrGAOt7/k5IEMir4CcE1lhLH+rauL/DIM7ruHgeE0czJVXcfD6gMFsfuUkrRMzpOlDXq4smTTdZwTukqMLnVdE4IsvHpyr8F9zX7CcfCz+m5jzNvwHo1dPNos8E9I//hEzzchUaP+NVOPAifrqTFr6DxMCm11Lr52JYfQlYe9QKUBWuLw1Gbk1E7NaR9G1NfH8Fwy9aWviHKtVr59PzbgkVl/saelI2sCAVuAMYrxooisxGkGmbuhsYrQ4PD2vXWrzq7d2yYFfqk5yMA3lrkXKCFS6IEFLDIPgVIax13Htku63kiTGR3KEkZ3XJL8Iqzz2RTSsVTM3k27h6SrAw1bvDviW7POXgPffP/DN5vncotXxjxWtc5KGJI3k+jdoxLsVr7J2VPJqhWoVnClLVZ6rVqcgQpRE6gf2QDJK/QA+V5Uokf8D3MJCQsKwSJLHSmImtVe0YHcs9bB8oJJMT1bKvfzCUvuJZXSk7D3G7As6Gzkt/x3QnCr/B/LungE=

And if we analyze the code (Control Binding In Angular1) visually it looks something as shown below.

7Vjvb9o8EP5rkLYP70QwpPQjUNZOWrVq7dp3H93YJFZNjIz51b++5+RMnIS2rC2lSEUIxefz2X6ex2cuDTIYL081nSTninHZaDXZskFOGq1Wt9uEX2tY5YZOE1rWEGvBclNQGC7FPUcjjotngvFpydEoJY2YlI2RSlMemZKNaq0WZbeRkuVZJzR2MxaGy4jKuvVGMJPgtlphYT/jIk7czEF4nPfc0ugu1mqW4nyNFhlln7x7TF0s3OiymTfd+BW2gzYaJjQtLeleqXHJoPm0gA+3K8qIpHRemlSK9K4M0K3SjGvPiQyBXa0UBLJP4+WAS8uwY69NmyN6G7Lu8YjBl/2Xh/6+rfsaYM1TXOxrQ6LC5lTOEI6rpfkzhW1l9qlZOXYzfriNEzRIf5EIwy8nNLK9C5Az2BIzltg9TShTC2zEkk4tcsBSH6fj2nCU/TabynxwR6dcjbnRK6uD3P0IGcJjE3SwvShEGDifxBOg86NIa7yOXCAIDwjiloCSGqC9NJ5JekiAEoIxPgSi7Rqig9nUQOBDgrRz/JFE2qlBWoOSp6xn7wRoRRYbEVnIDNWmbvZA5Uth/vee/1pMv3VsK4VV2y4LcdYo+vLZOavdL8/hDUtWM50R/ER2g1XH/LE42YGt8+bx4ijYRIvmkhoxL697E1c4w4USsKO1LNZ3N8qChBW68+3hKD+xVwO5gS6QC+wC5RjUAmXSWW/7ZWrC+30XanpCM48rbVdqwtT+pJqyZLUvNZFKkiHtF6qp7QZioJYL/A5qOnqhmjYkoUIoVhy2Z6eJZl+0B1W2XCHxr7QHHbwYXKDq5bND2ruHSPt+7w4Xx532Kltbn/YAM/geaMeC7bBo32uS71TKnVpu3pb28Gh/p939O/F4vznrXQ2vh78brVACYn0m5vAY28cv14Iv8HUJzNW8gPIdGLQFgG0OFPwzUFJy/dUNhgV542uSgj/21u4XAxDhjg+UVLagT1UKnv2RkLJiolLE9t1ClM9P+rZMEPAOpIcdY8GYnWZj9aHAeyQzKSfgx2FAv1yzvG+d16xIqY1Z2FPy+v2HL+UQT+mbFiUBbsjTxPWP4c0neZvJC8gjx9cjz/0x8LlzfL4td/Ui/fzXyfDnJ3mbyQvbz5PnKrpXkgfN4pVknruLt89k+AA=

Friday 6 November 2015

Component in Angular2

In Angular 2, Components are the main way we build and specify elements and logic on the page.

In Angular 1, we achieved this through directives, controllers, and scope. In Angular 2, all those concepts are combined into Components.

To build an Angular 2 application you define a set of components, for every UI element, screen, and route. An application will always have a root component that contains all other components. In other words, every Angular 2 application will have a component tree, which may look like this:

5VhPb6M+EP00HHcFGGhybLtp9/KTVuphd48OTMCqwcg4f+inrw3jEIemza9VmkabQ5R5NmP7vWePiUduy829pHXxn8iAe6GfbTzywwvDycTX3wZoeyD2dWSAXLKsh4IBeGBPgCA+ly9ZBo3TUQnBFatdMBVVBalyMCqlWLvdFoK7o9Y0tyMOwENK+Rj9zTJV4LLCZMB/AssLO3KQTPuWOU0fcymWFY7nhWTRffrmktpcuNCNjxkSBFoEYkxY08qZ0pMQpQNIaAb6cLnMZaSiKyfmrHp0CZoLmYHcmRmZaXWlEDqR+VVuboEbha16YeKHizidJHQaTefz4Fs//btju28JllDhZD+aEh22onyJdFzXNWcpZYqJqm9sVGsl7kQCkyzwyM26YAoeapqa1rX2tMYKVXJsbgqaiTUGOaeNoU8rdYNjglSA3j9mZV0fXNY9iBKUbI0ZsPsEc+DmsdZYD04MrH+KHRfafhS1zbeZBxr1D2TySFbJiNU7xhXI5oIIDRKX0MAeT2dhNBoxOitrLlrQB97lcBr5X4nT+CCnl7Tvp7YG9DGx1fAslGKpu2xKoy9F6dWI0hGVUGXX5v6io9Rww1KXPU2EbP8Yxr7HNvyLBMKGqZ0mHZkW81Q/DGSjS89bxOq5iaXslHyl5CoqcziUpysgY4F2BIhf4N9iEjhVbOXO+yVRcIRfgukVDVvKamtPKbKna788fGr3trGf6MpNZE87m6enYJSns8h21e9zzeRfdE1XJM/lGhLt1bb90+BY15AYxTtkvxPaBt8fPmSbT7fGWWW3tWHv2v3/RT9Qcz5BdDvUaVR/7Rg5qSPeOCy6q8q5XBNt39xxdtE7fbO9QWMiW3E+bBsdDm/yfffhTxsyewY=

LET US SEE A SIMPLE COMPONENT

Thursday 29 October 2015

AngularJS Providers

Provider Singleton Instantiable Configurable
Constant
Value
Service
Factory
Decorator
Provider

Constant

A constant can be injected everywhere. A constant can not be intercepted by a decorator, that means that the value of a constant should never be changed (though it is still possible to change it programmatically in Angular 1.x).

 angular.module('app', []);

 app.constant('MOVIE_TITLE', 'The Matrix');

 .controller('MyController', function (MOVIE_TITLE) {
   expect(MOVIE_TITLE).toEqual('The Matrix');
 });
    

Value

A value is nothing more than a simple injectable value. The value can be a string, number but also a function. Value differs from constant in that value can not be injected into configurations, but it can be intercepted by decorators.

 angular.module('app', []);

 .value('movieTitle', 'The Matrix');

 .controller('MyController', function (movieTitle) {
   expect(movieTitle).toEqual('The Matrix');
 })
    

Service

Use Service when you need just a simple object such as a Hash, for example {foo:1, bar:2} It's easy to code, but you cannot instantiate it. A service is an injectable constructor. If you want you can specify the dependencies that you need in the function. A service is a singleton and will only be created once by AngularJS. Services are a great way for communicating between controllers like sharing data.

 angular.module('app' ,[]);

 .service('movie', function () {
   this.title = 'The Matrix';
 });

 .controller('MyController', function (movie) {
   expect(movie.title).toEqual('The Matrix');
 });
    

Factory

A factory is an injectable function. A factory is a lot like a service in the sense that it is a singleton and dependencies can be specified in the function. The difference between a factory and a service is that a factory injects a plain function so AngularJS will call the function and a service injects a constructor. A constructor creates a new object so new is called on a service and with a factory you can let the function return anything you want. As you will see later on, a factory is a provider with only a $get method.

 angular.module('app', []);

 .factory('movie', function () {
   return {
     title: 'The Matrix';
   }
 });
 .controller('MyController', function (movie) {
   expect(movie.title).toEqual('The Matrix');
 });
 .factory('catalogueService', function($rootScope, $http) {
   // We first define a private API for our service.

   // Private vars.
   var items = [];

   // Private methods.
   function add( id ) {
     $http.put( $rootScope.apiURL, {id:id} )
     .success(function(data,status,headers,config) { items.push(data); })
     .then(function(response) { console.log(response.data); });
   }

   function store( obj ) {
     // do stuff
   }

   function remove( obj ) {
     // do stuff
   }

   // We now return a public API for our service.
   return {
     add: add,
     store: store,
     rm: remove
   };
 };
    

Decorator

A decorator can modify or encapsulate other providers. There is one exception and that a constant cannot be decorated.

 var app = angular.module('app', []);

 app.value('movieTitle', 'The Matrix');

 app.config(function ($provide) {
   $provide.decorator('movieTitle', function ($delegate) {
     return $delegate + ' - starring Keanu Reeves';
   });
 });

 app.controller('MyController', function (movieTitle) {
   expect(movieTitle).toEqual('The Matrix - starring Keanu Reeves');
 });
    

Provider

A provider is the most sophisticated method of all the providers. It allows you to have a complex creation function and configuration options. A provider is actually a configurable factory. The provider accepts an object or a constructor.

 var app = angular.module('app', []);

 app.provider('movie', function () {
   var version;
   return {
     setVersion: function (value) {
       version = value;
     },
     $get: function () {
       return {
           title: 'The Matrix' + ' ' + version
       }
     }
   }
 });

 app.config(function (movieProvider) {
   movieProvider.setVersion('Reloaded');
 });

 app.controller('MyController', function (movie) {
   expect(movie.title).toEqual('The Matrix Reloaded');
 });
    

Summary

  • All the providers are instantiated only once. That means that they are all singletons.
  • All the providers except constant can be decorated.
  • A constant is a value that can be injected everywhere. The value of a constant can never be changed.
  • A value is just a simple injectable value.
  • A service is an injectable constructor.
  • A factory is an injectable function.
  • A decorator can modify or encapsulate other providers except a constant.
  • A provider is a configurable factory.

Wednesday 21 October 2015

Android vs. iOS vs. Windows Phone: Which is Best for Business?

The best business smartphones have sharp displays, high-quality builds and long battery life. But there's a lot more to a smartphone than hardware.

But, what makes a phone great for business is the software it runs on.

There are three major OS today

  • iOS from Apple
  • Android from Google
  • Windows Phone from Microsoft

Lets see comparision between them.

Andriod iOS Windows
Apps Android app store (Google Play store) rivals the iOS App Store, with more than 1 million apps available. It can match almost every offering and Android and Windows Phone. The Windows Phone Store has about 100,000, Apps compared to selections of more than 1 million on Android and iOS.
Features Offers Google Now, an intelligent personal assistant.

The service works by monitoring your activity within the Google ecosystem and pushing relevant notifications to you as they're detected.

The service can notify you weather, traffic delay, appointmemnt and much more
The iWork for iOS apps are fully integrated with Apple's desktop iWork applications, letting users view and edit documents seamlessly on multiple devices.

It has similar notification features as andriod has.
Live Tiles, which update in real time to display relevant information right on your home screen, ensuring you never miss a message or meeting.
Security It's easy to side-load an unapproved app on an Android phone by downloading and installing the application from a source other than the Google Play store. Apple's iOS is a highly secure mobile operating system. It's virtually impossible to install apps from unofficial sources Windows Phone platform is comparable to iOS. All apps are reviewed and approved by Microsoft, and unlike on Android there's no need to consider dedicated anti-virus and anti-malware software - See more at: http://www.businessnewsdaily.com/5759-android-vs-ios-vs-windows-phone-small-business.html#sthash.oGqedQTx.dpuf

Tuesday 13 October 2015

Toggle class with ng-click on several elements

There is one liner code for Toggle class in jquery
   $('#page-wrapper').toggleClass('nav-small');

But what if we want to do it in a angular way

So I made simple directive for same:

module.directive('toggleClass', function() {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
            element.bind('click', function() {
                element.toggleClass(attrs.toggleClass);
            });
        }
    };
});

so you can make any element toggle class you need

<button id="btn" toggle-class="active">Change Class</button>
<div toggle-class="whatever"></div>



Hey, if there's anybody I can help out there, just let me know. Thanks ;)

Are hashbang URLs a recommended practice?

No, hashbang URLs are not a recommended practice. But it's important to be absolutely clear about what this means, so read on.

http://example.com/#foo is a hash URL. The #foo portion of the URL is never sent to the server, and will cause the page to automatically scroll to the first element with an id of "foo" (or the first <a> element with a name of "foo"). This is a perfectly good thing, and is a recommended practice for linking to specific sections within a page.

However, http://example.com/#foo could also be interpreted by JavaScript to indicate a particular state. Perhaps the "foo" state means "make an Ajax request to get the dictionary definition of the word 'foo' so we can display it to the user".

Now you've got a problem, because while this logic will work just fine as long as the JS runs, nothing at all will happen if the JS doesn't run. Furthermore, if you ever decide to change your URL structure to use a real URL like http://example.com/foo instead, then you'll either have to break all existing hash URLs that link to your site, or you'll need to keep that hash-handling JavaScript on your page forever so it can redirect users to the new URL.

In addition, search bots always ignore the hash portion of a URL when indexing a page. Always, with one exception: that one exception is that the GoogleBot (and only the GoogleBot) has some special and convoluted logic that allows to it recognize hashbang URLs like http://example.com/#!foo.

But there's a massive, massive caveat: the hashbang itself doesn't do a damn thing for you. All it does is tell the GoogleBot "hey, this website claims to support the Google Ajax Crawling Scheme". But the Ajax Crawling Scheme requires some pretty complicated server-side logic as well. You don't get it for free just by changing a # to a #!. So unless you've actually implemented the server-side logic necessary to support the Ajax Crawling Scheme, that #! in your URL is quite possibly damaging your Google rankings instead of helping them.

Furthermore, since Google is the only search engine that currently supports the Google Ajax Crawling Scheme (hint: the "Google" in the name of the scheme means "we just came up with this nonsense ourselves and didn't bother actually asking any other search engines if they thought it was a good idea"), your hashbang URLs will only be indexed by Google, even if you jump through all the hoops required to make this work properly.

So, to sum up:

  • "Hash" URLs and "hashbang" URLs aren't the same thing, although "hashbang" has unfortunately become the generic name for "hash URLs that trigger JavaScript-based logic".
  • Hash URLs are never sent to the server, so they're useless without JavaScript if you depend on them to trigger application logic.
  • Since hash URLs require JS, you're doomed to either break all existing URLs or maintain a JS URL handler forever if you ever decide to change your URL scheme.
  • "Hashbang" URLs don't automatically make your page indexable by search engines. You still need to do a lot of server-side work to make that happen. Even if you support the full Google Ajax Crawling Scheme correctly, that only helps you with Google. You're still screwed with the other search engines.

In short: relying on hash URLs for application logic should be an absolute last resort. If at all possible, you should avoid it.

Hey, if there's anybody I can help out there, just let me know. Thanks ;)

Monday 5 October 2015

Standard function to check for null, undefined, or blank variables in JavaScript?

Question

Is there a universal JavaScript function that checks that a variable has a value and ensures that it's not undefined or null? I've got this code, but I'm not sure if it covers all cases:

function isEmpty(val){
    return (val === undefined || val == null || val.length <= 0) ? true : false;
}

Answer

You can just check if the variable has a truthy value or not. That means

if( value ) {
}

will evaluate to true if value is not:

  • null
  • undefined
  • NaN
  • empty string ("")
  • 0
  • false

Sunday 4 October 2015

What is “upstream” and “downstream”

Question

I've started playing with Git and have come across the terms "upstream" and "downstream". I've seen these before but never understand them fully. What do these terms mean in the context of SCMs and source code?

Answer (Simple)

In terms of source control, you're "downstream" when you copy (clone, checkout, etc) from a repository. Information flowed "downstream" to you.

When you make changes, you usually want to send them back "upstream" so they make it into that repository so that everyone pulling from the same source is working with all the same changes. This is mostly a social issue of how everyone can coordinate their work rather than a technical requirement of source control. You want to get your changes into the main project so you're not tracking divergent lines of development.

Answer (Git)

There are two different contexts for upstream/downstream in git: remotes, and time/history. Upstream/downstream with respect to remotes is, the downstream repo will be pulling from the upstream repo (changes will flow downstream naturally). Upstream/downstream with respect to time/history can be confusing, because upstream in time means downstream in history, and vice-versa (genealogy terminology works much better here - parent/ancestor/child/descendant).

Saturday 3 October 2015

Angular CRUD operation helper service for sharepoint

Here we have some beautiful Angular Factory class Which help's us in any crud operation For Rest API in sharepoint

    "use strict";
    (function () {
        angular.module("docapp")
            .factory("baseSvc", ["$http", "$q", function ($http, $q) {
                var baseUrl = _spPageContextInfo.siteAbsoluteUrl;
                var getRequest = function (query) {
                    var deferred = $q.defer();
                    $http({
                        url: baseUrl + query,
                        method: "GET",
                        headers: {
                            "accept": "application/json;odata=verbose",
                            "content-Type": "application/json;odata=verbose"
                        }
                    })
                        .success(function (result) {
                            deferred.resolve(result);
                        })
                        .error(function (result, status) {
                            deferred.reject(status);
                        });
                    return deferred.promise;
                };
                var postRequest = function (data, url) {
                    var deferred = $q.defer();
                    $http({
                        url: baseUrl + url,
                        method: "POST",
                        headers: {
                            "accept": "application/json;odata=verbose",
                            "X-RequestDigest": document.getElementById("__REQUESTDIGEST").value,
                            "content-Type": "application/json;odata=verbose"
                        },
                        data: JSON.stringify(data)
                    })
                        .success(function (result) {
                            deferred.resolve(result);
                        })
                        .error(function (result, status) {
                            deferred.reject(status);
                        });
                    return deferred.promise;
                };
                var updateRequest = function (data, url) {
                    var deferred = $q.defer();
                    $http({
                        url: baseUrl + url,
                        method: "PATCH",
                        headers: {
                            "accept": "application/json;odata=verbose",
                            "X-RequestDigest": document.getElementById("__REQUESTDIGEST").value,
                            "content-Type": "application/json;odata=verbose",
                            "X-Http-Method": "PATCH",
                            "If-Match": "*"
                        },
                        data: JSON.stringify(data)
                    })
                        .success(function (result) {
                            deferred.resolve(result);
                        })
                        .error(function (result, status) {
                            deferred.reject(status);
                        });
                    return deferred.promise;
                };
                var deleteRequest = function (url) {
                    var deferred = $q.defer();
                    $http({
                        url: baseUrl + url,
                        method: "DELETE",
                        headers: {
                            "accept": "application/json;odata=verbose",
                            "X-RequestDigest": document.getElementById("__REQUESTDIGEST").value,
                            "IF-MATCH": "*"
                        }
                    })
                        .success(function (result) {
                            deferred.resolve(result);
                        })
                        .error(function (result, status) {
                            deferred.reject(status);
                        });
                    return deferred.promise;
                };
                return {
                    getRequest: getRequest,
                    postRequest: postRequest,
                    updateRequest: updateRequest,
                    deleteRequest: deleteRequest
                };
            }]);
    })();

Ok How do we use it then ?

Answer is very simple. Just make another factory class accoding to your business logic
    (function () {
        'use strict';
        var app = angular.module('docapp');
        app.factory("taskSvc", ["baseSvc", function (baseService) {
            var listEndPoint = '/_api/web/lists/';
            var getAll = function () {
                var query = listEndPoint + "GetByTitle('Asana2')/Items?$select=Title,Category,ID,PriorityCod,Desc2,AssignedTo&$filter=Status ne 'compleated'";
                return baseService.getRequest(query);
            };

            var getTaskByUser = function (userID) {
                var query = listEndPoint + "GetByTitle('Asana2')/Items?$select=Title,Category,ID,PriorityCod,Desc2,AssignedTo&$filter=Status ne 'compleated' and AssignedTo eq '"+userID+"'";
                return baseService.getRequest(query);
            };

            var getCommentsById = function (ID) {
                var query = listEndPoint + "GetByTitle('Activities')/Items?$select=TaskID,ActivityType,Cmnt,ID,EntryDate,UserCmnt,ProfilePic&$filter=ActivityType eq '2' and TaskID eq " + ID + "";

                return baseService.getRequest(query);
            }
            var addNewTask = function (tsk) {
                var data = {
                    __metadata: { 'type': 'SP.Data.Asana2ListItem' },
                    Title: tsk.Title,
                    PriorityCod: tsk.PriorityCod.toString(),
                    Category:  tsk.CategoryCode.toString(),
                    Desc2: tsk.Description,
                    AssignedTo: tsk.AssignedUserId.toString()
                };

                //console.log(tsk.AssignedUserId);
                var url = listEndPoint + "GetByTitle('Asana2')/Items";
                return baseService.postRequest(data, url);
            };
            var updatePriority = function (updatePriorityTsk) {
                var data = {
                    __metadata: { 'type': 'SP.Data.Asana2ListItem' },
                    PriorityCod: updatePriorityTsk.PriorityCod.toString(),
                };
                var url = listEndPoint + "/GetByTitle('Asana2')/GetItemById(" + updatePriorityTsk.ID + ")";
                return baseService.updateRequest(data, url);
            };

            var updateUser = function (updateUserTsk) {
                var data = {
                    __metadata: { 'type': 'SP.Data.Asana2ListItem' },
                    AssignedTo: updateUserTsk.AssignedTo,
                };
                var url = listEndPoint + "/GetByTitle('Asana2')/GetItemById(" + updateUserTsk.ID + ")";
                return baseService.updateRequest(data, url);
            };

            //var updatePriority = function (updatePriorityTsk) {
            //    var data = {
            //        __metadata: { 'type': 'SP.Data.Asana2ListItem' },
            //        PriorityCod: updatePriorityTsk.PriorityCod.toString(),
            //    };
            //    var url = listEndPoint + "/GetByTitle('Asana2')/GetItemById(" + updatePriorityTsk.ID + ")";
            //    return baseService.updateRequest(data, url);
            //};

            var updateCategory = function (updateCategoryTsk) {
                var data = {
                    __metadata: { 'type': 'SP.Data.Asana2ListItem' },
                    Category: updateCategoryTsk.Category.toString(),
                };
                var url = listEndPoint + "/GetByTitle('Asana2')/GetItemById(" + updateCategoryTsk.ID + ")";
                return baseService.updateRequest(data, url);
            };

            var updateDesc = function (updateDescTsk) {
                var data = {
                    __metadata: { 'type': 'SP.Data.Asana2ListItem' },
                    Desc2: updateDescTsk.Desc2.toString(),
                };
                var url = listEndPoint + "/GetByTitle('Asana2')/GetItemById(" + updateDescTsk.ID + ")";
                return baseService.updateRequest(data, url);
            };

            var updateTitle = function (updateTitleTsk) {
                var data = {
                    __metadata: { 'type': 'SP.Data.Asana2ListItem' },
                    Title: updateTitleTsk.Title.toString(),
                };
                var url = listEndPoint + "/GetByTitle('Asana2')/GetItemById(" + updateTitleTsk.ID + ")";
                return baseService.updateRequest(data, url);
            };

            var compleateTask = function (ID) {
                var data = {
                    __metadata: { 'type': 'SP.Data.Asana2ListItem' },
                    Status: 'compleated',
                };
                var url = listEndPoint + "/GetByTitle('Asana2')/GetItemById(" + ID + ")";
                return baseService.updateRequest(data, url);
            };


            var addNewActivities = function (comment) {
                var data = {
                    __metadata: { 'type': 'SP.Data.ActivitiesListItem' },
                   // Title:'title',
                    ActivityType: '2',
                    Cmnt: comment.Cmnt,
                    UserCmnt: comment.User,
                    ProfilePic: 'img/Users/ryan-301.jpg',
                    TaskID: comment.tskid.toString(),


                };
                var url = listEndPoint + "GetByTitle('Activities')/Items";
                return baseService.postRequest(data, url);
            };
        

            return {
                getAll: getAll,
                getCommentsById: getCommentsById,
                addNewTask: addNewTask,
                addNewActivities: addNewActivities,
                updatePriority: updatePriority,
                updateCategory: updateCategory,
                updateDesc: updateDesc,
                updateTitle: updateTitle,
                compleateTask: compleateTask,
                updateUser: updateUser,
                getTaskByUser: getTaskByUser
            };


        }]);

    })();

And now use like this below.

        $scope.GetContractMaster = function () {
            clauseSvc.getAll()
              .then(function (response) {
                  $scope.ContractMst.rowData = response.d.results;
                 
              });
        };

        $scope.updateUser = function () {
            $scope.updateUserTsk = {
                ID: $scope.comment.tskid,
                AssignedTo: $scope.TaskDtl.AllUsers,
            };

            taskSvc.updateUser($scope.updateUserTsk)
            .then(function (response) {
                $scope.getMyTask();
            });
        };

and so on ;) Cheers ;)

Friday 2 October 2015

Windows Task Scheduler SharePoint Backup Script

Create Windows PowerShell script

    Add-PSSnapin Microsoft.SharePoint.PowerShell 
    backup-spsite -identity $args[0] -path $args[1] -force

Create Batch Script to execute PowerShell script

    @echo off
    SET SOURCE_SITE=http://SPFarm:20045/ 
    SET DEST=C:\backup\Backup_site.bak
    echo "backup Started at" %DATE% >> C:\ backup\Log.txt
    powershell -command C:\Scripts\BackupSPSite.ps1  %SOURCE_SITE% %DEST%
    echo "Backup completed successfully at %DEST%" on %DATE% >> C:\ backup\Log.txt
    @echo on

Run Batch Script to execute PowerShell script

  • Run batch script to check successful backup and log creation at c:\backup.
  • Now run it from the Windows Task Scheduler. :)

Restore Sharepoint Site

EXAMPLE

    Restore-SPSite http://server_name/sites/site_name -Path C:\Backup\site_name.bak
This example restores a site collection from the backup file C:\Backup\site_name.bak to the site collection URL http://server_name/sites/site_name.

EXAMPLE

    Restore-SPSite http://server_name/sites/site_name -Path C:\Backup\site_name.bak -Force -DatabaseServer SQLBE1 -DatabaseName SQLDB1
This example restores a site collection backup from the backup file C:\Backup\site_name.bak, but overwrites the existing site collection at http://server_name/sites/site_name while specifying that the site collection must be stored in a specific content database.

EXAMPLE

    Restore-SPSite http://www.example.com -Path \\file_server\share\site_name.bak -HostHeaderWebApplication http://server_name
This example restores a site collection backup from the backup file \\file_server\share\site_name.bak to the host-named site collection http://www.example.com on the Web application http://server_name.

Backup Sharepoint Site

EXAMPLE

    Backup-SPSite http://server_name/sites/site_name -Path C:\Backup\site_name.bak
This example backs up a site collection at http://server_name/sites/site_name to the C:\Backup\site_name.bak file.

EXAMPLE

    Get-SPSiteAdministration http://server_name/sites/site_name | Backup-SPSite -Path C:\Backup\site_name.bak
This example backs up a site collection at http://server_name/sites/site_name to the C:\Backup\site_name.bak file. Same result as Example 1, but a different way of performing the operation.

EXAMPLE

    Backup-SPSite http://server_name/sites/site_name -Path C:\Backup\site_name.bak -UseSqlSnapshot
This example backs up a site collection using database snapshots to ensure backup integrity.

Build JSON Hierarchy from Structured Data

After a troublesome fight i almost figured how to convert a flat json file to a Hierarchical one.
  list = [
    {
      id: 1,
      title: 'home',
      parent: null
    },
    {
      id: 2,
      title: 'about',
      parent: null
    },
    {
      id: 3,
      title: 'team',
      parent: 2
    },
    {
      id: 4,
      title: 'company',
      parent: 2
    }
  ]

  function treeify(list, idAttr, parentAttr, childrenAttr) {
      if (!idAttr) idAttr = 'id';
      if (!parentAttr) parentAttr = 'parent';
      if (!childrenAttr) childrenAttr = 'children';
      var treeList = [];
      var lookup = {};
      list.forEach(function(obj) {
          lookup[obj[idAttr]] = obj;
          obj[childrenAttr] = [];
      });
      list.forEach(function(obj) {
          if (obj[parentAttr] != null) {
              lookup[obj[parentAttr]][childrenAttr].push(obj);
          } else {
              treeList.push(obj);
          }
      });
      return treeList;
  };

  console.log(JSON.stringify(treeify(list)));

Sunday 27 September 2015

CSOM vs JSOM vs SSOM vs REST

Sharepoint 2013

Model Types:

  • CSOM Client-side object model. C# (or Visual Basic) only
  • JSOM JavaScript object model. JavaScript only.
    • SP.ClientContext.get_current() for normal use. new SP.ClientContext('url...') for specific SPSite. Note this works cross-SPSite in 2013.
  • SSOM Server-side object model.
  • REST REST web technologies and standard Open Data Protocol (OData) syntax.
    • Either JS (JavaScript) or C# (or Visual Basic)

Technologies table:

CSOM JSOM SSOM REST JS REST C#
JavaScript
C#
From browser
From server
OAuth2
S2S

Hosting table:

CSOM JSOM SSOM REST JS REST C#
SharePoint hosted
Autohosted
Provider hosted
Sandboxed solution (Limited)
Farm solution

Fix for SharePoint 2010 scrolling problems

Scrolling did not work when visiting the site. I was able to identify that the source of these scrolling issues was due to the manner in which the static placement of the SharePoint style was implemented.

The Solution

The solution is simple just add following style to page
    body.v4master { overflow:auto; }

ASANA type task management in sharepoint using Angularjs

Hi, i have created new app in sharepoint. ASANA type Task Management System




Download

Friday 18 September 2015

Wednesday 16 September 2015

Differences between hosting options for SharePoint apps

When we create a new app in Visual Studio, we are given the option to select an hosting model:

So, a quick introduction of the different hosting options. It is really based on your requirements which one you should / need to choose.

SharePoint-hosted App

Start with the simplest option: SharePoint-hosted apps, or apps where all components are hosted on either an on-premises or Office 365 SharePoint farm. SharePoint-hosted apps are installed on a SharePoint 2013 website, called the host web. They have their resources hosted on an isolated subsite of a host web, called the app web. It’s important to know the difference between host webs and app webs.
Get these benefits But consider this
Reuse common SharePoint items, like lists and Web Parts. You can use only JavaScript in the add-in—you can’t use any server-side code.
Relatively easy to create and deploy, so they are good for small team productivity add-ins and business process automation, with lower complexity business rules. Your add-in has only the authorization privileges of the signed-in user.

Provider-hosted App

Provider-hosted apps for SharePoint include components that are deployed and hosted outside the SharePoint farm. They are installed to the host web, but their remote components are hosted on another server.
Get these benefits But consider this
Host the add-in on Microsoft Azure or any remote web platform, including non-Microsoft platforms. You are responsible for creating the installation, upgrade, and uninstallation logic of the remote components.
Use one of the SharePoint client object models, the JavaScript cross-domain library, or the SharePoint 2013 REST/OData-based web service to interact with SharePoint. Each way of interacting with SharePoint has corresponding options for approaches to data access.
Gain authorization to SharePoint data using one of the three authorization systems. You need to decide between OAuth and the cross-domain library to authorize your add-in’s access to SharePoint.
Deciding on a hosting pattern. You can use the following table to help sort out which hosting pattern best fits your needs.
Your requirements Recommended Hosting pattern Example
Work with and provision new SharePoint entities exclusively SharePoint-hosted An add-in that includes a people picker control and that stores information about SharePoint users in a SharePoint list
Use existing SharePoint entities and interact with external (non-SharePoint) web services Provider-hosted An add-in that gets customer addresses from an existing SharePoint list in the host web and uses a mapping service in a web application to display their locations
Provision new SharePoint entities and interact with external web services Combined SharePoint-hosted and provider-hosted A mapping add-in that provisions a SharePoint list on the appweb so that it can store latitude and longitude coordinates for addresses that are supplied by the user or pulled from an existing SharePoint list

Tuesday 15 September 2015

App Management Shared Service Proxy is Not Installed -- Error --

In this article you will see how to resolve the issue "Error: App Management Shared Service Proxy is not installed" in SharePoint 2013.

Reason

This is because the App Management Service application is not created or the App Management Service is not running or the App Management Service Proxy is not added to the default proxy group.

Solution 1

  1. Open "Central Administration".
  2. Click on "Application Management" in the quick launch bar.
  3. Click on "Manage Service Applications" available under the Service Applications section.
  4. Check whether the App Management Service application is created, if not then create the App Management Service application.



  5. Click on "Application Management" in the quick launch bar.
  6. Click on "Configure service application associations" available under the Service Applications section.
  7. Check whether the App Management Service proxy is added to the default proxy group, if not then add it to the default proxy group.
  8. Click on "Application Management" in the quick launch bar.
  9. Click on "Manage services on server" available under the Service Applications section.
  10. Check whether the App Management Service is started, if not then start the service.

Solution 2 : Powershell

  1. Launch SharePoint 2013 "Management Shell"
  2. Get the Farm account
    $account = Get-SPManagedAccount FarmAccount
  3. Create a new application pool using this account
    $appPoolAppSvc = New-SPServiceApplicationPool -Name AppServiceAppPool -Account $account
  4. Create the "App management" service application, using this application pool
    $appAppSvc = New-SPAppManagementServiceApplication -ApplicationPool $appPoolAppSvc -Name AppServiceApp -DatabaseName NomDeLaBDD
  5. Create a proxy for the service application
    $proxyAppSvc = New-SPAppManagementServiceApplicationProxy -ServiceApplication $appAppSvc
  6. Start the "App Management Service" service
    Get-SPServiceInstance | where-object {$_.TypeName -eq "App Management Service"}
    (Get-SPServiceInstance | where-object {$_.TypeName -eq "App Management Service"}).Provision()
    Get-SPServiceInstance | where-object {$_.TypeName -eq "App Management Service"}

Monday 14 September 2015

App Part vs Web Part

App Part Web Part
Environment An App webpart can run outside the SharePoint environment Web Part has to run under the SharePoint premises.
Deploy An App webpart can be deployed to the Cloud premises Web part has to be deployed in the OnPremises server.
Crashes If an App web part crashes, it won't significantly impact the SharePoint farm Whereas, in case of the webpart, it does affect the farm.

Friday 11 September 2015

Sharepoint 2013 Vs Sharepoint 2010

SharePoint 2013 SharePoint 2010
What is it A new version of Microsoft famous Collaboration portal called SharePoint. The version adds few new exciting features such as Social Feed,SharePoint Apps and cross-site publishing. It is a previous of SharePoint that was released in year 2010.
Development Changes In SharePoint 2013 Microsoft Introduced a new Cloud App Model for designing Apps for SharePoint. Apps for SharePoint are self-contained pieces of functionality that extend the capabilities of a SharePoint website. You can use HTML, CSS, JavaScript and protocols like the Open Data protocol (OData), and OAuth to communicate with SharePoint using Apps

No more Sandbox solutions. SharePoint 2013 sandboxed solutions are deprecated. So all we got is the New App model and the Old SharePoint Farm solutions. check out
SharePoint 2010 Introduced Sandbox solutions to help developers deploy code that did not effect the whole farm.

In SharePoint 2010 you could use Server Object model and Client Object model (.Net Managed, ECMASCRIPT and silverlight) to extract data from SharePoint.
Social and Collaboration Microsoft in SharePoint 2013 Introduced new Social capabilities for better collaboration in the company.New Features added are
  • Interactive feed
  • Community Site
  • Follow people
  • Follow Sites
SharePoint 2010 had very few social capabilities.
  • My sites
  • Tags and Tag profile pages
  • Notes
Search SharePoint 2013 includes several enhancements, custom content processing with the Content Enrichment web service, and a new framework for presenting search result types. Some of the features added are
  • Consolidated Search Results
  • Rich Results Framework
  • keyword query language (KQL) enhancements
SharePoint 2010 had Introduced Integrated FAST search as an Enterprise search. In addition to this build-in SharePoint search is still widely used in companies.
Enterprise Content Management (ECM) SharePoint 2013 added some of the best capabilities of an ECM software. The newly added stuff is
  • Design Manager
  • Managed Navigation
  • Cross-site Publishing
  • EDiscovery
SharePoint 2010 on the other hand had Introduced Managed metadata and taxonomy as a part of new ECM benefits for SP 2010. This version did not had Managed Navigation and Cross-site Publishing. SharePoint designer was a primary tool to modify Master pages instead of the new Design Manager.