added crontab to products without translations and setting values to generator form for existing crontab line
This commit is contained in:
parent
6c26db070d
commit
c927abd073
|
@ -1,6 +0,0 @@
|
||||||
class CrontabsController < ApplicationController
|
|
||||||
|
|
||||||
def show
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -46,6 +46,14 @@ class Product < ActiveRecord::Base
|
||||||
self.attributes = attrs
|
self.attributes = attrs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cron_command
|
||||||
|
self.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def cron_tab
|
||||||
|
self[:cron_tab].present? ? self[:cron_tab] : "*\t*\t*\t*\t*"
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def destroy_tar?
|
def destroy_tar?
|
||||||
|
|
|
@ -1,170 +0,0 @@
|
||||||
- content_for :javascripts do
|
|
||||||
:javascript
|
|
||||||
$(function(){
|
|
||||||
$(".chooser").click(function() {
|
|
||||||
var for_element = this.name.replace(/_chooser/,"");
|
|
||||||
$("#" + for_element).attr("disabled", (this.value !== "1"));
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#crontab_generator").submit(function() {
|
|
||||||
var minute, hour, day, month, weekday;
|
|
||||||
|
|
||||||
minute = getSelected('minute');
|
|
||||||
hour = getSelected('hour');
|
|
||||||
day = getSelected('day');
|
|
||||||
month = getSelected('month');
|
|
||||||
weekday = getSelected('weekday');
|
|
||||||
|
|
||||||
var command = $("#command").attr("value");
|
|
||||||
$("#cron").attr("value", minute + "\t" + hour + "\t" + day + "\t" + month + "\t" + weekday + "\t" + command);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function getSelected(name) {
|
|
||||||
var chosen;
|
|
||||||
|
|
||||||
if ($("#" + name + "_chooser_every").attr("checked")) {
|
|
||||||
chosen = '*';
|
|
||||||
} else {
|
|
||||||
var all_selected = [];
|
|
||||||
|
|
||||||
$("#" + name + " option:selected").each(function(i, ele) { all_selected.push($(ele).attr("value")); });
|
|
||||||
|
|
||||||
if (all_selected.length) {
|
|
||||||
chosen = all_selected.join(",");
|
|
||||||
} else {
|
|
||||||
chosen = '*';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return chosen;
|
|
||||||
}
|
|
||||||
|
|
||||||
.block
|
|
||||||
.content
|
|
||||||
%h2.title= t("layout.crontabs.new_header")
|
|
||||||
.inner
|
|
||||||
= form_tag "", :class => :form, :id => "crontab_generator" do
|
|
||||||
.group
|
|
||||||
= label_tag :command, "Comman", :class => :label
|
|
||||||
= text_field_tag :command, "", :class => :text_field
|
|
||||||
|
|
||||||
.columns.wat-cf
|
|
||||||
.column.left
|
|
||||||
%h3.title Minutes
|
|
||||||
.group
|
|
||||||
= label_tag :minute_chooser_every, "Every minute", :class => :label
|
|
||||||
= radio_button_tag :minute_chooser, 0, true, :id => :minute_chooser_every, :class => :chooser
|
|
||||||
|
|
||||||
= label_tag :minute_chooser_choose, "Choose", :class => :label
|
|
||||||
= radio_button_tag :minute_chooser, 1, false, :id => :minute_chooser_choose, :class => :chooser
|
|
||||||
|
|
||||||
.group
|
|
||||||
-#= select_tag :minute, options_from_collection_for_select((0..59)), :id => :minute, :multiple => true, :disabled => true
|
|
||||||
%select{ :name => :minute, :id => :minute, :multiple => true, :disabled => true }
|
|
||||||
- (0..59).each do |min|
|
|
||||||
%option{ :value => min }= min
|
|
||||||
|
|
||||||
.column.right
|
|
||||||
%h3.title Hour
|
|
||||||
.group
|
|
||||||
= label_tag :hour_chooser_every, "Every hour", :class => :label
|
|
||||||
= radio_button_tag :hour_chooser, 0, true, :id => :minute_chooser_every, :class => :chooser
|
|
||||||
|
|
||||||
= label_tag :hour_chooser_choose, "Choose", :class => :label
|
|
||||||
= radio_button_tag :hour_chooser, 1, false, :id => :minute_chooser_choose, :class => :chooser
|
|
||||||
|
|
||||||
.group
|
|
||||||
%select{ :name => :hour, :id => :hour, :multiple => true, :disabled => true }
|
|
||||||
%option{ :value => "0" } 12 Midnight
|
|
||||||
%option{ :value => "1" } 1 AM
|
|
||||||
%option{ :value => "2" } 2 AM
|
|
||||||
%option{ :value => "3" } 3 AM
|
|
||||||
%option{ :value => "4" } 4 AM
|
|
||||||
%option{ :value => "5" } 5 AM
|
|
||||||
%option{ :value => "6" } 6 AM
|
|
||||||
%option{ :value => "7" } 7 AM
|
|
||||||
%option{ :value => "8" } 8 AM
|
|
||||||
%option{ :value => "9" } 9 AM
|
|
||||||
%option{ :value => "10" } 10 AM
|
|
||||||
%option{ :value => "11" } 11 AM
|
|
||||||
%option{ :value => "12" } 12 Noon
|
|
||||||
%option{ :value => "13" } 1 PM
|
|
||||||
%option{ :value => "14" } 2 PM
|
|
||||||
%option{ :value => "15" } 3 PM
|
|
||||||
%option{ :value => "16" } 4 PM
|
|
||||||
%option{ :value => "17" } 5 PM
|
|
||||||
%option{ :value => "18" } 6 PM
|
|
||||||
%option{ :value => "19" } 7 PM
|
|
||||||
%option{ :value => "20" } 8 PM
|
|
||||||
%option{ :value => "21" } 9 PM
|
|
||||||
%option{ :value => "22" } 10 PM
|
|
||||||
%option{ :value => "23" } 11 PM
|
|
||||||
|
|
||||||
.columns.wat-cf
|
|
||||||
.column.left
|
|
||||||
%h3.title Day
|
|
||||||
.group
|
|
||||||
= label_tag :day_chooser_every, "Every day", :class => :label
|
|
||||||
= radio_button_tag :day_chooser, 0, true, :id => :day_chooser_every, :class => :chooser
|
|
||||||
|
|
||||||
= label_tag :day_chooser_choose, "Choose", :class => :label
|
|
||||||
= radio_button_tag :day_chooser, 1, false, :id => :day_chooser_choose, :class => :chooser
|
|
||||||
|
|
||||||
.group
|
|
||||||
-#= select_tag :day, options_from_collection_for_select((0..31)), :id => :day, :multiple => true, :disabled => true
|
|
||||||
%select{ :name => "day", :id => "day", :multiple => true, :disabled => true }
|
|
||||||
- (1..31).each do |day|
|
|
||||||
%option{ :value => day }= day
|
|
||||||
|
|
||||||
.column.right
|
|
||||||
%h3.title Month
|
|
||||||
.group
|
|
||||||
= label_tag :month_chooser_every, "Every month", :class => :label
|
|
||||||
= radio_button_tag :month_chooser, 0, true, :id => :month_chooser_every, :class => :chooser
|
|
||||||
|
|
||||||
= label_tag :month_chooser_choose, "Choose", :class => :label
|
|
||||||
= radio_button_tag :month_chooser, 1, false, :id => :month_chooser_choose, :class => :chooser
|
|
||||||
|
|
||||||
.group
|
|
||||||
%select{ :name => "month", :id => "month", :multiple => true, :disabled => true }
|
|
||||||
%option{ :value => "1" } January
|
|
||||||
%option{ :value => "2" } February
|
|
||||||
%option{ :value => "3" } March
|
|
||||||
%option{ :value => "4" } April
|
|
||||||
%option{ :value => "5" } May
|
|
||||||
%option{ :value => "6" } June
|
|
||||||
%option{ :value => "7" } July
|
|
||||||
%option{ :value => "8" } August
|
|
||||||
%option{ :value => "9" } September
|
|
||||||
%option{ :value => "10" } October
|
|
||||||
%option{ :value => "11" } November
|
|
||||||
%option{ :value => "12" } December
|
|
||||||
|
|
||||||
.columns.wat-cf
|
|
||||||
.column.left
|
|
||||||
%h3.title Weekday
|
|
||||||
.group
|
|
||||||
= label_tag :weekday_chooser_every, "Every weekday", :class => :label
|
|
||||||
= radio_button_tag :weekday_chooser, 0, true, :id => :weekday_chooser_every, :class => :chooser
|
|
||||||
|
|
||||||
= label_tag :weekday_chooser_choose, "Choose", :class => :label
|
|
||||||
= radio_button_tag :weekday_chooser, 1, false, :id => :weekday_chooser_choose, :class => :chooser
|
|
||||||
|
|
||||||
.group
|
|
||||||
%select{ :name => "weekday", :id => "weekday", :multiple => true, :disabled => "disabled" }
|
|
||||||
%option{ :value => "0" } Sunday
|
|
||||||
%option{ :value => "1" } Monday
|
|
||||||
%option{ :value => "2" } Tuesday
|
|
||||||
%option{ :value => "3" } Wednesday
|
|
||||||
%option{ :value => "4" } Thursday
|
|
||||||
%option{ :value => "5" } Friday
|
|
||||||
%option{ :value => "6" } Saturday
|
|
||||||
|
|
||||||
.group
|
|
||||||
%textarea{ :name => "cron", :id => "cron", :rows => "3", :cols => "70" }
|
|
||||||
|
|
||||||
.group.navform.wat-cf
|
|
||||||
%button.button{ :type => "submit" }= t("layout.crontabs.generate_crontab_line")
|
|
|
@ -0,0 +1,188 @@
|
||||||
|
- content_for :javascripts do
|
||||||
|
:javascript
|
||||||
|
$(function(){
|
||||||
|
$(".chooser").click(function() {
|
||||||
|
var for_element = this.name.replace(/_chooser/,"");
|
||||||
|
$("#" + for_element).attr("disabled", (this.value !== "1"));
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".cron").change(function() {
|
||||||
|
var minute, hour, day, month, weekday;
|
||||||
|
|
||||||
|
minute = getSelected('minute');
|
||||||
|
hour = getSelected('hour');
|
||||||
|
day = getSelected('day');
|
||||||
|
month = getSelected('month');
|
||||||
|
weekday = getSelected('weekday');
|
||||||
|
|
||||||
|
$("#cron").attr("value", minute + "\t" + hour + "\t" + day + "\t" + month + "\t" + weekday);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#product_use_cron").change(function(){
|
||||||
|
if ($("#product_use_cron:checked").length > 0) {
|
||||||
|
$("#cron").attr("disabled", false);
|
||||||
|
} else {
|
||||||
|
$("#cron").attr("disabled", true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#genereator_btn a").click(function(){
|
||||||
|
$("#crontab_generator").slideToggle(function(){
|
||||||
|
|
||||||
|
if ($("#crontab_generator").css("display") == "none") {
|
||||||
|
$("#genereator_btn a").text("Show crontab generator");
|
||||||
|
} else {
|
||||||
|
$("#genereator_btn a").text("Hide crontab generator");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function getSelected(name) {
|
||||||
|
var chosen;
|
||||||
|
|
||||||
|
if ($("#" + name + "_chooser_every").attr("checked")) {
|
||||||
|
chosen = '*';
|
||||||
|
} else {
|
||||||
|
var all_selected = [];
|
||||||
|
|
||||||
|
$("#" + name + " option:selected").each(function(i, ele) { all_selected.push($(ele).attr("value")); });
|
||||||
|
|
||||||
|
if (all_selected.length) {
|
||||||
|
chosen = all_selected.join(",");
|
||||||
|
} else {
|
||||||
|
chosen = '*';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return chosen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.group
|
||||||
|
= form.check_box :use_cron
|
||||||
|
= form.label :use_cron
|
||||||
|
|
||||||
|
#genereator_btn
|
||||||
|
%a{ :href => "#" } Show crontab generator
|
||||||
|
|
||||||
|
#crontab_generator{ :style => "display: none;" }
|
||||||
|
.columns.wat-cf
|
||||||
|
.column.left
|
||||||
|
%h3.title Minutes
|
||||||
|
.group
|
||||||
|
= label_tag :minute_chooser_every, "Every minute", :class => :label
|
||||||
|
= radio_button_tag :minute_chooser, 0, true, :id => :minute_chooser_every, :class => "chooser cron"
|
||||||
|
|
||||||
|
= label_tag :minute_chooser_choose, "Choose", :class => :label
|
||||||
|
= radio_button_tag :minute_chooser, 1, false, :id => :minute_chooser_choose, :class => "chooser cron"
|
||||||
|
|
||||||
|
.group
|
||||||
|
%select{ :name => :minute, :id => :minute, :multiple => true, :disabled => true, :class => "cron" }
|
||||||
|
- (0..59).each do |min|
|
||||||
|
%option{ :value => min }= min
|
||||||
|
|
||||||
|
.column.right
|
||||||
|
%h3.title Hour
|
||||||
|
.group
|
||||||
|
= label_tag :hour_chooser_every, "Every hour", :class => :label
|
||||||
|
= radio_button_tag :hour_chooser, 0, true, :id => :minute_chooser_every, :class => "chooser cron"
|
||||||
|
|
||||||
|
= label_tag :hour_chooser_choose, "Choose", :class => :label
|
||||||
|
= radio_button_tag :hour_chooser, 1, false, :id => :minute_chooser_choose, :class => "chooser cron"
|
||||||
|
|
||||||
|
.group
|
||||||
|
%select{ :name => :hour, :id => :hour, :multiple => true, :disabled => true, :class => "cron" }
|
||||||
|
%option{ :value => "0" } 12 Midnight
|
||||||
|
%option{ :value => "1" } 1 AM
|
||||||
|
%option{ :value => "2" } 2 AM
|
||||||
|
%option{ :value => "3" } 3 AM
|
||||||
|
%option{ :value => "4" } 4 AM
|
||||||
|
%option{ :value => "5" } 5 AM
|
||||||
|
%option{ :value => "6" } 6 AM
|
||||||
|
%option{ :value => "7" } 7 AM
|
||||||
|
%option{ :value => "8" } 8 AM
|
||||||
|
%option{ :value => "9" } 9 AM
|
||||||
|
%option{ :value => "10" } 10 AM
|
||||||
|
%option{ :value => "11" } 11 AM
|
||||||
|
%option{ :value => "12" } 12 Noon
|
||||||
|
%option{ :value => "13" } 1 PM
|
||||||
|
%option{ :value => "14" } 2 PM
|
||||||
|
%option{ :value => "15" } 3 PM
|
||||||
|
%option{ :value => "16" } 4 PM
|
||||||
|
%option{ :value => "17" } 5 PM
|
||||||
|
%option{ :value => "18" } 6 PM
|
||||||
|
%option{ :value => "19" } 7 PM
|
||||||
|
%option{ :value => "20" } 8 PM
|
||||||
|
%option{ :value => "21" } 9 PM
|
||||||
|
%option{ :value => "22" } 10 PM
|
||||||
|
%option{ :value => "23" } 11 PM
|
||||||
|
|
||||||
|
.columns.wat-cf
|
||||||
|
.column.left
|
||||||
|
%h3.title Day
|
||||||
|
.group
|
||||||
|
= label_tag :day_chooser_every, "Every day", :class => :label
|
||||||
|
= radio_button_tag :day_chooser, 0, true, :id => :day_chooser_every, :class => "chooser cron"
|
||||||
|
|
||||||
|
= label_tag :day_chooser_choose, "Choose", :class => :label
|
||||||
|
= radio_button_tag :day_chooser, 1, false, :id => :day_chooser_choose, :class => "chooser cron"
|
||||||
|
|
||||||
|
.group
|
||||||
|
%select{ :name => "day", :id => "day", :multiple => true, :disabled => true, :class => "cron" }
|
||||||
|
- (1..31).each do |day|
|
||||||
|
%option{ :value => day }= day
|
||||||
|
|
||||||
|
.column.right
|
||||||
|
%h3.title Month
|
||||||
|
.group
|
||||||
|
= label_tag :month_chooser_every, "Every month", :class => :label
|
||||||
|
= radio_button_tag :month_chooser, 0, true, :id => :month_chooser_every, :class => "chooser cron"
|
||||||
|
|
||||||
|
= label_tag :month_chooser_choose, "Choose", :class => :label
|
||||||
|
= radio_button_tag :month_chooser, 1, false, :id => :month_chooser_choose, :class => "chooser cron"
|
||||||
|
|
||||||
|
.group
|
||||||
|
%select{ :name => "month", :id => "month", :multiple => true, :disabled => true, :class => "cron" }
|
||||||
|
%option{ :value => "1" } January
|
||||||
|
%option{ :value => "2" } February
|
||||||
|
%option{ :value => "3" } March
|
||||||
|
%option{ :value => "4" } April
|
||||||
|
%option{ :value => "5" } May
|
||||||
|
%option{ :value => "6" } June
|
||||||
|
%option{ :value => "7" } July
|
||||||
|
%option{ :value => "8" } August
|
||||||
|
%option{ :value => "9" } September
|
||||||
|
%option{ :value => "10" } October
|
||||||
|
%option{ :value => "11" } November
|
||||||
|
%option{ :value => "12" } December
|
||||||
|
|
||||||
|
.columns.wat-cf
|
||||||
|
.column.left
|
||||||
|
%h3.title Weekday
|
||||||
|
.group
|
||||||
|
= label_tag :weekday_chooser_every, "Every weekday", :class => :label
|
||||||
|
= radio_button_tag :weekday_chooser, 0, true, :id => :weekday_chooser_every, :class => "chooser cron"
|
||||||
|
|
||||||
|
= label_tag :weekday_chooser_choose, "Choose", :class => :label
|
||||||
|
= radio_button_tag :weekday_chooser, 1, false, :id => :weekday_chooser_choose, :class => "chooser cron"
|
||||||
|
|
||||||
|
.group
|
||||||
|
%select{ :name => "weekday", :id => "weekday", :multiple => true, :disabled => "disabled", :class => "cron" }
|
||||||
|
%option{ :value => "0" } Sunday
|
||||||
|
%option{ :value => "1" } Monday
|
||||||
|
%option{ :value => "2" } Tuesday
|
||||||
|
%option{ :value => "3" } Wednesday
|
||||||
|
%option{ :value => "4" } Thursday
|
||||||
|
%option{ :value => "5" } Friday
|
||||||
|
%option{ :value => "6" } Saturday
|
||||||
|
|
||||||
|
.group
|
||||||
|
= form.label :cron_tab, :class => :label
|
||||||
|
= form.text_field :cron_tab, :id => "cron", :class => "text_field", :style => "width: 40%", :disabled => !@product.use_cron, :value => @product.cron_tab
|
||||||
|
= @product.cron_command
|
|
@ -22,6 +22,10 @@
|
||||||
= link_to @product.tar_file_name, @product.tar.url
|
= link_to @product.tar_file_name, @product.tar.url
|
||||||
= f.check_box :delete_tar
|
= f.check_box :delete_tar
|
||||||
= f.label :delete_tar, t('layout.delete')
|
= f.label :delete_tar, t('layout.delete')
|
||||||
|
|
||||||
|
.group
|
||||||
|
= render :partial => "products/crontab", :locals => { :form => f }
|
||||||
|
|
||||||
.group
|
.group
|
||||||
= f.label :is_template, :class => :label
|
= f.label :is_template, :class => :label
|
||||||
= f.check_box :is_template, :class => 'check_box'
|
= f.check_box :is_template, :class => 'check_box'
|
||||||
|
|
|
@ -34,9 +34,7 @@ Rosa::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :users
|
resources :users
|
||||||
|
|
||||||
match 'crontabs', :to => 'crontabs#show'
|
|
||||||
|
|
||||||
match 'build_lists/status_build', :to => "build_lists#status_build"
|
match 'build_lists/status_build', :to => "build_lists#status_build"
|
||||||
match 'build_lists/post_build', :to => "build_lists#post_build"
|
match 'build_lists/post_build', :to => "build_lists#post_build"
|
||||||
match 'build_lists/pre_build', :to => "build_lists#pre_build"
|
match 'build_lists/pre_build', :to => "build_lists#pre_build"
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
class AddCronTabToProducts < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :products, :cron_tab, :text
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :products, :cron_tab
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
class AddUseCronToProducts < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :products, :use_cron, :boolean, :default => false
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :products, :use_cron
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20110414145300) do
|
ActiveRecord::Schema.define(:version => 20110428140753) do
|
||||||
|
|
||||||
create_table "arches", :force => true do |t|
|
create_table "arches", :force => true do |t|
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
|
@ -99,6 +99,8 @@ ActiveRecord::Schema.define(:version => 20110414145300) do
|
||||||
t.datetime "tar_updated_at"
|
t.datetime "tar_updated_at"
|
||||||
t.boolean "is_template", :default => false
|
t.boolean "is_template", :default => false
|
||||||
t.boolean "system_wide", :default => false
|
t.boolean "system_wide", :default => false
|
||||||
|
t.text "cron_tab"
|
||||||
|
t.boolean "use_cron", :default => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "projects", :force => true do |t|
|
create_table "projects", :force => true do |t|
|
||||||
|
|
Loading…
Reference in New Issue