-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
56 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* eslint-disable promise/prefer-await-to-callbacks */ | ||
import baseApi from './apiBase'; | ||
import { fetchLoginInfo } from './loginBase'; | ||
import { store } from '../store'; | ||
|
||
const api = baseApi | ||
.options({ credendials: 'include' }) | ||
.catcher(401, async (error) => { | ||
// User got logged out somehow: refetch login info to update local state and redirect to login page. | ||
// Don't use `getLoginInfo` action to avoid import cycle. | ||
const loginInfo = await fetchLoginInfo(); | ||
store.dispatch({ type: 'SET_LOGIN_INFO', loginInfo }); | ||
throw error; | ||
}); | ||
|
||
export default api; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import wretch from 'wretch'; | ||
import safeJsonAddon from './addons/safeJson'; | ||
|
||
const api = wretch('/mxcube/api/v0.1') | ||
const baseApi = wretch('/mxcube/api/v0.1') | ||
.addon(safeJsonAddon()) | ||
.options({ credendials: 'include' }) | ||
.headers({ Accept: 'application/json' }); | ||
|
||
export default api; | ||
export default baseApi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import api from '.'; | ||
import api from './api'; | ||
|
||
const endpoint = api.url('/beamline'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import api from '.'; | ||
import api from './api'; | ||
|
||
const endpoint = api.url('/detector'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import api from '.'; | ||
import api from './api'; | ||
|
||
const endpoint = api.url('/diffractometer'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import api from '.'; | ||
import api from './api'; | ||
|
||
const endpoint = api.url('/harvester'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import api from '.'; | ||
import api from './api'; | ||
|
||
const endpoint = api.url('/lims'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import api from '.'; | ||
import api from './api'; | ||
|
||
const endpoint = api.url('/log'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Unauthenticated `/login/*` endpoints. | ||
* Separate from authenticated endpoints to avoid import cycle with `api.js`. | ||
*/ | ||
import baseApi from './apiBase'; | ||
|
||
const endpoint = baseApi.url('/login'); | ||
|
||
export function sendLogIn(proposal, password, previousUser) { | ||
return endpoint.post({ proposal, password, previousUser }, '/').safeJson(); | ||
} | ||
|
||
export function fetchLoginInfo() { | ||
return endpoint.get('/login_info').safeJson(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import api from '.'; | ||
import api from './api'; | ||
|
||
const endpoint = api.url('/queue'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import api from '.'; | ||
import api from './api'; | ||
|
||
const endpoint = api.url('/ra'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import api from '.'; | ||
import api from './api'; | ||
|
||
const endpoint = api.url('/sample_changer'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import api from '.'; | ||
import api from './api'; | ||
|
||
const endpoint = api.url('/sampleview'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import api from '.'; | ||
import api from './api'; | ||
|
||
const endpoint = api.url('/workflow'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters