Skip to content

Commit 788907e

Browse files
committed
add time restirction for updater
1 parent ad95ce9 commit 788907e

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed

l10n/customDataTypeIconclass.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ custom.data.type.iconclass.modal.form.popup.choose,Eintrag aus dem iconclass-Bau
3232
custom.data.type.iconclass.modal.form.popup.treeviewreset,Baum zurücksetzen,Reset tree
3333
custom.data.type.iconclass.modal.form.popup.add_choose,Eintrag wählen,Choose entry
3434
custom.data.type.iconclass.modal.form.popup.loadingstringtreeview,Lade Baumansicht,loading treeview
35-
server.config.name.system.update_interval_iconclass,iconclass-Update-Einstellungen,iconclass-Update-Configuration
36-
server.config.parameter.system.update_interval_iconclass.days.label,"Tage zwischen Updates. Hinweis: Das Update sollte nicht automatisch aktiviert werden, sondern nur in bestimmten Fällen manuell gestartet werden.",Days between updates
37-
server.config.parameter.system.update_interval_iconclass.default_language.label,Standard-Datensprache als Fallback (ISO 639-1),Default-data-language as fallback (ISO 639-1)
35+
server.config.name.system.update_iconclass,iconclass-Update-Einstellungen,iconclass-Update-Configuration
36+
server.config.parameter.system.update_iconclass.days.label,"Tage zwischen Updates. Hinweis: Das Update sollte nicht automatisch aktiviert werden, sondern nur in bestimmten Fällen manuell gestartet werden.",Days between updates
37+
server.config.parameter.system.update_iconclass.default_language.label,Standard-Datensprache als Fallback (ISO 639-1),Default-data-language as fallback (ISO 639-1)
3838
custom.data.type.iconclass.modal.form.popup.brackets.choose,Wähle einen Wert für die Klammern um fortzufahren,choose a value for the brackets to continue
3939
custom.data.type.iconclass.modal.form.popup.brackets.select,Ausgewählt:,Selected:
4040
server.config.group.system.plugin_custom-data-type-iconclass.title,ICONCLASS,ICONCLASS

manifest.master.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,30 @@ custom_types:
5656
timeout: 60
5757
batch_size: 1
5858
expires_days: 1
59-
interval_base_config: update_interval_iconclass.days
6059

6160

6261
base_config:
63-
- name: update_interval_iconclass
62+
- name: update_iconclass
6463
group: update_custom_data_type
6564
parameters:
66-
days:
65+
restrict_time:
66+
type: bool
67+
default: false
68+
position: 0
69+
from_time:
6770
type: int
71+
default: 19
6872
min: 0
69-
default: 0
70-
position: 0
73+
max: 24
74+
position: 1
75+
to_time:
76+
type: int
77+
default: 4
78+
min: 0
79+
max: 24
80+
position: 2
7181
default_language:
7282
type: text
7383
default: 'de'
74-
position: 1
84+
position: 3
7585

src/updater/iconclassUpdater.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,29 @@ outputErr = (err2) => {
265265

266266
process.stdin.setEncoding('utf8');
267267

268+
////////////////////////////////////////////////////////////////////////////
269+
// check if hour-restriction is set
270+
////////////////////////////////////////////////////////////////////////////
271+
272+
if (info?.config?.plugin?.['custom-data-type-iconclass']?.config?.update_iconclass?.restrict_time === true) {
273+
iconclass_config = info.config.plugin['custom-data-type-iconclass'].config.update_iconclass;
274+
// check if hours are configured
275+
if (iconclass_config?.from_time !== false && iconclass_config?.to_time !== false) {
276+
const now = new Date();
277+
const hour = now.getHours();
278+
// check if hours do not match
279+
if (hour < iconclass_config.from_time && hour >= iconclass_config.to_time) {
280+
// exit if hours do not match
281+
outputData({
282+
"state": {
283+
"theend": 2,
284+
"log": ["hours do not match, cancel update"]
285+
}
286+
});
287+
}
288+
}
289+
}
290+
268291
access_token = info && info.plugin_user_access_token;
269292

270293
if (access_token) {
@@ -281,7 +304,7 @@ outputErr = (err2) => {
281304

282305
frontendLanguages = config.system.config.languages.frontend;
283306

284-
const testDefaultLanguageConfig = config.plugin['custom-data-type-iconclass'].config.update_interval_iconclass.default_language;
307+
const testDefaultLanguageConfig = config.plugin['custom-data-type-iconclass'].config.update_iconclass.default_language;
285308
if (testDefaultLanguageConfig) {
286309
if (testDefaultLanguageConfig.length == 2) {
287310
defaultLanguage = testDefaultLanguageConfig;

0 commit comments

Comments
 (0)