Commit Graph

1991 Commits

Author SHA1 Message Date
Chris Hill-Scott
33b18cedeb Revert "Comment out ajax queries to update content on frontend."
This reverts commit 651584d056.

Should be safe to turn the AJAX back on now it’s not going to
denial-of-service any slow pages.
2016-06-12 14:16:27 +01:00
Chris Hill-Scott
940170159a Handle AJAX errors when updating content
With the change in implementation in the previous commit, any error
(eg server responds with `500`) would cause the page to not be updated
again.

This is better than the previous implementation, whereby the browser
would re-request as fast as it could until it got a successful response.

This commit handles errors by clearing the render queue if the server
returns an error. So:

- Any updates that would have been performed based on this request are
  dropped
- Subsequent updates will be attempted as if it was the first load of
  the page, ie after a delay of `x` seconds
2016-06-12 14:16:27 +01:00
Chris Hill-Scott
9c92a2bd86 Stop AJAX updates queuing requests
The `updateContent` module updates a section of the page based on an
AJAX request.

The current implementation will poll every `x` seconds. If the server
takes a long time to respond, this results in a the browser queuing up
requests. If a particular endpoint is slow, this can result in one
client making enough requests to slow down the whole server, to the
point where it gets removed from the loadbalancer, eventually bringing
the whole site down.

This commit rewrites the module so that it queues up the render
operations, not the requests.

There is one queue per endpoint, so for
`http://example.com/endpoint.json`:

1. Queue is empty
```javascript
{
  'http://example.com/endpoint.json': []
}
```

2. Inital re-render is put on the queue…
```javascript
{
  'http://example.com/endpoint.json': [
    function render(){…}
  ]
}
```

…AJAX request fires
```
GET http://example.com/endpoint.json
```

3. Every `x` seconds, another render operation is put on the queue
```javascript
{
  'http://example.com/endpoint.json': [
    function render(){…},
    function render(){…},
    function render(){…}
  ]
}
```

4. AJAX request returns queue is flushed by executing each queued
render function in sequence
```javascript
render(response); render(response); render(response);
```
```javascript
{
  'http://example.com/endpoint.json': []
}
```

5. Repeat

This means that, at most, the AJAX requests will never fire more than
once every `x` seconds, where `x` defaults to `1.5`.
2016-06-12 14:15:04 +01:00
NIcholas Staples
50a81a96a3 Merge pull request #670 from alphagov/remove_ajax_calls
Comment out ajax queries to update content on frontend.
2016-06-10 14:00:50 +01:00
Nicholas Staples
651584d056 Comment out ajax queries to update content on frontend. 2016-06-10 12:31:35 +01:00
Chris Hill-Scott
6f0f91e9a7 Merge pull request #667 from alphagov/make-tables-line-up
Make tables line up
2016-06-09 13:25:19 +01:00
Chris Hill-Scott
04ef730fd1 Remove redundant if statement on job page
We had this if statement to lay out the table differently with and
without row numbers.

Since we don’t show row numbers at all, this isn’t needed.
2016-06-09 11:36:22 +01:00
Chris Hill-Scott
a9f79bcf07 Truncate items that don’t fit in the first column
The first column of a table is a heading, and will always be 50% wide.

It makes the table harder to scan when the information in the first
column breaks onto multiple lines, and introduces uneven whitespace in
the table.

This commit adds some CSS to force things in the first column to only
ever be one line. If they are too long to fit, they get truncated with
an ellipsis (`…`)
2016-06-09 11:36:22 +01:00
Chris Hill-Scott
2e8e650733 Put same info in both tables of notifications
We have tables listing notifications on:
- the job page
- the ‘activity’ page

Previously that had subtly different information, in a different order.
This commit makes them exactly the same.
2016-06-09 11:36:22 +01:00
Chris Hill-Scott
c31762265c Colour code notification statuses
Makes the table easier to scan.

Delivered stays as before.

Sending is greyed out.

All other statuses are failure, and stand out by being red and bold.
2016-06-09 11:36:22 +01:00
Chris Hill-Scott
d213e2cc67 Give each row in a table a heading
The first columns of our tables are always headings for the
subsequent columns, even though they go horizontally.

HTML has the `<th>` tag, which doesn’t just have to be used for headings
along the top of a table. So this commit changes the first column to be
a `<th>`.

This then allows us to style these elements differently, specifically
making them 50% wide. This makes pages like the dashboard align more
nicely.
2016-06-09 11:36:22 +01:00
Chris Hill-Scott
b1852f4b78 Make permanent failure status more human
Replace with ‘Phone number doesn’t exist’ or ‘Email address doesn’t’
exist.
2016-06-09 11:36:21 +01:00
Chris Hill-Scott
0a337a2663 On the activity page, only link to template or job
If the notification has come from an API call, the template is the
only thing that exists

If it’s a job, then we need to tell you name of the file. But you can
click though to see the template.
2016-06-09 11:06:53 +01:00
Adam Shimali
d005406682 Merge pull request #661 from alphagov/invite-accepted-bug
Change when invite gets marked as accepted.
2016-06-08 13:32:20 +01:00
Chris Hill-Scott
29f8b94612 Merge pull request #657 from alphagov/make-activity-consistent
Make activity consistent
2016-06-08 12:57:07 +01:00
Pete Herlihy
94e88cf6f7 Merge pull request #647 from alphagov/placeholder-appearance
Make placeholders look more consistent and editable
2016-06-08 12:20:35 +01:00
Adam Shimali
0544ea776b Change when invite gets marked as accepeted. 2016-06-08 11:52:26 +01:00
Chris Hill-Scott
3d7f07493b Add filters for ‘processed’ and sending states
- _Processed_ is all the notifications that we know about, ie sending,
  failed and delivered

- _Sending_ is notifications that we have either put into a queue or are
  waiting to hear back from the provider about.

The big numbers on the dashboard are a count of all the messages we’ve
processed. So when you click them, the table of notifications you see
on the dashboard should contain that number of notifications.

This also gets the activity page one step closer to being like the job
page:

         | Before                     | After
---------|----------------------------|---------------------------------
Activity | Sending, failed, both      | Processed, sending, failed, delivered
Job page | Sending, failed, delivered | Sending, failed, delivered
2016-06-07 16:37:06 +01:00
Chris Hill-Scott
8d7850ead1 Use .csv extension not querystring parameter
The link to download a CSV of notifications looks like
`/endpoint?download=csv`. This not not very web idiomatic.

The service manual recommends:
> Only use query strings for URLs with unordered parameters like options
> to search pages.

The CSV is a different representation of the same data, it does not
perform searching or filtering on the data.

The proper way (as we do elsewhere in this app) is to put an extension
on the endpoint to indicate an alternate representation, eg
`/endpoint.csv`
2016-06-07 16:35:49 +01:00
Chris Hill-Scott
e1b2999371 Move test for downloads CSV of notifications
Downloading a CSV of notifications is very similar to viewing them on
a webpage. So I think it’s sensible to move the assertions about the
CSV download link into the same test, rather than it being it’s own
test.

This means being able to reuse the parametrization introuced in this
commit’s parent.
2016-06-07 16:35:49 +01:00
Chris Hill-Scott
9b099d78c7 Make test for activity page more thorough
This commit paramaterizes the test for the activity page, so that it
checks all combinations of template type and notification status.
2016-06-07 16:35:49 +01:00
Chris Hill-Scott
06903d54be Remove template type filter from activity
This commit splits the activity page into two pages, one for emails
and one for SMS.

Technically this means moving from having template type in the
querystring and putting in it the URL, eg:

*Before*:
`/services/abc/notifications/?template_type=sms`

*After*:
`/services/abc/notifications/sms`
This commit changes the activity page to only have controls
2016-06-07 16:35:49 +01:00
Leo Hemsted
65615360eb Merge pull request #658 from alphagov/last-used-message
Last used message
2016-06-07 16:13:30 +01:00
NIcholas Staples
f399e4b240 Merge pull request #656 from alphagov/bug_fix_for_tour_back_button
Bug fixed when sending yourself a test the back button links to the c…
2016-06-07 15:17:40 +01:00
Leo Hemsted
c4305d1610 only get template statistics for specific template 2016-06-07 14:28:02 +01:00
Leo Hemsted
9db20819ef tests for last used message
also now parsing the datetime correctly and removing its UTC tz info to make comparisons work
2016-06-07 11:50:15 +01:00
Leo Hemsted
4831e068d9 Add warning message showing date template last used when deleting 2016-06-07 11:50:15 +01:00
Nicholas Staples
d53b4bd7cd Bug fixed when sending yourself a test the back button links to the correct url.
Remove traceback.
2016-06-07 09:55:04 +01:00
Chris Hill-Scott
2e2e15bd95 Merge pull request #654 from alphagov/fix-500-notification-no-updated-at
Fix 500 on job page when notifications are sending
2016-06-07 09:40:04 +01:00
Adam Shimali
83b1158472 Merge pull request #652 from alphagov/permissions-bug-fix
Expand permissions before post to api
2016-06-07 09:36:50 +01:00
Adam Shimali
67236d0c2b Merge pull request #655 from alphagov/two-factor-bug-fix
Two factor page bug
2016-06-06 14:58:32 +01:00
Adam Shimali
18ba6c16b4 In case user details were not in session the redirect did not use
url_for to redirect to sign in.
2016-06-06 14:46:16 +01:00
Chris Hill-Scott
5b5ad2c5dc Fix 500 on job page when notifications are sending
Sending notifications don’t have an `updated_at`. This causes the time
formatting to throw a wobly, because it doesn’t expect `None`.

This commit changes the template to also look for the `created_at`,
which all notifications have.
2016-06-06 13:53:49 +01:00
Chris Hill-Scott
51f6450e5d Make placeholder look more editable
Depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/40

In research we’ve noticed two problems with the appearance of
placeholders:

1. We are inconsistent about when we display the ((double brackets)).
   Sometimes we show them, sometimes we don’t. This doesn’t help user’s
   understanding about where the column names in their CSV file come
   from, or how they can edit the template to fix any errors.

2. Because they look so different from normal `<textarea>` text, it’s
   not immediately obvious that they can be edited just like normal
   text. They look more like something that can be dragged/inserted.

So this commit:

1. Makes the brackets always-visible.

2. Makes the text colour of the placeholder `$text-colour`, and only
   highlights the name of the ‘variable’, not the brackets themselves.
2016-06-06 12:59:40 +01:00
Chris Hill-Scott
1aa24e8f97 Remove placeholder template component
We weren’t using this anywhere.
2016-06-06 12:59:24 +01:00
Adam Shimali
813e1c3351 Expand permissions to all possible values on admin before posting to
api. This makes template work for both existing and invited users.

API will no longer need to convert from what ui presents as permissions
2016-06-06 12:40:21 +01:00
Chris Hill-Scott
3ddc1d171d Merge pull request #646 from alphagov/rearrange-csv-errors
Prioritise CSV errors to help you match placeholders to column headers
2016-06-06 12:21:13 +01:00
Chris Hill-Scott
f71780ee27 Merge pull request #648 from alphagov/redirect-after-saving-template
Redirect to single template view after edit
2016-06-06 11:06:24 +01:00
Chris Hill-Scott
7884f7870b Redirect to single template view after edit
When you edit a template, you’re probably going to do something with
it straight afterwards, eg send yourself a test.

We could make it easy to find the template you’ve just saved by putting
it at the top of the pile. This gets confusing for other reasons (order
of templates will constantly shift about).

So this commit changes the flow to take you to the single page for the
template you’ve just edited.
2016-06-06 10:23:33 +01:00
Chris Hill-Scott
a6833f4ad2 Change page <title> on check page
It was no longer accurate.
2016-06-05 18:41:19 +01:00
Chris Hill-Scott
4ac1a03a89 Use message_count_label component
For the button on the check page, we need to be able to say ‘1 text message’ or
‘55 emails’. We already have the logic to do this on the dashboard (101 text
messages sent), and it’s already in a component. So this commit makes the check
page use the same component.
2016-06-05 18:41:19 +01:00
Chris Hill-Scott
9332f57f55 Make components for nicely formatted lists
We have a couple of places now where we want nice lists made from `list`s, eg

- ‘name’, ‘date’ and ‘phone number’
- ((firstname)) ((lastname)) or ((date))

This commit adds a more generic component for doing this, which can handle:

- 1, 2, and n items
- comma (or other character) separated lists
- a conjunction between the last and one-before-last item
- characters to be inserted before and after each item, eg an opening and
  closing HTML tag

It also pulls the `list_of_placeholders` component from the breaking change
page, and makes it use the `formatted_list` component under the hood.
2016-06-05 18:39:32 +01:00
Chris Hill-Scott
3ace856d74 Only show row-level errors if all columns are OK
Row-level errors are:

- bad phone number/email address
- missing data

I think it’s distracting to show these on the page if there’s something more
fundamentally wrong with the file, eg placeholders don’t match.

So this commit makes sure that these error messages are only displayed when the
top-level error says ‘There is a problem with your data’
2016-06-03 16:26:59 +01:00
Chris Hill-Scott
2ff6cf049f Change order of errors for bad CSV files
This commit rearranges the CSV errors (again) to make them geared towards
teaching you how to match placeholders to the column headers.

So the order of errors now is:

1. No phone number/email column
2. Column headers don’t match placeholders
3. Missing or bad data
4. Trial mode
5. Daily limit reached

This depends on:
- [x] https://github.com/alphagov/notifications-utils/pull/39 for 1.
2016-06-03 16:26:58 +01:00
Chris Hill-Scott
2c17261795 Merge pull request #640 from alphagov/better-wording-around-example
Change wording around the example on the send page
2016-06-03 12:45:54 +01:00
minglis
bc9b37da7a Merge pull request #641 from alphagov/platform-admins-invite-users
Added invite user button for platform admins on any service
2016-06-03 12:00:23 +01:00
minglis
b35f747fc1 Removed print 2016-06-03 12:00:08 +01:00
Martyn Inglis
29fd69258c Added invite user button for platform admins on any service 2016-06-03 11:10:38 +01:00
Chris Hill-Scott
20b2331b1e Change wording around the example on the send page
‘How to format your file’ sounds complicated and incidental.

‘See an example’ sounds like something that might be useful if you’re feeling
stuck.

Also makes the list of file formats a list, because it’s a list.
2016-06-03 09:06:12 +01:00
minglis
0219ddf2f8 Merge pull request #634 from alphagov/research-mode
Research mode
2016-06-02 12:00:39 +01:00