More progress on influxdb query editor, templating, refactoring, unit tests, #740, #507, #586