Skip to content

[IMPAC-335] Multiple Recipients - #292

Merged
xaun merged 16 commits into
maestrano:release/1.4.8from
adamaziz15:feature/335-multiple-recipients
Feb 9, 2017
Merged

xaun merged 16 commits into
maestrano:release/1.4.8from
adamaziz15:feature/335-multiple-recipients

Conversation

@adamaziz15

Copy link
Copy Markdown
Contributor

No description provided.

@xaun
xaun changed the base branch from master to release/1.5.0 January 18, 2017 15:27
@xaun

xaun commented Jan 18, 2017

Copy link
Copy Markdown
Contributor

@adamaziz15
adamaziz15 force-pushed the feature/335-multiple-recipients branch from aabb2e2 to 3161de3 Compare January 18, 2017 15:34
@adamaziz15 adamaziz15 changed the title [IMPAC-335] Multiple Recipients [IMPAC-335] [WIP] Multiple Recipients Jan 18, 2017
@adamaziz15

adamaziz15 commented Jan 20, 2017

Copy link
Copy Markdown
Contributor Author

@xaun @cesar-tonnoir I have begun modifying the frontend to send up multiple recipients when creating an alert. My first concern was to make sure the data was going to mno-hub properly so that it could be used to create the alert. This is where I got a little stuck, I think her is removing the data from params. I am not too familiar with it so I am still figuring things out. 😅

Update: I think I'm on the right track. Let me know if you guys think I should approach this differently. It looks like I'd have to change the alerts controller a bit in mnoe to allow for the recipients to be passed through to the resources controller in mno-hub.

@xaun
xaun changed the base branch from release/1.5.0 to release/1.4.8 January 23, 2017 17:55
@adamaziz15
adamaziz15 force-pushed the feature/335-multiple-recipients branch from 6d9a3a3 to 1056ec8 Compare January 23, 2017 18:03
Comment thread src/services/kpis/kpis.svc.coffee Outdated

for alert in alertsToCreate
promises.push ImpacAlerts.create(kpi.id, { alert: _.pick(alert, ['service']) })
promises.push ImpacAlerts.create(kpi.id, { alert: _.pick(alert, ['service']), recipients: alert.recipients })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@adamaziz15 an in-app alert wont have key recipients, maybe do a merge if service is email instead.

@adamaziz15

Copy link
Copy Markdown
Contributor Author

@xaun I've improved the UI to initialize org members as active or inactive so that in the alerts modal it will show who is already receiving the alert. I've also added the appropriate functions to all of the services needed to allow for updating alerts.

@adamaziz15 adamaziz15 changed the title [IMPAC-335] [WIP] Multiple Recipients [IMPAC-335] Multiple Recipients Jan 26, 2017
@adamaziz15

Copy link
Copy Markdown
Contributor Author

@cesar-tonnoir @xaun Should be ready to go 👍 , Please Review.

@xaun xaun left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi Adam, good work with this 👍 here are some suggested changes :)

$compile(alertsConfig.contents())(scope)

controller: ($scope) ->
$scope.members = [{email: "example@maestrano.io"},{email: "example@maestrano.io"},{email: "example@maestrano.io"},{email: "example@maestrano.io"}]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should probably remove these hardcoded members :)

(config) ->
$scope.members = config.currentOrgMembers
#Sets current state of recipients for email alerts
email_alert = _.filter($scope.kpi.alerts, (alert) -> alert.service == 'email')[0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_.find() would be better here for what you're doing as it returns the first match.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, this is javascript/coffeescript, no snake-case unless accessing an object property returned from a ruby API. Please rename to emailAlert.

for member in $scope.members
member.active = true if email_recipients.includes(member.id)
else
_.filter($scope.members, (member) -> member.email == config.userData.email)[0].active = true

@xaun xaun Jan 27, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If for some reason $scope.members doesn't contain the currentUsers email how will this behave?
Should do something like?:

currentUserMember = _.find($scope.members, (member) -> member.email == config.userData.email)
currentUserMember.active = true if currentUserMember

label: "By sending me an email to:"
}

$scope.search = { text: "" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should give this a more specific name?

#Sets current state of recipients for email alerts
email_alert = _.filter($scope.kpi.alerts, (alert) -> alert.service == 'email')[0]
if email_alert
email_recipients = email_alert.recipients.map((recipient) -> recipient.id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we rename this emailAlertRecipients


$scope.onKeyPress = (event) ->
if event.which == 13
recipient = _.filter($scope.members, (member) -> member.email == $scope.search.text)[0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_.find() instead

{{member.email}}
<button type="button" class="close" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doesn't look like this remove button is hooked up to a method?

@adamaziz15 adamaziz15 Jan 30, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because the ng-click directive is on the < li > element it is triggered when the button is clicked. The button is really there more for UX purposes as it makes clearer which members are receiving the alert as well as how to remove them.


<ul class="list-group recipients-list available" ng-show="showRecipientList(alert)">

<li class="list-group-item" ng-repeat="member in members | filter:search.text" ng-hide="member.active" ng-click="toggleRecipient(member)">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Like above, ng-if="!member.active" to remove element from dom.

Comment thread src/services/kpis/kpis.svc.coffee Outdated

# Update existing alerts that have been modified
alertsToUpdate = _.filter(alerts, (alert) ->
active_alert = _.filter(kpi.alerts, (kpi_alert) -> kpi_alert.service == alert.service)[0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rename to existingAlertand use _.find()

Comment thread src/services/kpis/kpis.svc.coffee Outdated
recipient_change = false
recipient_change = true if recipient_ids.length != active_ids.length
for i in [0...recipient_ids.length]
recipient_change = true if recipient_ids[i] != active_ids[i]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lets simplify the change detection above by comparing the arrays like so: "#{[1, 3, 2].sort()}" == "#{[2, 1, 3].sort()}", also I think it should be clear with the variable naming what is existing and what is new. So naming active_ids to existingActiveIds etc.

@xaun

xaun commented Jan 27, 2017

Copy link
Copy Markdown
Contributor

Hi @adamaziz15 will post this here for other reviewers, as discussed in slack if we could also adjust / add these things:

  1. hide suggestions box unless there are suggestions available, and input is focused.
  2. Change placeholder of input to something more verbose e.g “Add recipients in your Organization by email” .. if that’s too long, maybe a sleek label would help users understand what the input is for, and who they can invite?
  3. The whole expanded area of the email alert section has a cursor: pointer effect, this should probably be adjusted for only clickable things.
  4. Navigate down suggestions with up & down arrow keys

🍻!

@cesar-tonnoir
cesar-tonnoir requested review from cesar-tonnoir and removed request for cesar-tonnoir January 30, 2017 04:32
@cesar-tonnoir

Copy link
Copy Markdown
Contributor

@xaun / @adamaziz15 From what I've seen so far I think this won't be a problem, but please verify that there is no backward incompatibility with mno-enterprise (= if you upgrade impac-angular without upgrading mno-enterprise, you can still add alerts with recipients)

@adamaziz15

Copy link
Copy Markdown
Contributor Author

@cesar-tonnoir @xaun I made a few changes to make sure there is no issue with backward-compatibility and tested everything. Seems to work with no issues. Please review, should be all set 👌

@xaun
xaun merged commit 418983a into maestrano:release/1.4.8 Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants