Newer
Older
/**
* This file contains package/quiqqer/cron/bin/CronWindow
*
* @author www.namerobot.com (Henning Leutz)
*/
define('package/quiqqer/cron/bin/CronWindow', [
'css!package/quiqqer/cron/bin/CronWindow'
], function(QUIConfirm, QUIParams, Ajax)
Type : 'package/quiqqer/cron/bin/CronWindow',
title : 'Cron hinzufügen',
icon : 'icon-time',
maxWidth : 500,
maxHeight : 300,
cronId : null // if you want to edit a cron
},
initialize : function(options)
{
this.parent( options );
this.$available = [];
this.$List = null;
this.$Min = null;
this.$Hour = null;
this.$Day = null;
this.$Month = null;
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
},
/**
* Open the Window
*
* @return {self}
*/
open : function()
{
this.parent();
this.Loader.show();
var self = this,
Content = this.getContent();
Content.set(
'html',
'<div class="control-cron-add">' +
'<label for="control-cron-add-list">' +
'Cron' +
'</label>' +
'<select ' +
'class="control-cron-add-list" ' +
'id="control-cron-add-list">' +
'</select>' +
'<div class="control-cron-add-intervall">' +
'<div class="control-cron-add-intervall-title">' +
'Intervall:' +
'</div>' +
'<div class="control-cron-add-intervall-entries">' +
'<div class="control-cron-add-intervall-entry">' +
'<input type="text" name="min" id="control-cron-add-minute" />' +
'<label for="control-cron-add-minute">Minute</label>' +
'</div>' +
'<div class="control-cron-add-intervall-entry">' +
'<input type="text" name="hour" id="control-cron-add-hour" />' +
'<label for="control-cron-add-hour">Stunde</label>' +
'</div>' +
'<div class="control-cron-add-intervall-entry">' +
'<input type="text" name="day" id="control-cron-add-day" />' +
'<label for="control-cron-add-day">Tag</label>' +
'</div>' +
'<div class="control-cron-add-intervall-entry">' +
'<input type="text" name="month" id="control-cron-add-month" />' +
'<label for="control-cron-add-month">Monat</label>' +
'</div>' +
'</div>' +
'</div>' +
'<label for="control-cron-add-params">' +
'Parameter' +
'</label>' +
'<input type="text" name="params" id="control-cron-add-params" />' +
'</div>'
);
this.$List = Content.getElement( '.control-cron-add-list' );
this.$Min = Content.getElement( '[name="min"]' );
this.$Hour = Content.getElement( '[name="hour"]' );
this.$Day = Content.getElement( '[name="day"]' );
this.$Month = Content.getElement( '[name="month"]' );
this.$Params = Content.getElement( '[name="params"]' );
Ajax.get('package_quiqqer_cron_ajax_getAvailableCrons', function(result)
{
var i, len;
self.$available = result;
for ( i = 0, len = result.length; i < len; i++ )
{
new Element('option', {
html : result[ i ].title +' - '+ result[ i ].description
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
if ( !self.getAttribute( 'cronId' ) )
{
self.Loader.hide();
return;
}
Ajax.get('package_quiqqer_cron_ajax_cron_get', function(result)
{
var size = self.getElm().getSize();
self.$List.value = result.title;
self.$Min.value = result.min;
self.$Hour.value = result.hour;
self.$Day.value = result.day;
self.$Month.value = result.month;
self.$Params.value = result.params;
self.$ParamsControl = new QUIParams( self.$Params, {
windowMaxHeight : size.y,
windowMaxWidth : size.x
} );
self.Loader.hide();
}, {
'package' : 'quiqqer/cron',
cronId : self.getAttribute( 'cronId' )
});
}, {
'package' : 'quiqqer/cron'
});
return this;
},
/**
* Add the Cron to the list
*
* @return {self}
*/
submit : function()
{
var self = this;
if ( !this.$List ) {
return this;
}
if ( !this.getContent() ) {
return this;
}
if ( this.getAttribute( 'cronId' ) )
{
Ajax.post('package_quiqqer_cron_ajax_edit', function(result)
{
self.fireEvent( 'submit' );
self.close();
}, {
'package' : 'quiqqer/cron',
cronId : this.getAttribute( 'cronId' ),
cron : this.$List.value,
min : this.$Min.value,
hour : this.$Hour.value,
day : this.$Day.value,
month : this.$Month.value,
params : JSON.decode( this.$ParamsControl.getValue() )
});
return this;
}
Ajax.post('package_quiqqer_cron_ajax_add', function(result)
{
self.fireEvent( 'submit' );
cron : this.$List.value,
min : this.$Min.value,
hour : this.$Hour.value,
day : this.$Day.value,
month : this.$Month.value,
params : JSON.decode( this.$ParamsControl.getValue() )