Skip to content

Commit 71cc0f7

Browse files
author
Bogdan Tsechoev
committed
Merge branch 'dblab-notifications' into 'master'
DBLab email notifications settings See merge request postgres-ai/database-lab!984
2 parents e838cc8 + f073aec commit 71cc0f7

File tree

10 files changed

+644
-1
lines changed

10 files changed

+644
-1
lines changed

ui/packages/platform/src/actions/actions.js

+37
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const Actions = Reflux.createActions([{
5656
createOrg: ASYNC_ACTION,
5757
updateAiBotSettings: ASYNC_ACTION,
5858
updateAuditSettings: ASYNC_ACTION,
59+
updateDBLabSettings: ASYNC_ACTION,
5960
inviteUser: ASYNC_ACTION,
6061
useDemoData: ASYNC_ACTION,
6162
setReportsProject: {},
@@ -730,6 +731,42 @@ Actions.updateAuditSettings.listen(function (token, orgId, orgData) {
730731
});
731732
});
732733

734+
Actions.updateDBLabSettings.listen(function (token, orgId, orgData) {
735+
let action = this;
736+
737+
if (!api) {
738+
settings.init(function () {
739+
api = new Api(settings);
740+
});
741+
}
742+
743+
action.progressed({ orgId } + orgData);
744+
timeoutPromise(REQUEST_TIMEOUT, api.updateDBLabSettings(token, orgId, orgData))
745+
746+
.then(result => {
747+
result.json()
748+
.then(json => {
749+
if (json) {
750+
action.completed(json);
751+
} else {
752+
action.failed(new Error('wrong_reply'));
753+
}
754+
})
755+
.catch(err => {
756+
console.error(err);
757+
action.failed(new Error('wrong_reply'));
758+
});
759+
})
760+
.catch(err => {
761+
console.error(err);
762+
if (err && err.message && err.message === 'timeout') {
763+
action.failed(new Error('failed_fetch'));
764+
} else {
765+
action.failed(new Error('wrong_reply'));
766+
}
767+
});
768+
});
769+
733770
Actions.createOrg.listen(function (token, orgData) {
734771
let action = this;
735772

ui/packages/platform/src/api/api.js

+29
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ class Api {
132132
body.last_name = data.last_name;
133133
}
134134

135+
if (data.dblab_low_disk_space_notifications_enabled !== 'undefined') {
136+
body.dblab_low_disk_space_notifications_enabled = data.dblab_low_disk_space_notifications_enabled;
137+
}
138+
139+
if (data.dblab_old_clones_notifications_enabled !== 'undefined') {
140+
body.dblab_old_clones_notifications_enabled = data.dblab_old_clones_notifications_enabled;
141+
}
142+
135143
return this.post(`${this.apiServer}/rpc/update_user_profile`, body, {
136144
headers: headers
137145
});
@@ -528,6 +536,27 @@ class Api {
528536
});
529537
}
530538

539+
updateDBLabSettings(token, orgId, orgData) {
540+
let params = {};
541+
let headers = {
542+
Authorization: 'Bearer ' + token,
543+
prefer: 'return=representation'
544+
};
545+
546+
if (typeof orgData.dblab_low_disk_space_notifications_threshold_percent !== 'undefined') {
547+
params.dblab_low_disk_space_notifications_threshold_percent = orgData.dblab_low_disk_space_notifications_threshold_percent
548+
}
549+
550+
if (typeof orgData.dblab_old_clones_notifications_threshold_hours !== 'undefined') {
551+
params.dblab_old_clones_notifications_threshold_hours = orgData.dblab_old_clones_notifications_threshold_hours
552+
}
553+
554+
return this.patch(`${this.apiServer}/orgs?id=eq.` + orgId, params, {
555+
headers: headers
556+
});
557+
}
558+
559+
531560
testSiemServiceConnection(token, data) {
532561
let params = {};
533562
let headers = {

0 commit comments

Comments
 (0)