web: As containers are starting/stopping on overview page show waiting

Show a throbber as containers on the overview page are starting
or stopping.

We cannot use /events or container state to track the waiting state,
as docker doesn't seem to give us anything useful here. So we do this
ourselves.

The small-spinner.gif looks *really* ugly, so we use an alternate
throbber here, at least for now.

Along with previous commits this, fixes #301, closes #317

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Add $cockpit.debugging control knob

$cockpit.debugging can be set from the javascript console to one of
these values:

 * 'rest'
 * 'channel'
 * 'dbus'

... to see the relevant debugging logs. Or set to 'all' to see
everything.

Set cookie like this to see debugging information during the loading
of the page:

document.cookie = "debugging=all;" + document.cookie

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Add 'resource' debugging knob for $cockpit.debugging

This will show cgroup monitoring samples in the javascript
console as they come in.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Cleanup cockpit-docker.js javascript console debugging

Warnings go to console.warn(). Events are already logged via
rest_debug() and remove some other noise.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Switch overview display of memory back to MiB

Use base-2 suffixes for memory display on overview containers page.
This fixes a regression.

Closes #351
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
agent: Convert non-UTF8 with replacement char in CockpitTextStream

When we encounter non-UTF8 in text-stream channels, replace the bad
characters with the unicode replacement character U+FFFD. This
usually shows up as a diamond with a question mark in it in modern
fonts.

This allows us to not be so fragile with the text-stream channels,
and close unexpectedly.

The terminal stuff didn't really need this, because it seems that
terminal escape codes are all ASCII clean.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Show a usable terminal in container details

Show a usable terminal in container details, where you can type
see output, scroll, etc.

Disconnects when container stops, hides cursor. Reconnects when
container starts and shows cursor.

For now we show the terminal when the docker container has a tty.
But this seems like the default. When no tty Docker's /attach
command uses a strange binary framing, which we can't handle on
our text-stream socket.

Closes #346
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Fix memory danger indication for containers.

This slipped through review, sorry.

Closes #348

Signed-off-by: Stef Walter <stefw@redhat.com>
 * Make sure to only pass boolean to toggleClass('bar-row-danger', x)
web: Implement slider for choosing a container memory limit

This implements the memory row as described by the mockup here:

https://github.com/cockpit-project/cockpit-design/blob/f1d6e8c560d6230bad24e4ac11c8916dc75d9e52/docker/docker-run-hires.png

The only difference is that the total memory is not shown, as the
container is not actually being allocated a portion of the memory. This
is about setting a limit.

Fixes #295
Closes #353
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Implement CPU priority slider

This is done on a logarithmic scale. Defaults to 'default' priority.

Fixes #296
Closes #353
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Reset CPU and Memory limit check boxes in run dialog

Reset the check boxes whenever the page is displayed for consistent
behavior.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
agent: Don't poll when interval is zero, as documented.

Closes #359

Reviewed-by: Stef Walter <stefw@redhat.com>
web: Use HTML ids of image/container ids for locating container rows

These should be unique enough for us to use them directly. This
allows us to highlight them using jQuery straight from unrelated
code like the graph plotting code.

Signed-off-by: Marius Vollmer <mvollmer@redhat.com>
web: Return the element we're going to plot in

So that we can use it to catch events and stuff.

Signed-off-by: Marius Vollmer <mvollmer@redhat.com>
web: Add 'highlight' CSS class.

Signed-off-by: Stef Walter <stefw@redhat.com>
web: Highlight container rows when hovering over the graphs.

Closes #360

Signed-off-by: Stef Walter <stefw@redhat.com>
Hide docker images without repotags.

This is for example the case when an image has been partially deleted
or if it is based on multiple layers.

Fixes #291
Closes #328

Signed-off-by: Stef Walter <stefw@redhat.com>
 * Rebased, also ignore "<none>:<none>"
web: Style graphs on #server like the ones on #containers.

Fixes #340
Closes #363

Reviewed-by: Stef Walter <stefw@redhat.com>
web: Fix container images appearing multiple times

This happens when you come back to the overview page. Regression.

Closes #364

Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
agent: Fix test-textstream tests for UTF8 handling changes

This is a regression.

Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>