Commit 8b3e2695 authored by Valeriy Panov's avatar Valeriy Panov
Browse files

#196 console.log

parent 6b9a9206
......@@ -8,6 +8,7 @@ import { checkAccessTokens } from 'actions/login';
import rootReducer from 'reducers/index';
import thunk from 'redux-thunk';
import routes from 'ui/routes';
import {log} from 'utilities/debug';
// JSS & MUI
import {MuiThemeProvider} from 'material-ui/styles';
......@@ -36,7 +37,7 @@ if (__PRELOADED_STATE__ === undefined) {
);
})
.catch((err) => {
console.log('Oh, oh', err);
log('Oh, oh', err);
});
} else {
......@@ -50,7 +51,7 @@ if (__PRELOADED_STATE__ === undefined) {
document.getElementById('the-app'),
() => {
// We don't need the static css any more once we have launched our application.
console.log('Removing SSR-rendered styles');
log('Removing SSR-rendered styles');
const ssStyles = document.getElementById('server-side-styles');
ssStyles.parentNode.removeChild(ssStyles);
},
......
......@@ -3,6 +3,7 @@ import {Crop} from 'model/crop.model';
import {CropService} from 'service/CropService';
import {CREATE_CROP, GET_CROP, RECEIVE_CROP, RECEIVE_CROPS} from 'constants/crop';
import {IReducerAction} from 'model/common.model';
import {log} from 'utilities/debug';
export const createCrop = () => (dispatch) => {
return Promise.all([
......@@ -28,7 +29,7 @@ export const loadCrop = (uuid: string) => (dispatch, getState) => {
.then((crop) => {
return dispatch(receiveCrop(crop));
}).catch((error) => {
console.log(`No crop with uuid ${uuid}`, error);
log(`No crop with uuid ${uuid}`, error);
});
};
......@@ -48,7 +49,7 @@ export const listCrops = () => (dispatch, getState) => {
dispatch(receiveCrops(list));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
......@@ -59,7 +60,7 @@ export const saveCrop = (crop: Crop) => (dispatch, getState) => {
dispatch(receiveCrop(saved));
dispatch(push('/crops'));
}).catch((error) => {
console.log('Save error', error);
log('Save error', error);
});
};
......@@ -69,6 +70,6 @@ export const deleteCrop = (crop: Crop) => (dispatch, getState) => {
dispatch(push('/crops'));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
......@@ -10,6 +10,7 @@ import { DatasetService } from 'service/DatasetService';
import { CreatorService } from 'service/CreatorService';
import { LocationService } from 'service/LocationService';
import { RepositoryFileService } from 'service/RepositoryFileService';
import {log} from 'utilities/debug';
import { CREATE_DATASET, RECEIVE_DATASET, RECEIVE_DATASET_PAGE, ADD_CREATOR_TO_DATASET, REMOVE_CREATOR_FROM_DATASET, UPDATE_DATASET_CREATOR, ADD_LOCATION, RECEIVE_LOCATION, REMOVE_LOCATION } from 'constants/datasets';
......@@ -43,7 +44,7 @@ function listMyDatasets(page?, results?, sortBy?, filter?, order?) {
dispatch(receiveDatasetPage(paged, page, results, sortBy, filter, order));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
}
......@@ -57,7 +58,7 @@ function listDatasetsRequest(page?, results?, sortBy?, filter?, order?) {
return dispatch(receiveDatasetPage(paged, page, results, sortBy, filter, order));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
}
......@@ -71,7 +72,7 @@ function loadDataset(uuid: string) {
dispatch(receiveDataset(dataset));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
}
......@@ -99,7 +100,7 @@ const saveDataset = (dataset: Dataset) => (dispatch, getState) => {
.then((saved) => {
dispatch(receiveDataset(saved));
}).catch((error) => {
console.log('Save error', error);
log('Save error', error);
});
};
......@@ -112,7 +113,7 @@ function publishDataset(dataset: Dataset, published: boolean = true) {
dispatch(receiveDataset(saved));
dispatch(showDataset(saved.uuid));
}).catch((error) => {
console.log('Publish error', error);
log('Publish error', error);
});
};
}
......@@ -126,7 +127,7 @@ function deleteDataset(dataset: Dataset) {
dispatch(receiveDataset(saved));
// dispatch(showDataset(saved.uuid));
}).catch((error) => {
console.log('Delete error', error);
log('Delete error', error);
});
};
}
......@@ -139,7 +140,7 @@ function updateDatasetAccessionIdentifiers(dataset: Dataset, accessionIdentifier
.then((saved) => {
dispatch(receiveDataset(saved));
}).catch((error) => {
console.log('Publish error', error);
log('Publish error', error);
});
};
}
......@@ -153,7 +154,7 @@ function addDescriptorsToDatasetRequest(dataset: Dataset, descriptor: Descriptor
.then((saved) => {
dispatch(receiveDataset(saved));
}).catch((error) => {
console.log('Add error', error);
log('Add error', error);
});
};
}
......@@ -166,7 +167,7 @@ function removeDescriptorsFromDatasetRequest(dataset: Dataset, descriptor: Descr
.then((saved) => {
dispatch(receiveDataset(saved));
}).catch((error) => {
console.log('Delete error', error);
log('Delete error', error);
});
};
}
......@@ -184,7 +185,7 @@ export const uploadRepositoryFileRequest = (datasetUUID: string, file: File) =>
.then((dataset) => {
dispatch(receiveDataset(dataset));
}).catch((error) => {
console.log('Save error', error);
log('Save error', error);
});
};
......@@ -195,7 +196,7 @@ export const updateRepositoryFileRequest = (datasetUUID: string, repositoryfile:
.then((dataset) => {
dispatch(receiveDataset(dataset));
}).catch((error) => {
console.log('Save error', error);
log('Save error', error);
});
};
......@@ -206,7 +207,7 @@ export const deleteRepositoryFileRequest = (datasetUUID: string, uuid: string) =
.then((dataset) => {
dispatch(receiveDataset(dataset));
}).catch((error) => {
console.log('Delete error', error);
log('Delete error', error);
});
};
......@@ -223,12 +224,12 @@ function addCreatorToDataset(creator: Creator, uuid: string) {
// FIXME No uuid param required, currentDataset is available in state
function createDatasetCreator(uuid: string) {
return (dispatch, getState) => {
console.log('createCreator');
log('createCreator');
return CreatorService.createCreator(getState().login.access_token, uuid)
.then((obj) => {
dispatch(addCreatorToDataset(obj, uuid));
}).catch((error) => {
console.log('Create creator error', error);
log('Create creator error', error);
});
};
}
......@@ -249,7 +250,7 @@ function updateCreatorRequest(uuid: string, creator: Creator) {
.then((obj) => {
dispatch(updateCreator(obj));
}).catch((error) => {
console.log('Update creator error', error);
log('Update creator error', error);
});
};
}
......@@ -271,7 +272,7 @@ function deleteCreatorRequest(uuid: string, creator: Creator) {
.then((obj) => {
dispatch(removeCreator(obj, uuid));
}).catch((error) => {
console.log('Delete creator error', error);
log('Delete creator error', error);
});
};
}
......@@ -301,7 +302,7 @@ function createLocationRequest(datasetUUID: string) {
.then((saved) => {
dispatch(addLocation(datasetUUID, saved));
}).catch((error) => {
console.log('Save error', error);
log('Save error', error);
});
};
}
......@@ -324,7 +325,7 @@ function updateLocationRequest(datasetUUID: string, location: Location) {
.then((saved) => {
dispatch(receiveLocation(saved));
}).catch((error) => {
console.log('Save error', error);
log('Save error', error);
});
};
}
......@@ -347,7 +348,7 @@ function deleteLocationRequest(datasetUUID: string, location: Location) {
.then((saved) => {
dispatch(deleteLocation(datasetUUID, saved));
}).catch((error) => {
console.log('Delete error', error);
log('Delete error', error);
});
};
}
......
......@@ -3,6 +3,7 @@ import { push } from 'react-router-redux';
import { DescriptorListService } from 'service/DescriptorListService';
import { DescriptorList, Descriptor, IDescriptorListFilter } from 'model/descriptor.model';
import { Page } from 'model/common.model';
import {log} from 'utilities/debug';
import {
GET_DESCRIPTORLIST, RECEIVE_DESCRIPTORLIST,
......@@ -27,7 +28,7 @@ const loadingDescriptorLists = (page, results, sortBy, filter, order) => ({
// Just load a descriptor list
export const loadDescriptorList = (uuid: string) => (dispatch, getState) => {
console.log('Loading descriptor list', uuid);
log('Loading descriptor list', uuid);
const token = getState().login.access_token;
dispatch({ type: GET_DESCRIPTORLIST, payload: uuid });
......@@ -40,13 +41,13 @@ export const loadDescriptorList = (uuid: string) => (dispatch, getState) => {
.then((descriptorList) => {
dispatch(receiveDescriptorList(descriptorList));
}).catch((error) => {
console.log(`No descriptor list with uuid ${uuid}`, error);
log(`No descriptor list with uuid ${uuid}`, error);
});
};
// List current user's descriptor lists
export const listMyDescriptorLists = (page?, results?, sortBy?, filter?, order?) => (dispatch, getState) => {
console.log('Loading my descriptor lists');
log('Loading my descriptor lists');
const token = getState().login.access_token;
dispatch(loadingDescriptorLists(page, results, sortBy, filter, order));
......@@ -56,13 +57,13 @@ export const listMyDescriptorLists = (page?, results?, sortBy?, filter?, order?)
.then((descriptorLists) => {
return dispatch(receiveDescriptorLists(descriptorLists, page, results, sortBy, filter, order));
}).catch((error) => {
console.log(`Error loading my descriptor lists`, error);
log(`Error loading my descriptor lists`, error);
});
};
// List published descriptor lists
export const listDescriptorLists = (page?, results?, sortBy?, filter?, order?) => (dispatch, getState) => {
console.log('Loading published descriptor lists');
log('Loading published descriptor lists');
const token = getState().login.access_token;
dispatch(loadingDescriptorLists(page, results, sortBy, filter, order));
......@@ -72,7 +73,7 @@ export const listDescriptorLists = (page?, results?, sortBy?, filter?, order?) =
.then((descriptorLists) => {
return dispatch(receiveDescriptorLists(descriptorLists, page, results, sortBy, filter, order));
}).catch((error) => {
console.log(`Error loading published descriptor lists`, error);
log(`Error loading published descriptor lists`, error);
});
};
......@@ -91,7 +92,7 @@ export const editDescriptorList = (uuid: string) => (dispatch, getState) => {
// Save the descriptor list
export const saveDescriptorList = (descriptorList: DescriptorList) => (dispatch, getState) => {
console.log('Saving descriptor list', descriptorList);
log('Saving descriptor list', descriptorList);
const createOrSave = descriptorList.version ? DescriptorListService.updateDescriptorList : DescriptorListService.createDescriptorList;
return createOrSave(getState().login.access_token, descriptorList)
......@@ -102,7 +103,7 @@ export const saveDescriptorList = (descriptorList: DescriptorList) => (dispatch,
// and redirect to proper edit page
return dispatch(push(`/descriptorlist/${descriptorList.uuid}/edit`));
}).catch((error) => {
console.log(`Error saving descriptor list`, error, descriptorList);
log(`Error saving descriptor list`, error, descriptorList);
});
};
......
......@@ -7,6 +7,7 @@ import {CREATE_DESCRIPTOR, RECEIVE_DESCRIPTOR, RECEIVE_DESCRIPTOR_PAGE, GET_DESC
import {Descriptor, IDescriptorFilter} from 'model/descriptor.model';
import {Partner} from 'model/partner.model';
import {Page} from 'model/common.model';
import {log} from 'utilities/debug';
const receiveDescriptor = (descriptor: Descriptor) => ({
type: RECEIVE_DESCRIPTOR,
......@@ -36,7 +37,7 @@ export function showDescriptorsDashboard() {
}
export function loadDescriptor(uuid: string) {
console.log('Loading descriptor', uuid);
log('Loading descriptor', uuid);
return (dispatch, getState) => {
const token = getState().login.access_token;
......@@ -46,7 +47,7 @@ export function loadDescriptor(uuid: string) {
.then((loaded) => {
dispatch(receiveDescriptor(loaded));
}).catch((error) => {
console.log(`No descriptor with uuid ${uuid}`, error);
log(`No descriptor with uuid ${uuid}`, error);
throw new SubmissionError({ title: 'Title already used', _error: error.error });
});
};
......@@ -65,7 +66,7 @@ export const editDescriptor = (uuid: string) => (dispatch, getState) => {
};
export const saveDescriptor = (descriptor: Descriptor) => (dispatch, getState) => {
console.log('Saving descriptor', descriptor);
log('Saving descriptor', descriptor);
const createOrSave = descriptor.version && descriptor.uuid ? DescriptorService.updateDescriptor : DescriptorService.createDescriptor;
return createOrSave(getState().login.access_token, descriptor)
......@@ -75,7 +76,7 @@ export const saveDescriptor = (descriptor: Descriptor) => (dispatch, getState) =
// and redirect to proper edit page
return dispatch(push(`/descriptor/${descriptor.uuid}/edit`));
}).catch((error) => {
console.log('Save error', error);
log('Save error', error);
throw new SubmissionError({ title: 'Could not save descriptor', _error: error.error });
});
};
......@@ -87,7 +88,7 @@ export const deleteDescriptor = (descriptor: Descriptor) => (dispatch, getState)
dispatch(push(`/descriptors`));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
......@@ -103,7 +104,7 @@ export function listMyDescriptors(page?, results?, sortBy?, filter?, order?) {
return dispatch(receiveDescriptorPage(paged, page, results, sortBy, filter, order));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
}
......@@ -120,7 +121,7 @@ export function loadDescriptors(page?, results?, sortBy?, filter?, order?) {
return dispatch(receiveDescriptorPage(paged, page, results, sortBy, filter, order));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
}
......@@ -134,7 +135,7 @@ export function publishDescriptor(descriptor: Descriptor, published: boolean = t
.then((saved) => {
dispatch(receiveDescriptor(saved));
}).catch((error) => {
console.log('Publish error', error);
log('Publish error', error);
});
};
}
......@@ -3,6 +3,7 @@ import * as Constants from 'constants/login';
import * as cookies from 'es-cookie';
import { clearCookies, saveCookies } from 'utilities';
import { ROLE_CLIENT } from 'constants/userRoles';
import {log} from 'utilities/debug';
export function checkAccessTokens(dispatch) {
const cookieToken: string = typeof window !== 'undefined' && cookies.get('access_token');
......@@ -10,29 +11,24 @@ export function checkAccessTokens(dispatch) {
const applicationLogin = () =>
LoginService.loginApp()
.then((data) => {
// console.log('Doing application login');
saveCookies({access_token: data.access_token, authorities: [ROLE_CLIENT]});
dispatch(loginApp(data));
})
.catch((error) => {
console.log('Something went wrong', error);
log('Something went wrong', error);
});
if (cookieToken) {
// console.log('Checking cookie token');
return LoginService.checkToken(cookieToken)
.then((data) => {
// console.log('Cookie token okay');
dispatch(loginUser({ access_token: cookieToken, ...data }));
return true;
})
.catch((error) => {
// console.log('Failed to check token');
clearCookies();
return applicationLogin();
});
} else {
// console.log('No cookie token');
clearCookies();
return applicationLogin();
}
......@@ -71,10 +67,10 @@ function logoutRequest() {
function checkTokenRequest(token) {
return (dispatch) => {
console.log('checkTokenRequest verifying ', token);
log('checkTokenRequest verifying ', token);
return LoginService.checkToken(token)
.then((data) => {
console.log('checkTokenRequest got', data);
log('checkTokenRequest got', data);
return dispatch(checkToken({ access_token: token, ...data }));
});
};
......@@ -127,7 +123,7 @@ function verifyGoogleToken(d) {
};
}
export {
export {
loginRequest, loginUser, loginAppRequest, loginApp, logoutRequest, logout,
checkTokenRequest, checkToken, verifyGoogleTokenRequest, verifyGoogleToken,
checkTokenRequest, checkToken, verifyGoogleTokenRequest, verifyGoogleToken,
};
import {push} from 'react-router-redux';
export function navigateTo(path: string) {
// console.log('Navigating to', path);
return (dispatch) => {
dispatch(push(path));
};
......
......@@ -9,6 +9,7 @@ import {
import { IReducerAction, Page } from 'model/common.model';
import { Partner } from 'model/partner.model';
import { IPartnerFilter } from 'model/filter.model';
import {log} from 'utilities/debug';
const receiveMyPartnerList = (partners: Partner[]): IReducerAction => ({
type: RECEIVE_MY_PARTNERLIST, payload: partners,
......@@ -25,7 +26,7 @@ const receivePartner = (partner: Partner): IReducerAction => ({
// Create a new record
export const createPartner = () => (dispatch) => {
console.log('Create new partner');
log('Create new partner');
dispatch({ type: CREATE_PARTNER });
return dispatch(push(`/partner/edit`));
};
......@@ -37,13 +38,13 @@ export const deletePartner = (partner: Partner) => (dispatch, getState) => {
dispatch(push(`/partners`));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
// Just load a record
export const loadPartner = (uuid: string) => (dispatch, getState) => {
console.log('Loading partner', uuid);
log('Loading partner', uuid);
const token = getState().login.access_token;
dispatch({ type: GET_PARTNER, payload: uuid });
......@@ -53,7 +54,7 @@ export const loadPartner = (uuid: string) => (dispatch, getState) => {
.then((partner) => {
return dispatch(receivePartner(partner));
}).catch((error) => {
console.log(`No partner with uuid ${uuid}`, error);
log(`No partner with uuid ${uuid}`, error);
});
};
......@@ -64,7 +65,7 @@ export const editPartner = (uuid: string) => (dispatch, getState) => {
};
const showPartner = (uuid: string) => (dispatch) => {
console.log('Navigating to Partner details');
log('Navigating to Partner details');
dispatch(push(`/partner/${uuid}`));
};
......@@ -75,7 +76,7 @@ const loadMyPartners = () => (dispatch, getState) => {
dispatch(receiveMyPartnerList(paged.content));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
......@@ -84,11 +85,10 @@ const loadPartners = (page: number, results: number, sortBy?: string, filter?: I
return PartnerService.listPartners(getState().login.access_token, page, results, sortBy, order, filter)
.then((paged) => {
// console.log('fufu', paged);
dispatch(receivePartnerPage(paged, page, results, sortBy, filter, order));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
......@@ -99,7 +99,7 @@ const savePartner = (partner: Partner) => (dispatch, getState) => {
dispatch(receivePartner(saved));
dispatch(showPartner(saved.uuid));
}).catch((error) => {
console.log('Save error', error);
log('Save error', error);
throw new SubmissionError({ name: 'Name already used', _error: error.error });
});
};
......
import * as Constants from 'constants/serverInfo';
import {InfoService} from 'service/InfoService';
import {log} from 'utilities/debug';
function serverInfoRequest() {
return (dispatch, getState) => {
......@@ -7,7 +8,7 @@ function serverInfoRequest() {
return InfoService.getServerInfo(token)
.then((data) => dispatch(getServerInfo(data)))
.catch((error) => console.log('Error', error));
.catch((error) => log('Error', error));
};
}
......
import { push } from 'react-router-redux';
import { SubmissionError } from 'redux-form';
import { VocabularyService } from 'service/VocabularyService';
import {log} from 'utilities/debug';
import {
CREATE_VOCABULARY, RECEIVE_VOCABULARY, RECEIVE_VOCABULARIES, RECEIVE_MY_VOCABULARYLIST,
......@@ -23,7 +24,7 @@ const receiveVocabulary = (vocabulary: Vocabulary): IReducerAction => ({
// Create a new record
export const createVocabulary = () => (dispatch) => {
console.log('Create new vocabulary');
log('Create new vocabulary');
return Promise.all([
dispatch({ type: CREATE_VOCABULARY }),
dispatch(push(`/vocabulary/create`)),
......@@ -38,13 +39,13 @@ export const deleteVocabulary = (vocabulary: Vocabulary) => (dispatch, getState)
dispatch(push(`/vocabulary`));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};
// Just load a record
export const loadVocabulary = (uuid: string) => (dispatch, getState) => {
console.log('Loading vocabulary', uuid);
log('Loading vocabulary', uuid);
const token = getState().login.access_token;
return VocabularyService.getVocabulary(token, uuid)
......@@ -52,7 +53,7 @@ export const loadVocabulary = (uuid: string) => (dispatch, getState) => {
.then((vocabulary) => {
return dispatch(receiveVocabulary(vocabulary));
}).catch((error) => {
console.log(`No vocabulary with uuid ${uuid}`, error);
log(`No vocabulary with uuid ${uuid}`, error);
});
};
......@@ -65,7 +66,7 @@ export const editVocabulary = (uuid: string) => (dispatch, getState) => {
};
const showVocabulary = (uuid: string) => (dispatch) => {
console.log('Navigating to Vocabulary details');
log('Navigating to Vocabulary details');
dispatch(push(`/vocabulary/${uuid}`));
};
......@@ -76,7 +77,7 @@ const listMyVocabularies = () => (dispatch, getState) => {
dispatch(receiveMyVocabularyList(paged.content));
})
.catch((error) => {
console.log('Error', error);
log('Error', error);
});
};