-function setBusyFeedback(){
- return {
- type: tierSupportActionTypes.TIER_SUPPORT_ACTIVATE_BUSY_FEEDBACK
- };
-}
-
-function disableBusyFeedback(){
- return {
- type: tierSupportActionTypes.TIER_SUPPORT_DISABLE_BUSY_FEEDBACK
- };
-}
-
-export function fetchSelectedNodeElement(fetchRequestCallback) {
- return dispatch => {
- return fetchRequestCallback().then(
- (response) => {
- if (response.status === STATUS_CODE_204_NO_CONTENT || response.status >= STATUS_CODE_3XX_REDIRECTION) {
- return Promise.reject(new Error(response.status));
- } else {
- // assume 200 status
- return response.json();
- }
- }
- ).then(
- (responseJson) => {
- if (responseJson.nodes.length > 0) {
- dispatch(createNodeDetailsFoundEvent(responseJson));
- dispatch(createSelectedNodeDetails(responseJson));
- } else {
- dispatch(noNodeDetailsFoundEvent(NO_RESULTS_FOUND));
- }
- }
- ).then(
- () => {
- dispatch(disableBusyFeedback());
- }
- ).catch(
- (errorCode) => {
- dispatch(disableBusyFeedback());
- if (errorCode.message >= STATUS_CODE_5XX_SERVER_ERROR) {
- dispatch(getInvalidSelectedNodeSearchEvent(ERROR_RETRIEVING_DATA));
- } else {
- // TODO - assuming 204 status, but should include additional
- // statuses in the future with proper messaging in order to return
- // better messaging
- dispatch(noNodeDetailsFoundEvent(NO_RESULTS_FOUND));
- }
- }
- );
- };
-}
-
-export function querySelectedNodeElement(
- searchHashId, selectedNodeFetchRequest) {
- let payload = {
- hashId: searchHashId
- };
-
- if (selectedNodeFetchRequest === undefined) {
- let postBody = JSON.stringify(payload);
- selectedNodeFetchRequest =
- () => networkCall.fetchRequestObj(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST,
- POST_HEADER, postBody);
- }
-
- return dispatch => {
- dispatch(setBusyFeedback());
- dispatch(fetchSelectedNodeElement(selectedNodeFetchRequest));
- };
-}
-