mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-11 10:22:53 +00:00
more work on charts
This commit is contained in:
@@ -8,16 +8,9 @@ function loadSensorList(sensor_list){
|
||||
}
|
||||
}
|
||||
|
||||
function loadSensorInfoYear(sensor_info){
|
||||
function loadSensorInfo(sensor_info){
|
||||
return{
|
||||
type: types.LOAD_SENSOR_INFO_YEAR,
|
||||
sensor_info
|
||||
}
|
||||
}
|
||||
|
||||
function loadSensorInfoMonth(sensor_info){
|
||||
return{
|
||||
type: types.LOAD_SENSOR_INFO_MONTH,
|
||||
type: types.LOAD_SENSOR_INFO,
|
||||
sensor_info
|
||||
}
|
||||
}
|
||||
@@ -49,15 +42,9 @@ function fetchingList(){
|
||||
}
|
||||
}
|
||||
|
||||
function fetchingInfoYear(){
|
||||
function fetchingInfo(){
|
||||
return {
|
||||
type: types.FETCHING_INFO_YEAR
|
||||
}
|
||||
}
|
||||
|
||||
function fetchingInfoMonth(){
|
||||
return {
|
||||
type: types.FETCHING_INFO_MONTH
|
||||
type: types.FETCHING_INFO
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,11 +70,11 @@ export function fetchSensorList(){
|
||||
|
||||
export function fetchSensorInfoYear(location, year){
|
||||
return (dispatch) => {
|
||||
dispatch(fetchingInfoYear());
|
||||
dispatch(fetchingInfo());
|
||||
return fetch(`/api/sensor/${location}/${year}`)
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
dispatch(loadSensorInfoYear(json));
|
||||
dispatch(loadSensorInfo(json));
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
@@ -97,11 +84,11 @@ export function fetchSensorInfoYear(location, year){
|
||||
|
||||
export function fetchSensorInfoMonth(location, year, month){
|
||||
return (dispatch) => {
|
||||
dispatch(fetchingInfoMonth());
|
||||
dispatch(fetchingInfo());
|
||||
return fetch(`/api/sensor/${location}/${year}/${month}`)
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
dispatch(loadSensorInfoMonth(json));
|
||||
dispatch(loadSensorInfo(json));
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
@@ -119,7 +106,6 @@ export function fetchUniqueDates(location){
|
||||
if(json.length > 0){
|
||||
let year = json[0].year;
|
||||
let month = json[0].months[0].monthname;
|
||||
dispatch(fetchSensorInfoYear(location, year));
|
||||
dispatch(fetchSensorInfoMonth(location, year, month));
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
//constants
|
||||
export const LOAD_SENSOR_LIST = 'LOAD_SENSOR_LIST';
|
||||
export const LOAD_SENSOR_INFO_YEAR = 'LOAD_SENSOR_INFO_YEAR';
|
||||
export const LOAD_SENSOR_INFO_MONTH = 'LOAD_SENSOR_INFO_MONTH';
|
||||
export const LOAD_SENSOR_INFO = 'LOAD_SENSOR_INFO';
|
||||
export const LOAD_UNIQUE_DATES = 'LOAD_UNIQUE_DATES';
|
||||
|
||||
//fetching
|
||||
export const FETCHING_LIST = 'FETCHING_LIST';
|
||||
export const FETCHING_INFO_YEAR = 'FETCHING_INFO_YEAR';
|
||||
export const FETCHING_INFO_MONTH = 'FETCHING_INFO_MONTH';
|
||||
export const FETCHING_INFO = 'FETCHING_INFO_YEAR';
|
||||
export const FETCHING_UNIQUE_DATES = 'FETCHING_UNIQUE_DATES';
|
||||
|
||||
//indexes
|
||||
|
||||
@@ -4,21 +4,18 @@ import * as types from '../constants/sensor';
|
||||
//defaults -
|
||||
const defaultState = {
|
||||
list : [],
|
||||
infoMonth: [],
|
||||
infoYear: [],
|
||||
info: [],
|
||||
uniqueDates: {},
|
||||
|
||||
selectedYearIndex: 0,
|
||||
selectedMonthIndex: 0,
|
||||
|
||||
fetchingList: false,
|
||||
fetchingInfoMonth: false,
|
||||
fetchingInfoYear: false,
|
||||
fetchingInfo: false,
|
||||
fetchingUniqueDates: false,
|
||||
|
||||
fetchedList: false,
|
||||
fetchedInfoMonth: false,
|
||||
fetchedInfoYear: false,
|
||||
fetchedInfo: false,
|
||||
fetchedUniqueDates: false
|
||||
};
|
||||
|
||||
@@ -31,15 +28,10 @@ export default function app(state = defaultState, action) {
|
||||
fetchingList: true,
|
||||
fetchedList: false
|
||||
});
|
||||
case types.FETCHING_INFO_MONTH:
|
||||
case types.FETCHING_INFO:
|
||||
return Object.assign({}, state, {
|
||||
fetchingInfoMonth: true,
|
||||
fetchedInfoMonth: false
|
||||
});
|
||||
case types.FETCHING_INFO_YEAR:
|
||||
return Object.assign({}, state, {
|
||||
fetchingInfoYear: true,
|
||||
fetchedInfoYear: false
|
||||
fetchingInfo: true,
|
||||
fetchedInfo: false
|
||||
});
|
||||
case types:FETCHING_UNIQUE_DATES:
|
||||
return Object.assign({}, state, {
|
||||
@@ -54,17 +46,11 @@ export default function app(state = defaultState, action) {
|
||||
fetchingList: false,
|
||||
fetchedList: true
|
||||
});
|
||||
case types.LOAD_SENSOR_INFO_MONTH:
|
||||
case types.LOAD_SENSOR_INFO:
|
||||
return Object.assign({}, state, {
|
||||
infoMonth: action.sensor_info,
|
||||
fetchingInfoMonth: false,
|
||||
fetchedInfoMonth: true
|
||||
});
|
||||
case types.LOAD_SENSOR_INFO_YEAR:
|
||||
return Object.assign({}, state, {
|
||||
infoYear: action.sensor_info,
|
||||
fetchingInfoYear: false,
|
||||
fetchedInfoYear: true
|
||||
info: action.sensor_info,
|
||||
fetchingInfo: false,
|
||||
fetchedInfo: true
|
||||
});
|
||||
case types.LOAD_UNIQUE_DATES:
|
||||
return Object.assign({}, state, {
|
||||
|
||||
Reference in New Issue
Block a user