mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 05:19:39 +02:00
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
39 lines
1.7 KiB
JavaScript
39 lines
1.7 KiB
JavaScript
import $ from 'jquery';
|
|
|
|
/* @ngInject */
|
|
export function onStartupAngular($rootScope, $state, cfpLoadingBar, $transitions, HttpRequestHelper) {
|
|
$rootScope.$state = $state;
|
|
|
|
// Workaround to prevent the loading bar from going backward
|
|
// https://github.com/chieffancypants/angular-loading-bar/issues/273
|
|
const originalSet = cfpLoadingBar.set;
|
|
cfpLoadingBar.set = function overrideSet(n) {
|
|
if (n > cfpLoadingBar.status()) {
|
|
originalSet.apply(cfpLoadingBar, arguments);
|
|
}
|
|
};
|
|
|
|
$transitions.onBefore({}, () => {
|
|
HttpRequestHelper.resetAgentHeaders();
|
|
});
|
|
|
|
// EE-6751: screens not loading when switching quickly between side menu options
|
|
// Known bug of @uirouter/angularjs
|
|
// Fix found at https://github.com/angular-ui/ui-router/issues/3652#issuecomment-574499009
|
|
// This hook is cleaning the internal viewConfigs list, removing leftover data unrelated to the current transition
|
|
$transitions.onStart({}, (transition) => {
|
|
const toList = transition.treeChanges().to.map((t) => t.state.name);
|
|
const toConfigs = transition.router.viewService._viewConfigs.filter((vc) => toList.includes(vc.viewDecl.$context.name));
|
|
transition.router.viewService._viewConfigs = toConfigs;
|
|
});
|
|
|
|
$(document).ajaxSend((event, jqXhr, jqOpts) => {
|
|
const type = jqOpts.type === 'POST' || jqOpts.type === 'PUT' || jqOpts.type === 'PATCH';
|
|
const hasNoContentType = jqOpts.contentType !== 'application/json' && jqOpts.headers && !jqOpts.headers['Content-Type'];
|
|
if (type && hasNoContentType) {
|
|
jqXhr.setRequestHeader('Content-Type', 'application/json');
|
|
}
|
|
const csrfCookie = window.cookieStore.get('_gorilla_csrf');
|
|
jqXhr.setRequestHeader('X-CSRF-Token', csrfCookie);
|
|
});
|
|
}
|