diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a6437a..415a943 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,12 +1,13 @@
# InfinityOne Changelog
-## 1.0.0.beta10 (2018-04-02)
+## 1.0.0.beta10 (2018-04-03)
### Enhancements
* Add InfinityOnePages package including download desktop app support
* Update the default home page default text
* Support markdown for home page text entry
+* Added support for reset admin changes back to default value
### Bug Fixes
diff --git a/assets/css/admin.scss b/assets/css/admin.scss
index e98c0ec..fc6795a 100644
--- a/assets/css/admin.scss
+++ b/assets/css/admin.scss
@@ -59,3 +59,7 @@ form.backup {
padding-bottom: 10px;
}
}
+
+.reset-settings {
+ margin-left: 20px;
+}
diff --git a/assets/js/admin.js b/assets/js/admin.js
index a154e32..d2d65cf 100644
--- a/assets/js/admin.js
+++ b/assets/js/admin.js
@@ -30,29 +30,40 @@ class Admin {
save.attr('disabled', 'disabled')
$('button.discard').remove()
}
+ add_reset_setting_button(target, input_line) {
+ let data_settings = target.getAttribute('name').replace('[', '__').replace(']', '')
+ let reset = ``
+ if (input_line.find('button.reset-settings').length === 0) {
+ input_line.append(reset);
+
+ Rebel.set_event_handlers($(target).selector);
+ }
+ }
+ handle_change(e) {
+ let target = e.currentTarget;
+ let input_line = $(target).closest('.input-line');
+ this.enable_save_button()
+ input_line.addClass('setting-changed')
+ this.add_reset_setting_button(target, input_line);
+ }
register_events(admin) {
$('body')
- .on('click', 'button.discard', function() {
+ .on('click', 'button.discard', () => {
// admin.disable_save_button()
$('a.admin-link[data-id="admin_info"]').click()
})
- .on('change', '.admin-settings form input:not(.search)', function(e) {
- let target = e.currentTarget
- admin.enable_save_button()
- let reset = ``
- $(this).closest('.input-line').addClass('setting-changed') //.append(reset)
+ .on('change', '.admin-settings form input:not(.search)', (e) => {
+ this.handle_change(e);
})
- .on('change', '.admin-settings form select', function(e) {
- admin.enable_save_button()
- $(this).closest('.input-line').addClass('setting-changed') //.append(reset)
+ .on('change', '.admin-settings form select', (e) => {
+ this.handle_change(e);
})
- .on('keyup keypress paste', '.admin-settings form input:not(.search)', function(e) {
- admin.enable_save_button()
- $(this).closest('.input-line').addClass('setting-changed') //.append(reset)
+ .on('keyup keypress paste', '.admin-settings form input:not(.search)', (e) => {
+ this.handle_change(e);
})
- .on('keyup keypress paste', '.admin-settings form textarea', function(e) {
- admin.enable_save_button()
- $(this).closest('.input-line').addClass('setting-changed') //.append(reset)
+ .on('keyup keypress paste', '.admin-settings form textarea', (e) => {
+ this.handle_change(e);
})
.on('change', '.permissions-manager [type="checkbox"]', function(e, t) {
e.preventDefault()
diff --git a/mix.exs b/mix.exs
index b35be0e..edd3059 100644
--- a/mix.exs
+++ b/mix.exs
@@ -4,7 +4,7 @@ defmodule InfinityOne.Mixfile do
def project do
[
app: :infinity_one,
- version: "1.0.0-beta9",
+ version: "1.0.0-beta10",
elixir: "~> 1.5",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
diff --git a/plugins/one_admin/lib/one_admin_web/channels/admin_channel.ex b/plugins/one_admin/lib/one_admin_web/channels/admin_channel.ex
index a71a45a..ace54f7 100644
--- a/plugins/one_admin/lib/one_admin_web/channels/admin_channel.ex
+++ b/plugins/one_admin/lib/one_admin_web/channels/admin_channel.ex
@@ -254,7 +254,7 @@ defmodule OneAdminWeb.AdminChannel do
def admin_restart_server(socket, _sender) do
SweetAlert.swal_modal socket, ~g(Are you sure?),
- ~g(This will disrupt servic for all active users), "warning",
+ ~g(This will disrupt service for all active users), "warning",
[
showCancelButton: true, closeOnConfirm: false, closeOnCancel: true,
confirmButtonColor: "#DD6B55", confirmButtonText: ~g(Yes, restart it)
@@ -382,6 +382,40 @@ defmodule OneAdminWeb.AdminChannel do
end
end
+ def admin_reset_setting_click(socket, sender) do
+ setting_name = sender["dataset"]["setting"]
+ [mod, field] = String.split(setting_name, "__", trim: true)
+ module = OneSettings.module_map(mod)
+ field = String.to_existing_atom(field)
+ schema = apply(module, :schema, [])
+ default = Map.get(schema.__struct__, field)
+
+ control_type = Rebel.Core.exec_js!(socket,
+ ~s/let e=$('[name="#{mod}[#{field}]"]'); e.attr('type') + ' ' + e.get(0).tagName/)
+
+ selector = "#" <> String.replace(setting_name, "__", "_")
+
+ case String.split(control_type) do
+ [_, "TEXTAREA"] ->
+ Rebel.Query.update(socket, :val, set: default, on: selector)
+ ["radio", _] ->
+ selector = selector <> "_"
+ which = if default in [true, "true"], do: "1", else: "0"
+ Rebel.Query.update(socket, prop: "checked", set: true, on: selector <> which)
+ [_, "INPUT"] ->
+ Rebel.Query.update(socket, :val, set: default, on: selector)
+ [_, "SELECT"] ->
+ Rebel.Query.update(socket, :val, set: default, on: selector)
+ other ->
+ raise "invalid control type: #{inspect other}"
+ end
+
+ socket
+ |> async_js(~s/OneChat.admin.enable_save_button()/)
+ |> async_js(~s/$('[data-setting="#{setting_name}"]').closest('.input-line').addClass('setting-changed')/)
+ |> async_js(~s/$('[data-setting="#{setting_name}"]').remove()/)
+ end
+
defp clear_selected_users(socket) do
async_js socket, ~s/$('.-autocomplete-container.users').addClass('hidden')/
end
diff --git a/plugins/one_admin/lib/one_admin_web/view/utils.ex b/plugins/one_admin/lib/one_admin_web/view/utils.ex
index fd105fc..b8612a1 100644
--- a/plugins/one_admin/lib/one_admin_web/view/utils.ex
+++ b/plugins/one_admin/lib/one_admin_web/view/utils.ex
@@ -33,7 +33,7 @@ defmodule OneAdminWeb.View.Utils do
~g"Reset section settings"
end,
content_tag :div, class: "setting-field" do
- content_tag :button, class: "reset-group button danger" do
+ content_tag :button, class: "reset-group button danger", "rebel-click": :admin_reset_settings_click do
~g"Reset"
end
end
@@ -41,7 +41,7 @@ defmodule OneAdminWeb.View.Utils do
end
end
- def text_input_line(f, _item, field, title, opts \\ []) do
+ def text_input_line(f, item, field, title, opts \\ []) do
type = opts[:type] || :text
description = opts[:description]
@@ -54,12 +54,43 @@ defmodule OneAdminWeb.View.Utils do
f
|> text_input(field, class: "input-monitor", type: type)
|> do_description(description)
- end
+ end,
+ add_changed(opts, item, field)
]
end
end
- def textarea_input_line(f, _item, field, title, opts \\ []) do
+
+ def add_changed(opts, item, field) do
+ module = item.__struct__ |> Module.split() |> List.last() |> Inflex.Underscore.underscore()
+ changed = opts[:changed]
+ if changed[field] do
+ content_tag :button, class: "reset-settings button danger", text: "Reset",
+ "data-setting": "#{module}__#{field}", "rebel-click": :admin_reset_setting_click do
+
+ content_tag :i, [class: "icon-ccw secondary-font-color color-error-contrast"], do: ""
+ end
+ else
+ []
+ end
+ end
+
+ def changed_bindings(module, current) do
+ defaults = apply(module, :new, [])
+ schema = apply(module, :schema, [])
+
+ changed =
+ Enum.reduce(schema.__schema__(:fields), %{}, fn field, acc ->
+ if Map.get(defaults, field) != Map.get(current, field) do
+ Map.put(acc, field, true)
+ else
+ acc
+ end
+ end)
+ [defaults: defaults, changed: changed]
+ end
+
+ def textarea_input_line(f, item, field, title, opts \\ []) do
type = opts[:type] || :text
description = opts[:description]
@@ -72,7 +103,8 @@ defmodule OneAdminWeb.View.Utils do
f
|> textarea(field, class: "input-monitor", type: type)
|> do_description(description)
- end
+ end,
+ add_changed(opts, item, field)
]
end
end
@@ -118,12 +150,13 @@ defmodule OneAdminWeb.View.Utils do
end
]
|> do_description(description)
- end
+ end,
+ add_changed(opts, item, field)
]
end
end
- def select_line(f, _item, field, options, title, opts \\ []) do
+ def select_line(f, item, field, options, title, opts \\ []) do
description = opts[:description]
content_tag :div, class: "input-line double-col" do
[
@@ -139,7 +172,8 @@ defmodule OneAdminWeb.View.Utils do
select(f, field, options)
]
|> do_description(description)
- end
+ end,
+ add_changed(opts, item, field)
]
end
end
diff --git a/plugins/one_chat/lib/one_chat_web/admin/accounts.ex b/plugins/one_chat/lib/one_chat_web/admin/accounts.ex
index 1518750..b04cf2d 100644
--- a/plugins/one_chat/lib/one_chat_web/admin/accounts.ex
+++ b/plugins/one_chat/lib/one_chat_web/admin/accounts.ex
@@ -2,6 +2,7 @@ defmodule OneChatWeb.Admin.Page.Accounts do
use OneAdmin.Page
alias InfinityOne.{Repo, Hooks, Settings.Accounts}
+ alias OneAdminWeb.View.Utils
def add_page do
new(
@@ -17,11 +18,12 @@ defmodule OneChatWeb.Admin.Page.Accounts do
end
def args(page, user, _sender, socket) do
+ accounts = Accounts.get()
{[
user: Repo.preload(user, Hooks.user_preload([])),
- changeset: Accounts.get() |> Accounts.changeset()
+ changeset: accounts |> Accounts.changeset()
|> Hooks.all_users_post_filter,
- ], user, page, socket}
+ ] ++ Utils.changed_bindings(Accounts, accounts), user, page, socket}
end
def check_perissions(_page, user) do
diff --git a/plugins/one_chat/lib/one_chat_web/admin/chat_general.ex b/plugins/one_chat/lib/one_chat_web/admin/chat_general.ex
index 64767ec..9768192 100644
--- a/plugins/one_chat/lib/one_chat_web/admin/chat_general.ex
+++ b/plugins/one_chat/lib/one_chat_web/admin/chat_general.ex
@@ -6,6 +6,7 @@ defmodule OneChatWeb.Admin.Page.ChatGeneral do
alias InfinityOne.{Repo, Hooks}
alias OneChat.Settings.ChatGeneral
+ alias OneAdminWeb.View.Utils
@doc """
Callback to add the ChatGeneral page into the administration pages.
@@ -27,10 +28,11 @@ defmodule OneChatWeb.Admin.Page.ChatGeneral do
Callback to provide the ChatGeneral page rendering bindings.
"""
def args(page, user, _sender, socket) do
+ general = ChatGeneral.get()
{[
user: Repo.preload(user, Hooks.user_preload([])),
- changeset: ChatGeneral.get |> ChatGeneral.changeset,
- ], user, page, socket}
+ changeset: general |> ChatGeneral.changeset(),
+ ] ++ Utils.changed_bindings(ChatGeneral, general), user, page, socket}
end
@doc """
diff --git a/plugins/one_chat/lib/one_chat_web/admin/general.ex b/plugins/one_chat/lib/one_chat_web/admin/general.ex
index 1ceb17c..9942e21 100644
--- a/plugins/one_chat/lib/one_chat_web/admin/general.ex
+++ b/plugins/one_chat/lib/one_chat_web/admin/general.ex
@@ -2,6 +2,7 @@ defmodule OneChatWeb.Admin.Page.General do
use OneAdmin.Page
alias InfinityOne.{Repo, Hooks, Settings.General}
+ alias OneAdminWeb.View.Utils
def add_page do
new(
@@ -17,11 +18,12 @@ defmodule OneChatWeb.Admin.Page.General do
end
def args(page, user, _sender, socket) do
+ general = General.get()
{[
user: Repo.preload(user, Hooks.user_preload([])),
- changeset: General.get() |> General.changeset()
+ changeset: general |> General.changeset()
|> Hooks.all_users_post_filter,
- ], user, page, socket}
+ ] ++ Utils.changed_bindings(General, general), user, page, socket}
end
def check_perissions(_page, user) do
diff --git a/plugins/one_chat/lib/one_chat_web/admin/layout.ex b/plugins/one_chat/lib/one_chat_web/admin/layout.ex
index 5fe528e..f28a70b 100644
--- a/plugins/one_chat/lib/one_chat_web/admin/layout.ex
+++ b/plugins/one_chat/lib/one_chat_web/admin/layout.ex
@@ -3,6 +3,7 @@ defmodule OneChatWeb.Admin.Page.Layout do
alias InfinityOne.{Repo, Hooks}
alias OneChat.Settings.Layout
+ alias OneAdminWeb.View.Utils
def add_page do
new(
@@ -18,10 +19,11 @@ defmodule OneChatWeb.Admin.Page.Layout do
end
def args(page, user, _sender, socket) do
+ layout = Layout.get()
{[
user: Repo.preload(user, Hooks.user_preload([])),
- changeset: Layout.get |> Layout.changeset,
- ], user, page, socket}
+ changeset: layout |> Layout.changeset,
+ ] ++ Utils.changed_bindings(Layout, layout), user, page, socket}
end
def check_perissions(_page, user) do
diff --git a/plugins/one_chat/lib/one_chat_web/admin/message.ex b/plugins/one_chat/lib/one_chat_web/admin/message.ex
index eb18b57..2e50162 100644
--- a/plugins/one_chat/lib/one_chat_web/admin/message.ex
+++ b/plugins/one_chat/lib/one_chat_web/admin/message.ex
@@ -3,6 +3,7 @@ defmodule OneChatWeb.Admin.Page.Message do
alias InfinityOne.{Repo, Hooks}
alias OneChat.Settings.Message
+ alias OneAdminWeb.View.Utils
def add_page do
new(
@@ -18,11 +19,12 @@ defmodule OneChatWeb.Admin.Page.Message do
end
def args(page, user, _sender, socket) do
+ message = Message.get()
{[
user: Repo.preload(user, Hooks.user_preload([])),
- changeset: Message.get |> Message.changeset,
+ changeset: message |> Message.changeset(),
message_opts: OneChatWeb.MessageView.message_opts()
- ], user, page, socket}
+ ] ++ Utils.changed_bindings(Message, message), user, page, socket}
end
def check_perissions(_page, user) do
diff --git a/plugins/one_chat/lib/one_chat_web/channels/user_channel.ex b/plugins/one_chat/lib/one_chat_web/channels/user_channel.ex
index 01f262f..858466b 100644
--- a/plugins/one_chat/lib/one_chat_web/channels/user_channel.ex
+++ b/plugins/one_chat/lib/one_chat_web/channels/user_channel.ex
@@ -93,7 +93,6 @@ defmodule OneChatWeb.UserChannel do
end
def join_room(user_id, room) do
- # Logger.debug ("...join_room user_id: #{inspect user_id}")
Endpoint.broadcast!(CC.chan_user() <> "#{user_id}", "room:join",
%{room: room, user_id: user_id})
end
@@ -757,7 +756,9 @@ defmodule OneChatWeb.UserChannel do
subscribe_callback "user:" <> user_id, "unread:update", :unread_update
OnePubSub.subscribe "message:new", "*"
# TODO: add Hooks for this
- # subscribe_callback "phone:presence", "presence:change", :phone_presence_change
+ subscribe_callback "user:all", "callback", :user_all_event
+
+ # TODO: Add hooks for this
OnePubSub.subscribe "user:all", "channel:deleted"
OnePubSub.subscribe "user:all", "channel:change:key"
OnePubSub.subscribe "user:all", "status:refresh"
@@ -982,6 +983,7 @@ defmodule OneChatWeb.UserChannel do
{:noreply, socket}
end
+
def handle_info({"user:all", "status:refresh", %{user_id: id}},
%{assigns: %{user_id: id}} = socket) do
@@ -1021,12 +1023,6 @@ defmodule OneChatWeb.UserChannel do
handle_callback("user:" <> _user_id)
handle_callback("user:all")
- def handle_info({"phone:presence", "presence:change", meta, {mod, fun}} = _payload, socket) do
- # Logger.info "payload: #{inspect payload}"
- apply(mod, fun, ["presence:change", meta, socket])
- {:noreply, socket}
- end
-
def handle_info({:EXIT, _, :normal}, socket) do
{:noreply, socket}
end
@@ -1129,6 +1125,26 @@ defmodule OneChatWeb.UserChannel do
end
end
+ def drop_notify_click(socket, sender) do
+ OnePubSub.broadcast "drop_notify", "click", sender
+ socket
+ end
+ def drop_notify_cancel(socket, sender) do
+ OnePubSub.broadcast "drop_notify", "cancel", sender
+
+ broadcast_js socket, """
+ var elem = $('#{this(sender)}').closest('.notice');
+ elem.animate({
+ height: "0px",
+ 'font-size': "0px"
+ }, 500, function() {
+ elem.remove();
+ });
+ """ |> String.replace("\n", " ")
+
+ socket
+ end
+
#################################
# Status Messages Implementation
#
@@ -1359,7 +1375,7 @@ defmodule OneChatWeb.UserChannel do
def start_audio_call(socket, sender) do
current_user_id = socket.assigns.user_id
user_id = sender["dataset"]["id"]
- Logger.debug "start audio curr_id: #{current_user_id}, user_id: #{user_id}"
+ Logger.debug fn -> "start audio curr_id: #{current_user_id}, user_id: #{user_id}" end
socket
end
@@ -1453,7 +1469,8 @@ defmodule OneChatWeb.UserChannel do
end
defp do_room_update(socket, field, _user_id, _channel_id) do
- Logger.warn "field: #{inspect field}, assigns: #{inspect socket.assigns}"
+ Logger.warn fn -> "Default case. Should not be called. field: " <>
+ "#{inspect field}, assigns: #{inspect socket.assigns}" end
socket
end
@@ -1461,7 +1478,7 @@ defmodule OneChatWeb.UserChannel do
[channel_id: channel_id]
|> Subscription.list_by
|> Enum.each(fn %{user_id: user_id} ->
- Logger.debug "broadcast update room room-visibility to user_id: #{inspect user_id}"
+ Logger.debug fn -> "broadcast update room room-visibility to user_id: #{inspect user_id}" end
socket.endpoint.broadcast CC.chan_user <> user_id, "update:room-visibility",
%{visible: visible?, room_name: room_name, user_id: user_id, channel_id: channel_id}
end)
@@ -1506,7 +1523,6 @@ defmodule OneChatWeb.UserChannel do
end
def video_stop(socket, sender) do
-
trace "video_stop", sender
broadcast_js(socket, "window.WebRTC.hangup()")
execute(socket, :click, on: ".tab-button.active")
@@ -1515,7 +1531,7 @@ defmodule OneChatWeb.UserChannel do
@doc """
Handle and event targeted to all users on the system.
- The event handles for a "user:all" event generated by the UcxPubSub system.
+ The event handles for a "user:all" event generated by the OnePubSub system.
This is a generic handler that simply runs the callback provided in the
payload map. The socket is provided to the callback so it can use Rebel
perform updates on the client side.
@@ -1547,7 +1563,7 @@ defmodule OneChatWeb.UserChannel do
status = sender["dataset"]["status"] || ""
OnePubSub.broadcast "status:" <> user_id, "set:" <> status, sender["dataset"]
- socket
+ execute socket, :click, on: ".account-box.active"
end
def phone_call(socket, sender) do
@@ -1753,5 +1769,6 @@ defmodule OneChatWeb.UserChannel do
defdelegateadmin :admin_user_role_search_channel
defdelegateadmin :admin_click_scoped_room
defdelegateadmin :admin_autocomplete_mouseenter
+ defdelegateadmin :admin_reset_setting_click
end
diff --git a/plugins/one_chat/lib/one_chat_web/templates/admin/accounts.html.slime b/plugins/one_chat/lib/one_chat_web/templates/admin/accounts.html.slime
index 81b3637..d221b16 100644
--- a/plugins/one_chat/lib/one_chat_web/templates/admin/accounts.html.slime
+++ b/plugins/one_chat/lib/one_chat_web/templates/admin/accounts.html.slime
@@ -18,21 +18,21 @@ section.page-container.page-home.page-static.page-settings.admin-settings
.rocket-form
.section
.section-content.border-component-color
- = radio_button_line f, item, :allow_users_delete_own_account, ~g'Allow users delete own account'
- = radio_button_line f, item, :allow_user_profile_change, ~g'Allow user profile change'
- = radio_button_line f, item, :allow_username_change, ~g'Allow username change'
- = radio_button_line f, item, :allow_email_change, ~g'Allow email change'
- = radio_button_line f, item, :allow_password_change, ~g'Allow password change'
- = radio_button_line f, item, :login_extiration_in_days, ~g'Login extiration in days', description: "feature coming soon"
+ = radio_button_line f, item, :allow_users_delete_own_account, ~g'Allow users delete own account', changed: @changed
+ = radio_button_line f, item, :allow_user_profile_change, ~g'Allow user profile change', changed: @changed
+ = radio_button_line f, item, :allow_username_change, ~g'Allow username change', changed: @changed
+ = radio_button_line f, item, :allow_email_change, ~g'Allow email change', changed: @changed
+ = radio_button_line f, item, :allow_password_change, ~g'Allow password change', changed: @changed
+ = radio_button_line f, item, :login_extiration_in_days, ~g'Login extiration in days', description: "feature coming soon", changed: @changed
= collapsable_section ~g"Registraton", fn _ ->
- = radio_button_line f, item, :require_account_confirmation, ~g'Require account confirmation', description: "feature coming soon"
- = radio_button_line f, item, :allow_remember_me, ~g'Allow remember me'
- = radio_button_line f, item, :require_name_for_signup, ~g'Require name for signup', description: "feature coming soon"
- = radio_button_line f, item, :require_password_confirmation, ~g'Require password confirmation', description: "feature coming soon"
- = radio_button_line f, item, :require_email_verificaton, ~g'Require email verificaton', description: "feature coming soon"
- = radio_button_line f, item, :manually_approve_new_users, ~g'Manually approve new users', description: "feature coming soon"
- = text_input_line f, item, :blocked_username_list, ~g(Blocked username list), description: "feature coming soon"
+ = radio_button_line f, item, :require_account_confirmation, ~g'Require account confirmation', description: "feature coming soon", changed: @changed
+ = radio_button_line f, item, :allow_remember_me, ~g'Allow remember me', changed: @changed
+ = radio_button_line f, item, :require_name_for_signup, ~g'Require name for signup', description: "feature coming soon", changed: @changed
+ = radio_button_line f, item, :require_password_confirmation, ~g'Require password confirmation', description: "feature coming soon", changed: @changed
+ = radio_button_line f, item, :require_email_verificaton, ~g'Require email verificaton', description: "feature coming soon", changed: @changed
+ = radio_button_line f, item, :manually_approve_new_users, ~g'Manually approve new users', description: "feature coming soon", changed: @changed
+ = text_input_line f, item, :blocked_username_list, ~g(Blocked username list), description: "feature coming soon", changed: @changed
- opts = [{~g(Public), "Public"}, {~g(Disabled), "Disabled"}, {~g(Secret URL), "Secret URL"}]
- = select_line f, item, :registraton_form, opts, ~g'Registraton form'
- = text_input_line f, item, :registration_form_secret_url, ~g(Registration form secret url), description: ~g(You must provide a random string that will be added to your registration URL.) <> "
" <> "feature coming soon"
- = radio_button_line f, item, :password_reset, ~g'Password reset'
+ = select_line f, item, :registraton_form, opts, ~g'Registraton form', changed: @changed
+ = text_input_line f, item, :registration_form_secret_url, ~g(Registration form secret url), description: ~g(You must provide a random string that will be added to your registration URL.) <> "
" <> "feature coming soon", changed: @changed
+ = radio_button_line f, item, :password_reset, ~g'Password reset', changed: @changed
diff --git a/plugins/one_chat/lib/one_chat_web/templates/admin/chat_general.html.slime b/plugins/one_chat/lib/one_chat_web/templates/admin/chat_general.html.slime
index 1dba5fe..6feb474 100644
--- a/plugins/one_chat/lib/one_chat_web/templates/admin/chat_general.html.slime
+++ b/plugins/one_chat/lib/one_chat_web/templates/admin/chat_general.html.slime
@@ -1,5 +1,5 @@
- item = @changeset.data
-- defer = Application.get_env :ucx_chat, :defer, true
+- defer = Application.get_env :infinity_one, :defer, true
- import OneChatWeb.Admin.Page.ChatGeneral, only: [options: 1]
section.page-container.page-home.page-static.page-settings.admin-settings
header.fixed-title.border-component-color
@@ -20,20 +20,20 @@ section.page-container.page-home.page-static.page-settings.admin-settings
.rocket-form
.section
.section-content.border-component-color
- = select_line f, item, :unread_count, options(:unread_count), ~g(Unread Count)
- = select_line f, item, :unread_count_dm, options(:unread_count_dm), ~g(Unread Count for Direct Messages)
- = text_input_line f, item, :first_channel_after_login, ~g(First channel after login), disabled: "disabled"
+ = select_line f, item, :unread_count, options(:unread_count), ~g(Unread Count), changed: @changed
+ = select_line f, item, :unread_count_dm, options(:unread_count_dm), ~g(Unread Count for Direct Messages), changed: @changed
+ = text_input_line f, item, :first_channel_after_login, ~g(First channel after login), disabled: "disabled", changed: @changed
= unless defer do
- = radio_button_line(f, item, :enable_favorite_rooms, ~g"Enable Favorite Rooms")
+ = radio_button_line(f, item, :enable_favorite_rooms, ~g"Enable Favorite Rooms", changed: @changed)
= collapsable_section ~g"Notifications", fn _ ->
- desc = ~g(Can be any custom sound or the default ones: beep, chelle, ding, droplet, highbell, seasons)
- = text_input_line f, item, :default_message_notification_audio, ~g"Default message notification audio", description: desc
- = select_line f, item, :audio_notifications_default_alert, options(:notifications), ~g(Audio Notifications Default Alert)
- = select_line f, item, :desktop_notifications_default_alert, options(:notifications), ~g(Desktop Notifications Default Alert)
- = select_line f, item, :mobile_notifications_default_alert, options(:notifications), ~g(Mobile Notifications Default Alert)
+ = text_input_line f, item, :default_message_notification_audio, ~g"Default message notification audio", description: desc, changed: @changed
+ = select_line f, item, :audio_notifications_default_alert, options(:notifications), ~g(Audio Notifications Default Alert), changed: @changed
+ = select_line f, item, :desktop_notifications_default_alert, options(:notifications), ~g(Desktop Notifications Default Alert), changed: @changed
+ = select_line f, item, :mobile_notifications_default_alert, options(:notifications), ~g(Mobile Notifications Default Alert), changed: @changed
- msg = ~g(Max room members before disabling all message notifications)
- desc = ~g"Max number of members in room when notifications for all messages gets disabled. Users can still change per room setting to receive all notifications on an individual basis. (0 to disable)"
- = text_input_line f, item, :max_members_disable_notifications, msg, type: :number, description: desc
+ = text_input_line f, item, :max_members_disable_notifications, msg, type: :number, description: desc, changed: @changed
- = render "slash_commands.html", f: f, item: item, field: :rooms_slash_commands, title: ~g"Slash Commands (Rooms Mode)"
- = render "slash_commands.html", f: f, item: item, field: :chat_slash_commands, title: ~g"Slash Commands (Chat Mode)"
+ = render "slash_commands.html", f: f, item: item, field: :rooms_slash_commands, title: ~g"Slash Commands (Rooms Mode)", changed: @changed
+ = render "slash_commands.html", f: f, item: item, field: :chat_slash_commands, title: ~g"Slash Commands (Chat Mode)", changed: @changed
diff --git a/plugins/one_chat/lib/one_chat_web/templates/admin/general.html.slime b/plugins/one_chat/lib/one_chat_web/templates/admin/general.html.slime
index effee79..e99a140 100644
--- a/plugins/one_chat/lib/one_chat_web/templates/admin/general.html.slime
+++ b/plugins/one_chat/lib/one_chat_web/templates/admin/general.html.slime
@@ -18,12 +18,12 @@ section.page-container.page-home.page-static.page-settings.admin-settings
.rocket-form
.section
.section-content.border-component-color
- = text_input_line f, item, :site_name, ~g(Site Name)
- = text_input_line f, item, :site_url, ~g(Site Url)
+ = text_input_line f, item, :site_name, ~g(Site Name), changed: @changed
+ = text_input_line f, item, :site_url, ~g(Site Url), changed: @changed
.input-line.double-col
label.setting-label title="#{~g(Restart)}" = ~g(Restart)
.setting-field
button.button.primary.action type="button" rebel-click="admin_restart_server" = ~g(Restart the server)
= collapsable_section ~g"Notifications", fn _ ->
- = radio_button_line f, item, :enable_desktop_notifications, ~g'Enable desktop notifications'
- = text_input_line f, item, :desktop_notification_duration, ~g"AutoLinker URL Regular Expression", type: :number
+ = radio_button_line f, item, :enable_desktop_notifications, ~g'Enable desktop notifications', changed: @changed
+ = text_input_line f, item, :desktop_notification_duration, ~g"AutoLinker URL Regular Expression", type: :number, changed: @changed
diff --git a/plugins/one_chat/lib/one_chat_web/templates/admin/layout.html.slime b/plugins/one_chat/lib/one_chat_web/templates/admin/layout.html.slime
index f393bef..416fbc7 100644
--- a/plugins/one_chat/lib/one_chat_web/templates/admin/layout.html.slime
+++ b/plugins/one_chat/lib/one_chat_web/templates/admin/layout.html.slime
@@ -1,5 +1,5 @@
- item = @changeset.data
-- defer = Application.get_env :ucx_chat, :defer, true
+- defer = Application.get_env :infinity_one, :defer, true
section.page-container.page-home.page-static.page-settings.admin-settings
header.fixed-title.border-component-color
= render OneChatWeb.MasterView, "burger.html"
@@ -18,19 +18,19 @@ section.page-container.page-home.page-static.page-settings.admin-settings
= hidden_input f, :id, value: item.id
.rocket-form
= collapsable_section ~g"Content", fn _ ->
- = text_input_line f, item, :content_home_title, ~g"Home Title"
- = textarea_input_line f, item, :content_home_body, ~g"Home Body"
- = text_input_line f, item, :content_side_nav_footer, ~g"Side Navigation Footer"
+ = text_input_line f, item, :content_home_title, ~g"Home Title", changed: @changed
+ = textarea_input_line f, item, :content_home_body, ~g"Home Body", changed: @changed
+ = text_input_line f, item, :content_side_nav_footer, ~g"Side Navigation Footer", changed: @changed
= unless defer do
= reset_section_settings()
= collapsable_section ~g"Fonts", fn _ ->
- = text_input_line f, item, :body_font_family, ~g"Body Font Family"
+ = text_input_line f, item, :body_font_family, ~g"Body Font Family", changed: @changed
= reset_section_settings()
= collapsable_section ~g"User Interface", fn _ ->
- = radio_button_line f, item, :display_roles, ~g"Display Roles"
+ = radio_button_line f, item, :display_roles, ~g"Display Roles", changed: @changed
= unless defer do
- = radio_button_line f, item, :merge_private_groups, ~g"Merge private groups with channels"
- = radio_button_line f, item, :user_full_initials_for_avatars, ~g"Use full name initials to generate default avatar"
+ = radio_button_line f, item, :merge_private_groups, ~g"Merge private groups with channels", changed: @changed
+ = radio_button_line f, item, :user_full_initials_for_avatars, ~g"Use full name initials to generate default avatar", changed: @changed
= reset_section_settings()
diff --git a/plugins/one_chat/lib/one_chat_web/templates/admin/message.html.slime b/plugins/one_chat/lib/one_chat_web/templates/admin/message.html.slime
index 6f16a69..28fb156 100644
--- a/plugins/one_chat/lib/one_chat_web/templates/admin/message.html.slime
+++ b/plugins/one_chat/lib/one_chat_web/templates/admin/message.html.slime
@@ -1,5 +1,5 @@
- item = @changeset.data
-- defer = Application.get_env :ucx_chat, :defer, true
+- defer = Application.get_env :infinity_one, :defer, true
section.page-container.page-home.page-static.page-settings.admin-settings
header.fixed-title.border-component-color
= render OneChatWeb.MasterView, "burger.html"
@@ -19,49 +19,49 @@ section.page-container.page-home.page-static.page-settings.admin-settings
.rocket-form
.section
.section-content.border-component-color
- = radio_button_line f, item, :allow_message_editing, ~g"Allow Message Editing"
+ = radio_button_line f, item, :allow_message_editing, ~g"Allow Message Editing", changed: @changed
= unless defer do
- = text_input_line f, item, :block_message_editing_after, ~g"Block Message Editing After (n) Minutes", type: :number, description: ~g"Enter 0 to disable blocking."
- = radio_button_line f, item, :allow_message_deleting, ~g"Allow Message Deleting"
+ = text_input_line f, item, :block_message_editing_after, ~g"Block Message Editing After (n) Minutes", type: :number, description: ~g"Enter 0 to disable blocking.", changed: @changed
+ = radio_button_line f, item, :allow_message_deleting, ~g"Allow Message Deleting", changed: @changed
= unless defer do
- = text_input_line f, item, :block_message_deleting_after, ~g"Block Message Deleting After (n) Minutes", type: :number, description: ~g"Enter 0 to disable blocking."
- = radio_button_line f, item, :show_edited_status, ~g"Show Edited Status"
- = radio_button_line f, item, :show_deleted_status, ~g"Show Deleted Status"
+ = text_input_line f, item, :block_message_deleting_after, ~g"Block Message Deleting After (n) Minutes", type: :number, description: ~g"Enter 0 to disable blocking.", changed: @changed
+ = radio_button_line f, item, :show_edited_status, ~g"Show Edited Status", changed: @changed
+ = radio_button_line f, item, :show_deleted_status, ~g"Show Deleted Status", changed: @changed
= unless defer do
- = radio_button_line f, item, :allow_bad_words_filtering, ~g"Allow Message bad words filtering"
- = radio_button_line f, item, :add_bad_words_to_blacklist, ~g"Add bad words to the blacklist"
- = text_input_line f, item, :max_channel_size_for_all_message, ~g"Maximum channel size for ALL message", type: :number
- = text_input_line f, item, :max_allowed_message_size, ~g"Maximum Allowed Message Size", type: :number
- = radio_button_line f, item, :show_formatting_tips, ~g"Show Formatting Tips"
- = text_input_line f, item, :grouping_period_seconds, ~g"Grouping Period (in seconds)", type: :number, description: ~g"Messages will be grouped with previous message if both are from the same user and the elapsed time was less than the informed time in seconds."
+ = radio_button_line f, item, :allow_bad_words_filtering, ~g"Allow Message bad words filtering", changed: @changed
+ = radio_button_line f, item, :add_bad_words_to_blacklist, ~g"Add bad words to the blacklist", changed: @changed
+ = text_input_line f, item, :max_channel_size_for_all_message, ~g"Maximum channel size for ALL message", type: :number, changed: @changed
+ = text_input_line f, item, :max_allowed_message_size, ~g"Maximum Allowed Message Size", type: :number, changed: @changed
+ = radio_button_line f, item, :show_formatting_tips, ~g"Show Formatting Tips", changed: @changed
+ = text_input_line f, item, :grouping_period_seconds, ~g"Grouping Period (in seconds)", type: :number, description: ~g"Messages will be grouped with previous message if both are from the same user and the elapsed time was less than the informed time in seconds.", changed: @changed
= unless defer do
- = radio_button_line f, item, :embed_link_previews, ~g"Embed Link Previews", description: ~g"Whether embedded link previews are enabled or not when a user posts a link to a website."
- - opts = [description: ~g"Comma-separated list of usernames to disable the embedded link previews."]
+ = radio_button_line f, item, :embed_link_previews, ~g"Embed Link Previews", description: ~g"Whether embedded link previews are enabled or not when a user posts a link to a website.", changed: @changed
+ - opts = [description: ~g"Comma-separated list of usernames to disable the embedded link previews.", changed: @changed]
= text_input_line f, item, :disable_embedded_for_users, ~g"Disable Embed for Users", opts
- - opts = [description: ~g"Comma-separated list of hosts or CIDR addresses, eg. localhost, 127.0.0.1, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16"]
+ - opts = [description: ~g"Comma-separated list of hosts or CIDR addresses, eg. localhost, 127.0.0.1, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16", changed: @changed]
= text_input_line f, item, :embeded_ignore_hosts, ~g"Embed Ignored Hosts", opts
- - opts = [description: ~g"See also: Moment.js"]
+ - opts = [description: ~g"See also: Moment.js", changed: @changed]
= text_input_line f, item, :time_format, ~g"Time Format", opts
- - opts = [description: ~g"See also: Moment.js"]
+ - opts = [description: ~g"See also: Moment.js", changed: @changed]
= text_input_line f, item, :date_format, ~g"Date Format", opts
- = radio_button_line f, item, :hide_user_join, ~g'Hide "User Join" messages'
- = radio_button_line f, item, :hide_user_leave, ~g'Hide "User Leave" messages'
- = radio_button_line f, item, :hide_user_removed, ~g'Hide "User Removed" messages'
- = radio_button_line f, item, :hide_user_added, ~g'Hide "User Added" messages'
- = radio_button_line f, item, :hide_user_muted, ~g'Hide "User Muted / Unmuted" messages'
- - opts = [description: ~g"Allow messages to be pinned to any of the channels."]
+ = radio_button_line f, item, :hide_user_join, ~g'Hide "User Join" messages', changed: @changed
+ = radio_button_line f, item, :hide_user_leave, ~g'Hide "User Leave" messages', changed: @changed
+ = radio_button_line f, item, :hide_user_removed, ~g'Hide "User Removed" messages', changed: @changed
+ = radio_button_line f, item, :hide_user_added, ~g'Hide "User Added" messages', changed: @changed
+ = radio_button_line f, item, :hide_user_muted, ~g'Hide "User Muted / Unmuted" messages', changed: @changed
+ - opts = [description: ~g"Allow messages to be pinned to any of the channels.", changed: @changed]
= radio_button_line f, item, :allow_message_pinning, ~g'Allow Message Pinning', opts
- = radio_button_line f, item, :allow_message_staring, ~g'Allow Message Staring'
+ = radio_button_line f, item, :allow_message_staring, ~g'Allow Message Staring', changed: @changed
= unless defer do
- = radio_button_line f, item, :allow_message_snippeting, ~g'Allow Message Snippeting'
+ = radio_button_line f, item, :allow_message_snippeting, ~g'Allow Message Snippeting', changed: @changed
= reset_section_settings()
= unless defer do
= collapsable_section ~g"AutoLinker", fn _ ->
- - opts = [description: "Short display. e.g. https://emetrotel.com => emetrotel.com"]
+ - opts = [description: "Short display. e.g. https://emetrotel.com => emetrotel.com", changed: @changed]
= radio_button_line f, item, :autolinker_strip_prefix, ~g'AutoLinker Strip Prefix', opts
- = radio_button_line f, item, :autolinker_scheme_urls, ~g'AutoLinker Scheme:// URLs'
- = radio_button_line f, item, :autolinker_www_urls, ~g"AutoLinker 'www' URLs"
- = radio_button_line f, item, :autolinker_tld_urls, ~g'AutoLinker TLD URLs'
- = text_input_line f, item, :autolinker_url_regexl, ~g"AutoLinker URL Regular Expression"
- = radio_button_line f, item, :autolinker_email, ~g'AutoLinker Email'
- = radio_button_line f, item, :autolinker_phone, ~g'AutoLinker Phone'
+ = radio_button_line f, item, :autolinker_scheme_urls, ~g'AutoLinker Scheme:// URLs', changed: @changed
+ = radio_button_line f, item, :autolinker_www_urls, ~g"AutoLinker 'www' URLs", changed: @changed
+ = radio_button_line f, item, :autolinker_tld_urls, ~g'AutoLinker TLD URLs', changed: @changed
+ = text_input_line f, item, :autolinker_url_regexl, ~g"AutoLinker URL Regular Expression", changed: @changed
+ = radio_button_line f, item, :autolinker_email, ~g'AutoLinker Email', changed: @changed
+ = radio_button_line f, item, :autolinker_phone, ~g'AutoLinker Phone', changed: @changed
diff --git a/plugins/one_settings/lib/one_settings.ex b/plugins/one_settings/lib/one_settings.ex
index d1b8d36..7fc9649 100644
--- a/plugins/one_settings/lib/one_settings.ex
+++ b/plugins/one_settings/lib/one_settings.ex
@@ -49,7 +49,28 @@ defmodule OneSettings do
end)
end)
- # Module.register_attribute(__MODULE__, :modules, persist: true, accumulate: true)
+ @module_map :infinity_one |>
+ Application.get_env(:settings_modules, []) |>
+ Enum.map(fn m -> {m |> Module.split() |> List.last() |> Module.concat(nil), m} end) |>
+ Enum.into(%{})
+
+ @doc """
+ Return a map of the module.
+
+ Returns a map of the full module indexed by the last segment of the module.
+ """
+ def module_map, do: @module_map
+
+ @doc """
+ Get the fill module give either an Atom or a binary.
+ """
+ def module_map(module) when is_atom(module) do
+ Map.get(@module_map, module)
+ end
+
+ def module_map(module) when is_binary(module) do
+ Map.get(@module_map, module |> Inflex.camelize() |> Module.concat(nil))
+ end
fields =
:infinity_one