Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move to production #1823

Merged
merged 14 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion k8s/netmanager/values-prod.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
replicaCount: 2
image:
repository: eu.gcr.io/airqo-250220/airqo-platform-frontend
tag: prod-2a4a71cb-1705952613
tag: prod-cf54d49a-1705956587
pullPolicy: Always
imagePullSecrets: []
nameOverride: ''
Expand Down
2 changes: 1 addition & 1 deletion k8s/netmanager/values-stage.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
replicaCount: 2
image:
repository: eu.gcr.io/airqo-250220/airqo-stage-platform-frontend
tag: stage-2ccd405a-1705952469
tag: stage-5fa514e6-1705956502
pullPolicy: Always
imagePullSecrets: []
nameOverride: ''
Expand Down
2 changes: 1 addition & 1 deletion k8s/platform/values-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ replicaCount: 1
image:
repository: eu.gcr.io/airqo-250220/airqo-stage-next-platform
pullPolicy: Always
tag: stage-f07de671-1705390026
tag: stage-3fac4c24-1706008122
imagePullSecrets: []
nameOverride: ''
fullnameOverride: ''
Expand Down
5 changes: 2 additions & 3 deletions netmanager/src/views/pages/CohortsRegistry/AddCohortForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { updateMainAlert } from 'redux/MainAlert/operations';
import Select from 'react-select';
import { useDispatch } from 'react-redux';
import { createAlertBarExtraContentFromObject } from 'utils/objectManipulators';
import { setActiveCohort } from 'redux/Analytics/operations';
import { fetchAllCohorts } from '../../../redux/Analytics/operations';
import { fetchCohortsSummary } from 'redux/Analytics/operations';

