Skip to content

Commit 052285f

Browse files
committed
Updated abp bower package.
1 parent 883ce33 commit 052285f

File tree

8 files changed

+166
-41
lines changed

8 files changed

+166
-41
lines changed

src/AbpCompanyName.AbpProjectName.Web/bower.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
"jquery-validation": "^1.15.0",
1515
"blockUI": "jquery.blockUI#*",
1616
"spin.js": "^2.3.2"
17+
},
18+
"resolutions": {
19+
"abp-web-resources": "^0.11.1"
1720
}
1821
}

src/AbpCompanyName.AbpProjectName.Web/wwwroot/lib/abp-web-resources/.bower.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"authors": [
55
"Halil İbrahim Kalkan"
66
],
7-
"version": "0.10.3",
7+
"version": "0.11.1",
88
"description": "Script and style resources for ASP.NET Boilerplate based web projects.",
99
"main": "Abp/Framework/scripts/abp.js",
1010
"moduleType": [],
@@ -25,13 +25,14 @@
2525
".nuget",
2626
"packages"
2727
],
28-
"_release": "0.10.3",
28+
"_release": "0.11.1",
2929
"_resolution": {
3030
"type": "version",
31-
"tag": "v0.10.3",
32-
"commit": "756cbf5522a25e09a3604edbaf3aec7e8d7e0d21"
31+
"tag": "v0.11.1",
32+
"commit": "a7d6729adf20dbaada1b271f73c4c6e97ab52cc0"
3333
},
3434
"_source": "https://github.com/aspnetboilerplate/bower-abp-resources.git",
35-
"_target": "^0.10.0",
36-
"_originalSource": "abp-web-resources"
35+
"_target": "^0.11.1",
36+
"_originalSource": "abp-web-resources",
37+
"_direct": true
3738
}

src/AbpCompanyName.AbpProjectName.Web/wwwroot/lib/abp-web-resources/Abp/Framework/scripts/abp.js

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@
504504
var fix = search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
505505
return str.replace(new RegExp(fix, 'g'), replacement);
506506
};
507-
507+
508508
/* Formats a string just like string.format in C#.
509509
* Example:
510510
* abp.utils.formatString('Hello {0}','Tuana') = 'Hello Tuana'
@@ -580,6 +580,78 @@
580580
return !!(obj && obj.constructor && obj.call && obj.apply);
581581
};
582582

583+
/**
584+
* parameterInfos should be an array of { name, value } objects
585+
* where name is query string parameter name and value is it's value.
586+
* includeQuestionMark is true by default.
587+
*/
588+
abp.utils.buildQueryString = function (parameterInfos, includeQuestionMark) {
589+
if (includeQuestionMark === undefined) {
590+
includeQuestionMark = true;
591+
}
592+
593+
var qs = '';
594+
595+
for (var i = 0; i < parameterInfos.length; ++i) {
596+
var parameterInfo = parameterInfos[i];
597+
if (parameterInfo.value === undefined) {
598+
continue;
599+
}
600+
601+
if (!qs.length) {
602+
if (includeQuestionMark) {
603+
qs = qs + '?';
604+
}
605+
} else {
606+
qs = qs + '&';
607+
}
608+
609+
qs = qs + parameterInfo.name + '=' + escape(parameterInfo.value);
610+
}
611+
612+
return qs;
613+
}
614+
615+
/**
616+
* Sets a cookie value for given key.
617+
* @param {string} key
618+
* @param {string} value
619+
* @param {Date} expireDate Optional expire date (default: 30 days).
620+
*/
621+
abp.utils.setCookieValue = function (key, value, expireDate) {
622+
if (!expireDate) {
623+
expireDate = new Date();
624+
expireDate.setDate(expireDate.getDate() + 30);
625+
}
626+
627+
document.cookie = encodeURIComponent(key) + '=' + encodeURIComponent(value) + "; expires=" + expireDate.toUTCString();
628+
};
629+
630+
/**
631+
* Gets a cookie with given key.
632+
* @param {string} key
633+
* @returns {string} Cookie value
634+
*/
635+
abp.utils.getCookieValue = function (key) {
636+
var equalities = document.cookie.split('; ');
637+
for (var i = 0; i < equalities.length; i++) {
638+
if (!equalities[i]) {
639+
continue;
640+
}
641+
642+
var splitted = equalities[i].split('=');
643+
if (splitted.length != 2) {
644+
continue;
645+
}
646+
647+
if (decodeURIComponent(splitted[0]) === key) {
648+
return decodeURIComponent(splitted[1] || '');
649+
}
650+
}
651+
652+
return null;
653+
};
654+
583655
/* TIMING *****************************************/
584656
abp.timing = abp.timing || {};
585657

