Show diff with current file in running backup page

This commit is contained in:
鳥井 雪 2015-02-04 15:21:02 +09:00
parent 696008e821
commit 638f681541
5 changed files with 24 additions and 3 deletions

View File

@ -10,7 +10,7 @@ module SettingHistoryConcern
def show def show
current = @fluentd.agent.config current = @fluentd.agent.config
target = @backup_file.content target = @backup_file.content
@sdiff = Diff::LCS.sdiff(current.split("\n").map(&:rstrip), target.split("\n").map(&:rstrip)) @sdiff = Diff::LCS.sdiff(current.split("\n").map(&:rstrip), target.split("\n").map(&:rstrip)) if target
end end
def reuse def reuse

View File

@ -12,9 +12,20 @@
.row .row
.col-xs-12 .col-xs-12
- if @backup_file.content - if @backup_file.content
%h2
= t('.page_title')
%pre %pre
= preserve do = preserve do
= @backup_file.content = @backup_file.content
- else - else
%p %p
=t('fluentd.common.never_started_yet', brand: fluentd_ui_brand) =t('fluentd.common.never_started_yet', brand: fluentd_ui_brand)
- if @backup_file.content
.col-xs-12.diff
%h2
Diff:
%div
= t(".diff_discription")
%div.pull-right
= link_to t(".show_current"), daemon_setting_path(@fluentd)
= preserve render "/shared/settings/diff"

View File

@ -263,12 +263,14 @@ en:
page_title: "Reuse Setting History" page_title: "Reuse Setting History"
target_config: "Target Config" target_config: "Target Config"
current_config: "Current Config" current_config: "Current Config"
diff_discription: "diff between current config and target config(%{file_name})" diff_discription: "diff between current config and target config(%{file_name}) (showing with '+' and '-' if any)"
show_current: "> see current config" show_current: "> see current config"
running_backup: running_backup:
title: "Running Config" title: "Running Config"
show: show:
page_title: "Running Config" page_title: "Running Config"
diff_discription: "diff between config and running config (showing with '+' and '-' if any)"
show_current: "> see current config"
misc: misc:
information: information:

View File

@ -268,12 +268,14 @@ ja:
page_title: "設定履歴 | 詳細" page_title: "設定履歴 | 詳細"
target_config: "対象設定" target_config: "対象設定"
current_config: "現在の設定" current_config: "現在の設定"
diff_discription: "現在の設定と対象設定(%{file_name})の差分" diff_discription: "現在の設定と対象設定(%{file_name})の差分(+-で表示)"
show_current: "> 現在の設定を見る" show_current: "> 現在の設定を見る"
running_backup: running_backup:
title: "使用中の設定" title: "使用中の設定"
show: show:
page_title: "使用中の設定" page_title: "使用中の設定"
diff_discription: "現在の設定と使用中の設定の差分(+-で表示)"
show_current: "> 現在の設定を見る"
misc: misc:
information: information:

View File

@ -36,6 +36,12 @@ describe "running_backup", stub: :daemon do
expect(page).to have_text(I18n.t("terms.reuse")) expect(page).to have_text(I18n.t("terms.reuse"))
end end
it 'has diff' do
expect(page).to have_text("- type http")
expect(page).to have_text("- port 8899")
expect(page).to have_text("+ Running backup file content")
end
it 'update config and redirect to setting#show' do it 'update config and redirect to setting#show' do
click_link I18n.t("terms.reuse") click_link I18n.t("terms.reuse")