-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #5102 display an error message in case we cannot load any angula…
…rjs html template
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
angular.module('piwikApp').factory('http404CheckInterceptor', function($q) { | ||
|
||
function isClientError(rejection) | ||
{ | ||
return rejection.status >= 400 && rejection.status < 408; | ||
} | ||
|
||
return { | ||
|
||
'responseError': function(rejection) { | ||
if (rejection | ||
&& isClientError(rejection) | ||
&& rejection.config | ||
&& rejection.config.url | ||
&& -1 !== rejection.config.url.indexOf('.html') | ||
&& -1 !== rejection.config.url.indexOf('plugins')) { | ||
|
||
var message = 'Please check your server configuration. You may want to whitelist "*.html" files from the "plugins" directory.'; | ||
message += ' The HTTP status code is ' + rejection.status; | ||
|
||
var UI = require('piwik/UI'); | ||
var notification = new UI.Notification(); | ||
notification.show(message, { | ||
title: 'Failed to load HTML file:', | ||
context: 'error', | ||
id: 'Network_HtmlFileLoadingError' | ||
}); | ||
} | ||
|
||
return $q.reject(rejection); | ||
} | ||
}; | ||
}); | ||
|
||
angular.module('piwikApp').config(['$httpProvider',function($httpProvider) { | ||
$httpProvider.interceptors.push('http404CheckInterceptor'); | ||
}]); |