@goodandready/dsh-cron 0.1.3 → 0.1.4
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/lib/client.js +61 -16
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -90,6 +90,11 @@ window.__ModuleLoader__.load({
|
|
|
90
90
|
.dsh-cron-modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
|
|
91
91
|
.dsh-cron-btn-primary { background: #ededed; color: #111; border: none; border-radius: 8px; padding: 7px 16px; font-size: 13.5px; font-weight: 500; cursor: pointer; }
|
|
92
92
|
.dsh-cron-btn-secondary { background: transparent; color: #999; border: 1px solid #383838; border-radius: 8px; padding: 7px 16px; font-size: 13.5px; cursor: pointer; }
|
|
93
|
+
|
|
94
|
+
.dsh-cron-card { background: var(--dsw-alias-bg-layer-2, #1f1f1f); border: 1px solid var(--dsw-alias-border-l1, #333); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
|
|
95
|
+
.dsh-cron-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
|
|
96
|
+
.dsh-cron-card-title { font-size: 15px; font-weight: 600; color: var(--dsw-alias-label-primary, #fff); }
|
|
97
|
+
.dsh-cron-card-desc { font-size: 13px; color: var(--dsw-alias-label-secondary, #888); margin-bottom: 16px; line-height: 1.4; }
|
|
93
98
|
`;
|
|
94
99
|
|
|
95
100
|
function ensureStyles() {
|
|
@@ -376,22 +381,27 @@ window.__ModuleLoader__.load({
|
|
|
376
381
|
);
|
|
377
382
|
}
|
|
378
383
|
|
|
384
|
+
function CronSettingsCard(props) {
|
|
385
|
+
const { ctx, toggle } = props;
|
|
386
|
+
return React.createElement('div', { className: 'dsh-cron-card' },
|
|
387
|
+
React.createElement('div', { className: 'dsh-cron-card-head' },
|
|
388
|
+
React.createElement('span', { className: 'dsh-cron-card-title' }, '⏰ Планировщик задач (Cron)'),
|
|
389
|
+
React.createElement('button', {
|
|
390
|
+
type: 'button',
|
|
391
|
+
className: 'dsh-cron-btn-primary',
|
|
392
|
+
onClick: () => { if (toggle) toggle.set(true); }
|
|
393
|
+
}, 'Открыть запланированные задачи')
|
|
394
|
+
),
|
|
395
|
+
React.createElement('div', { className: 'dsh-cron-card-desc' },
|
|
396
|
+
'Автоматическое выполнение задач в фоновом режиме по заданному расписанию (cron/интервалы), отслеживание логов и интеграция с чатом через команду /cron.'
|
|
397
|
+
)
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
|
|
379
401
|
function nativeButton() {
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
'
|
|
383
|
-
'[class*="sidebar"] button[class*="sidebar-entry"]',
|
|
384
|
-
'nav button',
|
|
385
|
-
'aside button',
|
|
386
|
-
'[class*="sidebar"] button'
|
|
387
|
-
];
|
|
388
|
-
for (const sel of candidates) {
|
|
389
|
-
const found = document.querySelectorAll(sel);
|
|
390
|
-
for (const el of found) {
|
|
391
|
-
if (el.hasAttribute(ENTRY_ATTR)) continue;
|
|
392
|
-
if (el.dataset && el.dataset.dshPart === 'sidebar-entry') continue;
|
|
393
|
-
if (el.offsetWidth > 0 || el.offsetHeight > 0) return el;
|
|
394
|
-
}
|
|
402
|
+
const nodes = document.querySelectorAll('button[class*="newSession"]');
|
|
403
|
+
for (const node of nodes) {
|
|
404
|
+
if (String(node.className).indexOf('newSessionLabel') === -1) return node;
|
|
395
405
|
}
|
|
396
406
|
return undefined;
|
|
397
407
|
}
|
|
@@ -428,7 +438,7 @@ window.__ModuleLoader__.load({
|
|
|
428
438
|
let anchor = target;
|
|
429
439
|
let next = target.nextElementSibling;
|
|
430
440
|
while (next !== null && next.tagName === 'BUTTON'
|
|
431
|
-
&&
|
|
441
|
+
&& String(next.className).indexOf('sidebar-entry') >= 0) {
|
|
432
442
|
anchor = next;
|
|
433
443
|
next = next.nextElementSibling;
|
|
434
444
|
}
|
|
@@ -523,9 +533,42 @@ window.__ModuleLoader__.load({
|
|
|
523
533
|
};
|
|
524
534
|
}
|
|
525
535
|
|
|
536
|
+
function registerFirst(ctx, candidates, component) {
|
|
537
|
+
if (!ctx || !ctx.slots) return undefined;
|
|
538
|
+
for (const entry of candidates) {
|
|
539
|
+
try {
|
|
540
|
+
let ok = false;
|
|
541
|
+
ctx.slots.inject(entry.name, () => {
|
|
542
|
+
ctx.slots.register(entry, component);
|
|
543
|
+
ok = true;
|
|
544
|
+
});
|
|
545
|
+
if (ok) return entry.name;
|
|
546
|
+
} catch (e) {}
|
|
547
|
+
}
|
|
548
|
+
return undefined;
|
|
549
|
+
}
|
|
550
|
+
|
|
526
551
|
function apply(ctx) {
|
|
527
552
|
ensureStyles();
|
|
528
553
|
const toggle = createToggle();
|
|
554
|
+
|
|
555
|
+
// Карточка в Настройках -> Плагины
|
|
556
|
+
const cardSlot = registerFirst(ctx, [
|
|
557
|
+
{ name: 'settings.plugin.item', key: NS, inject: () => ({ ctx, toggle }) },
|
|
558
|
+
{ name: 'settings.section', id: '@goodandready/dsh-cron', order: 34, label: () => 'Cron Задачи', inject: () => ({ ctx, toggle }) }
|
|
559
|
+
], CronSettingsCard);
|
|
560
|
+
|
|
561
|
+
// Чип в шапке диалога
|
|
562
|
+
const chipSlot = registerFirst(ctx, [
|
|
563
|
+
{ name: 'conversation.session.header.utilities', id: '@goodandready/dsh-cron.chip', order: 27, inject: () => ({ ctx, toggle }) }
|
|
564
|
+
], () => React.createElement('button', {
|
|
565
|
+
type: 'button',
|
|
566
|
+
style: { background: 'none', border: 'none', color: 'var(--dsw-alias-label-secondary, #999)', cursor: 'pointer', padding: '4px', display: 'inline-flex', alignItems: 'center' },
|
|
567
|
+
title: 'Запланированные задачи (Cron)',
|
|
568
|
+
onClick: () => toggle.toggle(),
|
|
569
|
+
dangerouslySetInnerHTML: { __html: ICON_TIMER }
|
|
570
|
+
}));
|
|
571
|
+
|
|
529
572
|
ctx.effect(() => {
|
|
530
573
|
const off = [
|
|
531
574
|
mountSidebarEntry(toggle, 'Запланированные задачи'),
|
|
@@ -533,6 +576,8 @@ window.__ModuleLoader__.load({
|
|
|
533
576
|
];
|
|
534
577
|
return () => { for (const dispose of off) dispose(); };
|
|
535
578
|
}, 'dsh-cron: client overlay');
|
|
579
|
+
|
|
580
|
+
exports.slots = { card: cardSlot, chip: chipSlot };
|
|
536
581
|
}
|
|
537
582
|
|
|
538
583
|
module.exports = { apply, inject: ['slots', 'locale', 'settingsScope'] };
|