mirror of
https://github.com/portainer/portainer.git
synced 2025-08-09 07:45:22 +02:00
fix(frontend) prevent notification showing Object Object EE-1745 (#5778)
* fix(frontend) prevent notification showing Object Object EE-1745 * fix(frontend) fix notification args in wrong order EE-1745 * fix(rbac) add metrics rbac for regular users EE-1745 Co-authored-by: Simon Meng <simon.meng@portainer.io>
This commit is contained in:
parent
d93d88fead
commit
6a67e8142d
11 changed files with 45 additions and 35 deletions
|
@ -1,5 +1,6 @@
|
|||
import _ from 'lodash-es';
|
||||
import toastr from 'toastr';
|
||||
import lodash from 'lodash-es';
|
||||
|
||||
angular.module('portainer.app').factory('Notifications', [
|
||||
'$sanitize',
|
||||
|
@ -15,31 +16,35 @@ angular.module('portainer.app').factory('Notifications', [
|
|||
toastr.warning($sanitize(_.escape(text)), $sanitize(title), { timeOut: 6000 });
|
||||
};
|
||||
|
||||
function pickErrorMsg(e) {
|
||||
const props = [
|
||||
'err.data.details',
|
||||
'err.data.message',
|
||||
'data.details',
|
||||
'data.message',
|
||||
'data.content',
|
||||
'data.error',
|
||||
'message',
|
||||
'err.data[0].message',
|
||||
'err.data.err',
|
||||
'data.err',
|
||||
'msg',
|
||||
];
|
||||
|
||||
let msg = '';
|
||||
|
||||
lodash.forEach(props, (prop) => {
|
||||
const val = lodash.get(e, prop);
|
||||
if (typeof val === 'string') {
|
||||
msg = msg || val;
|
||||
}
|
||||
});
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
service.error = function (title, e, fallbackText) {
|
||||
var msg = fallbackText;
|
||||
if (e.err && e.err.data && e.err.data.details && typeof e.err.data.details === 'string') {
|
||||
msg = e.err.data.details;
|
||||
} else if (e.err && e.err.data && e.err.data.message) {
|
||||
msg = e.err.data.message;
|
||||
} else if (e.data && e.data.details) {
|
||||
msg = e.data.details;
|
||||
} else if (e.data && e.data.message) {
|
||||
msg = e.data.message;
|
||||
} else if (e.data && e.data.content) {
|
||||
msg = e.data.content;
|
||||
} else if (e.data && e.data.error) {
|
||||
msg = e.data.error;
|
||||
} else if (e.message) {
|
||||
msg = e.message;
|
||||
} else if (e.err && e.err.data && e.err.data.length > 0 && e.err.data[0].message) {
|
||||
msg = e.err.data[0].message;
|
||||
} else if (e.err && e.err.data && e.err.data.err) {
|
||||
msg = e.err.data.err;
|
||||
} else if (e.data && e.data.err) {
|
||||
msg = e.data.err;
|
||||
} else if (e.msg) {
|
||||
msg = e.msg;
|
||||
}
|
||||
const msg = pickErrorMsg(e) || fallbackText;
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(e);
|
||||
|
|
|
@ -61,7 +61,7 @@ class InitEndpointController {
|
|||
case PortainerEndpointConnectionTypes.AGENT:
|
||||
return this.createAgentEndpoint();
|
||||
default:
|
||||
this.Notifications.error('Failure', 'Unable to determine which action to do to create environment');
|
||||
this.Notifications.error('Failure', null, 'Unable to determine which action to do to create environment');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ export default class WizardAciController {
|
|||
// Check name is duplicated or not
|
||||
let nameUsed = await this.NameValidator.validateEnvironmentName(name);
|
||||
if (nameUsed) {
|
||||
this.Notifications.error('Failure', true, 'This name is been used, please try another one');
|
||||
this.Notifications.error('Failure', null, 'This name is been used, please try another one');
|
||||
return;
|
||||
}
|
||||
await this.EndpointService.createAzureEndpoint(name, azureApplicationId, azureTenantId, azureAuthenticationKey, groupId, tagIds);
|
||||
|
|
|
@ -65,7 +65,7 @@ export default class WizardDockerController {
|
|||
// Check name is duplicated or not
|
||||
const nameUsed = await this.NameValidator.validateEnvironmentName(name);
|
||||
if (nameUsed) {
|
||||
this.Notifications.error('Failure', true, 'This name is been used, please try another one');
|
||||
this.Notifications.error('Failure', null, 'This name is been used, please try another one');
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
|
|
|
@ -33,7 +33,7 @@ export default class WizardKubernetesController {
|
|||
// Check name is duplicated or not
|
||||
let nameUsed = await this.NameValidator.validateEnvironmentName(name);
|
||||
if (nameUsed) {
|
||||
this.Notifications.error('Failure', true, 'This name is been used, please try another one');
|
||||
this.Notifications.error('Failure', null, 'This name is been used, please try another one');
|
||||
return;
|
||||
}
|
||||
await this.addRemoteEndpoint(name, creationType, url, publicUrl, groupId, tagIds, tls, tlsSkipVerify, tlsSkipClientVerify, tlsCaFile, tlsCertFile, tlsKeyFile);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue