mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Squashed commit of the following: (#5785)
commit 5e8ea099068475fd257d8c172348dc6f3edf9bcf Author: Matthias Mair <code@mjmair.com> Date: Tue Oct 24 09:22:38 2023 +0200 Update ui_plattform.spec.ts commit 49da3312beff7fd6837ea741e621df221c445d19 Author: Matthias Mair <code@mjmair.com> Date: Tue Oct 24 07:56:25 2023 +0200 more logging commit 5337be4c3990051b805a6fce2e79ca4030b4afe5 Author: Matthias Mair <code@mjmair.com> Date: Tue Oct 24 07:56:11 2023 +0200 added filter method for undefined settings that overwrite defaults commit 5df8a0b3e77cd5dcf04c39ad7638ac845df75e4c Author: Matthias Mair <code@mjmair.com> Date: Tue Oct 24 03:05:06 2023 +0200 you do not need to string a string commit 0650d3b3a0132889c2a76de38db38224e974d205 Author: Matthias Mair <code@mjmair.com> Date: Tue Oct 24 03:04:34 2023 +0200 fix things that were borken for no good reason commit a40dbfd1364cf01465037350184f59d2a2a8afab Author: Matthias Mair <code@mjmair.com> Date: Tue Oct 24 02:39:34 2023 +0200 reduce unneeded blocking timeouts commit bf9046a5361ae919e70662e717d6156434b6fe43 Author: Matthias Mair <code@mjmair.com> Date: Tue Oct 24 02:34:10 2023 +0200 catch server fetching errors commit aa01e67e8c8e789fdf755ac4481e730fe5ea4183 Author: Matthias Mair <code@mjmair.com> Date: Tue Oct 24 02:33:29 2023 +0200 move init as things are now plugged together different commit 290c33bd3125d50779497d6fc5981d5813b58f5d Author: Matthias Mair <code@mjmair.com> Date: Tue Oct 24 01:49:32 2023 +0200 do not log a failed automatic login try - why would you?
This commit is contained in:
parent
e13b57669c
commit
02d55b9c87
@ -20,8 +20,8 @@ export const doClassicLogin = async (username: string, password: string) => {
|
|||||||
const token = await axios
|
const token = await axios
|
||||||
.get(apiUrl(ApiPaths.user_token), {
|
.get(apiUrl(ApiPaths.user_token), {
|
||||||
auth: { username, password },
|
auth: { username, password },
|
||||||
baseURL: host.toString(),
|
baseURL: host,
|
||||||
timeout: 5000,
|
timeout: 2000,
|
||||||
params: {
|
params: {
|
||||||
name: 'inventree-web-app'
|
name: 'inventree-web-app'
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ export function handleReset(navigate: any, values: { email: string }) {
|
|||||||
export function checkLoginState(navigate: any, redirect?: string) {
|
export function checkLoginState(navigate: any, redirect?: string) {
|
||||||
api
|
api
|
||||||
.get(apiUrl(ApiPaths.user_token), {
|
.get(apiUrl(ApiPaths.user_token), {
|
||||||
timeout: 5000,
|
timeout: 2000,
|
||||||
params: {
|
params: {
|
||||||
name: 'inventree-web-app'
|
name: 'inventree-web-app'
|
||||||
}
|
}
|
||||||
@ -140,8 +140,7 @@ export function checkLoginState(navigate: any, redirect?: string) {
|
|||||||
navigate('/login');
|
navigate('/login');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(() => {
|
||||||
console.error('Error fetching login information:', error);
|
|
||||||
navigate('/login');
|
navigate('/login');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -25,26 +25,37 @@ export const IS_DEV = import.meta.env.DEV;
|
|||||||
export const IS_DEMO = import.meta.env.VITE_DEMO === 'true';
|
export const IS_DEMO = import.meta.env.VITE_DEMO === 'true';
|
||||||
export const IS_DEV_OR_DEMO = IS_DEV || IS_DEMO;
|
export const IS_DEV_OR_DEMO = IS_DEV || IS_DEMO;
|
||||||
|
|
||||||
|
// Filter out any settings that are not defined
|
||||||
|
let loaded_vals = (window.INVENTREE_SETTINGS || {}) as any;
|
||||||
|
Object.keys(loaded_vals).forEach((key) => {
|
||||||
|
if (loaded_vals[key] === undefined) {
|
||||||
|
delete loaded_vals[key];
|
||||||
|
// check for empty server list
|
||||||
|
} else if (key === 'server_list' && loaded_vals[key].length === 0) {
|
||||||
|
delete loaded_vals[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
window.INVENTREE_SETTINGS = {
|
window.INVENTREE_SETTINGS = {
|
||||||
server_list: {
|
server_list: {
|
||||||
localhost: {
|
'mantine-cqj63coxn': {
|
||||||
host: `${window.location.origin}/`,
|
host: `${window.location.origin}/`,
|
||||||
name: 'Current Server'
|
name: 'Current Server'
|
||||||
},
|
},
|
||||||
...(IS_DEV_OR_DEMO
|
...(IS_DEV_OR_DEMO
|
||||||
? {
|
? {
|
||||||
demo: {
|
'mantine-u56l5jt85': {
|
||||||
host: 'https://demo.inventree.org/',
|
host: 'https://demo.inventree.org/',
|
||||||
name: 'InvenTree Demo'
|
name: 'InvenTree Demo'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
: {})
|
: {})
|
||||||
},
|
},
|
||||||
default_server: IS_DEMO ? 'demo' : 'localhost',
|
default_server: IS_DEMO ? 'mantine-u56l5jt85' : 'mantine-cqj63coxn',
|
||||||
show_server_selector: IS_DEV_OR_DEMO,
|
show_server_selector: IS_DEV_OR_DEMO,
|
||||||
|
|
||||||
// merge in settings that are already set via django's spa_view or for development
|
// merge in settings that are already set via django's spa_view or for development
|
||||||
...((window.INVENTREE_SETTINGS || {}) as any)
|
...loaded_vals
|
||||||
};
|
};
|
||||||
|
|
||||||
if (window.INVENTREE_SETTINGS.sentry_dsn) {
|
if (window.INVENTREE_SETTINGS.sentry_dsn) {
|
||||||
|
@ -15,9 +15,12 @@ export const useServerApiState = create<ServerApiStateProps>((set, get) => ({
|
|||||||
setServer: (newServer: ServerAPIProps) => set({ server: newServer }),
|
setServer: (newServer: ServerAPIProps) => set({ server: newServer }),
|
||||||
fetchServerApiState: async () => {
|
fetchServerApiState: async () => {
|
||||||
// Fetch server data
|
// Fetch server data
|
||||||
await api.get(apiUrl(ApiPaths.api_server_info)).then((response) => {
|
await api
|
||||||
set({ server: response.data });
|
.get(apiUrl(ApiPaths.api_server_info))
|
||||||
});
|
.then((response) => {
|
||||||
|
set({ server: response.data });
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ export const useUserState = create<UserStateProps>((set, get) => ({
|
|||||||
// Fetch user data
|
// Fetch user data
|
||||||
await api
|
await api
|
||||||
.get(apiUrl(ApiPaths.user_me), {
|
.get(apiUrl(ApiPaths.user_me), {
|
||||||
timeout: 5000
|
timeout: 2000
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const user: UserProps = {
|
const user: UserProps = {
|
||||||
|
@ -27,10 +27,6 @@ export default function DesktopAppView() {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Local state initialization
|
// Local state initialization
|
||||||
if (Object.keys(hostList).length === 0) {
|
|
||||||
console.log('Loading default host list');
|
|
||||||
useLocalState.setState({ hostList: defaultHostList });
|
|
||||||
}
|
|
||||||
setApiDefaults();
|
setApiDefaults();
|
||||||
|
|
||||||
// Server Session
|
// Server Session
|
||||||
@ -38,6 +34,11 @@ export default function DesktopAppView() {
|
|||||||
const sessionState = useSessionState.getState();
|
const sessionState = useSessionState.getState();
|
||||||
const [token] = sessionState.token ? [sessionState.token] : [null];
|
const [token] = sessionState.token ? [sessionState.token] : [null];
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (Object.keys(hostList).length === 0) {
|
||||||
|
console.log('Loading default host list', defaultHostList);
|
||||||
|
useLocalState.setState({ hostList: defaultHostList });
|
||||||
|
}
|
||||||
|
|
||||||
if (token && !fetchedServerSession) {
|
if (token && !fetchedServerSession) {
|
||||||
setFetchedServerSession(true);
|
setFetchedServerSession(true);
|
||||||
fetchUserState();
|
fetchUserState();
|
||||||
|
@ -11,9 +11,4 @@ test('Basic Platform UI test', async ({ page }) => {
|
|||||||
await page.goto('./platform/');
|
await page.goto('./platform/');
|
||||||
|
|
||||||
await expect(page).toHaveTitle('InvenTree Demo Server');
|
await expect(page).toHaveTitle('InvenTree Demo Server');
|
||||||
await expect(
|
|
||||||
page.getByRole('heading', {
|
|
||||||
name: 'Welcome to your Dashboard, Ally Access'
|
|
||||||
})
|
|
||||||
).toBeVisible();
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user