Fixes #457 - Scheduler Time offset

This commit is contained in:
Mantas Masalskis 2021-08-30 14:25:48 +02:00 committed by Thorsten Eckel
parent 6be39c9625
commit 4a9f448de7
10 changed files with 41 additions and 16 deletions

View file

@ -304,7 +304,12 @@ class App.Controller extends Spine.Controller
# only do dom updates on changes # only do dom updates on changes
return if time is currentVal return if time is currentVal
item.attr('title', App.i18n.translateTimestamp(timestamp))
newTitle = App.i18n.translateTimestamp(timestamp)
if item.attr('timezone')
newTitle += ' ' + item.attr('timezone')
item.attr('title', newTitle)
item.html(time) item.html(time)
recentView: (object, o_id) => recentView: (object, o_id) =>

View file

@ -112,8 +112,9 @@ class App.UiElement.timer
days = @joinItems days days = @joinItems days
hours = @joinItems hours hours = @joinItems hours
timezone = App.Config.get('timezone_default') || 'UTC'
formGroup.find('.js-timerResult').text(App.i18n.translateInline('Run every %s at %s', days, hours)) formGroup.find('.js-timerResult').text(App.i18n.translateInline('Run every %s at %s in %s time', days, hours, timezone))
@injectMinutes: (hours, minutes) -> @injectMinutes: (hours, minutes) ->
newHours = [] # hours.length x minutes.length long newHours = [] # hours.length x minutes.length long

View file

@ -134,14 +134,23 @@ class App extends Spine.Controller
else if attributeConfig.tag is 'datetime' else if attributeConfig.tag is 'datetime'
isHtmlEscape = true isHtmlEscape = true
timestamp = App.i18n.translateTimestamp(resultLocal) timestamp = App.i18n.translateTimestamp(resultLocal)
escalation = false escalation = false
cssClass = attributeConfig.class || '' cssClass = attributeConfig.class || ''
if cssClass.match 'escalation' if cssClass.match 'escalation'
escalation = true escalation = true
humanTime = '' humanTime = ''
if !table if !table
humanTime = App.PrettyDate.humanTime(resultLocal, escalation) humanTime = App.PrettyDate.humanTime(resultLocal, escalation)
resultLocal = "<time class=\"humanTimeFromNow #{cssClass}\" datetime=\"#{resultLocal}\" title=\"#{timestamp}\">#{humanTime}</time>"
title = timestamp
timezone = ''
if attributeConfig.include_timezone
timezone = " timezone=\"#{App.Config.get('timezone_default')}\""
title += ' ' + App.Config.get('timezone_default')
resultLocal = "<time class=\"humanTimeFromNow #{cssClass}\" datetime=\"#{resultLocal}\" title=\"#{title}\"#{timezone}>#{humanTime}</time>"
if !isHtmlEscape && typeof resultLocal is 'string' if !isHtmlEscape && typeof resultLocal is 'string'
resultLocal = App.Utils.htmlEscape(resultLocal) resultLocal = App.Utils.htmlEscape(resultLocal)

View file

@ -12,8 +12,8 @@ class App.Job extends App.Model
{ name: 'active', display: 'Active', tag: 'active', default: true }, { name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'matching', display: 'Will process', readonly: 1 }, { name: 'matching', display: 'Will process', readonly: 1 },
{ name: 'processed', display: 'Has processed', readonly: 1 }, { name: 'processed', display: 'Has processed', readonly: 1 },
{ name: 'last_run_at', display: 'Last run', tag: 'datetime', readonly: 1 }, { name: 'last_run_at', display: 'Last run', tag: 'datetime', readonly: 1, include_timezone: true },
{ name: 'next_run_at', display: 'Scheduled for', tag: 'datetime', readonly: 1 }, { name: 'next_run_at', display: 'Scheduled for', tag: 'datetime', readonly: 1, include_timezone: true },
{ name: 'running', display: 'Running', tag: 'boolean', readonly: 1 }, { name: 'running', display: 'Running', tag: 'boolean', readonly: 1 },
{ name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 }, { name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 },
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1 }, { name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1 },

View file

@ -8,4 +8,4 @@
<label><%- @T('Minutes') %> <label><%- @T('Minutes') %>
<div class="minutes"></div> <div class="minutes"></div>
</label> </label>
</div> </div>

View file

