mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-24 15:26:46 -06:00
764677431f
Following changes done for the framework: - Framework for creating React based dynamic form view out of a pre-defined UI schema. Previously, it was based on Backform/Backbone. - The new framework and components will use MaterialUI as the base. Previously, Bootstrap/Backform/jQuery components were used. - The new code uses JSS instead of CSS since material UI and most modern React libraries also use JSS. In the future, this will allow us to change the theme in real-time without refresh. - 90% code covered by 80-85 new jasmine test cases. - Server group node UI Schema migration to new, with schema test cases. - Server node UI Schema migration to new, with schema test cases. - Database node UI Schema migration to new, with schema test cases. - Few other UI changes. Fixes #6130
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
/////////////////////////////////////////////////////////////
|
|
//
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
//
|
|
// Copyright (C) 2013 - 2021, The pgAdmin Development Team
|
|
// This software is released under the PostgreSQL Licence
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
import pgAdmin from 'sources/pgadmin';
|
|
import gettext from 'sources/gettext';
|
|
import axios from 'axios';
|
|
|
|
/* Get the axios instance to call back end APIs.
|
|
Do not import axios directly, instead use this */
|
|
export default function getApiInstance(headers={}) {
|
|
const api = axios.create({
|
|
headers: {
|
|
'Content-type': 'application/json',
|
|
[pgAdmin.csrf_token_header]: pgAdmin.csrf_token,
|
|
...headers,
|
|
}
|
|
});
|
|
return api;
|
|
}
|
|
|
|
export function parseApiError(error) {
|
|
if (error.response) {
|
|
// The request was made and the server responded with a status code
|
|
// that falls out of the range of 2xx
|
|
if(error.response.headers['content-type'] == 'application/json') {
|
|
return error.response.data.errormsg;
|
|
} else {
|
|
return error.response.statusText;
|
|
}
|
|
} else if (error.request) {
|
|
// The request was made but no response was received
|
|
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
// http.ClientRequest in node.js
|
|
return gettext('Connection to pgAdmin server has been lost');
|
|
} else {
|
|
// Something happened in setting up the request that triggered an Error
|
|
return error.message;
|
|
}
|
|
}
|