@@ -697,4 +769,15 @@
697769

698770
abp.clock.provider = abp.timing.unspecifiedClockProvider;
699771

700-
})(jQuery);
772+
/* SECURITY ***************************************/
773+
abp.security = abp.security || {};
774+
abp.security.antiForgery = abp.security.antiForgery || {};
775+
776+
abp.security.antiForgery.tokenCookieName = 'XSRF-TOKEN';
777+
abp.security.antiForgery.tokenHeaderName = 'X-XSRF-TOKEN';
778+
779+
abp.security.antiForgery.getToken = function () {
780+
return abp.utils.getCookieValue(abp.security.antiForgery.tokenCookieName);
781+
};
782+
783+
})(jQuery);

src/AbpCompanyName.AbpProjectName.Web/wwwroot/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.jquery.js

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
details: 'You are not allowed to perform this operation.'
5858
},
5959

60+
defaultError404: {
61+
message: 'Resource not found!',
62+
details: 'The resource requested could not found on the server.'
63+
},
64+
6065
logError: function (error) {
6166
abp.log.error(error);
6267
},
@@ -78,19 +83,24 @@
7883
},
7984

8085
handleNonAbpErrorResponse: function (jqXHR, userOptions, $dfd) {
81-
switch (jqXHR.status) {
82-
case 401:
83-
abp.ajax.handleUnAuthorizedRequest(
84-
abp.ajax.showError(abp.ajax.defaultError401),
85-
abp.appPath
86-
);
87-
break;
88-
case 403:
89-
abp.ajax.showError(abp.ajax.defaultError403);
90-
break;
91-
default:
92-
abp.ajax.showError(abp.ajax.defaultError);
93-
break;
86+
if (userOptions.abpHandleError !== false) {
87+
switch (jqXHR.status) {
88+
case 401:
89+
abp.ajax.handleUnAuthorizedRequest(
90+
abp.ajax.showError(abp.ajax.defaultError401),
91+
abp.appPath
92+
);
93+
break;
94+
case 403:
95+
abp.ajax.showError(abp.ajax.defaultError403);
96+
break;
97+
case 404:
98+
abp.ajax.showError(abp.ajax.defaultError404);
99+
break;
100+
default:
101+
abp.ajax.showError(abp.ajax.defaultError);
102+
break;
103+
}
94104
}
95105

96106
$dfd.reject.apply(this, arguments);
@@ -120,7 +130,9 @@
120130
var messagePromise = null;
121131

122132
if (data.error) {
123-
messagePromise = abp.ajax.showError(data.error);
133+
if (userOptions.abpHandleError !== false) {
134+
messagePromise = abp.ajax.showError(data.error);
135+
}
124136
} else {
125137
data.error = abp.ajax.defaultError;
126138
}
@@ -130,7 +142,7 @@
130142
$dfd && $dfd.reject(data.error, jqXHR);
131143
userOptions.error && userOptions.error(data.error, jqXHR);
132144

133-
if (jqXHR.status == 401) {
145+
if (jqXHR.status === 401 && userOptions.abpHandleError !== false) {
134146
abp.ajax.handleUnAuthorizedRequest(messagePromise, data.targetUrl);
135147
}
136148
} else { //not wrapped result
@@ -161,9 +173,19 @@
161173
abp.ui.clearBusy(options.blockUI);
162174
}
163175
}
176+
},
177+
178+
ajaxSendHandler: function (event, request, settings) {
179+
if (!settings.headers || settings.headers[abp.security.antiForgery.tokenHeaderName] === undefined) {
180+
request.setRequestHeader(abp.security.antiForgery.tokenHeaderName, abp.security.antiForgery.getToken());
181+
}
164182
}
165183
});
166184

185+
$(document).ajaxSend(function (event, request, settings) {
186+
return abp.ajax.ajaxSendHandler(event, request, settings);
187+
});
188+
167189
/* JQUERY PLUGIN ENHANCEMENTS ********************************************/
168190

