Skip to content

Commit

Permalink
0.62.0
Browse files Browse the repository at this point in the history
  • Loading branch information
coni2k committed Jul 8, 2016
1 parent d7b9b0b commit d8c8073
Show file tree
Hide file tree
Showing 60 changed files with 2,958 additions and 2,536 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

**0.62.0**

* Typescript was introduced
* Resharper was installed
* Comments signature update - coni2k

**0.61.3**
Expand Down Expand Up @@ -369,7 +371,7 @@ Now both cases call updateAnonymousChanges method which handles this case correc

**0.40.0**

* Email confirmation has implemented
* Email confirmation was implemented
* Survey.docx: A simple survey about the content.
* logger.js minor improvements
* forEach, some, filter functions instead of 'for' loops for arrays
Expand Down
3,396 changes: 1,774 additions & 1,622 deletions ngClient/_system/ts/app/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ngClient/_system/ts/app/app.js.map

Large diffs are not rendered by default.

102 changes: 42 additions & 60 deletions ngClient/_system/ts/app/config/authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,56 @@
* Authorization interceptors for angular & OData
*/

module Main {
module Main.Config {
'use strict';

var angularInterceptorId = 'AngularInterceptor';

export class AuthorizationConfig {

static $inject = [
'$httpProvider'
];
angular.module('main')
.config(['$httpProvider', authorizationConfig])
.run(['logger', '$window', authorizationRun])
.factory(angularInterceptorId, ['logger', '$q', '$window', angularInterceptor]);

constructor($httpProvider: ng.IHttpProvider) {
$httpProvider.interceptors.push(angularInterceptorId);
}
function authorizationConfig($httpProvider: ng.IHttpProvider) {
$httpProvider.interceptors.push(angularInterceptorId);
}

export class AuthorizationRun {

static $inject = ['logger', '$window'];

constructor(logger, $window) {

// Logger
logger = logger.forSource('authorizationRun');

// OData interceptor
var oldClient = $window.OData.defaultHttpClient;
var newClient = {
request: function (request, success, error) {
request.headers = request.headers || {};
var token = angular.fromJson($window.localStorage.getItem('token'));
request.headers.Authorization = token !== null ? 'Bearer ' + token.access_token : '';
return oldClient.request(request, success, error);
}
};
$window.OData.defaultHttpClient = newClient;
}
function authorizationRun(logger, $window) {

// Logger
logger = logger.forSource('authorizationRun');

// OData interceptor
var oldClient = $window.OData.defaultHttpClient;
var newClient = {
request(request, success, error) {
request.headers = request.headers || {};
var token = angular.fromJson($window.localStorage.getItem('token'));
request.headers.Authorization = token !== null ? 'Bearer ' + token.access_token : '';
return oldClient.request(request, success, error);
}
};
$window.OData.defaultHttpClient = newClient;
}

export class AngularInterceptor {

static $inject = ['logger', '$q', '$window'];

constructor(logger, $q, $window) {

// Logger
logger = logger.forSource(angularInterceptorId);

return {
request: function (config) {
config.headers = config.headers || {};
var token = angular.fromJson($window.localStorage.getItem('token'));
config.headers.Authorization = token !== null ? 'Bearer ' + token.access_token : '';
return config;
},
response: function (response) {
if (response.status === 401) {
// handle the case where the user is not authenticated
}
return response || $q.when(response);
function angularInterceptor(logger, $q, $window) {

// Logger
logger = logger.forSource(angularInterceptorId);

return {
request(config) {
config.headers = config.headers || {};
var token = angular.fromJson($window.localStorage.getItem('token'));
config.headers.Authorization = token !== null ? 'Bearer ' + token.access_token : '';
return config;
},
response(response) {
if (response.status === 401) {
// handle the case where the user is not authenticated
}
};
}
return response || $q.when(response);
}
};
}

// Register
angular.module('main')
.config(AuthorizationConfig)
.run(AuthorizationRun)
.factory(angularInterceptorId, AngularInterceptor);
}
}
24 changes: 8 additions & 16 deletions ngClient/_system/ts/app/config/breeze.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module Main {
module Main.Config {
'use strict';

angular.module('main')
.config(['breezeProvider', breezeConfig])
.config(['zDirectivesConfigProvider', breezeConfigDirective]);
.config(['zDirectivesConfigProvider', breezeDirectiveConfig]);

function breezeConfig(breezeProvider: any) {

breeze.config.initializeAdapterInstance('uriBuilder', 'odata');

// Use Web API OData to query and save
Expand All @@ -19,13 +18,8 @@ module Main {
function getRoutePrefix_Microsoft_AspNet_WebApi_OData_5_3_x(dataService: any) {

// Copied from breeze.debug and modified for Web API OData v.5.3.1.
var parser = null;
//if (typeof document === 'object') { // browser
parser = document.createElement('a');
var parser = document.createElement('a');
parser.href = dataService.serviceName;
//} else { // node
// parser = url.parse(dataService.serviceName);
//}

// THE CHANGE FOR 5.3.1: Add '/' prefix to pathname
var prefix = parser.pathname;
Expand All @@ -40,13 +34,11 @@ module Main {
}
}

// Configure the Breeze Validation Directive for bootstrap
function breezeConfigDirective(config: any) {

// Custom template with warning icon before the error message
config.zRequiredTemplate = '';
config.zValidateTemplate = '<span class="help-block">%error%!</span>';
function breezeDirectiveConfig(config: any) {

// Custom template with warning icon before the error message
config.zRequiredTemplate = '';
config.zValidateTemplate = '<span class="help-block">%error%!</span>';

}

}
43 changes: 18 additions & 25 deletions ngClient/_system/ts/app/config/exceptionHandlerExtension.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
(function () {
module Main.Config {
'use strict';

var factoryId = 'exceptionHandlerExtension';
angular.module('main')
.config(['$provide', extendHandler]);

function extendHandler($provide) {
function extendHandler($provide: any) {
$provide.decorator('$exceptionHandler', ['logger', 'serviceAppUrl', '$delegate', '$injector', '$window', exceptionHandlerExtension]);
}

function exceptionHandlerExtension(logger, serviceAppUrl, $delegate, $injector, $window) {
logger = logger.forSource(factoryId);
function exceptionHandlerExtension(logger: any, serviceAppUrl: any, $delegate: any, $injector: any, $window: any) {
logger = logger.forSource('exceptionHandlerExtension');

var exceptionUrl = serviceAppUrl + '/api/Exception/Record';

return function (exception, cause) {
return (exception, cause) => {

// No need to call the base, will be logged here
// $delegate(exception, cause);
Expand All @@ -26,7 +25,7 @@
}

getSourceMappedStackTrace(exception)
.then(function (sourceMappedStack) {
.then(sourceMappedStack => {

// Send the exception to the server
var exceptionModel = {
Expand All @@ -40,25 +39,25 @@
$http.post(exceptionUrl, exceptionModel);

// Rethrow the exception
setTimeout(function () {
setTimeout(() => {
throw exception;
});
});
};

function getSourceMappedStackTrace(exception) {
function getSourceMappedStackTrace(exception: any) {
var $q = $injector.get('$q'),
$http = $injector.get('$http'),
SMConsumer = $window.sourceMap.SourceMapConsumer,
cache = {};

if (exception.stack) { // not all browsers support stack traces
return $q.all($.map(exception.stack.split(/\n/), function (stackLine) {
return $q.all($.map(exception.stack.split(/\n/), stackLine => {
var match = stackLine.match(/^(.+)(http.+):(\d+):(\d+)/);
if (match) {
var prefix = match[1], url = match[2], line = match[3], col = match[4];

return getMapForScript(url).then(function (map) {
return getMapForScript(url).then(map => {

var pos = map.originalPositionFor({
line: parseInt(line, 10),
Expand All @@ -69,34 +68,28 @@
mangledName = (mangledName && mangledName[2]) || '';

return ' at ' + (pos.name ? pos.name : mangledName) + ' ' +
$window.location.origin + pos.source + ':' + pos.line + ':' +
pos.column;
}, function () {
return stackLine;
});
$window.location.origin + pos.source + ':' + pos.line + ':' +
pos.column;
}, () => stackLine);
} else {
return $q.when(stackLine);
}
})).then(function (lines) {
return lines.join('\n');
});
})).then(lines => lines.join('\n'));
} else {
return $q.when('');
}

// Retrieve a SourceMap object for a minified script URL
function getMapForScript(url) {
function getMapForScript(url: any) {
if (cache[url]) {
return cache[url];
} else {
var promise = $http.get(url).then(function (response) {
var promise = $http.get(url).then(response => {
var m = response.data.match(/\/\/# sourceMappingURL=(.+\.map)/);
if (m) {
var path = url.match(/^(.+)\/[^/]+$/);
path = path && path[1];
return $http.get(path + '/' + m[1]).then(function (response) {
return new SMConsumer(response.data);
});
return $http.get(path + '/' + m[1]).then(response => new SMConsumer(response.data));
} else {
return $q.reject();
}
Expand All @@ -107,4 +100,4 @@
}
}
}
})();
}
10 changes: 5 additions & 5 deletions ngClient/_system/ts/app/config/googleAnalytics.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(function () {
module Main.Config {
'use strict';

angular.module('main')
.config(['AnalyticsProvider', 'analyticsTrackingCode', 'analyticsDomainName', analyticsConfig]);

angular.module('main').run(['Analytics', function (Analytics) { }]);
angular.module('main').run(['Analytics', analytics => { }]);

function analyticsConfig(AnalyticsProvider, analyticsTrackingCode, analyticsDomainName) {
AnalyticsProvider.setAccount(analyticsTrackingCode)
function analyticsConfig(analyticsProvider: any, analyticsTrackingCode: any, analyticsDomainName: any) {
analyticsProvider.setAccount(analyticsTrackingCode)
.setDomainName(analyticsDomainName)
.ignoreFirstPageLoad(true);
}
})();
}
Loading

0 comments on commit d8c8073

Please sign in to comment.