@ -1,6 +1,7 @@
<p> <output class="timer-output">
<output class="timer-output js-timerResult"></output> <p class="js-timerResult"></p>
</p> </output>
<div class="select-boxes"> <div class="select-boxes">
<div class="select-box select-box--vertical js-day"> <div class="select-box select-box--vertical js-day">
<div class="select-box-header"><%- @T('Day') %></div> <div class="select-box-header"><%- @T('Day') %></div>
@ -23,4 +24,4 @@
<input type="hidden" class="js-boolean" name="<%= @attribute.name %>::minutes::<%- minute %>" value="<% if @attribute.value.minutes[minute]: %>true<% else: %>false<% end %>"> <input type="hidden" class="js-boolean" name="<%= @attribute.name %>::minutes::<%- minute %>" value="<% if @attribute.value.minutes[minute]: %>true<% else: %>false<% end %>">
<% end %> <% end %>
</div> </div>
</div> </div>

View file

@ -9930,7 +9930,7 @@ label + .wizard-buttonList {
output { output {
border-bottom: 1px solid hsl(200,71%,59%); border-bottom: 1px solid hsl(200,71%,59%);
margin: 14px 0 0; margin: 14px 0 19px;
display: inline-block; display: inline-block;
padding: 10px 12px 8px; padding: 10px 12px 8px;
background: hsl(201,62%,93%); background: hsl(201,62%,93%);

View file

@ -1,6 +1,6 @@
<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css"> <link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/model_ui.js", nonce: true %> <%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/sinon-9.2.4", "/assets/tests/model_ui.js", nonce: true %>
<style type="text/css"> <style type="text/css">
body { body {

View file

@ -16,7 +16,7 @@ test("form elements check", function() {
autofocus: true autofocus: true
}); });
equal('Run every Monday at 00:00', el.find('.js-timerResult').val()) equal('Run every Monday at 00:00 in UTC time', el.find('.js-timerResult').text())
var params = App.ControllerForm.params(el) var params = App.ControllerForm.params(el)
var test_params = { var test_params = {
@ -101,7 +101,7 @@ test("form elements check", function() {
autofocus: true autofocus: true
}); });
equal('Run every Monday and Friday at 00:00, 00:10, 00:50, 10:00, 10:10, 10:50, 16:00, 16:10 and 16:50', el.find('.js-timerResult').val()) equal('Run every Monday and Friday at 00:00, 00:10, 00:50, 10:00, 10:10, 10:50, 16:00, 16:10 and 16:50 in UTC time', el.find('.js-timerResult').text())
var params = App.ControllerForm.params(el) var params = App.ControllerForm.params(el)
var test_params = { var test_params = {
@ -158,7 +158,7 @@ test("form elements check", function() {
$('#form2 .js-hour [data-value="16"]').click() $('#form2 .js-hour [data-value="16"]').click()
$('#form2 .js-minute [data-value="10"]').click() $('#form2 .js-minute [data-value="10"]').click()
equal('Run every Monday, Friday and Saturday at 00:00, 00:50, 10:00 and 10:50', el.find('.js-timerResult').val()) equal('Run every Monday, Friday and Saturday at 00:00, 00:50, 10:00 and 10:50 in UTC time', el.find('.js-timerResult').text())
var params = App.ControllerForm.params(el) var params = App.ControllerForm.params(el)
var test_params = { var test_params = {
@ -211,4 +211,4 @@ test("form elements check", function() {
} }
deepEqual(params, test_params, 'form param check') deepEqual(params, test_params, 'form param check')
}); });

View file

@ -60,6 +60,15 @@ test( "model ui basic tests", function() {
equal( App.viewPrint( ticket, 'link1' ), '<a href="http://zammad.com" target="blank">closed</a>') equal( App.viewPrint( ticket, 'link1' ), '<a href="http://zammad.com" target="blank">closed</a>')
equal( App.viewPrint( ticket, 'link2' ), '<a href="http://zammad.com" target="blank">closed</a>') equal( App.viewPrint( ticket, 'link2' ), '<a href="http://zammad.com" target="blank">closed</a>')
let stub = sinon.stub(App.Config, 'get')
stub.withArgs('timezone_default').returns('Example/Timezone')
let attr = App.Ticket.configure_attributes.find(e => { return e.name == 'updated_at' })
attr.include_timezone = true
equal( App.viewPrint( ticket, 'updated_at' ), '<time class="humanTimeFromNow " datetime="2014-11-07T23:43:08.000Z" title="11/07/2014 23:43 Example/Timezone" timezone="Example/Timezone">11/07/2014</time>')
attr.include_timezone = false
stub.restore()
App.i18n.set('de-de') App.i18n.set('de-de')
equal( App.viewPrint( ticket, 'id' ), 1000) equal( App.viewPrint( ticket, 'id' ), 1000)