diff --git a/app/controllers/api/v1/profiles_controller.rb b/app/controllers/api/v1/profiles_controller.rb index 20b8e7ae8..cbf801e82 100644 --- a/app/controllers/api/v1/profiles_controller.rb +++ b/app/controllers/api/v1/profiles_controller.rb @@ -18,6 +18,10 @@ class Api::V1::ProfilesController < Api::BaseController head :ok end + def auto_offline + @user.account_users.find_by!(account_id: auto_offline_params[:account_id]).update!(auto_offline: auto_offline_params[:auto_offline] || false) + end + def availability @user.account_users.find_by!(account_id: availability_params[:account_id]).update!(availability: availability_params[:availability]) end @@ -37,6 +41,10 @@ class Api::V1::ProfilesController < Api::BaseController params.require(:profile).permit(:account_id, :availability) end + def auto_offline_params + params.require(:profile).permit(:account_id, :auto_offline) + end + def profile_params params.require(:profile).permit( :email, diff --git a/app/javascript/dashboard/api/auth.js b/app/javascript/dashboard/api/auth.js index ef1762f46..19ba40a42 100644 --- a/app/javascript/dashboard/api/auth.js +++ b/app/javascript/dashboard/api/auth.js @@ -144,6 +144,12 @@ export default { }); }, + updateAutoOffline(accountId, autoOffline = false) { + return axios.post(endPoints('autoOffline').url, { + profile: { account_id: accountId, auto_offline: autoOffline }, + }); + }, + deleteAvatar() { return axios.delete(endPoints('deleteAvatar').url); }, diff --git a/app/javascript/dashboard/api/endPoints.js b/app/javascript/dashboard/api/endPoints.js index 8deb8d56a..678386d50 100644 --- a/app/javascript/dashboard/api/endPoints.js +++ b/app/javascript/dashboard/api/endPoints.js @@ -16,6 +16,9 @@ const endPoints = { availabilityUpdate: { url: '/api/v1/profile/availability', }, + autoOffline: { + url: '/api/v1/profile/auto_offline', + }, logout: { url: 'auth/sign_out', }, diff --git a/app/javascript/dashboard/components/layout/AvailabilityStatus.vue b/app/javascript/dashboard/components/layout/AvailabilityStatus.vue index 1c70e6755..0a2698a9a 100644 --- a/app/javascript/dashboard/components/layout/AvailabilityStatus.vue +++ b/app/javascript/dashboard/components/layout/AvailabilityStatus.vue @@ -18,12 +18,35 @@ + + + + + + {{ $t('SIDEBAR.SET_AUTO_OFFLINE.TEXT') }} + + + + + +