(type, error, promptmsg, onJSONResult)
| 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. |
no test coverage detected