diff --git a/bundler/webpack.common.js b/bundler/webpack.common.js index b37bde4..5ee33bc 100644 --- a/bundler/webpack.common.js +++ b/bundler/webpack.common.js @@ -1,6 +1,6 @@ const CopyWebpackPlugin = require('copy-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); -const { ProvidePlugin } = require('webpack'); +const { ProvidePlugin, DefinePlugin } = require('webpack'); const path = require('path'); @@ -12,6 +12,9 @@ module.exports = { }, devtool: 'source-map', plugins: [ + new DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development') + }), new ProvidePlugin({ $: 'jquery', // Rende $ disponibile globalmente jQuery: 'jquery', diff --git a/bundler/webpack.prod.js b/bundler/webpack.prod.js index 793bed3..d58ff1e 100644 --- a/bundler/webpack.prod.js +++ b/bundler/webpack.prod.js @@ -1,7 +1,7 @@ const commonConfiguration = require('./webpack.common.js'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); -const { ProvidePlugin } = require('webpack'); +const { ProvidePlugin, DefinePlugin } = require('webpack'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const path = require('path'); @@ -16,6 +16,9 @@ module.exports = { }, plugins: [ new CleanWebpackPlugin(), + new DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify('production') + }), new ProvidePlugin({ $: 'jquery', // Rende $ disponibile globalmente jQuery: 'jquery', diff --git a/src/modules/controller.js b/src/modules/controller.js index c501368..5aea338 100644 --- a/src/modules/controller.js +++ b/src/modules/controller.js @@ -16,16 +16,16 @@ let prescrizione; let def_config; let lang = navigator.language.split('-')[0] != 'it' ? 'en' : 'it'; const hidden_fields = {}; -let API = 'http://localhost/api/'; -let CRM_URL = 'http://localhost/prescrizioni/'; -let CFG_URL = 'http://localhost/config-predefinite/'; +let API = 'https://lto.test/api/'; +let CRM_URL = 'https://lto.test/prescrizioni/'; +let CFG_URL = 'https://lto.test/config-predefinite-tads/'; -//if(process.env.NODE_ENV === 'production'){ +if(process.env.NODE_ENV === 'production'){ API = 'https://setup.allineatoriinvisibili.it/api/'; CRM_URL = 'https://setup.allineatoriinvisibili.it/prescrizioni/'; - CFG_URL = 'https://setup.allineatoriinvisibili.it/config-predefinite/'; + CFG_URL = 'https://setup.allineatoriinvisibili.it/config-predefinite-tads/'; -//} +} const assetDir = './assets/' const anteprimaDir = assetDir+'images/anteprima_finiture/'; @@ -108,7 +108,7 @@ export const init = async (_scene, _cameraControls) => { let edit = url.searchParams.get("edit"); - let force_lang = url.searchParams.get("lang"); + let force_lang = url.searchParams.get("lang") || localStorage.getItem('lang'); if(force_lang != null){ lang = force_lang; }else{ @@ -118,18 +118,20 @@ export const init = async (_scene, _cameraControls) => { if(id != null){ if(type != null && type == 'default'){ - def_config = await (await fetch(API+'frontend/def-config/'+id)).json(); + fetch(API+'frontend/def-config-tads/'+id).then(res => res.json()).then(data => { + console.log(data); + }) + + def_config = await (await fetch(API+'frontend/def-config-tads/'+id)).json(); $(".btn-torna-prescrizione").addClass('d-none'); $(".btn-torna-prescrizione-modal").addClass('d-none'); if(demo_mode != null){ - $(".btn-salva").addClass('d-none'); $(".btn-torna-prescrizione").addClass('d-none'); }else{ $(".btn-torna-config-modal,.btn-torna-indietro").removeClass('d-none').on('click', ()=>{ location.href = CFG_URL }) - } @@ -139,7 +141,7 @@ export const init = async (_scene, _cameraControls) => { let cfg = configurazione[k]; $("#"+cfg.field.id).val(cfg.value); $("#"+cfg.field.id).trigger('change'); - //updateConfig(cfg.field, cfg.value, cfg.label) + updateConfig(cfg.field, cfg.value, cfg.label) } } }else{ @@ -150,7 +152,7 @@ export const init = async (_scene, _cameraControls) => { let ed_config = null; if(id_config != null){ - ed_config = await (await fetch(API+'frontend/def-config/'+id_config)).json(); + ed_config = await (await fetch(API+'frontend/def-config-tads/'+id_config)).json(); } prescrizione = await (await fetch(API+'frontend/config/'+id)).json(); @@ -174,7 +176,7 @@ export const init = async (_scene, _cameraControls) => { $("#"+cfg.field.id).val(cfg.value); $("#"+cfg.field.id).trigger('change'); - //updateConfig(cfg.field, cfg.value, cfg.label) + updateConfig(cfg.field, cfg.value, cfg.label) } } } @@ -445,7 +447,7 @@ const salvaConfigurazione = async () => { let toSend = {configurazione: config, configurazione_html: config_html.innerHTML} if(def_config != null){ - url = API+'frontend/save-def-config'; + url = API+'frontend/save-def-config-tads'; toSend.id = def_config.id; }else{ toSend.prescrizione_id = prescrizione.id; @@ -497,5 +499,7 @@ window.appendLang = (lang) => { }else{ window.location.href += '?lang='+lang; } + + localStorage.setItem('lang', lang); } \ No newline at end of file diff --git a/src/modules/scena-controller.js b/src/modules/scena-controller.js index 76e3628..1959463 100644 --- a/src/modules/scena-controller.js +++ b/src/modules/scena-controller.js @@ -342,7 +342,7 @@ export const loadModels = async (config) => { } - console.log("Active objs:", activeObjs); + //console.log("Active objs:", activeObjs); mainGroup.traverse((el) => { if(el.isMesh && el.userData.type != 'arcata') el.visible = false;