2019-03-21 05:46:49 +00:00
|
|
|
import toastr from 'toastr';
|
|
|
|
import { Terminal } from 'xterm';
|
|
|
|
import * as fit from 'xterm/lib/addons/fit/fit';
|
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
angular.module('portainer').config([
|
|
|
|
'$urlRouterProvider',
|
|
|
|
'$httpProvider',
|
|
|
|
'localStorageServiceProvider',
|
|
|
|
'jwtOptionsProvider',
|
|
|
|
'$uibTooltipProvider',
|
|
|
|
'$compileProvider',
|
|
|
|
'cfpLoadingBarProvider',
|
2020-08-06 22:46:25 +00:00
|
|
|
function ($urlRouterProvider, $httpProvider, localStorageServiceProvider, jwtOptionsProvider, $uibTooltipProvider, $compileProvider, cfpLoadingBarProvider) {
|
2017-09-21 08:23:51 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var environment = '@@ENVIRONMENT';
|
|
|
|
if (environment === 'production') {
|
|
|
|
$compileProvider.debugInfoEnabled(false);
|
|
|
|
}
|
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
localStorageServiceProvider.setPrefix('portainer');
|
2017-09-21 08:23:51 +00:00
|
|
|
|
|
|
|
jwtOptionsProvider.config({
|
2020-04-10 21:54:53 +00:00
|
|
|
tokenGetter: [
|
|
|
|
'LocalStorage',
|
|
|
|
function (LocalStorage) {
|
|
|
|
return LocalStorage.getJWT();
|
|
|
|
},
|
|
|
|
],
|
2017-09-21 08:23:51 +00:00
|
|
|
});
|
|
|
|
$httpProvider.interceptors.push('jwtInterceptor');
|
2018-10-28 09:27:06 +00:00
|
|
|
$httpProvider.interceptors.push('EndpointStatusInterceptor');
|
2018-04-25 14:00:29 +00:00
|
|
|
$httpProvider.defaults.headers.post['Content-Type'] = 'application/json';
|
|
|
|
$httpProvider.defaults.headers.put['Content-Type'] = 'application/json';
|
|
|
|
$httpProvider.defaults.headers.patch['Content-Type'] = 'application/json';
|
2017-09-21 08:23:51 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$httpProvider.interceptors.push([
|
|
|
|
'HttpRequestHelper',
|
|
|
|
function (HttpRequestHelper) {
|
|
|
|
return {
|
|
|
|
request: function (config) {
|
|
|
|
if (config.url.indexOf('/docker/') > -1) {
|
|
|
|
config.headers['X-PortainerAgent-Target'] = HttpRequestHelper.portainerAgentTargetHeader();
|
|
|
|
if (HttpRequestHelper.portainerAgentManagerOperation()) {
|
|
|
|
config.headers['X-PortainerAgent-ManagerOperation'] = '1';
|
|
|
|
}
|
2019-01-14 23:10:29 +00:00
|
|
|
}
|
2020-04-10 21:54:53 +00:00
|
|
|
return config;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
]);
|
2018-05-06 07:15:57 +00:00
|
|
|
|
2017-09-21 08:23:51 +00:00
|
|
|
toastr.options.timeOut = 3000;
|
|
|
|
|
2018-03-06 07:40:02 +00:00
|
|
|
Terminal.applyAddon(fit);
|
|
|
|
|
2017-09-21 08:23:51 +00:00
|
|
|
$uibTooltipProvider.setTriggers({
|
2020-04-10 21:54:53 +00:00
|
|
|
mouseenter: 'mouseleave',
|
|
|
|
click: 'click',
|
|
|
|
focus: 'blur',
|
|
|
|
outsideClick: 'outsideClick',
|
2017-09-21 08:23:51 +00:00
|
|
|
});
|
|
|
|
|
2017-11-12 19:27:28 +00:00
|
|
|
cfpLoadingBarProvider.includeSpinner = false;
|
|
|
|
cfpLoadingBarProvider.parentSelector = '#loadingbar-placeholder';
|
2018-10-28 09:27:06 +00:00
|
|
|
cfpLoadingBarProvider.latencyThreshold = 600;
|
2017-11-12 19:27:28 +00:00
|
|
|
|
2017-09-21 08:23:51 +00:00
|
|
|
$urlRouterProvider.otherwise('/auth');
|
2020-04-10 21:54:53 +00:00
|
|
|
},
|
|
|
|
]);
|