Skip to content

Commit

Permalink
Merge pull request #617 from statonlab/616-report-observation-notific…
Browse files Browse the repository at this point in the history
…ations-not-working

notify_user now gets a value of 1 in the db
  • Loading branch information
florence-77 authored Apr 2, 2024
2 parents b7714d5 + 57d24dc commit dd68612
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/SendFilterNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SendFilterNotifications extends Command
*
* @var string
*/
protected $signature = 'notify:filters {-p|--print=0}';
protected $signature = 'notify:filters {--print}';

/**
* The console command description.
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/FiltersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function create(Request $request, $with_observations = false)
'user_id' => $user->id,
'name' => $request->name,
'rules' => $request->all(),
'notify_user' => false,
'notify_user' => $request->notify_user,
]);
}

Expand Down
9 changes: 8 additions & 1 deletion resources/assets/js/components/AdvancedFiltersModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default class AdvancedFiltersModal extends Component {
endDate : null,
groups : [],
selectedGroup : -1,
notify_user : true,
}
}

Expand Down Expand Up @@ -128,6 +129,7 @@ export default class AdvancedFiltersModal extends Component {
start: this.state.startDate ? this.state.startDate.format('YYYY-MM-DD') : null,
end : this.state.endDate ? this.state.endDate.format('YYYY-MM-DD') : null,
},
notify_user : this.state.notify_user,
}

if (this.props.applyFilters) {
Expand Down Expand Up @@ -168,6 +170,10 @@ export default class AdvancedFiltersModal extends Component {

this.setState({loading: false})
})

if(this.state.notify_user == true){
console.log('triggered')
}
}

count(changed) {
Expand Down Expand Up @@ -204,6 +210,7 @@ export default class AdvancedFiltersModal extends Component {
start: this.state.startDate ? this.state.startDate.format('YYYY-MM-DD') : null,
end : this.state.endDate ? this.state.endDate.format('YYYY-MM-DD') : null,
},
notify_user : filters.notify_user
}).then(response => {
this.setState({
loading : false,
Expand Down Expand Up @@ -538,7 +545,7 @@ export default class AdvancedFiltersModal extends Component {
<div className="field">
<div className="control">
<label className="label checkbox">
<input type="checkbox" className="mr-0" defaultChecked={false}/>
<input type="checkbox" className="mr-0" defaultChecked={this.state.notify_user}/>
Notify me via email if new observations fitting this criteria get submitted
</label>
<p className="help mr-1">Maximum of 3 emails per week.</p>
Expand Down

0 comments on commit dd68612

Please sign in to comment.