Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Implement Toast Service #350

Merged
merged 21 commits into from
Oct 25, 2017
Merged

Implement Toast Service #350

merged 21 commits into from
Oct 25, 2017

Conversation

alexbarnsley
Copy link
Member

@fix @luciorubeens please take a look and see if this is implemented the way you were looking for. As I said in the issue, I've replaced all existing toasts to use the Service, but have set them up as either SUCCESS or ERROR. Please see below as I've added colours for each toast - GitHub has blown the images up so they're not that blurry in practice.

Config can be changed in client/app/config/config.js:

logFile - true or false - appends to logs/ark.log if enabled.
level - what log messages to show/log. Below is the mapping - this value shows itself and above (E.g. 1 shows ERROR and SUCCESS messages)
defaultHideDelay - how long until the toast disappears. Some places have been overridden, but the majority will use this value

Logging Enum

0: ERROR
1: SUCCESS
2: WARN
3: LOG
4: DEBUG

ERROR
image

SUCCESS
image

WARN
image

LOG
image

DEBUG
image

Resolves #344

Copy link

@spresnal spresnal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to utilize string interpolation in the toast messages. Also, I'm undecided on whether we need the 3000ms toast messages vs using 5000ms across the board as the default.

Nice work!

.hideDelay(hideDelay || self.hideDelay)
.textContent(message);
if (typeName) {
toast.theme(self.TypeName[type]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to use typename here vs self.TypeName[type]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice spot! :)


self.show = function(message, type, hideDelay, stopTranslate) {
if (type > self.loggingType) {
return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should log an error here before returning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh it may be worth doing this. I will get it to log all messages to the log file, if enabled.

'use strict';

angular.module('arkclient.services')
.service('configService', ['$mdToast', 'gettextCatalog', ConfigService]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some of these services aren't being used

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I removed the parameters from the constructor, but not here!

* ToastService
* @constructor
*/
function ToastService(configService, $mdToast, gettextCatalog) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getTextCatalog*

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is passed in. I agree, I'd use camelcase normally but wanted to keep it consistent with the value on line 6/7 (as well as other places like account.controller.js):

angular.module('arkclient.services')
  .service('toastService', ['configService', '$mdToast', 'gettextCatalog', ToastService]);

return;
}
self.fileStream.write(
'[' + new Date().toISOString() + '] ' + (typeName ? typeName.toUpperCase() + ': ' : '') + message + '\n'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would look a bit cleaner to use string interpolation here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, will do :)

@alexbarnsley
Copy link
Member Author

Thanks @spresnal! I've made all your changes aside from the camel case comment, if you'd like to take a look at my response :)

I agree with the hideDelay. I just kept it consistent with current functionality for now with the option of changing in the future if needed. Would be good to get the opinion of @fix and/or @luciorubeens, as to whether it's something we need to worry about.

Copy link

@spresnal spresnal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@luciorubeens luciorubeens merged commit 841c87a into ArkEcosystem:master Oct 25, 2017
@luciorubeens
Copy link
Contributor

Great! +10 to ConfigService and ToastService 👍🏻

alexbarnsley pushed a commit that referenced this pull request Dec 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants