-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
45 deletions.
There are no files selected for viewing
94 changes: 49 additions & 45 deletions
94
apps/dashboard/app/controllers/batch_connect/settings_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,59 @@ | ||
# frozen_string_literal: true | ||
|
||
# The controller to manage BatchConnect saved settings | ||
class BatchConnect::SettingsController < ApplicationController | ||
include BatchConnectConcern | ||
include UserSettingStore | ||
|
||
# GET /batch_connect/<app_token>/settings/<settings_name> | ||
def show | ||
set_app_groups | ||
set_saved_settings | ||
|
||
request_params = settings_request_params | ||
app_token = request_params[:token] | ||
settings_name = request_params[:id] | ||
settings_values = bc_templates(app_token)[settings_name.to_sym] | ||
if settings_values.nil? | ||
redirect_to new_batch_connect_session_context_path(token: app_token), | ||
alert: t('dashboard.bc_saved_settings.missing_settings') | ||
return | ||
module BatchConnect | ||
class SettingsController < ApplicationController | ||
include BatchConnectConcern | ||
include UserSettingStore | ||
|
||
# GET /batch_connect/<app_token>/settings/<settings_name> | ||
def show | ||
set_app_groups | ||
set_saved_settings | ||
|
||
request_params = settings_request_params | ||
app_token = request_params[:token] | ||
settings_name = request_params[:id] | ||
settings_values = bc_templates(app_token)[settings_name.to_sym] | ||
if settings_values.nil? | ||
redirect_to new_batch_connect_session_context_path(token: app_token), | ||
alert: t('dashboard.bc_saved_settings.missing_settings') | ||
return | ||
end | ||
|
||
@settings = BatchConnect::Settings.new(app_token, settings_name, settings_values) | ||
if @settings.outdated? | ||
flash.now[:alert] = t('dashboard.bc_saved_settings.outdated_message', app_title: @settings.app.title) | ||
end | ||
end | ||
|
||
@settings = BatchConnect::Settings.new(app_token, settings_name, settings_values) | ||
if @settings.outdated? | ||
flash.now[:alert] = t('dashboard.bc_saved_settings.outdated_message', app_title: @settings.app.title) | ||
# DELETE /batch_connect/<app_token>/settings/<settings_name> | ||
def destroy | ||
request_params = settings_request_params | ||
app_token = request_params[:token] | ||
settings_name = request_params[:id] | ||
delete_bc_template(app_token, settings_name) | ||
redirect_to new_batch_connect_session_context_path(token: app_token), | ||
notice: t('dashboard.bc_saved_settings.deleted_message', settings_name: settings_name) | ||
end | ||
end | ||
|
||
# DELETE /batch_connect/<app_token>/settings/<settings_name> | ||
def destroy | ||
request_params = settings_request_params | ||
app_token = request_params[:token] | ||
settings_name = request_params[:id] | ||
delete_bc_template(app_token, settings_name) | ||
redirect_to new_batch_connect_session_context_path(token: app_token), | ||
notice: t('dashboard.bc_saved_settings.deleted_message', settings_name: settings_name) | ||
end | ||
|
||
private | ||
private | ||
|
||
def settings_request_params | ||
params.permit(:token, :id) | ||
end | ||
def settings_request_params | ||
params.permit(:token, :id) | ||
end | ||
|
||
# Set the all the saved settings to render the navigation | ||
def set_saved_settings | ||
@bc_saved_settings = all_bc_templates | ||
end | ||
# Set the all the saved settings to render the navigation | ||
def set_saved_settings | ||
@bc_saved_settings = all_bc_templates | ||
end | ||
|
||
# Set list of app lists for navigation | ||
def set_app_groups | ||
@sys_app_groups = bc_sys_app_groups | ||
@usr_app_groups = bc_usr_app_groups | ||
@dev_app_groups = bc_dev_app_groups | ||
@apps_menu_group = bc_custom_apps_group | ||
# Set list of app lists for navigation | ||
def set_app_groups | ||
@sys_app_groups = bc_sys_app_groups | ||
@usr_app_groups = bc_usr_app_groups | ||
@dev_app_groups = bc_dev_app_groups | ||
@apps_menu_group = bc_custom_apps_group | ||
end | ||
end | ||
end |