Skip to content

Commit

Permalink
Merge pull request #60 from Ethan3600/1.x-develop
Browse files Browse the repository at this point in the history
Uprgrade to v1.6.1
  • Loading branch information
Ethan Yehuda authored May 14, 2018
2 parents dc48cb6 + 70677a5 commit 413c28f
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 129 deletions.
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="EthanYehuda_CronjobManager" setup_version="1.6.0" >
<module name="EthanYehuda_CronjobManager" setup_version="1.6.1" >
<sequence>
<module name="Magento_Cron"/>
</sequence>
Expand Down
1 change: 1 addition & 0 deletions view/adminhtml/web/css/source/module/_timeline.less
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@

&.running {
background-color: @status--running;
z-index: 0;
}

&.error {
Expand Down
10 changes: 0 additions & 10 deletions view/adminhtml/web/js/lib/knockout/bindings/boostrapExt.js

This file was deleted.

30 changes: 0 additions & 30 deletions view/adminhtml/web/js/lib/knockout/bindings/foreach-prop.js

This file was deleted.

37 changes: 28 additions & 9 deletions view/adminhtml/web/js/timeline/timeline.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
define([
'underscore',
'jquery',
'ko',
'uiLayout',
'Magento_Ui/js/lib/spinner',
'rjsResolver',
'uiRegistry',
'moment',
'uiCollection',
'../lib/knockout/bindings/boostrapExt',
], function (_, $, layout, loader, resolver, registry, moment, Collection) {
], function (_, $, ko, layout, loader, resolver, registry, moment, Collection) {
'use strict';

return Collection.extend({
Expand All @@ -31,6 +31,7 @@ define([
step: 2,
width: 0,
now: 0,
transformedRows: [],
tracks: {
rows: true,
range: true,
Expand All @@ -57,7 +58,10 @@ define([
* @returns {Listing} Chainable.
*/
initObservable: function () {
this._super();
this._super()
// fastForEach only takes observables
// we must NOT use ES5 get/set accessor descriptors
.observe('transformedRows');
return this;
},

Expand Down Expand Up @@ -89,16 +93,19 @@ define([

getCronWidth: function (job) {
var minWidth = 3,
start = moment.utc(job.executed_at).local(),
end = moment.utc(job.finished_at).local(),
timezoneOffset = new Date().getTimezoneOffset() * 60,
startTime = job.executed_at || job.scheduled_at || job.created_at,
start = new Date(startTime).getTime() / 1000,
end = new Date(job.finished_at).getTime() / 1000,
now = (new Date().getTime() / 1000) + timezoneOffset,
duration = 0;

if (job.finished_at == null && job.status == 'running') {
duration = moment().diff(start, 'seconds') / this.scale;
if (job.finished_at == null && job.status == 'running' && start != 0) {
duration = (now - start) / this.scale;
}

if (end.isValid()) {
duration = end.diff(start, 'seconds') / this.scale;
if (moment(end).isValid() && job.executed_at != null) {
duration = (end - start) / this.scale;
}
duration = Math.round(duration);
duration = duration > minWidth ? duration : minWidth;
Expand Down Expand Up @@ -250,6 +257,7 @@ define([
this.updateRange();
this.updateTimelineWidth();
this.setNow();
this.transformObject(this.rows);
},

reloader: function () {
Expand All @@ -262,6 +270,17 @@ define([
});
},

transformObject: function (obj) {
var properties = [];
ko.utils.objectForEach(obj, function (key, value) {
properties.push({ key: key, value: value });
});
// we don't need the range key, which is stored
// in the first element
properties.shift();
this.transformedRows(properties);
},

/**
* Handles dragging functionality on the timeline window
*/
Expand Down
55 changes: 0 additions & 55 deletions view/adminhtml/web/templates/timeline/details.html

This file was deleted.

93 changes: 69 additions & 24 deletions view/adminhtml/web/templates/timeline/timeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
<span data-bind="text: range.timeframe"/>
</div>
</div>
<div foreachProp="rows">
<!-- ko if: $index() != 0 -->
<fastForEach args="data: transformedRows">
<div class="row">
<div class="job-code">
<text args="$data.key" />
</div>
</div>
<!-- /ko -->
</div>
</fastForEach>
</div>
<div class="main-content">
<div class="timeline-container" afterRender="afterTimelineRender">
Expand All @@ -46,30 +44,77 @@
</div>
</div>
</div>
<div foreachProp="rows">
<!-- ko if: $index() != 0 -->
<div class="row">
<div data-bind="attr: { class: 'cjm-timeline cjm-timeline_' + $data.key }">
<div data-bind="foreach: $data.value">
<div data-bind="attr: { 'data-tooltip-search-scope': 'search-scope-' + $data.schedule_id }">
<div data-bind="
attr: {
class: 'cron-job ' + $data.status,
id: $data.schedule_id,
'data-tooltip-trigger': 'update-' + $data.schedule_id,
},
style: {
width: $parentContext.$parent.getCronWidth($data) + 'px',
left: $parentContext.$parent.getOffset($data)
}">
<div render="$parentContext.$parent.detailsTmpl"/>
<fastForEach args="data: transformedRows">
<div class="row">
<div data-bind="attr: { class: 'cjm-timeline cjm-timeline_' + $data.key }">
<fastForEach args="data: $data.value">
<div>
<div data-bind="
attr: {
class: 'cron-job ' + $data.status,
id: $data.schedule_id,
'data-tooltip-trigger': 'update-' + $data.schedule_id,
},
style: {
width: $parentContext.$parent.getCronWidth($data) + 'px',
left: $parentContext.$parent.getOffset($data)
}"/>
<div tooltip=" trigger: '[data-tooltip-trigger=update-' + schedule_id + ']',
action: 'hover',
delay: 0,
strict: false,
closeButton: false">
<div>
<div class="data-tooltip-title">
<text args="job_code"/>
</div>
<div class="data-tooltip-content">
<dl class="staging-events-summary">
<dt>
<translate args="'Schedule Id'"/>:
</dt>
<dd>
<text args="schedule_id"/>
</dd>
<dt>
<translate args="'Status'"/>:
</dt>
<dd>
<text args="status"/>
</dd>
<dt>
<translate args="'Created at'"/>:
</dt>
<dd>
<time text="$parentContext.$parent.formatTime(created_at)"/>
</dd>
<dt>
<translate args="'Scheduled at'"/>:
</dt>
<dd>
<time text="$parentContext.$parent.formatTime(scheduled_at) || 'N/A'"/>
</dd>
<dt>
<translate args="'Executed at'"/>:
</dt>
<dd>
<time text="$parentContext.$parent.formatTime(executed_at) || 'N/A'"/>
</dd>
<dt>
<translate args="'Finished at'"/>:
</dt>
<dd>
<time text="$parentContext.$parent.formatTime(finished_at) || 'N/A'"/>
</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
</fastForEach>
</div>
<!-- /ko -->
</div>
</div>
</fastForEach>
</div>
</div>
</div>
Expand Down

0 comments on commit 413c28f

Please sign in to comment.