mirror of https://github.com/portainer/portainer
Add a global interceptor to catch 'conflict.' API responses.
parent
a2a367725b
commit
f353dc2c41
20
app/app.js
20
app/app.js
|
@ -23,7 +23,7 @@ angular.module('dockerui', [
|
|||
'network',
|
||||
'networks',
|
||||
'volumes'])
|
||||
.config(['$routeProvider', function ($routeProvider) {
|
||||
.config(['$routeProvider', '$httpProvider', function ($routeProvider, $httpProvider) {
|
||||
'use strict';
|
||||
$routeProvider.when('/', {
|
||||
templateUrl: 'app/components/dashboard/dashboard.html',
|
||||
|
@ -67,9 +67,25 @@ angular.module('dockerui', [
|
|||
controller: 'EventsController'
|
||||
});
|
||||
$routeProvider.otherwise({redirectTo: '/'});
|
||||
|
||||
// The Docker API likes to return plaintext errors, this catches them and disp
|
||||
$httpProvider.interceptors.push(function() {
|
||||
return {
|
||||
'response': function(response) {
|
||||
if (typeof(response.data) === 'string' && response.data.startsWith('Conflict.')) {
|
||||
$.gritter.add({
|
||||
title: 'Error',
|
||||
text: response.data,
|
||||
time: 10000
|
||||
});
|
||||
}
|
||||
return response;
|
||||
}
|
||||
};
|
||||
});
|
||||
}])
|
||||
// This is your docker url that the api will use to make requests
|
||||
// You need to set this to the api endpoint without the port i.e. http://192.168.1.9
|
||||
.constant('DOCKER_ENDPOINT', 'dockerapi')
|
||||
.constant('DOCKER_PORT', '') // Docker port, leave as an empty string if no port is requred. If you have a port, prefix it with a ':' i.e. :4243
|
||||
.constant('UI_VERSION', 'v0.9.0-beta');
|
||||
.constant('UI_VERSION', 'v0.9.0-beta');
|
Loading…
Reference in New Issue