const AddCohortToolbar = ({ open, handleClose, deviceOptions }) => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -54,7 +53,7 @@ const AddCohortToolbar = ({ open, handleClose, deviceOptions }) => {
selectedDevices.map((device) => device.value)
)
.then((res) => {
dispatch(fetchAllCohorts(activeNetwork.net_name));
dispatch(fetchCohortsSummary(activeNetwork.net_name));
handleClose();
dispatch(
updateMainAlert({
Expand Down
5 changes: 2 additions & 3 deletions netmanager/src/views/pages/GridsRegistry/AddGridForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import { useDispatch, useSelector } from 'react-redux';
import PolygonMap from './PolygonMap';
import { createGridApi } from 'views/apis/deviceRegistry';
import Alert from '@material-ui/lab/Alert';
import { setActiveGrid } from 'redux/Analytics/operations';
import { refreshGridApi } from '../../apis/deviceRegistry';
import { fetchAllGrids } from '../../../redux/Analytics/operations';
import { fetchGridsSummary } from 'redux/Analytics/operations';

const AddGridToolbar = ({ open, handleClose }) => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -64,7 +63,7 @@ const AddGridToolbar = ({ open, handleClose }) => {
severity: 'success'
});
const activeNetwork = JSON.parse(localStorage.getItem('activeNetwork') || {});
dispatch(fetchAllGrids(activeNetwork.net_name));
dispatch(fetchGridsSummary(activeNetwork.net_name));
setTimeout(() => {
setErrorMessage(null);
clearState();
Expand Down
133 changes: 117 additions & 16 deletions platform/src/common/components/Collocation/AddMonitor/Calendar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { useDispatch } from 'react-redux';
import {
addEndDate,
Expand All @@ -11,18 +11,57 @@ import {
} from '@/lib/store/services/collocation/selectedCollocateDevicesSlice';
import Datepicker from 'react-tailwindcss-datepicker';
import moment from 'moment';
import { useSelector } from 'react-redux';

const ScheduleCalendar = () => {
const collationDurations = [4, 7, 14];
const [duration, setDuration] = useState(null);
const [customRange, setCustomRange] = useState(false);
const dispatch = useDispatch();
const storedStartDate = useSelector((state) => state.selectedCollocateDevices.startDate);
const storedEndDate = useSelector((state) => state.selectedCollocateDevices.endDate);
const scheduledBatchName = useSelector(
(state) => state.selectedCollocateDevices.scheduledBatchName,
);
const scheduledBatchDataCompletenessThresholdRedux = useSelector(
(state) => state.selectedCollocateDevices.scheduledBatchDataCompletenessThreshold,
);
const scheduledBatchInterCorrelationThresholdRedux = useSelector(
(state) => state.selectedCollocateDevices.scheduledBatchInterCorrelationThreshold,
);
const scheduledBatchIntraCorrelationThresholdRedux = useSelector(
(state) => state.selectedCollocateDevices.scheduledBatchIntraCorrelationThreshold,
);
const scheduledBatchDifferencesThresholdRedux = useSelector(
(state) => state.selectedCollocateDevices.scheduledBatchDifferencesThreshold,
);

const [value, setValue] = useState({
startDate: null,
endDate: null,
startDate: storedStartDate,
endDate: storedEndDate,
});

const collationDurations = [4, 7, 14];
const [duration, setDuration] = useState(null);
const [customRange, setCustomRange] = useState(false);

const [scheduledBatchDataCompletenessThreshold, setScheduledBatchDataCompletenessThreshold] =
useState(scheduledBatchDataCompletenessThresholdRedux);
const [scheduledBatchInterCorrelationThreshold, setScheduledBatchInterCorrelationThreshold] =
useState(scheduledBatchInterCorrelationThresholdRedux);
const [scheduledBatchIntraCorrelationThreshold, setScheduledBatchIntraCorrelationThreshold] =
useState(scheduledBatchIntraCorrelationThresholdRedux);
const [scheduledBatchDifferencesThreshold, setScheduledBatchDifferencesThreshold] = useState(
scheduledBatchDifferencesThresholdRedux,
);

useEffect(() => {
// Difference between the start and end date
if (value && value.startDate && value.endDate) {
const diffDates = moment(value.endDate).diff(moment(value.startDate), 'days');
if (diffDates > 0) {
setDuration(diffDates + 1);
}
}
}, []);

const handleValueChange = (newValue) => {
setValue(newValue);
dispatch(addStartDate(newValue.startDate));
Expand All @@ -48,6 +87,34 @@ const ScheduleCalendar = () => {
setCustomRange(event.target.checked);
};

const validateIntraCorrelationThreshold = (value) => {
if (value < 0 || value > 1) {
return 'Intra correlation threshold should range from 0 to 1';
}
return '';
};

const validateInterCorrelationThreshold = (value) => {
if (value < 0 || value > 1) {
return 'Inter correlation threshold should range from 0 to 1';
}
return '';
};

const validateDataCompletenessThreshold = (value) => {
if (value < 0 || value > 100) {
return 'Data completeness threshold should range from 1 to 100';
}
return '';
};

const validateDifferencesThreshold = (value) => {
if (value < 0 || value > 5) {
return 'Differences threshold should range from 0 to 5';
}
return '';
};

return (
<div className='pt-6'>
<div className='px-6 pb-7'>
Expand Down Expand Up @@ -100,67 +167,101 @@ const ScheduleCalendar = () => {
<h5 className='text-grey-300 text-sm mb-4'>
Customise the batch configurations. Can be modified later
</h5>
<div className='form-control w-full max-w-xs'>
<div className='form-control w-full'>
<label className='label'>
<span className='label-text'>Batch name*</span>
</label>
<input
type='text'
className='input input-bordered input-sm w-full max-w-xs rounded-md mb-3 bg-gray-50 border-none'
value={scheduledBatchName}
className='input input-bordered input-sm w-full rounded-md mb-3 bg-gray-50 border-none'
onChange={(e) => {
dispatch(addScheduledBatchName(e.target.value));
}}
required
aria-required='true'
/>
{
<p className='text-red-500 text-xs'>
{scheduledBatchName.length < 1 && 'Batch name is required'}
</p>
}
</div>
<div className='form-control w-full max-w-xs'>
<div className='form-control w-full'>
<label className='label'>
<span className='label-text'>Data completeness threshold</span>
</label>
<input
type='text'
className='input input-bordered input-sm w-full max-w-xs rounded-md mb-3 bg-gray-50 border-none'
value={scheduledBatchDataCompletenessThreshold}
className='input input-bordered input-sm w-full rounded-md mb-3 bg-gray-50 border-none'
onChange={(e) => {
setScheduledBatchDataCompletenessThreshold(e.target.value);
dispatch(addScheduledBatchDataCompletenessThreshold(e.target.value));
}}
/>
{
<p className='text-red-500 text-xs'>
{validateDataCompletenessThreshold(scheduledBatchDataCompletenessThreshold)}
</p>
}
</div>
<div className='form-control w-full max-w-xs'>
<div className='form-control w-full'>
<label className='label'>
<span className='label-text'>Intercorrelation threshold</span>
</label>
<input
type='text'
className='input input-bordered input-sm w-full max-w-xs rounded-md mb-3 bg-gray-50 border-none'
value={scheduledBatchInterCorrelationThreshold}
className='input input-bordered input-sm w-full rounded-md mb-3 bg-gray-50 border-none'
onChange={(e) => {
setScheduledBatchInterCorrelationThreshold(e.target.value);
dispatch(addScheduledBatchInterCorrelationThreshold(e.target.value));
}}
/>
{
<p className='text-red-500 text-xs'>
{validateInterCorrelationThreshold(scheduledBatchInterCorrelationThreshold)}
</p>
}
</div>
<div className='form-control w-full max-w-xs'>
<div className='form-control w-full'>
<label className='label'>
<span className='label-text'>Intracorrelation threshold</span>
</label>
<input
type='text'
className='input input-bordered input-sm w-full max-w-xs rounded-md mb-3 bg-gray-50 border-none'
value={scheduledBatchIntraCorrelationThreshold}
className='input input-bordered input-sm w-full rounded-md mb-3 bg-gray-50 border-none'
onChange={(e) => {
setScheduledBatchIntraCorrelationThreshold(e.target.value);
dispatch(addScheduledBatchIntraCorrelationThreshold(e.target.value));
}}
/>
{
<p className='text-red-500 text-xs'>
{validateIntraCorrelationThreshold(scheduledBatchIntraCorrelationThreshold)}
</p>
}
</div>
<div className='form-control w-full max-w-xs'>
<div className='form-control w-full'>
<label className='label'>
<span className='label-text'>Differences threshold</span>
</label>
<input
type='text'
className='input input-bordered input-sm w-full max-w-xs rounded-md mb-3 bg-gray-50 border-none'
value={scheduledBatchDifferencesThreshold}
className='input input-bordered input-sm w-full rounded-md mb-3 bg-gray-50 border-none'
onChange={(e) => {
setScheduledBatchDifferencesThreshold(e.target.value);
dispatch(addScheduledBatchDifferencesThreshold(e.target.value));
}}
/>
{
<p className='text-red-500 text-xs'>
{validateDifferencesThreshold(scheduledBatchDifferencesThreshold)}
</p>
}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion platform/src/lib/store/services/collocation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const collocationSlice = createSlice({
})
.addCase(collocateDevices.rejected, (state, action) => {
state.collocateDevices.loading = false;
state.collocateDevices.error = action.error.message || '';
state.collocateDevices.error = action.error.message;
state.collocateDevices.rejected = true;
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ const selectedCollocateDevicesSlice = createSlice({
state.scheduledBatchDifferencesThreshold = action.payload;
}
},
resetBatchData: (state) => {
state.startDate = null;
state.endDate = null;
state.scheduledBatchName = '';
state.scheduledBatchDataCompletenessThreshold = 80;
state.scheduledBatchInterCorrelationThreshold = 0.98;
state.scheduledBatchIntraCorrelationThreshold = 0.98;
state.scheduledBatchDifferencesThreshold = 5;
},
},
});

Expand All @@ -83,6 +92,7 @@ export const {
addScheduledBatchDifferencesThreshold,
addScheduledBatchInterCorrelationThreshold,
addScheduledBatchIntraCorrelationThreshold,
resetBatchData,
} = selectedCollocateDevicesSlice.actions;

export default selectedCollocateDevicesSlice.reducer;
3 changes: 1 addition & 2 deletions platform/src/lib/store/services/deviceRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ const deviceRegistrySlice = createSlice({
state.status = 'loading';
})
.addCase(getCollocationDevices.fulfilled, (state, action) => {
console.log(action.payload.data);
state.status = 'succeeded';
state.collocationDevices = action.payload.data;
state.collocationDevices = action.payload.devices;
})
.addCase(getCollocationDevices.rejected, (state, action) => {
state.status = 'failed';
Expand Down
Loading
Loading