From 02a369d8f7e342fdcd02b5532fc579ec27c464d8 Mon Sep 17 00:00:00 2001 From: Kazuhiro Fujieda Date: Sat, 19 May 2018 21:01:04 +0900 Subject: [PATCH] =?utf8?q?=E3=83=AD=E3=82=B0=E3=81=AE=E8=A1=A8=E7=A4=BA?= =?utf8?q?=E7=AF=84=E5=9B=B2=E3=81=AE=E9=81=B8=E6=8A=9E=E8=82=A2=E3=82=92?= =?utf8?q?=E5=A2=97=E3=82=84=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- LogViewer/index.html | 5 +- LogViewer/tags.tag | 130 +++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 99 insertions(+), 36 deletions(-) diff --git a/LogViewer/index.html b/LogViewer/index.html index 03cfaa4..9229c43 100644 --- a/LogViewer/index.html +++ b/LogViewer/index.html @@ -106,10 +106,11 @@ var mixin = { @@ -98,7 +121,7 @@ opts.observable.on("mainTabChanged", function(idx) { self.show(); }); -opts.observable.on("termApplied", function() { +opts.observable.on("logRangeChanged", function() { self.show(); }); @@ -133,14 +156,53 @@ this.init = function() { this.show = function() { if (this.mainTab >= this.jsons.length) return; - var query = "?from=" + moment().subtract(1, 'months').valueOf(); - if ($('input[name=term]:eq(1)').prop('checked')) { - var from = $('#term_from').datepicker("getDate"); + var now = moment(); + var from; + var query = "?from="; + switch (opts.logRange.val){ + case 0: + from = now.clone().startOf('day').hours(5); + if (now.hour() < 5) + from.subtract(1, 'days'); + query += from.valueOf(); + break; + case 1: + from = now.clone().startOf('week').hours(5); + if (now.hour() < 5 && now.days() === 1) + from.subtract(1, 'weeks'); + query += from.valueOf(); + break; + case 2: + if (now.hours() >= 22 && + now.dates() === now.clone().endOf('month').date()) { + from = now.clone().hours(22); + } else { + from = now.clone().startOf('month').subtract(1, 'days').hours(22); + } + query += from.valueOf(); + break; + case 3: + query = ""; + break; + case 4: + from = $('#term_from').datepicker("getDate"); var to = $('#term_to').datepicker("getDate"); - if (from !== null) - query = "?from=" + from.valueOf(); - if (to !== null) - query += "&to=" + (to.valueOf() + this.oneDay); + if (from === null) + return; + from = moment(from); + if (from.date() === 1) + from.subtract(2, 'hours'); + query += from.valueOf(); + if (to !== null) { + to = moment(to); + if (to.date() === to.clone().endOf('month').date()) { + to.hour(22); + } else { + to.add(1, 'days').hours(5); + } + query += "&to=" + to.valueOf(); + } + break; } $('#loading').show(); var url = this.jsons[this.mainTab] + query; @@ -250,11 +312,11 @@ this.init = function() { }); }; -this.on("mount", this.init); - this.mainTab = 0; var self = this; +this.on("mount", self.init); + opts.observable.on("mainTabChanged", function(idx) { self.update({mainTab: idx}); }); @@ -300,7 +362,7 @@ this.resize = function() { }; this.drawChart = function(data) { - range = this.calcRange(opts.chartSpec.seqRange); + var range = this.calcRange(opts.chartSpec.seqRange); if (range.last === 0) return; if (!data) { @@ -347,7 +409,7 @@ this.calcRange = function(range) { break; } return {first: first, last: last}; -} +}; this.unselected = {}; @@ -506,7 +568,7 @@ this.resize = function() { }; this.drawChart = function(data) { - range = this.calcRange(opts.chartSpec.diffRange); + var range = this.calcRange(opts.chartSpec.diffRange); if (range.last === 0) return; if (!data) { @@ -552,7 +614,7 @@ this.calcRange = function(range) { break; } return {first: first, last: last}; -} +}; this.unselected = {}; -- 2.11.0