1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-08 15:25:22 +02:00

fix(toast): update styles and custom button (#7450)

EE-3829
This commit is contained in:
Ali 2022-08-10 17:07:35 +12:00 committed by GitHub
parent c3ce4d8b53
commit 7bd971f838
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 115 additions and 92 deletions

View file

@ -117,7 +117,7 @@ export function AccessControlPanelForm({
updateAccess.mutate(accessControl, {
onSuccess() {
notifySuccess('Access control successfully updated');
notifySuccess('Success', 'Access control successfully updated');
},
});
}

View file

@ -54,7 +54,7 @@ class KubernetesAppGitFormController {
}
this.state.redeployInProgress = true;
await this.StackService.updateKubeGit(this.stack.Id, this.stack.EndpointId, this.namespace, this.formValues);
this.Notifications.success('Pulled and redeployed stack successfully');
this.Notifications.success('Success', 'Pulled and redeployed stack successfully');
await this.$state.reload(this.$state.current);
} catch (err) {
this.Notifications.error('Failure', err, 'Failed redeploying application');
@ -69,7 +69,7 @@ class KubernetesAppGitFormController {
try {
this.state.saveGitSettingsInProgress = true;
await this.StackService.updateKubeStack({ EndpointId: this.stack.EndpointId, Id: this.stack.Id }, null, this.formValues);
this.Notifications.success('Save stack settings successfully');
this.Notifications.success('Success', 'Save stack settings successfully');
} catch (err) {
this.Notifications.error('Failure', err, 'Unable to save application settings');
} finally {

View file

@ -95,7 +95,7 @@ class KubernetesRedeployAppGitFormController {
}
this.state.redeployInProgress = true;
await this.StackService.updateKubeGit(this.stack.Id, this.stack.EndpointId, this.namespace, this.formValues);
this.Notifications.success('Pulled and redeployed stack successfully');
this.Notifications.success('Success', 'Pulled and redeployed stack successfully');
await this.$state.reload();
} catch (err) {
this.Notifications.error('Failure', err, 'Failed redeploying application');
@ -112,7 +112,7 @@ class KubernetesRedeployAppGitFormController {
await this.StackService.updateKubeStack({ EndpointId: this.stack.EndpointId, Id: this.stack.Id }, null, this.formValues);
this.savedFormValues = angular.copy(this.formValues);
this.state.hasUnsavedChanges = false;
this.Notifications.success('Save stack settings successfully');
this.Notifications.success('Success', 'Save stack settings successfully');
} catch (err) {
this.Notifications.error('Failure', err, 'Unable to save application settings');
} finally {

View file

@ -121,7 +121,7 @@ class StackRedeployGitFormController {
this.formValues.Option.Prune,
this.formValues
);
this.Notifications.success('Pulled and redeployed stack successfully');
this.Notifications.success('Success', 'Pulled and redeployed stack successfully');
this.$state.reload();
} catch (err) {
this.Notifications.error('Failure', err, 'Failed redeploying stack');
@ -143,7 +143,7 @@ class StackRedeployGitFormController {
);
this.savedFormValues = angular.copy(this.formValues);
this.state.hasUnsavedChanges = false;
this.Notifications.success('Save stack settings successfully');
this.Notifications.success('Success', 'Save stack settings successfully');
this.stack = stack;
} catch (err) {

View file

@ -7,10 +7,25 @@ toastr.options = {
closeButton: true,
progressBar: true,
tapToDismiss: false,
// custom button, using the feather icon x.svg inside
closeHtml: `<button type="button"><svg
xmlns="http://www.w3.org/2000/svg"
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<line x1="18" y1="6" x2="6" y2="18" />
<line x1="6" y1="6" x2="18" y2="18" />
</svg></button>`,
};
export function notifySuccess(title: string, text?: string) {
toastr.success(sanitize(_.escape(text)), sanitize(title));
export function notifySuccess(title: string, text: string) {
toastr.success(sanitize(_.escape(text)), sanitize(_.escape(title)));
}
export function notifyWarning(title: string, text: string) {

View file

@ -64,6 +64,7 @@ export function AutoEnvCreationSettingsForm({ settings }: Props) {
updateSettings(variables, {
onSuccess() {
notifySuccess(
'Success',
'Successfully updated Automatic Environment Creation settings'
);
},

View file

@ -77,7 +77,7 @@ angular.module('portainer.app').controller('AccountController', [
selectedTokens.forEach((token) => {
UserService.deleteAccessToken($scope.userID, token.id)
.then(() => {
Notifications.success('Token successfully removed');
Notifications.success('Success', 'Token successfully removed');
var index = $scope.tokens.indexOf(token);
$scope.tokens.splice(index, 1);
})

View file

@ -111,7 +111,7 @@ class CreateCustomTemplateViewController {
const userId = userDetails.ID;
await this.ResourceControlService.applyResourceControl(userId, accessControlData, customTemplate.ResourceControl);
this.Notifications.success('Custom template successfully created');
this.Notifications.success('Success', 'Custom template successfully created');
this.state.isEditorDirty = false;
this.$state.go('docker.templates.custom');
} catch (err) {

View file

@ -107,7 +107,7 @@ class CustomTemplatesViewController {
for (let template of templates) {
try {
await this.CustomTemplateService.remove(template.id);
this.Notifications.success('Removed template successfully');
this.Notifications.success('Success', 'Removed template successfully');
_.remove(this.templates, template);
} catch (err) {
this.Notifications.error('Failed removing template', err, 'Unable to remove custom template');
@ -169,7 +169,7 @@ class CustomTemplatesViewController {
const createAction = this.state.selectedTemplate.Type === 1 ? this.StackService.createSwarmStackFromFileContent : this.StackService.createComposeStackFromFileContent;
const { ResourceControl: resourceControl } = await createAction(stackName, file, [], endpointId);
await this.ResourceControlService.applyResourceControl(userId, accessControlData, resourceControl);
this.Notifications.success('Stack successfully deployed');
this.Notifications.success('Success', 'Stack successfully deployed');
this.$state.go('docker.stacks');
} catch (err) {
this.Notifications.error('Deployment error', err, 'Failed to deploy stack');

View file

@ -110,7 +110,7 @@ class EditCustomTemplateViewController {
const userId = userDetails.ID;
await this.ResourceControlService.applyResourceControl(userId, this.formValues.AccessControlData, this.formValues.ResourceControl);
this.Notifications.success('Custom template successfully updated');
this.Notifications.success('Success', 'Custom template successfully updated');
this.state.isEditorDirty = false;
this.$state.go('docker.templates.custom');
} catch (err) {

View file

@ -110,7 +110,7 @@ angular
}
}
Notifications.success('Device(s) successfully imported');
Notifications.success('Success', 'Device(s) successfully imported');
$state.go('edge.devices');
});
};

View file

@ -44,7 +44,7 @@ export default function AddProfileController($scope, $async, $state, $window, Mo
try {
await createProfile(name, method, fileContent);
Notifications.success('Profile successfully created');
Notifications.success('Success', 'Profile successfully created');
$scope.state.isEditorDirty = false;
$state.go('portainer.settings.edgeCompute');
} catch (err) {

View file

@ -44,7 +44,7 @@ export default function EditProfileController($scope, $async, $state, $window, M
try {
await updateProfile($scope.state.profileID, name, fileContent);
Notifications.success('Profile successfully updated');
Notifications.success('Success', 'Profile successfully updated');
$scope.state.isEditorDirty = false;
$state.go('portainer.settings.edgeCompute');
} catch (err) {

View file

@ -36,7 +36,7 @@ class EndpointAccessController {
try {
this.state.actionInProgress = true;
await this.EndpointService.updateEndpoint(this.$transition$.params().id, this.endpoint);
this.Notifications.success('Access successfully updated');
this.Notifications.success('Success', 'Access successfully updated');
this.$state.reload(this.$state.current);
} catch (err) {
this.state.actionInProgress = false;

View file

@ -13,7 +13,7 @@ angular.module('portainer.app').controller('GroupAccessController', [
$scope.state.actionInProgress = true;
GroupService.updateGroup($scope.group, $scope.group.AssociatedEndpoints)
.then(() => {
Notifications.success('Access successfully updated');
Notifications.success('Success', 'Access successfully updated');
$state.reload();
})
.catch((err) => {

View file

@ -17,7 +17,7 @@ angular.module('portainer.app').controller('CreateGroupController', function Cre
$scope.state.actionInProgress = true;
GroupService.createGroup(model, associatedEndpoints)
.then(function success() {
Notifications.success('Group successfully created');
Notifications.success('Success', 'Group successfully created');
$state.go('portainer.groups', {}, { reload: true });
})
.catch(function error(err) {

View file

@ -9,7 +9,7 @@ angular.module('portainer.app').controller('GroupController', function GroupCont
$scope.state.actionInProgress = true;
GroupService.updateGroup(model)
.then(function success() {
Notifications.success('Group successfully updated');
Notifications.success('Success', 'Group successfully updated');
$state.go('portainer.groups', {}, { reload: true });
})
.catch(function error(err) {

View file

@ -123,7 +123,7 @@ angular.module('portainer.app').controller('InitAdminController', [
try {
await waitPortainerRestart();
Notifications.success('The backup has successfully been restored');
Notifications.success('Success', 'The backup has successfully been restored');
$state.go('portainer.auth');
} catch (err) {
handleError(err);

View file

@ -126,7 +126,7 @@ class CreateRegistryController {
try {
this.state.actionInProgress = true;
await this.RegistryService.createGitlabRegistries(this.model, this.state.gitlab.selectedItems);
this.Notifications.success('Registries successfully created');
this.Notifications.success('Success', 'Registries successfully created');
this.$state.go(this.state.originViewReference, { endpointId: this.state.originalEndpointId });
} catch (err) {
this.Notifications.error('Failure', err, 'Unable to create registries');
@ -140,7 +140,7 @@ class CreateRegistryController {
try {
this.state.actionInProgress = true;
await this.RegistryService.createRegistry(this.model);
this.Notifications.success('Registry successfully created');
this.Notifications.success('Success', 'Registry successfully created');
this.$state.go(this.state.originViewReference, { endpointId: this.state.originalEndpointId });
} catch (err) {
this.Notifications.error('Failure', err, 'Unable to create registry');

View file

@ -54,7 +54,7 @@ export default class RegistryController {
registry.Password = this.Password;
await this.RegistryService.updateRegistry(registry);
this.Notifications.success('Registry successfully updated');
this.Notifications.success('Success', 'Registry successfully updated');
this.$state.go('portainer.registries');
} catch (err) {
this.Notifications.error('Failure', err, 'Unable to update registry');

View file

@ -109,7 +109,7 @@ function SettingsAuthenticationController($q, $scope, $state, Notifications, Set
.then(function success() {
$scope.state.failedConnectivityCheck = false;
$scope.state.successfulConnectivityCheck = true;
Notifications.success('Connection to LDAP successful');
Notifications.success('Success', 'Connection to LDAP successful');
})
.catch(function error(err) {
$scope.state.failedConnectivityCheck = true;
@ -136,7 +136,7 @@ function SettingsAuthenticationController($q, $scope, $state, Notifications, Set
return SettingsService.update(settings);
})
.then(function success() {
Notifications.success('Authentication settings updated');
Notifications.success('Success', 'Authentication settings updated');
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to update authentication settings');

View file

@ -12,7 +12,7 @@ export default function SettingsEdgeComputeController($q, $async, $state, Notifi
this.onSubmitEdgeCompute = async function (settings) {
try {
await SettingsService.update(settings);
Notifications.success('Settings updated');
Notifications.success('Success', 'Settings updated');
StateManager.updateEnableEdgeComputeFeatures(settings.EnableEdgeComputeFeatures);
$state.reload();
} catch (err) {
@ -23,7 +23,7 @@ export default function SettingsEdgeComputeController($q, $async, $state, Notifi
this.onSubmitOpenAMT = async function (formValues) {
try {
await configureAMT(formValues);
Notifications.success(`OpenAMT successfully ${formValues.enabled ? 'enabled' : 'disabled'}`);
Notifications.success('Success', `OpenAMT successfully ${formValues.enabled ? 'enabled' : 'disabled'}`);
$state.reload();
} catch (err) {
Notifications.error('Failure', err, 'Failed applying changes');
@ -33,7 +33,7 @@ export default function SettingsEdgeComputeController($q, $async, $state, Notifi
this.onSubmitFDO = async function (formValues) {
try {
await configureFDO(formValues);
Notifications.success(`FDO successfully ${formValues.enabled ? 'enabled' : 'disabled'}`);
Notifications.success('Success', `FDO successfully ${formValues.enabled ? 'enabled' : 'disabled'}`);
$state.reload();
} catch (err) {
Notifications.error('Failure', err, 'Failed applying changes');

View file

@ -112,7 +112,7 @@ angular.module('portainer.app').controller('SettingsController', [
.then(function success(data) {
const downloadData = new Blob([data.file], { type: 'application/gzip' });
FileSaver.saveAs(downloadData, data.name);
Notifications.success('Backup successfully downloaded');
Notifications.success('Success', 'Backup successfully downloaded');
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to download backup');
@ -138,7 +138,7 @@ angular.module('portainer.app').controller('SettingsController', [
function updateSettings(settings) {
SettingsService.update(settings)
.then(function success() {
Notifications.success('Settings updated');
Notifications.success('Success', 'Settings updated');
StateManager.updateLogo(settings.LogoURL);
StateManager.updateSnapshotInterval(settings.SnapshotInterval);
StateManager.updateEnableTelemetry(settings.EnableTelemetry);

View file

@ -264,7 +264,7 @@ angular
return ResourceControlService.applyResourceControl(userId, accessControlData, resourceControl);
})
.then(function success() {
Notifications.success('Stack successfully deployed');
Notifications.success('Success', 'Stack successfully deployed');
$scope.state.isEditorDirty = false;
$state.go('docker.stacks');
})

View file

@ -115,7 +115,7 @@ angular.module('portainer.app').controller('StackController', [
return StackService.duplicateStack(name, $scope.stackFileContent, env, targetEndpointId, stack.Type).then(onDuplicationSuccess).catch(notifyOnError);
function onDuplicationSuccess() {
Notifications.success('Stack successfully duplicated');
Notifications.success('Success', 'Stack successfully duplicated');
$state.go('docker.stacks', {}, { reload: true });
// sets back the original endpointID as global for interceptors
EndpointProvider.setEndpointID(stack.EndpointId);
@ -266,7 +266,7 @@ angular.module('portainer.app').controller('StackController', [
$scope.state.actionInProgress = true;
StackService.updateStack(stack, stackFile, env, prune)
.then(function success() {
Notifications.success('Stack successfully deployed');
Notifications.success('Success', 'Stack successfully deployed');
$scope.state.isEditorDirty = false;
$state.reload();
})

View file

@ -92,7 +92,7 @@ angular.module('portainer.app').controller('TeamController', [
}
$scope.teamMembers = $scope.teamMembers.concat(users);
$scope.users = [];
Notifications.success('All users successfully added');
Notifications.success('Success', 'All users successfully added');
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to update team members');
@ -123,7 +123,7 @@ angular.module('portainer.app').controller('TeamController', [
$scope.users = $scope.users.concat($scope.teamMembers);
$scope.teamMembers = [];
$scope.leaderCount = 0;
Notifications.success('All users successfully removed');
Notifications.success('Success', 'All users successfully removed');
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to update team members');

View file

@ -117,7 +117,7 @@ angular.module('portainer.app').controller('TemplatesController', [
return ResourceControlService.applyResourceControl(userId, accessControlData, resourceControl, generatedVolumeIds);
})
.then(function success() {
Notifications.success('Container successfully created');
Notifications.success('Success', 'Container successfully created');
$state.go('docker.containers', {}, { reload: true });
})
.catch(function error(err) {
@ -151,7 +151,7 @@ angular.module('portainer.app').controller('TemplatesController', [
return ResourceControlService.applyResourceControl(userId, accessControlData, resourceControl);
})
.then(function success() {
Notifications.success('Stack successfully deployed');
Notifications.success('Success', 'Stack successfully deployed');
$state.go('docker.stacks');
})
.catch(function error(err) {
@ -190,7 +190,7 @@ angular.module('portainer.app').controller('TemplatesController', [
return ResourceControlService.applyResourceControl(userId, accessControlData, resourceControl);
})
.then(function success() {
Notifications.success('Stack successfully deployed');
Notifications.success('Success', 'Stack successfully deployed');
$state.go('docker.stacks');
})
.catch(function error(err) {

View file

@ -61,7 +61,7 @@ angular.module('portainer.app').controller('UserController', [
}
UserService.updateUser($scope.user.Id, { role, username })
.then(function success() {
Notifications.success('User successfully updated');
Notifications.success('Success', 'User successfully updated');
$state.reload();
})
.catch(function error(err) {
@ -77,7 +77,7 @@ angular.module('portainer.app').controller('UserController', [
}
UserService.updateUser($scope.user.Id, { password: $scope.formValues.newPassword })
.then(function success() {
Notifications.success('Password successfully updated');
Notifications.success('Success', 'Password successfully updated');
if (isCurrentUser) {
$state.go('portainer.logout');