Browse Source

FIX: webpack.config.js

Giancarlo Voci 7 years ago
parent
commit
3ac5e98097
7 changed files with 141 additions and 138 deletions
  1. 1 0
      cfg/config.bin
  2. 1 2
      package.json
  3. 0 0
      ui/images/favicon_omlink.ico
  4. 124 0
      ui/js/app.js
  5. 3 132
      ui/js/index.js
  6. 1 1
      ui/masterpage_template.tpl
  7. 11 3
      webpack.config.js

+ 1 - 0
cfg/config.bin

@@ -0,0 +1 @@
+eJx9kV1v2jAUhu8t+T9YXG2aGpwGaDdkaSEYSBtilA/EVlVRCC5ETWLmOPQD8d/nQKvdzZLl4yMfv895z8O2EOu0qB8hWNIgdJlPTKNvYAjsOGIes8ekU8us24HAsZ0ZRQRFQUwhiF3S5F0IxnQUT8k1BNR32Nj1p6QTR5OrW10wc6czT++IPGkFDsGdHRj8dZ9LTo5HlZf8y9dvltm3Bhjj00n/FfqkU77Vf4ofO1ErUogsLdpouBdSEcvCg+FmXaUlJ6Is8upZi2zWTc0lkUKo9rJP65qIPa/KvNpAMLdXychz/fskcuc0CalDLIwv+YBGwa9kwoJkYsdeREzcdrMkSjaaFYIhWqRqB8HIDmkceKR70YQgdCPq23NK2PzKO2c8NmWJE4cRm9NA9/bzo+Z06mqT8jLd8rpbiK0w9tUWAtdhftLWxNH/Hjfq8rxFCXnBM4Vednm2Q1lTK1FyibJCt4t4la4LjfwJcGb7hIXgwWEBNZ7Wj+eWpNg0mcpFBcHZY/P7tWEObg0TG2ZPO3B2uo97PesiKw9aJ6JhBMEzfyMO/rdMs3fTw9cW7t/outb433L7/ny4k+y+8kOnWlTTd6s52gM+C/3V8lC3OBpo4vrjEVuFNFi6DtVcoUfpop2QVsYX3UxUmxopgV7SXKEnIVHN9amnuhavOpaHPOOoEgqlhzQvLg5MA9uhyYIGLht/DBuCv3u+284=

+ 1 - 2
package.json

@@ -5,7 +5,7 @@
 	"description": "OM-Link Engine",
 	"author": "Open Mind",
 	"scripts": {
-		"Clean": "shx rm -rf tmp node_modules src_minified Site.log cfg/*.bin ui/dist/* ui/masterpage.tpl fbtpl",
+		"Clean": "shx rm -rf tmp node_modules src_minified Site.log cfg/*.old ui/dist/* ui/masterpage.tpl fbtpl",
 		"Install": "npm install",
 		"Build": "webpack --config webpack.config.js --display-error-details",
 		"Watch": "webpack --config webpack.config.js --display-error-details --watch",
@@ -27,7 +27,6 @@
 	},
 	"dependencies": {
 		"bootstrap": "^4.3.1",
-		"codeflask": "^1.4.0",
 		"jquery": "^3.4.0",
 		"popper.js": "^1.15.0"
 	}

+ 0 - 0
ui/images/favicon.ico → ui/images/favicon_omlink.ico


+ 124 - 0
ui/js/app.js

@@ -0,0 +1,124 @@
+/**
+ * Main Javascript file
+ *
+ * @author Open Mind
+ * @date 27/06/2018
+ * @time 17:42
+ */
+
+import $ from "jquery";
+
+let CUSTOM_NOTIFY = 0x4000;
+let REFRESH_FILTERS = CUSTOM_NOTIFY + 1;
+
+const fetchHeaders = {
+	'Accept': 'text/html',
+	'Content-Type': 'text/html',
+	'X-Requested-With': 'XMLHttpRequest',
+	'Cache-Control': 'no-cache',
+	'Pragma': 'no-cache',
+	'Expires': '0'
+};
+
+/* usefull if a blinking text is need, like in MaxMara project, you need to place this code in html:
+ *
+ * <nav class="navbar navbar-collapse p-0">
+ *   <span class="navbar-text blink" style="color: red" id="statusbartext"></span>
+ * </nav>
+ */
+function SetStatusBarText(msg) {
+	$('#statusbartext').text(msg);
+	setTimeout(() => {
+		$('#statusbartext').text('');
+	}, 60000);
+}
+
+function NotificationBuilder(notifications) {
+	let tplNotify = '';
+	let htmlNotificationArea = '';
+	if (notifications.length === 0) {
+		$('#notification_area_button').addClass('disabled');
+		$('#sysmsgnum').empty();
+	} else {
+		let notificationCount = 0;
+		notifications.forEach(function (element) {
+// If notification codes are >CUSTON_NOTIFY means that are special codes to skip in this logic
+			if (element.code > CUSTOM_NOTIFY)
+				return;
+
+			tplNotify += `<a class="dropdown-item" href="javascript:NotificationDelete('${element.link}', ${element.code})">[${element.timestamp}] ${element.caption}<span class="ml-1 badge badge-danger">${element.count}</span></a>`;
+			notificationCount++;
+		});
+
+		htmlNotificationArea = `
+${tplNotify}
+<a id="notification_area_deleteall" class="dropdown-item text-center" href="javascript:NotificationDelete('#', 0)" >Cancella tutto</a>
+`;
+		$('#notification_area_button').removeClass('disabled');
+		$('#sysmsgnum').html(notificationCount);
+	}
+
+	$('#notification_area').html(htmlNotificationArea);
+}
+
+function refreshNotificationArea() {
+	fetch(`${BASEURL}/api.system.getserverstatus`, {headers: fetchHeaders})
+		.then(resp => {
+			if (resp.status === 200)
+				return resp.json();
+			else
+				return Promise.reject("getserverstatus: error");
+		})
+		.then(data => {
+			NotificationBuilder(data.notify);
+		})
+		.catch(err => {
+			console.log(err);
+		});
+}
+
+function NotificationDelete(link, code) {
+	fetch(`${BASEURL}/api.system.removenotification/${code}`, {method: "POST"})
+		.then(() => {
+			if ((link != null) && (link.length != 0) && (link != '#'))
+				window.location.href = `${BASEURL}${link}`;
+		})
+		.catch(() => {
+			alert('NotificationDelete error');
+		});
+}
+
+function SetupConfirmationDialog() {
+	$('.requestconfirm').on('click', function (ev) {
+		let confirmText = $(this).data('confirmtext');
+		if (!confirm(confirmText))
+			ev.preventDefault();
+	});
+}
+
+function ForceFocus() {
+	setInterval(function () {
+		$("[forcefocus]").focus();
+	}, 1000);
+}
+
+document.addEventListener('DOMContentLoaded', function () {
+	SetupConfirmationDialog();
+
+	refreshNotificationArea();
+
+	ForceFocus(); // INPUT AUTOFOCUS
+
+	$('body').on('submit', 'form', function () {
+		$('body').focus();
+		$('form input,form select').prop('readonly', true);
+
+		// Manual submit for more control
+		this.submit();
+		return false;
+	});
+
+	setInterval(() => {
+		refreshNotificationArea();
+	}, 3000);
+});

+ 3 - 132
ui/js/index.js

@@ -1,135 +1,6 @@
-import $ from 'jquery';
 import 'bootstrap';
-import 'bootstrap/dist/css/bootstrap.min.css';
 import 'popper.js';
-import CodeFlask from 'codeflask';
-import '../css/omlink.scss';
-
-/**
- * Main Javascript file
- *
- * @author Open Mind
- * @date 27/06/2018
- * @time 17:42
- */
-
-let CUSTOM_NOTIFY = 0x4000;
-let REFRESH_FILTERS = CUSTOM_NOTIFY + 1;
-
-const fetchHeaders = {
-	'Accept': 'text/html',
-	'Content-Type': 'text/html',
-	'X-Requested-With': 'XMLHttpRequest',
-	'Cache-Control': 'no-cache',
-	'Pragma': 'no-cache',
-	'Expires': '0'
-};
-
-/* usefull if a blinking text is need, like in MaxMara project, you need to place this code in html:
- *
- * <nav class="navbar navbar-collapse p-0">
- *   <span class="navbar-text blink" style="color: red" id="statusbartext"></span>
- * </nav>
- */
-function SetStatusBarText(msg) {
-	$('#statusbartext').text(msg);
-	setTimeout(() => {
-		$('#statusbartext').text('');
-	}, 60000);
-}
-
-function NotificationBuilder(notifications) {
-	let tplNotify = '';
-	let htmlNotificationArea = '';
-	if (notifications.length === 0) {
-		$('#notification_area_button').addClass('disabled');
-		$('#sysmsgnum').empty();
-	} else {
-		let notificationCount = 0;
-		notifications.forEach(function (element) {
-// If notification codes are >CUSTON_NOTIFY means that are special codes to skip in this logic
-			if (element.code > CUSTOM_NOTIFY)
-				return;
-
-			tplNotify += `<a class="dropdown-item" href="javascript:NotificationDelete('${element.link}', ${element.code})">[${element.timestamp}] ${element.caption}<span class="ml-1 badge badge-danger">${element.count}</span></a>`;
-			notificationCount++;
-		});
-
-		htmlNotificationArea = `
-${tplNotify}
-<a id="notification_area_deleteall" class="dropdown-item text-center" href="javascript:NotificationDelete('#', 0)" >Cancella tutto</a>
-`;
-		$('#notification_area_button').removeClass('disabled');
-		$('#sysmsgnum').html(notificationCount);
-	}
-
-	$('#notification_area').html(htmlNotificationArea);
-}
-
-function refreshNotificationArea() {
-	fetch(`${BASEURL}/api.system.getserverstatus`, {headers: fetchHeaders})
-		.then(resp => {
-			if (resp.status === 200)
-				return resp.json();
-			else
-				return Promise.reject("getserverstatus: error");
-		})
-		.then(data => {
-			NotificationBuilder(data.notify);
-		})
-		.catch(err => {
-			console.log(err);
-		});
-}
-
-function NotificationDelete(link, code) {
-	fetch(`${BASEURL}/api.system.removenotification/${code}`, {method: "POST"})
-		.then(() => {
-			if ((link != null) && (link.length != 0) && (link != '#'))
-				window.location.href = `${BASEURL}${link}`;
-		})
-		.catch(() => {
-			alert('NotificationDelete error');
-		});
-}
+import './app.js';
 
-function SetupConfirmationDialog() {
-	$('.requestconfirm').on('click', function (ev) {
-		let confirmText = $(this).data('confirmtext');
-		if (!confirm(confirmText))
-			ev.preventDefault();
-	});
-}
-
-function ForceFocus() {
-	setInterval(function () {
-		$("[forcefocus]").focus();
-	}, 1000);
-}
-
-document.addEventListener('DOMContentLoaded', function () {
-	SetupConfirmationDialog();
-
-	refreshNotificationArea();
-
-	ForceFocus(); // INPUT AUTOFOCUS
-
-	$('body').on('submit', 'form', function () {
-		$('body').focus();
-		$('form input,form select').prop('readonly', true);
-
-		// Manual submit for more control
-		this.submit();
-		return false;
-	});
-
-	setInterval(() => {
-		refreshNotificationArea();
-	}, 3000);
-
-	const flask = new CodeFlask('#my-selector', {
-		language: 'ini',
-	});
-
-	console.log(flask);
-});
+import 'bootstrap/dist/css/bootstrap.min.css';
+import '../css/omlink.scss';

+ 1 - 1
ui/masterpage_template.tpl

@@ -4,7 +4,7 @@
   <meta charset="UTF-8">
   <meta content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no" name="viewport">
   <title>{{@SITENAME}}</title>
-  <link href="{{@BASEURL}}/ui/favicon_{{@CUSTOMERNAME}}.ico?v={{@VERSION}}" rel="shortcut icon" type="image/x-icon">
+  <link href="{{@BASEURL}}/ui/images/favicon_{{@CUSTOMERNAME}}.ico?v={{@VERSION}}" rel="shortcut icon" type="image/x-icon">
 
   <script type="text/javascript">
     const BASEURL = '{{@BASEURL}}';

+ 11 - 3
webpack.config.js

@@ -1,7 +1,7 @@
 const path = require("path");
 const TerserJSPlugin = require('terser-webpack-plugin');
 const HtmlPlugin = require("html-webpack-plugin");
-const HtmlPrefixPlugin = require("html-webpack-prefix-plugin");
+//const HtmlPrefixPlugin = require("html-webpack-prefix-plugin");
 const MiniCssExtractPlugin = require("mini-css-extract-plugin");
 const CleanWebpackPlugin = require("clean-webpack-plugin");
 const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
@@ -9,8 +9,15 @@ const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
 module.exports = {
 	plugins: [
 		new CleanWebpackPlugin(),
-		new HtmlPlugin({template: "./ui/masterpage_template.tpl", prefix: 'ui/', filename: "../masterpage.tpl"}),
-		new HtmlPrefixPlugin(),
+		new HtmlPlugin(
+			{
+				template: "./ui/masterpage_template.tpl",
+				//prefix: 'ui/',
+				filename: "../masterpage.tpl",
+				//favicon: "../omlink/ui/images/favicon.ico"
+			}
+		),
+		//new HtmlPrefixPlugin(),
 		new MiniCssExtractPlugin({filename: "styles.[contenthash].css"})
 	],
 	module: {
@@ -42,6 +49,7 @@ module.exports = {
 	},
 	entry: "./ui/js/index.js",
 	output: {
+		publicPath: 'ui/dist/',
 		path: path.resolve(__dirname, "ui/dist/"),
 		filename: "bundle.[contenthash].js"
 	},