Skip to content

Commit

Permalink
Merge pull request #2887 from Leantime/my-profile-fixes
Browse files Browse the repository at this point in the history
My profile fixes
  • Loading branch information
marcelfolaron authored Jan 8, 2025
2 parents 567b0f0 + 84c37b1 commit 83afb2c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 38 deletions.
10 changes: 7 additions & 3 deletions app/Domain/Users/Js/usersController.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import i18n from 'i18n';
import { appUrl } from 'js/app/core/instance-info.module';
import { saveUserPhoto } from './usersService';

let _croppieInstance = null;

export const readURL = function (input) {

clearCroppie();
Expand All @@ -14,7 +16,7 @@ export const readURL = function (input) {
reader.onload = function (e) {
//profileImg.attr('src', e.currentTarget.result);

_uploadResult = profileImg
_croppieInstance = profileImg
.croppie(
{
enableExif: true,
Expand All @@ -30,7 +32,7 @@ export const readURL = function (input) {
}
);

_uploadResult.croppie(
_croppieInstance.croppie(
'bind',
{
url: e.currentTarget.result
Expand All @@ -52,7 +54,7 @@ export const clearCroppie = function () {
export const saveCroppie = function () {
jQuery('#save-picture').addClass('running');
jQuery('#profileImg').attr('src', appUrl + '/images/loaders/loader28.gif');
_uploadResult.croppie(
_croppieInstance.croppie(
'result',
{
type: "blob",
Expand Down Expand Up @@ -160,3 +162,5 @@ export const usersController = {
initUserTable: initUserTable,
checkPWStrength: checkPWStrength,
};

export default usersController;
97 changes: 63 additions & 34 deletions app/Domain/Users/Templates/editOwn.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<x-slot:contents>
<x-global::content.tabs.content name="myProfile">
<form action="" method="post">
<form hx-boost="true" action="" method="post">
<input type="hidden" name="{{ session('formTokenName') }}" value="{{ session('formTokenValue') }}" />

<div class="row-fluid">
Expand Down Expand Up @@ -101,7 +101,7 @@ class="button"
@if (session("userdata.isLdap") );
<strong> {{ __("text.account_managed_ldap") }}</strong><br /><br />
@endif
<form method="post">
<form hx-boost="true" method="post">
<input type="hidden" name="{{ session("formTokenName") }}" value="{{ session("formTokenValue") }}" />
<div class="row-fluid">
<div class="form-group">
Expand Down Expand Up @@ -179,7 +179,7 @@ class="button"
</x-global::content.tabs.content>

<x-global::content.tabs.content name="settings">
<form action="" method="post">
<form hx-boost="true" action="" method="post">
<input type="hidden" name="{{ session("formTokenName") }}" value="{{ session("formTokenValue") }}" />
<div class="row-fluid">
<div class="form-group">
Expand Down Expand Up @@ -246,7 +246,7 @@ class="button"
</x-global::content.tabs.content>

<x-global::content.tabs.content name="theme">
<form action="" method="post">
<form hx-boost="true" action="" method="post">
<input type="hidden" name="{{ session("formTokenName") }}" value="{{ session("formTokenValue") }}" />
<div class="row-fluid">
<div class="form-group">
Expand All @@ -263,7 +263,7 @@ class="button"
<div class="col-md-12">

<hr />
<label for="colormode" >{{ __('label.colormode') }}</label>
<label for="colormode">{{ __('label.colormode') }}</label>

<x-global::forms.select-button :selected="($userColorMode == 'light') ? 'true' : ''" :id="'light'" :name="'colormode'" :value="'light'" :label="'Light'" onclick="leantime.snippets.toggleTheme('light')">
<label for="colormode-light" class="w-[100px]">
Expand All @@ -283,16 +283,18 @@ class="button"
<div class="col-md-12">
<hr />
<label>Font</label>
@foreach($availableFonts as $key => $font)

<x-global::forms.select-button :selected="($themeFont == $font) ? 'true' : ''" :id="$key" :name="'themeFont'" :value="$font" :label="$font" onclick="leantime.snippets.toggleFont('{{ $font }}')">
<label for="selectable-{{ $key }}" class="font w-[200px]"
style="font-family:'{{ $font }}'; font-size:16px;">
The quick brown fox jumps over the lazy dog
</label>
</x-global::forms.select-button>

@endforeach
<div class="mt-4">
@foreach($availableFonts as $key => $font)

<x-global::forms.select-button :selected="($themeFont == $font) ? 'true' : ''" :id="$key" name="themeFont" :value="$font" :label="$font" >
<label for="selectable-{{ $key }}" class="font w-[200px]"
style="font-family:'{{ $font }}'; font-size:14px;">
The quick brown fox jumps over the lazy dog
</label>
</x-global::forms.select-button>

@endforeach
</div>

</div>
</div>
Expand Down Expand Up @@ -324,16 +326,15 @@ class="button"
</x-global::content.tabs.content>

<x-global::content.tabs.content name="notifications">
<form action="" method="post">
<form hx-boost="true" action="" method="post">
<input type="hidden" name="{{ session("formTokenName") }}" value="{{ session("formTokenValue") }}" />
<div class="row-fluid">
<div class="form-group">
<div class="form-group" style="min-width: 250px; max-width: 400px;" >
<x-global::forms.checkbox
name="notifications"
id="notifications"
value="on"
:checked="$values['notifications'] == '1'"
{{-- class="input" --}}
labelText="{{ __('label.receive_notifications') }}"
labelPosition="left"
/>
Expand Down Expand Up @@ -411,7 +412,9 @@ class="button"
</div>
<div class="col-md-4">
<div class="maincontentinner center">
<img src='{{ BASE_URL }}/api/users?profileImage={{ $user['id'] }}?v={{ format($user['modified'])->timestamp() }}' class='profileImg rounded-full' alt='Profile Picture' id="previousImage"/>
<div class="w-full flex justify-center">
<img src='{{ BASE_URL }}/api/users?profileImage={{ $user['id'] }}?v={{ format($user['modified'])->timestamp() }}' class='profileImg rounded-full' alt='Profile Picture' id="previousImage"/>
</div>
<div id="profileImg">
</div>

Expand All @@ -422,23 +425,25 @@ class="button"
<div class='fileupload fileupload-new' data-provides='fileupload'>
<input type="hidden"/>
<div class="input-append">
<div class="uneditable-input span3">
{{-- <div class="uneditable-input span3">
<i class="fa-file fileupload-exists"></i>
<span class="fileupload-preview"></span>
</div>
<span class="btn btn-file">
<span class="fileupload-new">{{ __('buttons.select_file') }}</span>
<span class='fileupload-exists'>{{ __('buttons.change') }}</span>
<input type='file' name='file' onchange="leantime.usersController.readURL(this)" accept=".jpg,.png,.gif,.webp"/>
</span>

<a href='#' class='btn fileupload-exists' data-dismiss='fileupload' onclick="leantime.usersController.clearCroppie()">{{ __('buttons.remove') }}</a>
</div> --}}

<x-global::forms.button tag="button" id="file-input" content-role="secondary" class="btn-file" scale="md" >
{{ __('buttons.select_file') }}
<input type='file' name='file' accept=".jpg,.png,.gif,.webp"/>
</x-global::forms.button>

<x-global::forms.button tag="button" id="remove-picture" content-role="secondary" class="fileupload-exists" data-dismiss='fileupload' scale="md" >
{{ __('buttons.remove') }}
</x-global::forms.button>

</div>
<p class='stdformbutton'>
<span id="save-picture" class="btn btn-primary fileupload-exists ld-ext-right">
<span onclick="leantime.usersController.saveCroppie()">{{ __('buttons.save') }}</span>
<span class="ld ld-ring ld-spin"></span>
</span>
<x-global::forms.button tag="button" id="save-picture" class="fileupload-exists ld-ext-right">
{{ __('buttons.save') }}
</x-global::forms.button>
<input type="hidden" name="profileImage" value="1" />
<input id="picSubmit" type="submit" name="savePic" class="hidden"
value="{{ __('buttons.upload') }}"/>
Expand All @@ -451,11 +456,35 @@ class="button"
</div>


<script type="text/javascript">
<script type="module">
import "@mix('/js/Domain/Users/Js/usersController.js')"
import snippets from "@mix('/js/app.js')"
jQuery(document).ready(function(){
leantime.usersController.checkPWStrength('newPassword');
usersController.checkPWStrength('newPassword');
document.getElementById('file-input').addEventListener('change', (e) => {
usersController.readURL(e.target);
});
document.getElementById('save-picture').addEventListener('click', (e) => {
e.preventDefault();
usersController.saveCroppie();
});
document.getElementById('remove-picture').addEventListener('click', (e) => {
e.preventDefault();
usersController.clearCroppie();
});
// Add event listeners to all font buttons
document.querySelectorAll('[name="themeFont"]').forEach(button => {
button.addEventListener('click', function() {
const font = this.value;
snippets.toggleFont(font);
});
});
});
</script>
Expand Down
4 changes: 3 additions & 1 deletion public/assets/js/app/support/snippets.module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var toggleColors = function (accent1, accent2) {
};

// Make public what you want to have public, everything else is private
export default {
export const snippets ={
copyUrl: copyUrl,
copyToClipboard: copyToClipboard,
initConfettiClick: initConfettiClick,
Expand All @@ -87,3 +87,5 @@ export default {
toggleFont: toggleFont,
toggleColors: toggleColors
};

export default snippets;

0 comments on commit 83afb2c

Please sign in to comment.