Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Company settings fixes #2885

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions app/Domain/Setting/Js/settingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ import jQuery from "jquery";
import { saveLogo } from './settingService';
import { appUrl } from 'js/app/core/instance-info.module.mjs'

let _uploadResult;
// let _uploadResult;
let _croppieInstance = null;

export const readURL = function (input) {
clearCroppie();

console.log('Input is: ', input);
if (input.files && input.files[0]) {
var reader = new FileReader();

var profileImg = jQuery('#logoImg');
reader.onload = function (e) {
//profileImg.attr('src', e.currentTarget.result);

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

this._uploadResult.croppie(
_croppieInstance.croppie(
'bind',
{
url: e.currentTarget.result
Expand All @@ -45,16 +46,27 @@ export const readURL = function (input) {
}
};


export const clearCroppie = function () {
jQuery('#logoImg').croppie('destroy');
const logoImg = jQuery('#logoImg');
if (logoImg.data('croppie')) {
logoImg.croppie('destroy');
}
_croppieInstance = null;
jQuery("#previousImage").show();
};

export const saveCroppie = function () {

if (!_croppieInstance) {
console.error('No image has been loaded');
return;
}

jQuery('#save-logo').addClass('running');

jQuery('#logoImg').attr('src', appUrl + '/images/loaders/loader28.gif');
_uploadResult.croppie(
_croppieInstance.croppie(
'result',
{
type: "blob",
Expand All @@ -71,9 +83,8 @@ export const saveCroppie = function () {
};

// Make public what you want to have public, everything else is private
export default {
export const settingController = {
readURL: readURL,
clearCroppie: clearCroppie,
saveCroppie: saveCroppie
};

101 changes: 59 additions & 42 deletions app/Domain/Setting/Templates/editCompanySettings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

@section('content')
<?php
$companySettings = $tpl->get('companySettings');
$companySettings = $tpl->get('companySettings');
?>

<div class="pageheader">

<div class="pageicon"><span class="fa fa-cogs"></span></div>
<div class="pagetitle">
<h5><?= $tpl->__('label.administration') ?></h5>
<h1><?= $tpl->__('headlines.company_settings') ?></h1>
</div>
<div class="pageheader">
<div class="pageicon"><span class="fa fa-cogs"></span></div>
<div class="pagetitle">
<h5><?= $tpl->__('label.administration') ?></h5>
<h1><?= $tpl->__('headlines.company_settings') ?></h1>
</div>
</div>

<div class="maincontent">
@displayNotification()
Expand All @@ -35,7 +34,7 @@
<div class="col-md-8">
<form class="" method="post" id="" action="{{ BASE_URL }}/setting/editCompanySettings#details" >

<h5 class="subtitle"><?= $tpl->__('headlines.company_settings') ?></h5>
<h2 class="subtitle"><?= $tpl->__('headlines.company_settings') ?></h2>
<p><?= $tpl->__('text.these_are_system_wide_settings') ?></p>
<br />
<input type="hidden" value="1" name="saveSettings" />
Expand Down Expand Up @@ -85,17 +84,17 @@ class="pull-left"
<div class="col-md-2">
<label><?= $tpl->__('label.send_telemetry') ?></label>
</div>
<div class="col-md-8">
<div class="col-md-8 flex items-center gap-2">
<x-global::forms.checkbox
name="telemetryActive"
id="telemetryActive"
:checked="isset($companySettings['telemetryActive']) ? $companySettings['telemetryActive'] : false"
class="toggle"
/>

<i class="fa fa-question-circle" style="vertical-align: bottom;" data-tippy-content="<?=strip_tags($tpl->__("label.telemetry_background")) ?>"></i>
<div class="clearall"></div><br />
</div>
<i class="fa fa-question-circle mt-1" data-tippy-content="<?=strip_tags($tpl->__("label.telemetry_background")) ?>"></i>
<div class="clearall"></div><br />
</div>
</div>
<br />
<h4 class="widgettitle title-light"><span
Expand Down Expand Up @@ -166,21 +165,24 @@ class="fa fa-cog"></span>{{ __("subtitles.defaults") }}

<form class="" method="post" id="" action="{{ BASE_URL }}/setting/editCompanySettings" >
<input type="hidden" value="1" name="saveLogo" />
<h5 class="subtitle"><?=$tpl->__("headlines.logo")?></h5>
<h2 class="subtitle"><?=$tpl->__("headlines.logo")?></h2>
<br />

<div class="row">

<div class="col-md-12">
<?php if ($companySettings['logo'] != "") { ?>
<img src='<?php echo $companySettings['logo']; ?>' class='logoImg' alt='Logo'
id="previousImage" width="260" />
<img src='<?php echo $companySettings['logo']; ?>' class='logoImg' alt='Logo'
id="previousImage" width="260" />
<?php } else { ?>
<?= $tpl->__('text.no_logo') ?>
<?= $tpl->__('text.no_logo') ?>
<?php } ?>

<div id="logoImg" style="height:auto;">
</div>

<br />

<div class="par">

<label><?= $tpl->__('label.upload_new_logo') ?></label>
Expand All @@ -192,31 +194,30 @@ class="fa fa-cog"></span>{{ __("subtitles.defaults") }}
<i class="fa-file fileupload-exists"></i>
<span class="fileupload-preview"></span>
</div>

<span class="btn btn-default btn-file">
<span
class="fileupload-new"><?= $tpl->__('buttons.select_file') ?></span>
<span
class='fileupload-exists'><?= $tpl->__('buttons.change') ?></span>
<input type='file' name='file'
onchange="leantime.settingController.readURL(this)" />
<span>{{__('buttons.select_file')}}</span>
<input type='file' name='file' id='file-input' />
</span>

<a href='#' style="margin-left:5px;" class='btn btn-default fileupload-exists' data-dismiss='fileupload' onclick="leantime.usersController.clearCroppie()"><?=$tpl->__("buttons.remove")?></a>
</div>
<p class='stdformbutton'>
<x-global::forms.button tag="button" id="saveBtn" onclick="leantime.settingController.saveCroppie()">
{{ __('buttons.save') }}
</x-global::forms.button>
<input id="picSubmit" type="submit" name="savePic" class="hidden" value="<?=$tpl->__("buttons.upload")?>" />
</p>
<span id="remove-logo" style="margin-left:5px;" class='btn btn-default fileupload-exists' data-dismiss='fileupload'>{{__("buttons.remove")}}</span>
</div>

<p class='stdformbutton'>
<x-global::forms.button tag="button" id="save-logo">
{{ __('buttons.save') }}
</x-global::forms.button>
<input id="picSubmit" type="submit" name="savePic" class="hidden" value="<?=$tpl->__("buttons.upload")?>" />
</p>

</div>
</div>
</div>
</div>
</form>
<hr />
<?=$tpl->__("text.logo_reset")?><br /><br />
{{-- <a href="{{ BASE_URL }}/setting/editCompanySettings?resetLogo=1" class="btn btn-default"><?=$tpl->__("buttons.reset_logo")?></a> --}}

<x-global::forms.button tag="a" contentRole="ghost" href="{{ BASE_URL }}/setting/editCompanySettings?resetLogo=1" scale="sm">
{{ __("buttons.reset_logo") }}
</x-global::forms.button>
Expand Down Expand Up @@ -264,20 +265,36 @@ class="delete">
</div>
</div>

</div>


<script type="module">

</div>

import "@mix('/js/Domain/Setting/Js/settingController.js')"
import "@mix('/js/Domain/Users/Js/usersController.js')"

<script>
jQuery(document).ready(function() {
jQuery(".companyTabs").tabs({
activate: function(event, ui) {
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('file-input').addEventListener('change', (e) => {
settingController.readURL(e.target);
});

document.getElementById('save-logo').addEventListener('click', (e) => {
e.preventDefault();
settingController.saveCroppie();
});

document.getElementById('remove-logo').addEventListener('click', (e) => {
e.preventDefault();
settingController.clearCroppie();
});

window.location.hash = ui.newPanel.selector;
}
});
// Initialize tabs
jQuery(".companyTabs").tabs({
activate: function(event, ui) {
window.location.hash = ui.newPanel.selector;
}
});
</script>
});
</script>

@endsection
2 changes: 1 addition & 1 deletion app/Domain/Users/Js/usersController.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const checkPWStrength = function (pwField) {

}

export default {
export const usersController = {
readURL: readURL,
clearCroppie: clearCroppie,
saveCroppie: saveCroppie,
Expand Down
2 changes: 1 addition & 1 deletion public/assets/css/components/text-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ a .label.feature-label:after {
font-size: var(--font-size-xl);
color: var(--primary-font-color);
margin-bottom: 10px;
font-weight:lighter;
font-weight: bolder;

}

Expand Down
2 changes: 2 additions & 0 deletions public/assets/js/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import './core/globalLibraries.js';
import { addToGlobalScope } from './core/leantimeScope.mjs';
import { moduleLoader } from './core/moduleLoader.mjs';
import { initializeCore } from './core/bootstrap.mjs';
import "croppie/croppie";


addToGlobalScope({ moduleLoader: moduleLoader });

Expand Down
Loading