169191
/* jQuery Form Plugin
@@ -209,6 +231,8 @@
209231
abp.ajax.defaultError401.details = abp.localization.abpWeb('DefaultErrorDetail401');
210232
abp.ajax.defaultError403.message = abp.localization.abpWeb('DefaultError403');
211233
abp.ajax.defaultError403.details = abp.localization.abpWeb('DefaultErrorDetail403');
234+
abp.ajax.defaultError404.message = abp.localization.abpWeb('DefaultError404');
235+
abp.ajax.defaultError404.details = abp.localization.abpWeb('DefaultErrorDetail404');
212236
});
213237

214238
})(jQuery);

src/AbpCompanyName.AbpProjectName.Web/wwwroot/lib/abp-web-resources/Abp/Framework/scripts/libs/angularjs/abp.ng.js

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
details: 'You are not allowed to perform this operation.'
2323
},
2424

25+
defaultError404: {
26+
message: 'Resource not found!',
27+
details: 'The resource requested could not found on the server.'
28+
},
29+
2530
logError: function (error) {
2631
abp.log.error(error);
2732
},
@@ -43,19 +48,24 @@
4348
},
4449

4550
handleNonAbpErrorResponse: function (response, defer) {
46-
switch (response.status) {
47-
case 401:
48-
abp.ng.http.handleUnAuthorizedRequest(
49-
abp.ng.http.showError(abp.ng.http.defaultError401),
50-
abp.appPath
51-
);
52-
break;
53-
case 403:
54-
abp.ng.http.showError(abp.ajax.defaultError403);
55-
break;
56-
default:
57-
abp.ng.http.showError(abp.ng.http.defaultError);
58-
break;
51+
if (response.config.abpHandleError !== false) {
52+
switch (response.status) {
53+
case 401:
54+
abp.ng.http.handleUnAuthorizedRequest(
55+
abp.ng.http.showError(abp.ng.http.defaultError401),
56+
abp.appPath
57+
);
58+
break;
59+
case 403:
60+
abp.ng.http.showError(abp.ajax.defaultError403);
61+
break;
62+
case 404:
63+
abp.ng.http.showError(abp.ajax.defaultError404);
64+
break;
65+
default:
66+
abp.ng.http.showError(abp.ng.http.defaultError);
67+
break;
68+
}
5969
}
6070

6171
defer.reject(response);
@@ -85,7 +95,9 @@
8595
var messagePromise = null;
8696

8797
if (originalData.error) {
88-
messagePromise = abp.ng.http.showError(originalData.error);
98+
if (response.config.abpHandleError !== false) {
99+
messagePromise = abp.ng.http.showError(originalData.error);
100+
}
89101
} else {
90102
originalData.error = defaultError;
91103
}
@@ -95,7 +107,7 @@
95107
response.data = originalData.error;
96108
defer.reject(response);
97109

98-
if (response.status == 401) {
110+
if (response.status == 401 && response.config.abpHandleError !== false) {
99111
abp.ng.http.handleUnAuthorizedRequest(messagePromise, originalData.targetUrl);
100112
}
101113
} else { //not wrapped result
@@ -163,6 +175,8 @@
163175
abp.ng.http.defaultError401.details = abp.localization.abpWeb('DefaultErrorDetail401');
164176
abp.ng.http.defaultError403.message = abp.localization.abpWeb('DefaultError403');
165177
abp.ng.http.defaultError403.details = abp.localization.abpWeb('DefaultErrorDetail403');
178+
abp.ng.http.defaultError404.message = abp.localization.abpWeb('DefaultError404');
179+
abp.ng.http.defaultError404.details = abp.localization.abpWeb('DefaultErrorDetail404');
166180
});
167181

168182
})((abp || (abp = {})), (angular || undefined));

src/AbpCompanyName.AbpProjectName.Web/wwwroot/lib/abp-web-resources/bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"authors": [
55
"Halil İbrahim Kalkan"
66
],
7-
"version": "v0.10.3",
7+
"version": "v0.11.1",
88
"description": "Script and style resources for ASP.NET Boilerplate based web projects.",
99
"main": "Abp/Framework/scripts/abp.js",
1010
"moduleType": [],

src/AbpCompanyName.AbpProjectName.Web/wwwroot/lib/abp-web-resources/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "abp-web-resources",
3-
"version": "0.10.3",
3+
"version": "0.11.1",
44
"description": "ASP.NET Boilerplate web resources",
55
"main": "Abp/Framework/scripts/abp.js",
66
"dependencies": {},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Abp.Web.Resources" version="0.10.3.0" targetFramework="net452" />
3+
<package id="Abp.Web.Resources" version="0.11.0.2" targetFramework="net452" />
44
</packages>

0 commit comments

Comments
 (0)