1
This commit is contained in:
parent
2644093fc5
commit
5cdd55976d
14
dashmachine/static/css/settings_system/settings.css
Normal file
14
dashmachine/static/css/settings_system/settings.css
Normal file
@ -0,0 +1,14 @@
|
||||
body {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
.settings-page-card {
|
||||
max-height: calc(100vh - 30px);
|
||||
min-height: calc(100vh - 30px);
|
||||
}
|
||||
|
||||
#apps .dropdown-content {
|
||||
border-top-left-radius: 0px;
|
||||
border-top-right-radius: 0px;
|
||||
background: var(--theme-surface-1);
|
||||
}
|
@ -7,25 +7,6 @@ function js_Load() {
|
||||
document.body.style.visibility = 'visible';
|
||||
}
|
||||
|
||||
function init_datepicker() {
|
||||
$('.datepicker').datepicker({
|
||||
container: 'body',
|
||||
format: 'mm/dd/yy'
|
||||
});
|
||||
}
|
||||
function init_timepicker() {
|
||||
$('.timepicker').timepicker({
|
||||
container: 'body'
|
||||
});
|
||||
}
|
||||
// toggle/init tooltips
|
||||
function init_tooltips(){
|
||||
let tooltips_enabled = localStorage.getItem('tooltips_enabled');
|
||||
if (tooltips_enabled === 'false'){
|
||||
} else {
|
||||
$('.tooltipped').tooltip();
|
||||
}
|
||||
}
|
||||
|
||||
function updateTabIndicator(){
|
||||
sleep(250).then(() => {
|
||||
@ -65,141 +46,9 @@ function init_select(){
|
||||
});
|
||||
}
|
||||
|
||||
function loadContactForm(){
|
||||
let url = $("#load-contact-form-url").attr('data-url');
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'GET',
|
||||
success: function(data){
|
||||
$('body').append(data);
|
||||
init_select();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function autocomplete_chips_add_function(el_id, el){
|
||||
let instance = M.Chips.getInstance(el);
|
||||
let val_list = []
|
||||
$.each(instance.chipsData, function(index, el) {
|
||||
val_list.push(el.tag);
|
||||
});
|
||||
let hidden_inp = `#${el_id.split('-')[1]}`
|
||||
$(hidden_inp).val(val_list.toString());
|
||||
// console.log($(hidden_inp).val());
|
||||
$(`#${el_id} input`).trigger('focus');
|
||||
}
|
||||
|
||||
function init_autocomplete_chips(){
|
||||
$(".chips").each(function(index, el) {
|
||||
let el_id = $(this).attr('id');
|
||||
let el_this = $(this);
|
||||
$(this).chips({
|
||||
placeholder: $(this).attr('data-placeholder'),
|
||||
secondaryPlaceholder: $(this).attr('data-second-placeholder'),
|
||||
limit: $(this).attr('data-limit'),
|
||||
autocompleteOptions: {
|
||||
data: null,
|
||||
},
|
||||
onChipAdd: function (){
|
||||
autocomplete_chips_add_function(el_id, el);
|
||||
$("#deal-form-default-fields").trigger('change');
|
||||
},
|
||||
onChipDelete: function () {
|
||||
autocomplete_chips_add_function(el_id, el);
|
||||
$("#deal-form-default-fields").trigger('change');
|
||||
},
|
||||
});
|
||||
|
||||
let hidden_inp = `#${el_id.split('-')[1]}`
|
||||
if ($(hidden_inp).val() !== "None") {
|
||||
let instance = M.Chips.getInstance($(this));
|
||||
let contacts = $(hidden_inp).val();
|
||||
contacts = contacts.split(',');
|
||||
$.each(contacts, function(index, el) {
|
||||
instance.addChip({
|
||||
tag: el,
|
||||
});
|
||||
});
|
||||
}
|
||||
$(`#${el_id} input`).on('keydown', function(e) {
|
||||
let instance = M.Chips.getInstance(el_this);
|
||||
let keyCode = e.keyCode || e.which;
|
||||
if (keyCode == 9) {
|
||||
let option = $(el_this).find('.autocomplete-content li').first()
|
||||
if (option.length > 0) {
|
||||
instance.autocomplete.selectOption(option);
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(`#${el_id} input`).on('keyup', function(e) {
|
||||
let instance = M.Chips.getInstance(el_this);
|
||||
let keyCode = e.keyCode || e.which;
|
||||
let ign_codes = [40, 38, 37, 39, 16, 9, 20, 17, 18, 32]
|
||||
if (ign_codes.includes(keyCode)) {}
|
||||
else {
|
||||
$.ajax({
|
||||
url: $("#load-autocomplete-contacts-url").attr('data-url'),
|
||||
type: 'GET',
|
||||
data: {
|
||||
contact_group: $(`#${el_id}`).attr('data-contact_group'),
|
||||
inp_val: $(this).val(),
|
||||
},
|
||||
success: function(data){
|
||||
instance.autocomplete.updateData(data);
|
||||
sleep(100).then(() => {
|
||||
instance.autocomplete.open();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(`#${el_id} input`).on('blur', function() {
|
||||
let instance = M.Chips.getInstance(el_this);
|
||||
sleep(250).then(() => {
|
||||
if (instance.chipsData.length < 1 && $(this).val().length > 0){
|
||||
$(this).val('');
|
||||
M.toast({html: "Press enter to add a contact"})
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function toggleDarkMode(){
|
||||
let mode = localStorage.getItem('mode');
|
||||
if (mode === 'dark') {
|
||||
document.documentElement.setAttribute('data-theme', 'light');
|
||||
localStorage.setItem('mode', null);
|
||||
} else {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
localStorage.setItem('mode', 'dark');
|
||||
}
|
||||
// location.reload(true);
|
||||
}
|
||||
|
||||
function toggleTooltips(){
|
||||
let tooltips_enabled = localStorage.getItem('tooltips_enabled');
|
||||
if (tooltips_enabled === 'false'){
|
||||
localStorage.setItem('tooltips_enabled', null);
|
||||
$('.tooltipped').tooltip();
|
||||
} else {
|
||||
localStorage.setItem('tooltips_enabled', 'false');
|
||||
try {
|
||||
$(".tooltipped").tooltip('destroy');
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
function init_copy_btn(parent_class){
|
||||
$(".copy-btn").on('click', function(e) {
|
||||
let target_text = $(this).closest(parent_class).find('.copy-target').text();
|
||||
console.log(target_text)
|
||||
let copy_input = $("#copy-input");
|
||||
copy_input.val(target_text);
|
||||
copy_input.removeClass("hide");
|
||||
@ -211,73 +60,6 @@ function init_copy_btn(parent_class){
|
||||
});
|
||||
}
|
||||
|
||||
function isEmail(email) {
|
||||
let regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
|
||||
return regex.test(email);
|
||||
}
|
||||
|
||||
// Cleave
|
||||
function initCleave(){
|
||||
// prevent database from filling inputs with "None"
|
||||
$("input").each(function(e) {
|
||||
if($(this).val() === "None"){
|
||||
$(this).val('');
|
||||
}
|
||||
});
|
||||
M.updateTextFields();
|
||||
document.querySelectorAll('.input-phone').forEach(function (el) {
|
||||
new Cleave(el, {
|
||||
phone: true,
|
||||
phoneRegionCode: 'US',
|
||||
delimiter: '-',
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('.money').forEach(function (el) {
|
||||
new Cleave(el, {
|
||||
numeral: true,
|
||||
numeralThousandsGroupStyle: 'thousand',
|
||||
prefix: '$',
|
||||
noImmediatePrefix: true,
|
||||
numeralPositiveOnly: true
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('.days').forEach(function (el) {
|
||||
new Cleave(el, {
|
||||
blocks: [2],
|
||||
numericOnly: true,
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('.datepicker').forEach(function (el) {
|
||||
new Cleave(el, {
|
||||
date: true,
|
||||
delimiter: '/',
|
||||
datePattern: ['m', 'd', 'y']
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('.zip_code').forEach(function (el) {
|
||||
new Cleave(el, {
|
||||
blocks: [5],
|
||||
numericOnly: true,
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('.initial').forEach(function (el) {
|
||||
new Cleave(el, {
|
||||
blocks: [1],
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('.state').forEach(function (el) {
|
||||
new Cleave(el, {
|
||||
blocks: [2],
|
||||
uppercase: true
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('.number').forEach(function (el) {
|
||||
new Cleave(el, {
|
||||
numeral: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function hide_sidenav() {
|
||||
$("#main-sidenav").addClass('hide');
|
||||
$("#main.main-full").css('padding-left', 0);
|
||||
@ -299,10 +81,6 @@ $(document).ready(function () {
|
||||
"use strict";
|
||||
|
||||
// INITS
|
||||
init_datepicker();
|
||||
init_timepicker();
|
||||
initCleave();
|
||||
init_tooltips();
|
||||
init_select();
|
||||
|
||||
if (localStorage.getItem('sidenav_hidden') === 'true'){
|
||||
@ -324,7 +102,6 @@ $(document).ready(function () {
|
||||
constrainWidth: false
|
||||
});
|
||||
$(".tabs").tabs();
|
||||
$(".scrollspy").scrollSpy();
|
||||
|
||||
// Fab
|
||||
$(".fixed-action-btn").floatingActionButton();
|
||||
|
69
dashmachine/static/js/settings_system/settings.js
Normal file
69
dashmachine/static/js/settings_system/settings.js
Normal file
@ -0,0 +1,69 @@
|
||||
var d = document.getElementById("settings-sidenav");
|
||||
d.className += " active theme-primary";
|
||||
|
||||
function apply_settings(settings_theme, settings_accent){
|
||||
localStorage.setItem('mode', settings_theme);
|
||||
document.documentElement.setAttribute('data-theme', settings_theme);
|
||||
localStorage.setItem('accent', settings_accent);
|
||||
document.documentElement.setAttribute('data-accent', settings_accent);
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
initTCdrop('#images-tcdrop');
|
||||
$("#config-wiki-modal").modal();
|
||||
|
||||
$("#save-config-btn").on('click', function(e) {
|
||||
$.ajax({
|
||||
url: $(this).attr('data-url'),
|
||||
type: 'POST',
|
||||
data: $("#config-form").serialize(),
|
||||
success: function(data){
|
||||
if (data.data.msg === "success"){
|
||||
M.toast({html: 'Config applied successfully'});
|
||||
apply_settings(data.data.settings.theme, data.data.settings.accent);
|
||||
location.reload(true);
|
||||
} else {
|
||||
M.toast({html: data.data.msg, classes: "theme-warning"});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#save-images-btn").on('click', function(e) {
|
||||
$("#add-images-input").val(tcdrop_files['images-tcdrop'].toString());
|
||||
$.ajax({
|
||||
url: $(this).attr('data-url'),
|
||||
type: 'POST',
|
||||
data: $("#add-images-form").serialize(),
|
||||
success: function(data){
|
||||
$("#add-images-form").trigger('reset');
|
||||
$("#files-div").empty();
|
||||
$("#files-div").append(data);
|
||||
tcdropResetAll();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var template_apps = $("#templates-filter").attr("data-template_apps").split(',');
|
||||
var autocomplete_data = {}
|
||||
$.each(template_apps, function(i, e) {
|
||||
autocomplete_data[e.split('&&')[0]] = e.split('&&')[1]
|
||||
});
|
||||
|
||||
$("#templates-filter").autocomplete({
|
||||
limit: 16,
|
||||
data: autocomplete_data,
|
||||
onAutocomplete: function () {
|
||||
$.ajax({
|
||||
url: $("#templates-filter").attr('data-url'),
|
||||
type: 'GET',
|
||||
data: {name: $("#templates-filter").val()},
|
||||
success: function(data){
|
||||
$("#template-div").empty();
|
||||
$("#template-div").append(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
@ -89,9 +89,10 @@ col_id="",
|
||||
icon=None,
|
||||
spacer_icon=False,
|
||||
required='',
|
||||
helper=None
|
||||
helper=None,
|
||||
col_style=None
|
||||
)%}
|
||||
<div id="{{col_id}}" class="input-field col {{ size }} {{ col_class }}">
|
||||
<div id="{{col_id}}" class="input-field col {{ size }} {{ col_class }}" style="{{ col_style }}">
|
||||
{% if spacer_icon == True %}
|
||||
<i class="material-icons-outlined prefix hide"> home </i>
|
||||
{% endif %}
|
||||
|
@ -48,7 +48,7 @@
|
||||
|
||||
<body id="body" class="vertical-layout page-header-light vertical-menu-collapsible 2-columns " data-open="click"
|
||||
data-menu="vertical-dark-menu" data-col="2-columns">
|
||||
<input id="copy-input" class="hide">
|
||||
<input id="copy-input" style="white-space: pre" class="hide">
|
||||
|
||||
<input id="settings-theme" class="hide" value="{{ settings.theme }}">
|
||||
<input id="settings-accent" class="hide" value="{{ settings.accent }}">
|
||||
@ -64,7 +64,6 @@
|
||||
{% block sidenav %}{% endblock sidenav %}
|
||||
|
||||
{% block content %}
|
||||
<input id="copy-input" class="hide">
|
||||
{% endblock content %}
|
||||
|
||||
{% block footer %}{% endblock footer %}
|
||||
|
@ -5,22 +5,7 @@
|
||||
{% endblock page_vendor_css %}
|
||||
|
||||
{% block page_lvl_css %}
|
||||
<style>
|
||||
body {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
.settings-page-card {
|
||||
max-height: calc(100vh - 30px);
|
||||
min-height: calc(100vh - 30px);
|
||||
}
|
||||
|
||||
#apps .dropdown-content {
|
||||
border-top-left-radius: 0px;
|
||||
border-top-right-radius: 0px;
|
||||
background: var(--theme-surface-1);
|
||||
}
|
||||
</style>
|
||||
{{ process_css_sources(src="settings_system/settings.css")|safe }}
|
||||
{% if settings.background %}
|
||||
<style>
|
||||
#main {
|
||||
@ -234,9 +219,11 @@
|
||||
</div>
|
||||
<input name="files" id="add-images-input" class="hide">
|
||||
</form>
|
||||
<div class="col s12">
|
||||
{{ tcdrop(allowed_types='jpg,jpeg,png,gif', id="images-tcdrop", max_files="30") }}
|
||||
{{ button(text="save", icon="save", id="save-images-btn", float="left", data={"url": url_for('settings_system.add_images')}) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div id="files-div">{{ files_html|safe }}</div>
|
||||
@ -260,7 +247,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<div id="template-div" class="selectable-all"></div>
|
||||
<div id="template-div" class="selectable-all copy-target"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -314,74 +301,5 @@
|
||||
{% endblock page_vendor_js %}
|
||||
|
||||
{% block page_lvl_js %}
|
||||
<script type="text/javascript">
|
||||
var d = document.getElementById("settings-sidenav");
|
||||
d.className += " active theme-primary";
|
||||
|
||||
function apply_settings(settings_theme, settings_accent){
|
||||
localStorage.setItem('mode', settings_theme);
|
||||
document.documentElement.setAttribute('data-theme', settings_theme);
|
||||
localStorage.setItem('accent', settings_accent);
|
||||
document.documentElement.setAttribute('data-accent', settings_accent);
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
initTCdrop('#images-tcdrop');
|
||||
$("#config-wiki-modal").modal();
|
||||
$("#save-config-btn").on('click', function(e) {
|
||||
$.ajax({
|
||||
url: $(this).attr('data-url'),
|
||||
type: 'POST',
|
||||
data: $("#config-form").serialize(),
|
||||
success: function(data){
|
||||
if (data.data.msg === "success"){
|
||||
M.toast({html: 'Config applied successfully'});
|
||||
apply_settings(data.data.settings.theme, data.data.settings.accent);
|
||||
location.reload(true);
|
||||
} else {
|
||||
M.toast({html: data.data.msg, classes: "theme-warning"});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#save-images-btn").on('click', function(e) {
|
||||
$("#add-images-input").val(tcdrop_files['images-tcdrop'].toString());
|
||||
$.ajax({
|
||||
url: $(this).attr('data-url'),
|
||||
type: 'POST',
|
||||
data: $("#add-images-form").serialize(),
|
||||
success: function(data){
|
||||
$("#add-images-form").trigger('reset');
|
||||
$("#files-div").empty();
|
||||
$("#files-div").append(data);
|
||||
tcdropResetAll();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var template_apps = $("#templates-filter").attr("data-template_apps").split(',');
|
||||
var autocomplete_data = {}
|
||||
$.each(template_apps, function(i, e) {
|
||||
autocomplete_data[e.split('&&')[0]] = e.split('&&')[1]
|
||||
});
|
||||
|
||||
$("#templates-filter").autocomplete({
|
||||
limit: 16,
|
||||
data: autocomplete_data,
|
||||
onAutocomplete: function () {
|
||||
$.ajax({
|
||||
url: $("#templates-filter").attr('data-url'),
|
||||
type: 'GET',
|
||||
data: {name: $("#templates-filter").val()},
|
||||
success: function(data){
|
||||
$("#template-div").empty();
|
||||
$("#template-div").append(data)
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
{{ process_js_sources(src="settings_system/settings.js")|safe }}
|
||||
{% endblock page_lvl_js %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user