Merge pull request #461 from warrenbuckley/NG-Documentation

NG Documentation improvements
This commit is contained in:
Shannon Deminick
2014-08-28 17:45:51 +10:00
3 changed files with 132 additions and 11 deletions

3
.gitignore vendored
View File

@@ -117,3 +117,6 @@ build/ApiDocs/*
build/ApiDocs/Output/*
src/Umbraco.Web.UI.Client/bower_components/*
/src/Umbraco.Web.UI/Umbraco/preview
#Ignore Rule for output of generated documentation files from Grunt docserve
src/Umbraco.Web.UI.Client/docs/api

View File

@@ -4,6 +4,7 @@ module.exports = function (grunt) {
// Default task.
grunt.registerTask('default', ['jshint:dev','build','karma:unit']);
grunt.registerTask('dev', ['jshint:dev', 'build-dev', 'webserver', 'open:dev', 'watch']);
grunt.registerTask('docserve', ['docs:api', 'connect:docserver', 'open:docs', 'watch:docs']);
grunt.registerTask('vs', ['jshint:dev', 'build-dev', 'watch']);
//TODO: Too much watching, this brings windows to it's knees when in dev mode
@@ -75,12 +76,31 @@ module.exports = function (grunt) {
}
}
},
testserver: {}
testserver: {},
docserver: {
options: {
port: 8880,
hostname: '0.0.0.0',
base: './docs/api',
middleware: function(connect, options){
return [
//uncomment to enable CSP
// util.csp(),
//util.rewrite(),
connect.static(options.base),
connect.directory(options.base)
];
}
}
},
},
open : {
dev : {
path: 'http://localhost:9990/belle/'
},
docs : {
path: 'http://localhost:8880/index.html'
}
},
@@ -357,6 +377,11 @@ module.exports = function (grunt) {
packages: {
files: 'src/packages/**/*.*',
tasks: ['watch-packages', 'timestamp'],
},
docs: {
files: ['src/**/*.js', 'src/*.js'],
tasks: ['docs:api'],
}
},

View File

@@ -1,14 +1,38 @@
/**
* @ngdoc service
* @name umbraco.resources.authResource
* @description Loads in data for authentication
**/
* @ngdoc service
* @name umbraco.resources.authResource
* @description
* This Resource perfomrs actions to common authentication tasks for the Umbraco backoffice user
*
* @requires $q
* @requires $http
* @requires umbRequestHelper
* @requires angularHelper
*/
function authResource($q, $http, umbRequestHelper, angularHelper) {
return {
//currentUser: currentUser,
/** Logs the user in if the credentials are good */
/**
* @ngdoc method
* @name umbraco.resources.authResource#performLogin
* @methodOf umbraco.resources.authResource
*
* @description
* Logs the Umbraco backoffice user in if the credentials are good
*
* ##usage
* <pre>
* authResource.performLogin(login, password)
* .then(function(data) {
* //Do stuff for login...
* });
* </pre>
* @param {string} login Username of backoffice user
* @param {string} password Password of backoffice user
* @returns {Promise} resourcePromise object
*
*/
performLogin: function (username, password) {
if (!username || !password) {
@@ -28,6 +52,24 @@ function authResource($q, $http, umbRequestHelper, angularHelper) {
'Login failed for user ' + username);
},
/**
* @ngdoc method
* @name umbraco.resources.authResource#performLogout
* @methodOf umbraco.resources.authResource
*
* @description
* Logs out the Umbraco backoffice user
*
* ##usage
* <pre>
* authResource.performLogout()
* .then(function(data) {
* //Do stuff for logging out...
* });
* </pre>
* @returns {Promise} resourcePromise object
*
*/
performLogout: function() {
return umbRequestHelper.resourcePromise(
$http.post(
@@ -36,7 +78,24 @@ function authResource($q, $http, umbRequestHelper, angularHelper) {
"PostLogout")));
},
/** Sends a request to the server to get the current user details, will return a 401 if the user is not logged in */
/**
* @ngdoc method
* @name umbraco.resources.authResource#getCurrentUser
* @methodOf umbraco.resources.authResource
*
* @description
* Sends a request to the server to get the current user details, will return a 401 if the user is not logged in
*
* ##usage
* <pre>
* authResource.getCurrentUser()
* .then(function(data) {
* //Do stuff for fetching the current logged in Umbraco backoffice user
* });
* </pre>
* @returns {Promise} resourcePromise object
*
*/
getCurrentUser: function () {
return umbRequestHelper.resourcePromise(
@@ -47,7 +106,24 @@ function authResource($q, $http, umbRequestHelper, angularHelper) {
'Server call failed for getting current user');
},
/** Checks if the user is logged in or not - does not return 401 or 403 */
/**
* @ngdoc method
* @name umbraco.resources.authResource#isAuthenticated
* @methodOf umbraco.resources.authResource
*
* @description
* Checks if the user is logged in or not - does not return 401 or 403
*
* ##usage
* <pre>
* authResource.isAuthenticated()
* .then(function(data) {
* //Do stuff to check if user is authenticated
* });
* </pre>
* @returns {Promise} resourcePromise object
*
*/
isAuthenticated: function () {
return umbRequestHelper.resourcePromise(
@@ -72,8 +148,25 @@ function authResource($q, $http, umbRequestHelper, angularHelper) {
}
});
},
/** Gets the user's remaining seconds before their login times out */
/**
* @ngdoc method
* @name umbraco.resources.authResource#getRemainingTimeoutSeconds
* @methodOf umbraco.resources.authResource
*
* @description
* Gets the user's remaining seconds before their login times out
*
* ##usage
* <pre>
* authResource.getRemainingTimeoutSeconds()
* .then(function(data) {
* //Number of seconds is returned
* });
* </pre>
* @returns {Promise} resourcePromise object
*
*/
getRemainingTimeoutSeconds: function () {
return umbRequestHelper.resourcePromise(