forked from mirrors/Scribe.js
commit
c144c1ffb7
11 changed files with 125 additions and 20 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -7,4 +7,4 @@ logs*/
|
||||||
|
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
npm-debug.log
|
npm-debug.logGruntfile.js
|
||||||
|
|
44
Gruntfile.js
Normal file
44
Gruntfile.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
|
// Project configuration.
|
||||||
|
grunt.initConfig({
|
||||||
|
jshint: {
|
||||||
|
options: {
|
||||||
|
jshintrc: '.jshintrc'
|
||||||
|
},
|
||||||
|
gruntfile: {
|
||||||
|
src: ['scribe.js', 'Gruntfile.js']
|
||||||
|
},
|
||||||
|
lib: {
|
||||||
|
src: ['lib/**/*.js', 'examples/**/*.js', 'static/js/**/*.js']
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
src: ['test/**/*.js']
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
gruntfile: {
|
||||||
|
files: '<%= jshint.gruntfile.src %>',
|
||||||
|
tasks: ['jshint:gruntfile']
|
||||||
|
},
|
||||||
|
lib: {
|
||||||
|
files: '<%= jshint.lib.src %>',
|
||||||
|
tasks: ['jshint:lib']
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
files: '<%= jshint.test.src %>',
|
||||||
|
tasks: ['jshint:test']
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// These plugins provide necessary tasks.
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||||
|
|
||||||
|
// Default task.
|
||||||
|
grunt.registerTask('default', ['jshint']);
|
||||||
|
|
||||||
|
};
|
|
@ -236,6 +236,20 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* /api/timezone
|
||||||
|
*
|
||||||
|
* Send the server timezone offset
|
||||||
|
*/
|
||||||
|
webPanel.get('/api/timezoneOffset', function (req, res) {
|
||||||
|
|
||||||
|
res.status(200).json({
|
||||||
|
timezoneOffset : (new Date()).getTimezoneOffset()
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
return webPanel;
|
return webPanel;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -204,6 +204,43 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $rootScope.scribeTimezone
|
||||||
|
*
|
||||||
|
* Store the Scribe server timezoneOffset for showing good dates
|
||||||
|
*
|
||||||
|
* @type {Int}
|
||||||
|
*/
|
||||||
|
$rootScope.scribeTimezone = 0;
|
||||||
|
|
||||||
|
ScribeAPI.timezoneOffset(function (result) {
|
||||||
|
$rootScope.scribeTimezone = result.timezoneOffset;
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* timezoneDate
|
||||||
|
*
|
||||||
|
* Add/remove minutes to the timestamp according to
|
||||||
|
* the timezone offset between server and browser time
|
||||||
|
* Because angular date filter print date with the browser timezone
|
||||||
|
*
|
||||||
|
* @param {Int|String} timestamp
|
||||||
|
* @return {Int} the new timestamp
|
||||||
|
*
|
||||||
|
* @type {Function}
|
||||||
|
*/
|
||||||
|
$rootScope.timezoneDate = function (timestamp) {
|
||||||
|
|
||||||
|
timestamp = Number(timestamp);
|
||||||
|
|
||||||
|
var serverOffset = $rootScope.scribeTimezone;
|
||||||
|
var localOffset = (new Date()).getTimezoneOffset();
|
||||||
|
|
||||||
|
var offset = serverOffset - localOffset;
|
||||||
|
|
||||||
|
return timestamp + offset * 60;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $rootScope.back
|
* $rootScope.back
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* Go to to a next page
|
* Go to to a next page
|
||||||
*
|
*
|
||||||
* @param {int} next if < 0, goes to older dates, if > 0 goes to newer dates
|
* @param {int} next if < 0, goes to older dates, if > 0 goes to newer dates
|
||||||
*/
|
*/
|
||||||
$scope.nextPage = function (next) {
|
$scope.nextPage = function (next) {
|
||||||
|
|
||||||
var currentDate = $location.search().from || Date.now(),
|
var currentDate = $location.search().from || Date.now(),
|
||||||
|
@ -42,17 +42,21 @@
|
||||||
|
|
||||||
//build blocks
|
//build blocks
|
||||||
$scope.blocks = dates.map(function (item) {
|
$scope.blocks = dates.map(function (item) {
|
||||||
|
|
||||||
|
var itemDate = $rootScope.timezoneDate(item.date);
|
||||||
|
console.log(item.date);
|
||||||
|
console.log(itemDate);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type : 'date',
|
type : 'date',
|
||||||
messageTop : $filter('date')(item.date, 'MMM'),
|
messageTop : $filter('date')(itemDate, 'MMM'),
|
||||||
message : $filter('date')(item.date, 'd'),
|
message : $filter('date')(itemDate, 'd'),
|
||||||
messageBottom : $filter('date')(item.date, 'yyyy'),
|
messageBottom : $filter('date')(itemDate, 'yyyy'),
|
||||||
click : function () {
|
click : function () {
|
||||||
//save files
|
//save files
|
||||||
logs.setLogs(item.files.map(function (el, index) {
|
logs.setLogs(item.files.map(function (el, index) {
|
||||||
return {
|
return {
|
||||||
selected : index === 0, //select the first by default
|
selected : index === 0, //select the first by default
|
||||||
name : el.name,
|
name : el.name,
|
||||||
path : el.path
|
path : el.path
|
||||||
};
|
};
|
||||||
|
@ -62,7 +66,7 @@
|
||||||
$rootScope.go('logs');
|
$rootScope.go('logs');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -12,14 +12,14 @@
|
||||||
'logs',
|
'logs',
|
||||||
'folder',
|
'folder',
|
||||||
function ($scope, $rootScope, logs, folder) {
|
function ($scope, $rootScope, logs, folder) {
|
||||||
|
|
||||||
//reset
|
//reset
|
||||||
$rootScope.sidebar = false;
|
$rootScope.sidebar = false;
|
||||||
$scope.onlyFiles = true;
|
$scope.onlyFiles = true;
|
||||||
|
|
||||||
//build each block
|
//build each block
|
||||||
$scope.blocks = folder.map(function (item) {
|
$scope.blocks = folder.map(function (item) {
|
||||||
|
|
||||||
if (item.type !== 'file') {
|
if (item.type !== 'file') {
|
||||||
$scope.onlyFiles = false;
|
$scope.onlyFiles = false;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
message : item.name,
|
message : item.name,
|
||||||
click : function () {
|
click : function () {
|
||||||
if (item.type === 'file') {
|
if (item.type === 'file') {
|
||||||
|
|
||||||
//Save all current files of the folder
|
//Save all current files of the folder
|
||||||
//But select only the clicked one
|
//But select only the clicked one
|
||||||
var newFiles = folder.map(function (file) {
|
var newFiles = folder.map(function (file) {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
//build block for each logWriter
|
//build block for each logWriter
|
||||||
$scope.blocks = $rootScope.logWriters.map(function (item) {
|
$scope.blocks = $rootScope.logWriters.map(function (item) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message : item,
|
message : item,
|
||||||
click : function () {
|
click : function () {
|
||||||
|
|
|
@ -69,7 +69,9 @@
|
||||||
templateUrl : 'partials/elements/log.html',
|
templateUrl : 'partials/elements/log.html',
|
||||||
replace : true,
|
replace : true,
|
||||||
|
|
||||||
controller : ['$scope', function ($scope) {
|
controller : ['$rootScope', '$scope', function ($rootScope, $scope) {
|
||||||
|
|
||||||
|
$scope.timezoneDate = $rootScope.timezoneDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $scope.handleTags
|
* $scope.handleTags
|
||||||
|
|
|
@ -32,12 +32,12 @@
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
url : 'api/log',
|
url : 'api/log',
|
||||||
isArray : true,
|
isArray : true,
|
||||||
|
|
||||||
//As logs are lines of JSON, we want to parse each lines one by one
|
//As logs are lines of JSON, we want to parse each lines one by one
|
||||||
transformResponse : function (data) {
|
transformResponse : function (data) {
|
||||||
|
|
||||||
var lines = data.match(/[^\r\n]+/g); //cut lines
|
var lines = data.match(/[^\r\n]+/g); //cut lines
|
||||||
|
|
||||||
return lines.map(function (line) {
|
return lines.map(function (line) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(line);
|
return JSON.parse(line);
|
||||||
|
@ -46,6 +46,10 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
timezoneOffset : {
|
||||||
|
methof : 'GET',
|
||||||
|
url : 'api/timezoneOffset'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,13 +13,13 @@
|
||||||
|
|
||||||
<span class="log__item log__time log__time_80" ng-if="showDate != 0 && (showDate == 1 || log.show.date)">
|
<span class="log__item log__time log__time_80" ng-if="showDate != 0 && (showDate == 1 || log.show.date)">
|
||||||
<span class="log__time__higher">
|
<span class="log__time__higher">
|
||||||
{{log.context.time | date: 'EEE MMM dd yyyy'}}
|
{{timezoneDate(log.context.time) | date: 'EEE MMM dd yyyy'}}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="log__item log__time log__time_122" ng-if="showTime != 0 && (showTime == 1 || log.show.time)">
|
<span class="log__item log__time log__time_122" ng-if="showTime != 0 && (showTime == 1 || log.show.time)">
|
||||||
<span class="log__time__lower">
|
<span class="log__time__lower">
|
||||||
{{log.context.time | date: 'yyyy-MM-ddTHH:mm:ss:Z'}}
|
{{timezoneDate(log.context.time) | date: 'yyyy-MM-ddTHH:mm:ss:Z'}}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<ul class="content">
|
<ul class="content">
|
||||||
|
|
||||||
<li ng-repeat="logger in logWriters" class="sidebar__item">
|
<li ng-repeat="logger in logWriters" class="sidebar__item">
|
||||||
<a href="" ng-click="go(mode, {path : logger});">{{logger}}</a>
|
<a href="" ng-click="go(mode, {path : logger});">{{logger}}</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue