@opengis/fastify-table 1.3.71 → 1.3.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -86
- package/index.js +9 -0
- package/package.json +1 -1
- package/server/helpers/format/formatAuto.js +13 -13
- package/server/helpers/format/formatDate.js +258 -258
- package/server/helpers/format/formatDigit.js +20 -20
- package/server/helpers/format/formatNum.js +361 -361
- package/server/helpers/format/formatNumber.js +54 -54
- package/server/helpers/format/formatRelative.js +106 -106
- package/server/helpers/format/formatUnit.js +38 -38
- package/server/helpers/format/num_format.js +41 -41
- package/server/helpers/funcs/_math.js +49 -49
- package/server/helpers/funcs/empty.js +21 -21
- package/server/helpers/funcs/ifCond.js +106 -106
- package/server/helpers/funcs/ifCondAnd.js +96 -96
- package/server/helpers/funcs/ifCondOr.js +98 -98
- package/server/helpers/funcs/inc.js +20 -20
- package/server/helpers/funcs/json.js +2 -2
- package/server/helpers/funcs/round.js +27 -27
- package/server/helpers/string/coalesce.js +31 -31
- package/server/helpers/string/concat.js +28 -28
- package/server/helpers/string/split.js +19 -19
- package/server/helpers/string/str_replace.js +60 -60
- package/server/helpers/string/substr.js +31 -31
- package/server/helpers/string/translit.js +23 -23
- package/server/helpers/string/utils/alphabet.js +75 -75
- package/server/plugins/cron/funcs/addCron.js +52 -52
- package/server/plugins/cron/index.js +76 -76
- package/server/plugins/crud/funcs/getOpt.js +14 -14
- package/server/plugins/crud/funcs/setOpt.js +21 -21
- package/server/plugins/crud/funcs/setToken.js +43 -43
- package/server/plugins/crud/funcs/utils/getFolder.js +11 -11
- package/server/plugins/crud/index.js +23 -23
- package/server/plugins/hook/index.js +8 -8
- package/server/plugins/logger/errorStatus.js +19 -19
- package/server/plugins/logger/index.js +26 -26
- package/server/plugins/migration/index.js +7 -7
- package/server/plugins/pg/index.js +11 -2
- package/server/plugins/policy/sqlInjection.js +33 -33
- package/server/plugins/redis/client.js +8 -8
- package/server/plugins/redis/funcs/redisClients.js +3 -3
- package/server/plugins/redis/index.js +17 -17
- package/server/plugins/table/funcs/getFilterSQL/util/getCustomQuery.js +13 -13
- package/server/plugins/table/funcs/getFilterSQL/util/getTableSql.js +34 -34
- package/server/plugins/table/funcs/getTemplates.js +19 -19
- package/server/plugins/table/funcs/gisIRColumn.js +82 -82
- package/server/plugins/table/funcs/loadTemplate.js +1 -1
- package/server/plugins/table/funcs/loadTemplatePath.js +1 -1
- package/server/plugins/table/funcs/userTemplateDir.js +1 -1
- package/server/plugins/table/index.js +13 -13
- package/server/plugins/util/index.js +7 -7
- package/server/routes/cron/index.js +16 -14
- package/server/routes/crud/index.js +8 -7
- package/server/routes/data/controllers/cardData.js +144 -0
- package/server/routes/data/controllers/cardTabData.js +58 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/index.js +92 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/util/formatValue.js +170 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getCustomQuery.js +13 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getFilterQuery.js +64 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getOptimizedQuery.js +12 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getTableSql.js +34 -0
- package/server/routes/data/controllers/tableData.js +55 -0
- package/server/routes/data/controllers/tableFilter.js +16 -0
- package/server/routes/data/controllers/tableInfo.js +110 -0
- package/server/routes/data/controllers/tokenInfo.js +12 -0
- package/server/routes/data/controllers/utils/assignTokens.js +31 -0
- package/server/routes/data/controllers/utils/conditions.js +19 -0
- package/server/routes/data/controllers/utils/getColumns.js +9 -0
- package/server/routes/data/index.mjs +22 -0
- package/server/routes/data/schema.js +54 -0
- package/server/routes/dblist/index.mjs +9 -7
- package/server/routes/logger/controllers/logger.file.js +93 -93
- package/server/routes/logger/controllers/utils/checkUserAccess.js +19 -19
- package/server/routes/logger/controllers/utils/getRootDir.js +26 -26
- package/server/routes/logger/index.js +17 -17
- package/server/routes/menu/controllers/getMenu.js +97 -0
- package/server/routes/menu/controllers/interfaces.js +21 -0
- package/server/routes/menu/index.mjs +8 -0
- package/server/routes/menu/schema.js +0 -0
- package/server/routes/properties/controllers/properties.add.js +55 -55
- package/server/routes/properties/controllers/properties.get.js +17 -17
- package/server/routes/properties/index.js +16 -16
- package/server/routes/table/controllers/form.js +42 -42
- package/server/routes/table/controllers/search.js +74 -74
- package/server/routes/table/controllers/suggest.js +28 -14
- package/server/routes/table/index.js +10 -10
- package/server/routes/table/schema.js +65 -64
- package/server/routes/templates/controllers/getTemplate.js +51 -0
- package/server/routes/templates/index.mjs +10 -0
- package/server/routes/templates/schema.js +9 -0
- package/server/routes/util/controllers/status.monitor.js +8 -8
- package/server/routes/util/index.js +2 -2
- package/utils.js +2 -0
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Форматування до числа
|
|
3
|
-
*
|
|
4
|
-
* @summary Форматування до числа
|
|
5
|
-
* @priority 0
|
|
6
|
-
* @alias formatNumber
|
|
7
|
-
* @type helper
|
|
8
|
-
* @example
|
|
9
|
-
* {{{formatNumber space}}}
|
|
10
|
-
* @example
|
|
11
|
-
* {{{formatNumber amount}}}
|
|
12
|
-
* @example
|
|
13
|
-
* {{formatNumber size_log}}
|
|
14
|
-
* @example
|
|
15
|
-
* {{formatNumber (coalesce proj_finish 0) }}
|
|
16
|
-
* @param {String|Number} data Число для формування
|
|
17
|
-
* @param {Number} round Параметр округлення
|
|
18
|
-
* @param {String} style Стиль форматування (currency, decimal, percent, unit)
|
|
19
|
-
* @param {String} currency Валюта (наприклад, EUR)
|
|
20
|
-
* @param {String} unit Одиниця вимірювання (наприклад, liter)
|
|
21
|
-
* @param {String} locale Мова (наприклад, ua, en)
|
|
22
|
-
* @param {String} unitDisplay Стиль відображення одиниці (short, narrow, long)
|
|
23
|
-
* @param {String} notation Стиль скорочення чисел (compact)
|
|
24
|
-
* @returns {String} Відформатоване число
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
export default function formatNumber(data, options) {
|
|
28
|
-
const TP = typeof data;
|
|
29
|
-
|
|
30
|
-
if (!data || (TP !== 'number' && TP !== 'string')) return '';
|
|
31
|
-
|
|
32
|
-
if (TP === 'string') {
|
|
33
|
-
data = data.replace(',', '.') - 0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const round = options.hash?.round ?? 2;
|
|
37
|
-
const style = options.hash?.style ?? 'decimal';
|
|
38
|
-
const currency = options.hash?.currency ?? 'UAH';
|
|
39
|
-
const unit = options.hash?.unit ?? 'liter';
|
|
40
|
-
const locale = options.hash?.locale ?? 'ua';
|
|
41
|
-
const unitDisplay = options.hash?.unitDisplay ?? 'short';
|
|
42
|
-
const notation = options.hash?.notation ?? 'standard';
|
|
43
|
-
|
|
44
|
-
const formatter = new Intl.NumberFormat(locale, {
|
|
45
|
-
style: style,
|
|
46
|
-
currency: currency,
|
|
47
|
-
unit: unit,
|
|
48
|
-
unitDisplay: unitDisplay,
|
|
49
|
-
notation: notation,
|
|
50
|
-
maximumFractionDigits: round
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
return formatter.format(data - 0);
|
|
54
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Форматування до числа
|
|
3
|
+
*
|
|
4
|
+
* @summary Форматування до числа
|
|
5
|
+
* @priority 0
|
|
6
|
+
* @alias formatNumber
|
|
7
|
+
* @type helper
|
|
8
|
+
* @example
|
|
9
|
+
* {{{formatNumber space}}}
|
|
10
|
+
* @example
|
|
11
|
+
* {{{formatNumber amount}}}
|
|
12
|
+
* @example
|
|
13
|
+
* {{formatNumber size_log}}
|
|
14
|
+
* @example
|
|
15
|
+
* {{formatNumber (coalesce proj_finish 0) }}
|
|
16
|
+
* @param {String|Number} data Число для формування
|
|
17
|
+
* @param {Number} round Параметр округлення
|
|
18
|
+
* @param {String} style Стиль форматування (currency, decimal, percent, unit)
|
|
19
|
+
* @param {String} currency Валюта (наприклад, EUR)
|
|
20
|
+
* @param {String} unit Одиниця вимірювання (наприклад, liter)
|
|
21
|
+
* @param {String} locale Мова (наприклад, ua, en)
|
|
22
|
+
* @param {String} unitDisplay Стиль відображення одиниці (short, narrow, long)
|
|
23
|
+
* @param {String} notation Стиль скорочення чисел (compact)
|
|
24
|
+
* @returns {String} Відформатоване число
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export default function formatNumber(data, options) {
|
|
28
|
+
const TP = typeof data;
|
|
29
|
+
|
|
30
|
+
if (!data || (TP !== 'number' && TP !== 'string')) return '';
|
|
31
|
+
|
|
32
|
+
if (TP === 'string') {
|
|
33
|
+
data = data.replace(',', '.') - 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const round = options.hash?.round ?? 2;
|
|
37
|
+
const style = options.hash?.style ?? 'decimal';
|
|
38
|
+
const currency = options.hash?.currency ?? 'UAH';
|
|
39
|
+
const unit = options.hash?.unit ?? 'liter';
|
|
40
|
+
const locale = options.hash?.locale ?? 'ua';
|
|
41
|
+
const unitDisplay = options.hash?.unitDisplay ?? 'short';
|
|
42
|
+
const notation = options.hash?.notation ?? 'standard';
|
|
43
|
+
|
|
44
|
+
const formatter = new Intl.NumberFormat(locale, {
|
|
45
|
+
style: style,
|
|
46
|
+
currency: currency,
|
|
47
|
+
unit: unit,
|
|
48
|
+
unitDisplay: unitDisplay,
|
|
49
|
+
notation: notation,
|
|
50
|
+
maximumFractionDigits: round
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return formatter.format(data - 0);
|
|
54
|
+
}
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable no-param-reassign */
|
|
3
|
-
/**
|
|
4
|
-
* Форматування часу скільки залишилося чи пройшло від заданого
|
|
5
|
-
*
|
|
6
|
-
* @priority 3
|
|
7
|
-
* @deprecated true
|
|
8
|
-
* @type helper
|
|
9
|
-
* @alias formatRelative
|
|
10
|
-
* @example
|
|
11
|
-
* {{formatRelative '2022-01-13T13:05:40.841795' locate='ua'}}
|
|
12
|
-
* @example
|
|
13
|
-
* {{formatRelative '2022-01-13T13:20:40.841795' locate='ua' percent=1}}
|
|
14
|
-
* @param {Any} percent Будь-яке значення для відображення часу у відсотках
|
|
15
|
-
* @param {String} locale Мова якою відобразити час: en ru ua
|
|
16
|
-
* @param {String} data Отримана та введена дата для форматування
|
|
17
|
-
* @param {String} short
|
|
18
|
-
* @param {String} units
|
|
19
|
-
* @param {String} unit
|
|
20
|
-
* @param {String} data_only
|
|
21
|
-
* @returns {String} Returns HTML
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
export default function formatRelative(data, options) {
|
|
25
|
-
if (!data) return 'Date is required';
|
|
26
|
-
if (typeof data === 'string') {
|
|
27
|
-
data = new Date(data);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let chLang;
|
|
31
|
-
let timeOut;
|
|
32
|
-
|
|
33
|
-
const locale = options.hash.locate || 'en';
|
|
34
|
-
|
|
35
|
-
const dateFrom = data;
|
|
36
|
-
const dateTo = options.hash.date_to ? new Date(options.hash.date_to) : new Date();
|
|
37
|
-
|
|
38
|
-
const templDifPast = {
|
|
39
|
-
ua: ['секунд тому', 'хвилин тому', 'годин тому', 'днів тому', 'тижнів тому', 'місяців тому', 'років тому', 'Вибачте, але заданого типу не існує'],
|
|
40
|
-
ru: ['секунд назад', 'минут назад', 'часов назад', 'дней назад', 'недель назад', 'місяцев назад', 'лет назад', 'Простите, но данного типа не существует'],
|
|
41
|
-
en: ['seconds ago', 'minutes ago', 'hours ago', 'days ago', 'weeks ago', 'months ago', 'years ago', 'Sorry, no such type of date '],
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const templDifFeature = {
|
|
45
|
-
ua: ['секунд залишилось', 'хвилин залишилось', 'годин залишилось', 'днів залишилось', 'тижнів залишилось', 'місяців залишилось', 'років залишилось', 'Вибачте, але заданого типу не існує'],
|
|
46
|
-
ru: ['секунд осталось', 'минут осталось', 'часов осталось', 'дней осталось', 'недель осталось', 'місяцев осталось', 'лет осталось', 'Простите, но данного типа не существует'],
|
|
47
|
-
en: ['seconds left', 'minutes left', 'hours left', 'days left', 'weeks left', 'months left', 'years left', 'Sorry, no such type of date '],
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const short = {
|
|
51
|
-
ua: ['сек', 'хв', 'год', 'дн', 'тижд', 'міс', 'р', 'Вибачте, але заданого типу не існує'],
|
|
52
|
-
ru: ['сек', 'мин', 'час', 'дн', 'нед', 'мес', 'г', 'Простите, но данного типа не существует'],
|
|
53
|
-
en: ['sec', 'min', 'hr', 'day', 'wk', 'mon', 'y', 'Sorry, no such type of date '],
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
let dif = Math.floor(dateTo.getTime() - dateFrom.getTime()) / 1000;
|
|
57
|
-
|
|
58
|
-
if (options.hash.percent) {
|
|
59
|
-
return ((new Date().getTime() - dateFrom.getTime()) * 100) / (dateTo.getTime() - dateFrom.getTime());
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (dif > 0) {
|
|
63
|
-
chLang = options.hash.short ? short[locale] : templDifPast[locale];
|
|
64
|
-
} else if (dif < 0) {
|
|
65
|
-
chLang = options.hash.short ? short[locale] : templDifFeature[locale];
|
|
66
|
-
}
|
|
67
|
-
dif = Math.abs(dif);
|
|
68
|
-
|
|
69
|
-
const bestFit = [
|
|
70
|
-
dif < 60,
|
|
71
|
-
dif < 3600,
|
|
72
|
-
dif < 3600 * 24,
|
|
73
|
-
dif < 3600 * 24 * 30,
|
|
74
|
-
dif < 3600 * 24 * 365,
|
|
75
|
-
].lastIndexOf(false) + 1;
|
|
76
|
-
|
|
77
|
-
options.hash.units = options.hash.units || options.hash.unit || ['second', 'minute', 'hour', 'day', 'week', 'month', 'year'][bestFit];
|
|
78
|
-
|
|
79
|
-
switch (options.hash.units) {
|
|
80
|
-
case 'second':
|
|
81
|
-
timeOut = `${dif} ${options.hash.data_only ? '' : chLang[0]}`;
|
|
82
|
-
break;
|
|
83
|
-
case 'minute':
|
|
84
|
-
timeOut = `${Math.floor(dif / 60)} ${options.hash.data_only ? '' : chLang[1]}`;
|
|
85
|
-
break;
|
|
86
|
-
case 'hour':
|
|
87
|
-
timeOut = `${Math.floor(dif / (60 * 60))} ${options.hash.data_only ? '' : chLang[2]}`;
|
|
88
|
-
break;
|
|
89
|
-
case 'day':
|
|
90
|
-
timeOut = `${Math.floor(dif / (60 * 60 * 24))} ${options.hash.data_only ? '' : chLang[3]}`;
|
|
91
|
-
break;
|
|
92
|
-
case 'week':
|
|
93
|
-
timeOut = `${Math.floor(dif / (60 * 60 * 24 * 7))} ${options.hash.data_only ? '' : chLang[4]}`;
|
|
94
|
-
break;
|
|
95
|
-
case 'month':
|
|
96
|
-
timeOut = `${Math.floor(dif / (60 * 60 * 24 * 30))} ${options.hash.data_only ? '' : chLang[5]}`;
|
|
97
|
-
break;
|
|
98
|
-
case 'year':
|
|
99
|
-
timeOut = `${Math.floor(dif / (60 * 60 * 24 * 365))} ${options.hash.data_only ? '' : chLang[6]}`;
|
|
100
|
-
break;
|
|
101
|
-
default:
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return timeOut;
|
|
106
|
-
}
|
|
1
|
+
|
|
2
|
+
/* eslint-disable no-param-reassign */
|
|
3
|
+
/**
|
|
4
|
+
* Форматування часу скільки залишилося чи пройшло від заданого
|
|
5
|
+
*
|
|
6
|
+
* @priority 3
|
|
7
|
+
* @deprecated true
|
|
8
|
+
* @type helper
|
|
9
|
+
* @alias formatRelative
|
|
10
|
+
* @example
|
|
11
|
+
* {{formatRelative '2022-01-13T13:05:40.841795' locate='ua'}}
|
|
12
|
+
* @example
|
|
13
|
+
* {{formatRelative '2022-01-13T13:20:40.841795' locate='ua' percent=1}}
|
|
14
|
+
* @param {Any} percent Будь-яке значення для відображення часу у відсотках
|
|
15
|
+
* @param {String} locale Мова якою відобразити час: en ru ua
|
|
16
|
+
* @param {String} data Отримана та введена дата для форматування
|
|
17
|
+
* @param {String} short
|
|
18
|
+
* @param {String} units
|
|
19
|
+
* @param {String} unit
|
|
20
|
+
* @param {String} data_only
|
|
21
|
+
* @returns {String} Returns HTML
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export default function formatRelative(data, options) {
|
|
25
|
+
if (!data) return 'Date is required';
|
|
26
|
+
if (typeof data === 'string') {
|
|
27
|
+
data = new Date(data);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let chLang;
|
|
31
|
+
let timeOut;
|
|
32
|
+
|
|
33
|
+
const locale = options.hash.locate || 'en';
|
|
34
|
+
|
|
35
|
+
const dateFrom = data;
|
|
36
|
+
const dateTo = options.hash.date_to ? new Date(options.hash.date_to) : new Date();
|
|
37
|
+
|
|
38
|
+
const templDifPast = {
|
|
39
|
+
ua: ['секунд тому', 'хвилин тому', 'годин тому', 'днів тому', 'тижнів тому', 'місяців тому', 'років тому', 'Вибачте, але заданого типу не існує'],
|
|
40
|
+
ru: ['секунд назад', 'минут назад', 'часов назад', 'дней назад', 'недель назад', 'місяцев назад', 'лет назад', 'Простите, но данного типа не существует'],
|
|
41
|
+
en: ['seconds ago', 'minutes ago', 'hours ago', 'days ago', 'weeks ago', 'months ago', 'years ago', 'Sorry, no such type of date '],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const templDifFeature = {
|
|
45
|
+
ua: ['секунд залишилось', 'хвилин залишилось', 'годин залишилось', 'днів залишилось', 'тижнів залишилось', 'місяців залишилось', 'років залишилось', 'Вибачте, але заданого типу не існує'],
|
|
46
|
+
ru: ['секунд осталось', 'минут осталось', 'часов осталось', 'дней осталось', 'недель осталось', 'місяцев осталось', 'лет осталось', 'Простите, но данного типа не существует'],
|
|
47
|
+
en: ['seconds left', 'minutes left', 'hours left', 'days left', 'weeks left', 'months left', 'years left', 'Sorry, no such type of date '],
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const short = {
|
|
51
|
+
ua: ['сек', 'хв', 'год', 'дн', 'тижд', 'міс', 'р', 'Вибачте, але заданого типу не існує'],
|
|
52
|
+
ru: ['сек', 'мин', 'час', 'дн', 'нед', 'мес', 'г', 'Простите, но данного типа не существует'],
|
|
53
|
+
en: ['sec', 'min', 'hr', 'day', 'wk', 'mon', 'y', 'Sorry, no such type of date '],
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
let dif = Math.floor(dateTo.getTime() - dateFrom.getTime()) / 1000;
|
|
57
|
+
|
|
58
|
+
if (options.hash.percent) {
|
|
59
|
+
return ((new Date().getTime() - dateFrom.getTime()) * 100) / (dateTo.getTime() - dateFrom.getTime());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (dif > 0) {
|
|
63
|
+
chLang = options.hash.short ? short[locale] : templDifPast[locale];
|
|
64
|
+
} else if (dif < 0) {
|
|
65
|
+
chLang = options.hash.short ? short[locale] : templDifFeature[locale];
|
|
66
|
+
}
|
|
67
|
+
dif = Math.abs(dif);
|
|
68
|
+
|
|
69
|
+
const bestFit = [
|
|
70
|
+
dif < 60,
|
|
71
|
+
dif < 3600,
|
|
72
|
+
dif < 3600 * 24,
|
|
73
|
+
dif < 3600 * 24 * 30,
|
|
74
|
+
dif < 3600 * 24 * 365,
|
|
75
|
+
].lastIndexOf(false) + 1;
|
|
76
|
+
|
|
77
|
+
options.hash.units = options.hash.units || options.hash.unit || ['second', 'minute', 'hour', 'day', 'week', 'month', 'year'][bestFit];
|
|
78
|
+
|
|
79
|
+
switch (options.hash.units) {
|
|
80
|
+
case 'second':
|
|
81
|
+
timeOut = `${dif} ${options.hash.data_only ? '' : chLang[0]}`;
|
|
82
|
+
break;
|
|
83
|
+
case 'minute':
|
|
84
|
+
timeOut = `${Math.floor(dif / 60)} ${options.hash.data_only ? '' : chLang[1]}`;
|
|
85
|
+
break;
|
|
86
|
+
case 'hour':
|
|
87
|
+
timeOut = `${Math.floor(dif / (60 * 60))} ${options.hash.data_only ? '' : chLang[2]}`;
|
|
88
|
+
break;
|
|
89
|
+
case 'day':
|
|
90
|
+
timeOut = `${Math.floor(dif / (60 * 60 * 24))} ${options.hash.data_only ? '' : chLang[3]}`;
|
|
91
|
+
break;
|
|
92
|
+
case 'week':
|
|
93
|
+
timeOut = `${Math.floor(dif / (60 * 60 * 24 * 7))} ${options.hash.data_only ? '' : chLang[4]}`;
|
|
94
|
+
break;
|
|
95
|
+
case 'month':
|
|
96
|
+
timeOut = `${Math.floor(dif / (60 * 60 * 24 * 30))} ${options.hash.data_only ? '' : chLang[5]}`;
|
|
97
|
+
break;
|
|
98
|
+
case 'year':
|
|
99
|
+
timeOut = `${Math.floor(dif / (60 * 60 * 24 * 365))} ${options.hash.data_only ? '' : chLang[6]}`;
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return timeOut;
|
|
106
|
+
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Повертає розмір файлу на диску у встановлених одиницях вимірювання об'єму файлу.
|
|
3
|
-
*
|
|
4
|
-
* @summary Повертає розмір растру у відповідних одиницях об'єму файлу (Тбайт, Гбайт, Мбайт)
|
|
5
|
-
* @priority 2
|
|
6
|
-
* @type helper
|
|
7
|
-
* @tag format
|
|
8
|
-
* @alias formatUnit
|
|
9
|
-
* @example
|
|
10
|
-
* {{formatUnit '123.45678' number="2"}}
|
|
11
|
-
* @param {data} data Число для перетворення
|
|
12
|
-
* @param {Number} number Число після точки
|
|
13
|
-
* @param {String} unit "В"
|
|
14
|
-
* @returns {String} Returns HTML
|
|
15
|
-
*/
|
|
16
|
-
export default function formatUnit(data, options) {
|
|
17
|
-
data = parseFloat(data);
|
|
18
|
-
if (isNaN(data)) return data;
|
|
19
|
-
|
|
20
|
-
const _UNIT = {
|
|
21
|
-
B: {
|
|
22
|
-
4: 'TB', 3: 'GB', 2: 'MB', 1: 'KB', 0: 'B',
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const unit = _UNIT[options.hash.unit] || _UNIT.B;
|
|
27
|
-
const number = options.hash.number || 0;
|
|
28
|
-
|
|
29
|
-
for (let i = 4; i >= 0; i -= 1) {
|
|
30
|
-
/* If i=0 then dataNew>0 - size in min units (17/03/20 by Olya) */
|
|
31
|
-
if (data >= (i ? (10 ** (3 * i)) : i)) {
|
|
32
|
-
return (data / (10 ** (3 * i)))
|
|
33
|
-
.toFixed(data % (10 ** (3 * i)) ? number : 0) + unit[i];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return data.toString();
|
|
38
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Повертає розмір файлу на диску у встановлених одиницях вимірювання об'єму файлу.
|
|
3
|
+
*
|
|
4
|
+
* @summary Повертає розмір растру у відповідних одиницях об'єму файлу (Тбайт, Гбайт, Мбайт)
|
|
5
|
+
* @priority 2
|
|
6
|
+
* @type helper
|
|
7
|
+
* @tag format
|
|
8
|
+
* @alias formatUnit
|
|
9
|
+
* @example
|
|
10
|
+
* {{formatUnit '123.45678' number="2"}}
|
|
11
|
+
* @param {data} data Число для перетворення
|
|
12
|
+
* @param {Number} number Число після точки
|
|
13
|
+
* @param {String} unit "В"
|
|
14
|
+
* @returns {String} Returns HTML
|
|
15
|
+
*/
|
|
16
|
+
export default function formatUnit(data, options) {
|
|
17
|
+
data = parseFloat(data);
|
|
18
|
+
if (isNaN(data)) return data;
|
|
19
|
+
|
|
20
|
+
const _UNIT = {
|
|
21
|
+
B: {
|
|
22
|
+
4: 'TB', 3: 'GB', 2: 'MB', 1: 'KB', 0: 'B',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const unit = _UNIT[options.hash.unit] || _UNIT.B;
|
|
27
|
+
const number = options.hash.number || 0;
|
|
28
|
+
|
|
29
|
+
for (let i = 4; i >= 0; i -= 1) {
|
|
30
|
+
/* If i=0 then dataNew>0 - size in min units (17/03/20 by Olya) */
|
|
31
|
+
if (data >= (i ? (10 ** (3 * i)) : i)) {
|
|
32
|
+
return (data / (10 ** (3 * i)))
|
|
33
|
+
.toFixed(data % (10 ** (3 * i)) ? number : 0) + unit[i];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return data.toString();
|
|
38
|
+
};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Приведення чисел до стандартизованого виду
|
|
3
|
-
*
|
|
4
|
-
* @summary Форматування у число. Є можливість використання разом із значком span
|
|
5
|
-
* @priority 4
|
|
6
|
-
* @type helper
|
|
7
|
-
* @tag format
|
|
8
|
-
* @alias numFormat
|
|
9
|
-
* @example
|
|
10
|
-
* {{{num_format (coalesce rows.[0].attr 123.456) dec="2"}}}
|
|
11
|
-
* @example
|
|
12
|
-
* {{num_format (coalesce price 1) fixed="4"}}
|
|
13
|
-
* @example
|
|
14
|
-
* {{{num_format (math_sum multilang attr="total" fixed=2)}}}
|
|
15
|
-
* @param {String|Number} data Число для форматування
|
|
16
|
-
* @param {Object} span False - перевірка чи повернути у вигляді html з тега span
|
|
17
|
-
* @returns {String} Returns HTML
|
|
18
|
-
*/
|
|
19
|
-
export default function numFormat(data, options) {
|
|
20
|
-
const TP = typeof data;
|
|
21
|
-
const { dec, fixed, span } = options.hash;
|
|
22
|
-
const charAfterZero = dec || fixed;
|
|
23
|
-
|
|
24
|
-
if (!data || (TP !== 'number' && TP !== 'string')) return '';
|
|
25
|
-
|
|
26
|
-
if (TP === 'string') {
|
|
27
|
-
data = parseFloat(data.replace(',', '.'));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (isNaN(data)) return '';
|
|
31
|
-
|
|
32
|
-
const num = (data)
|
|
33
|
-
.toFixed(charAfterZero || 2)
|
|
34
|
-
.replace(/(\d)(?=(\d{3})+\.)/g, '$1 ')
|
|
35
|
-
.split('.');
|
|
36
|
-
|
|
37
|
-
if (span) {
|
|
38
|
-
return num.map((el, i) => `<span class="part${i + 1}">${el}</span>`).join('.');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return num.join('.');
|
|
1
|
+
/**
|
|
2
|
+
* Приведення чисел до стандартизованого виду
|
|
3
|
+
*
|
|
4
|
+
* @summary Форматування у число. Є можливість використання разом із значком span
|
|
5
|
+
* @priority 4
|
|
6
|
+
* @type helper
|
|
7
|
+
* @tag format
|
|
8
|
+
* @alias numFormat
|
|
9
|
+
* @example
|
|
10
|
+
* {{{num_format (coalesce rows.[0].attr 123.456) dec="2"}}}
|
|
11
|
+
* @example
|
|
12
|
+
* {{num_format (coalesce price 1) fixed="4"}}
|
|
13
|
+
* @example
|
|
14
|
+
* {{{num_format (math_sum multilang attr="total" fixed=2)}}}
|
|
15
|
+
* @param {String|Number} data Число для форматування
|
|
16
|
+
* @param {Object} span False - перевірка чи повернути у вигляді html з тега span
|
|
17
|
+
* @returns {String} Returns HTML
|
|
18
|
+
*/
|
|
19
|
+
export default function numFormat(data, options) {
|
|
20
|
+
const TP = typeof data;
|
|
21
|
+
const { dec, fixed, span } = options.hash;
|
|
22
|
+
const charAfterZero = dec || fixed;
|
|
23
|
+
|
|
24
|
+
if (!data || (TP !== 'number' && TP !== 'string')) return '';
|
|
25
|
+
|
|
26
|
+
if (TP === 'string') {
|
|
27
|
+
data = parseFloat(data.replace(',', '.'));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (isNaN(data)) return '';
|
|
31
|
+
|
|
32
|
+
const num = (data)
|
|
33
|
+
.toFixed(charAfterZero || 2)
|
|
34
|
+
.replace(/(\d)(?=(\d{3})+\.)/g, '$1 ')
|
|
35
|
+
.split('.');
|
|
36
|
+
|
|
37
|
+
if (span) {
|
|
38
|
+
return num.map((el, i) => `<span class="part${i + 1}">${el}</span>`).join('.');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return num.join('.');
|
|
42
42
|
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Хелпер для виконання математичних операцій з числами
|
|
3
|
-
*
|
|
4
|
-
* @summary Дії над числами. Дозволяє виконання простих математичних операцій.
|
|
5
|
-
* @priority 3
|
|
6
|
-
* @type helper
|
|
7
|
-
* @tag math
|
|
8
|
-
* @alias _math
|
|
9
|
-
* @example
|
|
10
|
-
* {{_math operator='-' arg1=10 arg2=5}}
|
|
11
|
-
* @descr Отримання різниці між arg1 та arg2
|
|
12
|
-
* @example
|
|
13
|
-
* {{_math '1' '+' '1'}}
|
|
14
|
-
* @descr Виконання складання довжини масиву + 2
|
|
15
|
-
* @param {Object} operator Оператор для дії з числами
|
|
16
|
-
* @param {Object} arg1 Перше число для дії
|
|
17
|
-
* @param {Object} arg2 Друге число для дії
|
|
18
|
-
* @param {Array} args[0]] Перше число для дії
|
|
19
|
-
* @param {Array} args[1]] Оператор для дії з числами
|
|
20
|
-
* @param {Array} args[2]] Друге число для дії
|
|
21
|
-
* @returns {String} Returns HTML
|
|
22
|
-
*/
|
|
23
|
-
export default function _math(...args) {
|
|
24
|
-
const options = args.pop();
|
|
25
|
-
const opt = options.hash;
|
|
26
|
-
|
|
27
|
-
const operator = opt.operator ? opt.operator : args[1];
|
|
28
|
-
opt.arg1 = (opt.arg1 || args[0]) - 0;
|
|
29
|
-
opt.arg2 = (opt.arg2 || args[2]) - 0;
|
|
30
|
-
|
|
31
|
-
if (+opt.arg1 !== 0 && !opt.arg1) return '';
|
|
32
|
-
if (+opt.arg2 !== 0 && !opt.arg2) return '';
|
|
33
|
-
|
|
34
|
-
switch (operator) {
|
|
35
|
-
case '/':
|
|
36
|
-
return opt.arg1 / opt.arg2;
|
|
37
|
-
case '%':
|
|
38
|
-
return opt.arg1 % opt.arg2;
|
|
39
|
-
case '*':
|
|
40
|
-
return opt.arg1 * opt.arg2;
|
|
41
|
-
case '-':
|
|
42
|
-
return opt.arg1 - opt.arg2;
|
|
43
|
-
case '+':
|
|
44
|
-
return opt.arg1 + opt.arg2;
|
|
45
|
-
case '.%':
|
|
46
|
-
return `${((opt.arg1 * 100) / opt.arg2).toFixed(0)}%`;
|
|
47
|
-
default:
|
|
48
|
-
return 'operator is not defined';
|
|
49
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Хелпер для виконання математичних операцій з числами
|
|
3
|
+
*
|
|
4
|
+
* @summary Дії над числами. Дозволяє виконання простих математичних операцій.
|
|
5
|
+
* @priority 3
|
|
6
|
+
* @type helper
|
|
7
|
+
* @tag math
|
|
8
|
+
* @alias _math
|
|
9
|
+
* @example
|
|
10
|
+
* {{_math operator='-' arg1=10 arg2=5}}
|
|
11
|
+
* @descr Отримання різниці між arg1 та arg2
|
|
12
|
+
* @example
|
|
13
|
+
* {{_math '1' '+' '1'}}
|
|
14
|
+
* @descr Виконання складання довжини масиву + 2
|
|
15
|
+
* @param {Object} operator Оператор для дії з числами
|
|
16
|
+
* @param {Object} arg1 Перше число для дії
|
|
17
|
+
* @param {Object} arg2 Друге число для дії
|
|
18
|
+
* @param {Array} args[0]] Перше число для дії
|
|
19
|
+
* @param {Array} args[1]] Оператор для дії з числами
|
|
20
|
+
* @param {Array} args[2]] Друге число для дії
|
|
21
|
+
* @returns {String} Returns HTML
|
|
22
|
+
*/
|
|
23
|
+
export default function _math(...args) {
|
|
24
|
+
const options = args.pop();
|
|
25
|
+
const opt = options.hash;
|
|
26
|
+
|
|
27
|
+
const operator = opt.operator ? opt.operator : args[1];
|
|
28
|
+
opt.arg1 = (opt.arg1 || args[0]) - 0;
|
|
29
|
+
opt.arg2 = (opt.arg2 || args[2]) - 0;
|
|
30
|
+
|
|
31
|
+
if (+opt.arg1 !== 0 && !opt.arg1) return '';
|
|
32
|
+
if (+opt.arg2 !== 0 && !opt.arg2) return '';
|
|
33
|
+
|
|
34
|
+
switch (operator) {
|
|
35
|
+
case '/':
|
|
36
|
+
return opt.arg1 / opt.arg2;
|
|
37
|
+
case '%':
|
|
38
|
+
return opt.arg1 % opt.arg2;
|
|
39
|
+
case '*':
|
|
40
|
+
return opt.arg1 * opt.arg2;
|
|
41
|
+
case '-':
|
|
42
|
+
return opt.arg1 - opt.arg2;
|
|
43
|
+
case '+':
|
|
44
|
+
return opt.arg1 + opt.arg2;
|
|
45
|
+
case '.%':
|
|
46
|
+
return `${((opt.arg1 * 100) / opt.arg2).toFixed(0)}%`;
|
|
47
|
+
default:
|
|
48
|
+
return 'operator is not defined';
|
|
49
|
+
}
|
|
50
50
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Повертає пустий рядок замість змісту іншого хелпера при компіляції шаблону (сторінки). Пишеться на початку хелпера та дозволяє ігнорувати подальший зміст. Аналогічно коментуванню ділянок коду лапками, проте не погіршує зовнішній вигляд коду
|
|
3
|
-
*
|
|
4
|
-
* @summary Повертає пустий рядок замість змісту іншого хелпера при компіляції шаблону.
|
|
5
|
-
* @priority 4
|
|
6
|
-
* @alias empty
|
|
7
|
-
* @type helper
|
|
8
|
-
* @tag condition
|
|
9
|
-
* @example
|
|
10
|
-
* {{{empty widget.widget_adverts}}}
|
|
11
|
-
* @example
|
|
12
|
-
* {{{empty _hb template="change-password-email-template"}}}
|
|
13
|
-
* @example
|
|
14
|
-
* {{empty formatDate bt_on_work_date format="dd.MM.yy / hh:mi:sec"}}
|
|
15
|
-
* @example
|
|
16
|
-
* {{{empty mls 'alertinfo'}}}
|
|
17
|
-
* @returns {String} Returns HTML
|
|
18
|
-
*/
|
|
19
|
-
export default function empty() {
|
|
20
|
-
return '';
|
|
21
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Повертає пустий рядок замість змісту іншого хелпера при компіляції шаблону (сторінки). Пишеться на початку хелпера та дозволяє ігнорувати подальший зміст. Аналогічно коментуванню ділянок коду лапками, проте не погіршує зовнішній вигляд коду
|
|
3
|
+
*
|
|
4
|
+
* @summary Повертає пустий рядок замість змісту іншого хелпера при компіляції шаблону.
|
|
5
|
+
* @priority 4
|
|
6
|
+
* @alias empty
|
|
7
|
+
* @type helper
|
|
8
|
+
* @tag condition
|
|
9
|
+
* @example
|
|
10
|
+
* {{{empty widget.widget_adverts}}}
|
|
11
|
+
* @example
|
|
12
|
+
* {{{empty _hb template="change-password-email-template"}}}
|
|
13
|
+
* @example
|
|
14
|
+
* {{empty formatDate bt_on_work_date format="dd.MM.yy / hh:mi:sec"}}
|
|
15
|
+
* @example
|
|
16
|
+
* {{{empty mls 'alertinfo'}}}
|
|
17
|
+
* @returns {String} Returns HTML
|
|
18
|
+
*/
|
|
19
|
+
export default function empty() {
|
|
20
|
+
return '';
|
|
21
|
+
};
|