MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / pgNotifier

Method pgNotifier

web/pgadmin/static/js/helpers/Notifier.jsx:127–163  ·  view source on GitHub ↗
(type, error, promptmsg, onJSONResult)

Source from the content-addressed store, hash-verified

125 }
126
127 pgNotifier(type, error, promptmsg, onJSONResult) {
128 let msg;
129
130 if(!error.response) {
131 msg = parseApiError(error);
132 promptmsg = gettext('Connection Lost');
133 } else if(error.response.headers['content-type'] == 'application/json') {
134 let resp = error.response.data;
135 if(resp.info == 'CRYPTKEY_MISSING') {
136 let pgBrowser = window.pgAdmin.Browser;
137 pgBrowser.set_master_password('', ()=> {
138 if(onJSONResult && typeof(onJSONResult) == 'function') {
139 onJSONResult('CRYPTKEY_SET');
140 }
141 }, ()=> {
142 if(onJSONResult && typeof(onJSONResult) == 'function') {
143 onJSONResult('CRYPTKEY_NOT_SET');
144 }
145 });
146 return;
147 } else if (resp.result != null && (!resp.errormsg || resp.errormsg == '') &&
148 onJSONResult && typeof(onJSONResult) == 'function') {
149 return onJSONResult(resp.result);
150 }
151 msg = resp.result || resp.errormsg || 'Unknown error';
152 } else {
153 if (type === 'error') {
154 this.alertText('Error', promptmsg);
155 }
156 return;
157 }
158 if(type == 'error-noalert' && onJSONResult && typeof(onJSONResult) == 'function') {
159 return onJSONResult();
160 }
161 this.alertText(promptmsg, msg);
162 onJSONResult?.('ALERT_CALLED');
163 }
164
165 alert(title, text, onOkClick, okLabel=gettext('OK')) {
166 /* Use this if you want to use pgAdmin global notifier.

Callers 10

onFailureFunction · 0.80
onFailureFunction · 0.80
connectServerFunction · 0.80
baseFieldsMethod · 0.80
StatisticsFunction · 0.80
initDataFunction · 0.80
onSaveClickFunction · 0.80
connectExistingServerFunction · 0.80
onSaveClickFunction · 0.80
Notifier.spec.jsFile · 0.80

Calls 3

alertTextMethod · 0.95
parseApiErrorFunction · 0.90
gettextFunction · 0.85

Tested by

no test coverage detected