Compare commits

...

11 Commits

Author SHA1 Message Date
Amir Raminfar 0f5cf053de Release 2.1.3 2020-07-19 19:32:35 -07:00
Amir Raminfar 25ec792acb Uses console.error instead 2020-07-19 19:25:47 -07:00
Amir Raminfar 7ae9230e32 Adds cancel 2020-07-19 19:19:35 -07:00
Amir Raminfar 6288380186 Fixes tests snapshots 2020-07-19 18:23:02 -07:00
Amir Raminfar 2ebb6d128d Created reset() 2020-07-19 17:16:39 -07:00
Amir Raminfar cd7ea2f904 Uses .flush() 2020-07-19 17:13:05 -07:00
Amir Raminfar cef015a722 Adds break with container stopped 2020-07-19 17:08:33 -07:00
dependabot-preview[bot] 95bc0072b5 Merge pull request #585 from amir20/dependabot/npm_and_yarn/caniuse-lite-1.0.30001103 2020-07-19 05:42:46 +00:00
dependabot-preview[bot] a3b489c9cd Bump caniuse-lite from 1.0.30001102 to 1.0.30001103
Bumps [caniuse-lite](https://github.com/ben-eb/caniuse-lite) from 1.0.30001102 to 1.0.30001103.
- [Release notes](https://github.com/ben-eb/caniuse-lite/releases)
- [Changelog](https://github.com/ben-eb/caniuse-lite/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ben-eb/caniuse-lite/compare/v1.0.30001102...v1.0.30001103)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-19 05:37:02 +00:00
dependabot-preview[bot] 575d7d3494 Merge pull request #583 from amir20/dependabot/npm_and_yarn/date-fns-2.15.0 2020-07-17 17:53:09 +00:00
dependabot-preview[bot] eff39d888c Bump date-fns from 2.14.0 to 2.15.0
Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.14.0 to 2.15.0.
- [Release notes](https://github.com/date-fns/date-fns/releases)
- [Changelog](https://github.com/date-fns/date-fns/blob/master/CHANGELOG.md)
- [Commits](https://github.com/date-fns/date-fns/compare/v2.14.0...v2.15.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-17 17:46:53 +00:00
5 changed files with 41 additions and 28 deletions
+10 -1
View File
@@ -91,6 +91,9 @@ X-Accel-Buffering: no
data: INFO Testing logs...
event: container-stopped
data: end of stream
/* snapshot: Test_handler_streamLogs_happy_container_stopped */
HTTP/1.1 200 OK
Connection: close
@@ -102,6 +105,9 @@ X-Accel-Buffering: no
event: container-stopped
data: end of stream
event: container-stopped
data: end of stream
/* snapshot: Test_handler_streamLogs_happy_with_id */
HTTP/1.1 200 OK
Connection: close
@@ -111,4 +117,7 @@ Content-Type: text/event-stream
X-Accel-Buffering: no
data: 2020-05-13T18:55:37.772853839Z INFO Testing logs...
id: 2020-05-13T18:55:37.772853839Z
id: 2020-05-13T18:55:37.772853839Z
event: container-stopped
data: end of stream
+19 -16
View File
@@ -25,35 +25,38 @@ export default {
created() {
this.es = null;
this.loadLogs(this.id);
this.flushBuffer = debounce(this.flushNow, 250, { maxWait: 1000 });
},
methods: {
loadLogs(id) {
if (this.es) {
this.es.close();
this.messages = [];
this.buffer = [];
this.es = null;
}
this.reset();
this.es = new EventSource(`${config.base}/api/logs/stream?id=${this.id}`);
this.es.addEventListener("container-stopped", (e) => {
this.es.close();
this.buffer.push({ event: "container-stopped", message: "Container stopped", date: new Date() });
flushNow();
this.flushBuffer();
this.flushBuffer.flush();
});
this.es.addEventListener("error", (e) => console.log("EventSource failed: " + JSON.stringify(e)));
const flushBuffer = debounce(() => flushNow(), 250, { maxWait: 1000 });
const flushNow = () => {
this.messages.push(...this.buffer);
this.buffer = [];
};
this.es.addEventListener("error", (e) => console.error("EventSource failed: " + JSON.stringify(e)));
this.es.onmessage = (e) => {
this.buffer.push(this.parseMessage(e.data));
flushBuffer();
this.flushBuffer();
};
this.$once("hook:beforeDestroy", () => this.es.close());
},
flushNow() {
this.messages.push(...this.buffer);
this.buffer = [];
},
reset() {
if (this.es) {
this.es.close();
this.es = null;
this.flushBuffer.cancel();
}
this.messages = [];
this.buffer = [];
},
async loadOlderLogs() {
if (this.messages.length < 300) return;
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "dozzle",
"version": "2.1.2",
"version": "2.1.3",
"description": "Realtime log viewer for docker containers. ",
"scripts": {
"prestart": "yarn clean",
@@ -30,7 +30,7 @@
"ansi-to-html": "^0.6.14",
"buefy": "^0.8.20",
"bulma": "^0.9.0",
"date-fns": "^2.14.0",
"date-fns": "^2.15.0",
"dompurify": "^2.0.12",
"hotkeys-js": "^3.8.1",
"lodash.debounce": "^4.0.8",
@@ -51,7 +51,7 @@
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^26.1.0",
"babel-preset-env": "^1.7.0",
"caniuse-lite": "^1.0.30001102",
"caniuse-lite": "^1.0.30001103",
"css-loader": "^3.6.0",
"eventsourcemock": "^2.0.0",
"html-webpack-plugin": "^4.3.0",
+1
View File
@@ -126,6 +126,7 @@ Loop:
select {
case message, ok := <-messages:
if !ok {
fmt.Fprintf(w, "event: container-stopped\ndata: end of stream\n\n")
break Loop
}
fmt.Fprintf(w, "data: %s\n", message)
+8 -8
View File
@@ -2538,10 +2538,10 @@ caniuse-api@^2.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000792, caniuse-lite@^1.0.30000805, caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30001102:
version "1.0.30001102"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001102.tgz#3275e7a8d09548f955f665e532df88de0b63741a"
integrity sha512-fOjqRmHjRXv1H1YD6QVLb96iKqnu17TjcLSaX64TwhGYed0P1E1CCWZ9OujbbK4Z/7zax7zAzvQidzdtjx8RcA==
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000792, caniuse-lite@^1.0.30000805, caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30001103:
version "1.0.30001103"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001103.tgz#fe81536d075b97cd013d4988c9212418faa289a8"
integrity sha512-EJkTPrZrgy712tjZ7GQDye5A67SQOyNS6X9b6GS/e5QFu5Renv5qfkx3GHq1S+vObxKzbWWYuPO/7nt4kYW/gA==
capture-exit@^2.0.0:
version "2.0.0"
@@ -3214,10 +3214,10 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"
date-fns@^2.14.0:
version "2.14.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.14.0.tgz#359a87a265bb34ef2e38f93ecf63ac453f9bc7ba"
integrity sha512-1zD+68jhFgDIM0rF05rcwYO8cExdNqxjq4xP1QKM60Q45mnO6zaMWB4tOzrIr4M4GSLntsKeE4c9Bdl2jhL/yw==
date-fns@^2.15.0:
version "2.15.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.15.0.tgz#424de6b3778e4e69d3ff27046ec136af58ae5d5f"
integrity sha512-ZCPzAMJZn3rNUvvQIMlXhDr4A+Ar07eLeGsGREoWU19a3Pqf5oYa+ccd+B3F6XVtQY6HANMFdOQ8A+ipFnvJdQ==
de-indent@^1.0.2:
version "1.0.2"