-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazureupdates.html
More file actions
692 lines (641 loc) · 32.3 KB
/
Copy pathazureupdates.html
File metadata and controls
692 lines (641 loc) · 32.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Azure Updates – Microsoft Communications Portal</title>
<script>
(() => {
const param = new URLSearchParams(window.location.search).get("clawpilotTheme");
const theme = param || (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
document.documentElement.setAttribute("data-theme", theme);
})();
</script>
<script src="/static/util.js" defer></script>
<link rel="stylesheet" href="/static/common.css">
<link rel="stylesheet" href="/static/roadmap.css">
</head>
<body>
<script src="/static/nav.js" defer></script>
<div class="page-content">
<h1 class="page-heading">Azure Roadmap</h1>
<div class="au-search-bar">
<label for="au-search" class="sr-only">Search updates by title or description</label>
<input type="text" class="au-search-input" id="au-search"
placeholder="Search updates by title or description…"
aria-label="Search updates by title or description" data-act="debouncedSearch" data-on="input">
</div>
<div class="au-filters">
<div class="au-filter-group">
<label class="au-filter-label" id="au-status-filter-label">Status:</label>
<div class="au-multi" id="au-status-multi">
<button type="button" class="au-multi-toggle" aria-haspopup="true" aria-expanded="false" aria-labelledby="au-status-filter-label au-status-label" data-act="toggleMenu" data-menu="au-status-multi">
<span id="au-status-label">All Statuses</span>
<span class="au-multi-caret" aria-hidden="true">▾</span>
</button>
<div class="au-multi-panel" id="au-status-panel">
<div class="au-multi-actions">
<button type="button" data-act="setAllOptions" data-kind="status" data-checked="1">Select all</button>
<button type="button" data-act="setAllOptions" data-kind="status" data-checked="0">Clear</button>
</div>
<div id="au-status-options"></div>
</div>
</div>
</div>
<div class="au-filter-group">
<label class="au-filter-label" id="au-product-filter-label">Product:</label>
<div class="au-multi" id="au-product-multi">
<button type="button" class="au-multi-toggle" aria-haspopup="true" aria-expanded="false" aria-labelledby="au-product-filter-label au-product-label" data-act="toggleMenu" data-menu="au-product-multi">
<span id="au-product-label">All Products</span>
<span class="au-multi-caret" aria-hidden="true">▾</span>
</button>
<div class="au-multi-panel" id="au-product-panel">
<div class="au-multi-actions">
<button type="button" data-act="setAllOptions" data-kind="product" data-checked="1">Select all</button>
<button type="button" data-act="setAllOptions" data-kind="product" data-checked="0">Clear</button>
</div>
<div id="au-product-options"></div>
</div>
</div>
</div>
<div class="au-filter-group">
<label class="au-filter-label" for="au-sort">Sort:</label>
<select class="au-filter-select" id="au-sort" data-act="filterUpdates" data-on="change">
<option value="date-desc">Newest First</option>
<option value="date-asc">Oldest First</option>
<option value="product">Group by Product</option>
</select>
<label class="au-filter-label" for="au-expand-all" id="au-expand-all-label" style="display:none;align-items:center;gap:0.4rem;cursor:pointer">
<input type="checkbox" id="au-expand-all" data-act="toggleExpandAll" data-on="change">
Expand all
</label>
</div>
<div class="au-filter-group" style="margin-left:auto;gap:0.75rem">
<span id="au-result-count" style="font-size:12px;color:var(--cp-text-muted)"></span>
<button class="export-btn" id="au-export-btn" type="button" data-act="openExportModal">⬇ Export</button>
<button class="export-btn" data-act="loadAzureUpdates">↻ Refresh</button>
</div>
</div>
<div class="au-cards" id="au-cards-container">
<div class="au-loading" role="status" aria-live="polite">
<div class="spinner" aria-hidden="true"></div>
<span>Loading Azure Updates…</span>
</div>
</div>
</div>
<div class="au-modal-overlay" id="au-modal" data-act="handleModalBackdrop">
<div class="au-modal" role="dialog" aria-modal="true" aria-labelledby="au-modal-title">
<div class="au-modal-header">
<div>
<div class="au-modal-title" id="au-modal-title"></div>
<div class="au-modal-meta" id="au-modal-meta"></div>
</div>
<button class="au-modal-close" data-act="closeUpdate" aria-label="Close">×</button>
</div>
<div class="au-modal-body" id="au-modal-body"></div>
</div>
</div>
<script>
let allUpdates = [];
let currentFiltered = [];
const statusFilter = new Set();
const productFilter = new Set();
// Register delegated actions that need arguments carried on data-* attributes.
// (Argument-less handlers resolve automatically to same-named global functions.)
if (window.CPActions) window.CPActions.register({
toggleMenu: (e, el) => toggleMenu(el.dataset.menu),
setAllOptions: (e, el) => setAllOptions(el.dataset.kind, el.dataset.checked === '1'),
toggleProductGroup: (e, el) => toggleProductGroup(el),
openUpdate: (e, el) => openUpdate(el.dataset.id),
selectAllExportProducts: (e, el) => selectAllExportProducts(el.dataset.state === '1'),
applyExportPreset7: () => applyExportPreset(7),
applyExportPreset30: () => applyExportPreset(30),
applyExportPreset60: () => applyExportPreset(60),
});
// Azure RSS uses these category values for status / type signalling.
// Anything else (Compute, Storage, Databases, Networking, AI + machine learning, …)
// is treated as a product/area bucket.
const STATUS_KEYWORDS = ['In development', 'In preview', 'Launched', 'Retirements'];
const RELEASE_KEYWORDS = ['Generally Available', 'Public Preview', 'Private Preview', 'Preview'];
// Generic noise categories from Azure RSS that aren't useful as products.
const IGNORED_PRODUCT_CATEGORIES = new Set(['Features', 'Feature', 'Services', 'Service']);
// toggleTheme() and escapeHtml() are provided by /static/util.js.
function classifyCategories(cats) {
const c = Array.isArray(cats) ? cats : [];
const out = { status: '', release: [], product: [] };
for (const raw of c) {
const cat = (raw || '').trim();
if (!cat) continue;
if (!out.status && STATUS_KEYWORDS.includes(cat)) { out.status = cat; continue; }
if (RELEASE_KEYWORDS.includes(cat)) { out.release.push(cat); continue; }
if (IGNORED_PRODUCT_CATEGORIES.has(cat)) continue;
out.product.push(cat);
}
return out;
}
function statusClass(status) {
const s = (status || '').toLowerCase();
if (s.includes('development')) return 'development';
if (s.includes('preview')) return 'preview';
if (s.includes('rolling')) return 'rolling';
if (s.includes('launched')) return 'launched';
if (s.includes('retire')) return 'retirement';
if (s.includes('cancel')) return 'cancelled';
return 'unknown';
}
function stripHtml(html) {
return window.CPUtil ? window.CPUtil.stripHtml(html) : '';
}
function safeUrl(value) {
if (!value) return '#';
const trimmed = String(value).trim();
if (/^[a-z][a-z0-9+.-]*:/i.test(trimmed)) {
if (!/^(https?|mailto|tel):/i.test(trimmed)) return '#';
}
return trimmed;
}
function descriptionHtml(html) {
// The RSS description is untrusted HTML; delegate to the shared hardened
// allow-list sanitizer in /static/util.js.
if (!html) return '';
return (window.CPUtil && window.CPUtil.sanitizeHtml) ? window.CPUtil.sanitizeHtml(html) : '';
}
function formatDate(s) {
if (!s) return '';
const d = new Date(s);
if (isNaN(d.getTime())) return s;
return d.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
}
async function loadAzureUpdates() {
const container = document.getElementById('au-cards-container');
container.innerHTML = '<div class="au-loading" role="status" aria-live="polite"><div class="spinner" aria-hidden="true"></div><span>Loading Azure Updates…</span></div>';
try {
const res = await fetch('/api/azureupdates');
const data = await res.json();
if (data.error && (!data.items || !data.items.length)) {
container.innerHTML = `<div class="au-empty">⚠️ ${escapeHtml(data.error)}</div>`;
return;
}
allUpdates = (data.items || []).map(item => {
const buckets = classifyCategories(item.categories);
return { ...item, buckets };
});
rebuildFilters();
filterUpdates();
} catch (err) {
container.innerHTML = `<div class="au-empty">❌ Failed to load: ${escapeHtml(err.message)}</div>`;
}
}
function rebuildFilters() {
const statuses = new Set();
const products = new Set();
allUpdates.forEach(u => {
if (u.buckets.status) statuses.add(u.buckets.status);
u.buckets.product.forEach(p => products.add(p));
});
// Preserve existing selections; only add new options.
const sortedStatuses = STATUS_KEYWORDS.filter(s => statuses.has(s))
.concat([...statuses].filter(s => !STATUS_KEYWORDS.includes(s)).sort());
const sortedProducts = [...products].sort((a, b) => a.localeCompare(b));
renderMultiOptions('au-status-options', sortedStatuses, statusFilter, 'status');
renderMultiOptions('au-product-options', sortedProducts, productFilter, 'product');
updateMultiLabel('status', sortedStatuses, 'Statuses');
updateMultiLabel('product', sortedProducts, 'Products');
}
function renderMultiOptions(containerId, values, selectedSet, kind) {
const c = document.getElementById(containerId);
c.innerHTML = values.map(v => `
<label class="au-multi-option">
<input type="checkbox" data-kind="${kind}" data-value="${escapeHtml(v)}"
${selectedSet.has(v) ? 'checked' : ''}
data-act="onMultiChange" data-on="change">
<span>${escapeHtml(v)}</span>
</label>`).join('');
}
function onMultiChange(ev) {
const kind = ev.target.dataset.kind;
const value = ev.target.dataset.value;
const set = kind === 'status' ? statusFilter : productFilter;
if (ev.target.checked) set.add(value); else set.delete(value);
const allKnown = kind === 'status'
? Array.from(document.querySelectorAll('#au-status-options input')).map(i => i.dataset.value)
: Array.from(document.querySelectorAll('#au-product-options input')).map(i => i.dataset.value);
updateMultiLabel(kind, allKnown, kind === 'status' ? 'Statuses' : 'Products');
filterUpdates();
}
function setAllOptions(kind, checked) {
const set = kind === 'status' ? statusFilter : productFilter;
const inputs = kind === 'status'
? document.querySelectorAll('#au-status-options input')
: document.querySelectorAll('#au-product-options input');
inputs.forEach(i => {
i.checked = checked;
if (checked) set.add(i.dataset.value); else set.delete(i.dataset.value);
});
const allKnown = Array.from(inputs).map(i => i.dataset.value);
updateMultiLabel(kind, allKnown, kind === 'status' ? 'Statuses' : 'Products');
filterUpdates();
}
function updateMultiLabel(kind, allValues, plural) {
const labelEl = document.getElementById(`au-${kind}-label`);
const set = kind === 'status' ? statusFilter : productFilter;
const total = allValues.length;
const sel = [...set].filter(v => allValues.includes(v));
if (sel.length === 0 || sel.length === total) labelEl.textContent = `All ${plural}`;
else if (sel.length === 1) labelEl.textContent = sel[0];
else labelEl.textContent = `${sel.length} ${plural}`;
}
function toggleMenu(id) {
document.querySelectorAll('.au-multi.open').forEach(el => {
if (el.id !== id) {
el.classList.remove('open');
const t = el.querySelector('.au-multi-toggle');
if (t) t.setAttribute('aria-expanded', 'false');
}
});
const wrap = document.getElementById(id);
const isOpen = wrap.classList.toggle('open');
const toggle = wrap.querySelector('.au-multi-toggle');
if (toggle) toggle.setAttribute('aria-expanded', String(isOpen));
}
document.addEventListener('click', (e) => {
if (e.target.closest && e.target.closest('.au-multi')) return;
document.querySelectorAll('.au-multi.open').forEach(el => {
el.classList.remove('open');
const t = el.querySelector('.au-multi-toggle');
if (t) t.setAttribute('aria-expanded', 'false');
});
});
let __searchTimer = null;
function debouncedSearch() {
clearTimeout(__searchTimer);
__searchTimer = setTimeout(filterUpdates, 150);
}
function filterUpdates() {
const q = (document.getElementById('au-search').value || '').toLowerCase().trim();
const sort = document.getElementById('au-sort').value;
const allKnownStatuses = Array.from(document.querySelectorAll('#au-status-options input')).map(i => i.dataset.value);
const allKnownProducts = Array.from(document.querySelectorAll('#au-product-options input')).map(i => i.dataset.value);
const statusActive = statusFilter.size > 0 && statusFilter.size < allKnownStatuses.length;
const productActive = productFilter.size > 0 && productFilter.size < allKnownProducts.length;
let filtered = allUpdates.filter(u => {
if (statusActive && !statusFilter.has(u.buckets.status)) return false;
if (productActive && !u.buckets.product.some(p => productFilter.has(p))) return false;
if (q) {
const hay = (u.title + ' ' + stripHtml(u.description)).toLowerCase();
if (!hay.includes(q)) return false;
}
return true;
});
filtered.sort((a, b) => {
const da = new Date(a.pubDate).getTime() || 0;
const db = new Date(b.pubDate).getTime() || 0;
return sort === 'date-asc' ? da - db : db - da;
});
currentFiltered = filtered;
document.getElementById('au-result-count').textContent =
`${filtered.length} of ${allUpdates.length}`;
const groupByProduct = sort === 'product';
document.getElementById('au-expand-all-label').style.display = groupByProduct ? 'flex' : 'none';
if (groupByProduct) renderGrouped(filtered);
else renderFlat(filtered);
}
function renderFlat(items) {
const grid = document.getElementById('au-cards-container');
grid.classList.remove('is-grouped');
if (!items.length) { grid.innerHTML = '<div class="au-empty">No updates match the filter.</div>'; return; }
grid.innerHTML = items.map(cardHtml).join('');
}
function renderGrouped(items) {
const grid = document.getElementById('au-cards-container');
grid.classList.add('is-grouped');
if (!items.length) { grid.innerHTML = '<div class="au-empty">No updates match the filter.</div>'; return; }
const expandAll = !!document.getElementById('au-expand-all').checked;
const groups = new Map();
items.forEach(u => {
const key = (u.buckets.product[0] || 'Other').trim();
if (!groups.has(key)) groups.set(key, []);
groups.get(key).push(u);
});
const sortedKeys = [...groups.keys()].sort((a, b) => a.localeCompare(b));
const chevron = '<svg class="au-product-chevron" viewBox="0 0 12 12" aria-hidden="true" focusable="false"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';
grid.innerHTML = sortedKeys.map(key => {
const list = groups.get(key);
const collapsedClass = expandAll ? '' : ' is-collapsed';
return `
<div class="au-product-group${collapsedClass}">
<div class="au-product-header" role="button" tabindex="0" aria-expanded="${expandAll ? 'true' : 'false'}" data-act="toggleProductGroup">
${chevron}
<span>${escapeHtml(key)}</span>
<span class="au-product-count">${list.length} update${list.length !== 1 ? 's' : ''}</span>
</div>
<div class="au-product-cards">
${list.map(cardHtml).join('')}
</div>
</div>`;
}).join('');
}
function toggleProductGroup(header) {
const group = header.closest('.au-product-group');
if (!group) return;
const collapsed = group.classList.toggle('is-collapsed');
header.setAttribute('aria-expanded', String(!collapsed));
syncExpandAllCheckbox();
}
function toggleExpandAll() {
const expand = !!document.getElementById('au-expand-all').checked;
document.querySelectorAll('.au-product-group').forEach(g => {
g.classList.toggle('is-collapsed', !expand);
const h = g.querySelector('.au-product-header');
if (h) h.setAttribute('aria-expanded', String(expand));
});
}
function syncExpandAllCheckbox() {
const cb = document.getElementById('au-expand-all');
const groups = document.querySelectorAll('.au-product-group');
if (!groups.length) { cb.checked = false; cb.indeterminate = false; return; }
let expanded = 0;
groups.forEach(g => { if (!g.classList.contains('is-collapsed')) expanded++; });
cb.checked = expanded === groups.length;
cb.indeterminate = expanded > 0 && expanded < groups.length;
}
function cardHtml(u) {
const sc = statusClass(u.buckets.status);
const product = u.buckets.product[0] || '';
const release = u.buckets.release[0] || '';
const date = formatDate(u.pubDate);
const snippet = stripHtml(u.description).slice(0, 220);
return `
<div class="au-card" data-act="openUpdate" data-id="${escapeHtml(u.id)}">
<div class="au-card-body">
<div class="au-card-top">
<span class="au-card-id">#${escapeHtml(u.id || '')}</span>
<span class="au-status-pill ${sc}">${escapeHtml(u.buckets.status || 'Unknown')}</span>
</div>
${product ? `
<div class="au-card-product">
${(window.ProductIcons && window.ProductIcons.getProductIcon(product))
? window.ProductIcons.productIconImg(product)
: '<span class="au-card-product-dot"></span>'}
<span>${escapeHtml(product)}</span>
</div>` : ''}
<div class="au-card-title">${escapeHtml(u.title || 'Untitled update')}</div>
${snippet ? `<div class="au-card-snippet">${escapeHtml(snippet)}</div>` : ''}
<div class="au-card-meta">
${release ? `<span class="au-tag-pill release">${escapeHtml(release)}</span>` : ''}
${date ? `<span>${escapeHtml(date)}</span>` : ''}
</div>
</div>
</div>`;
}
function openUpdate(id) {
const u = allUpdates.find(x => String(x.id) === String(id));
if (!u) return;
document.getElementById('au-modal-title').textContent = u.title || 'Update';
const metaParts = [];
if (u.buckets.status) metaParts.push(u.buckets.status);
if (u.pubDate) metaParts.push(`Published ${formatDate(u.pubDate)}`);
if (u.id) metaParts.push(`ID ${u.id}`);
document.getElementById('au-modal-meta').textContent = metaParts.join(' · ');
const body = document.getElementById('au-modal-body');
const tagSection = (label, list) => list && list.length
? `
<div class="au-modal-section">
<div class="au-modal-section-title">${label}</div>
<div class="au-tag-list">${list.map(v => `<span class="au-tag-pill">${escapeHtml(v)}</span>`).join('')}</div>
</div>` : '';
body.innerHTML = `
<div class="au-modal-section">
<div class="au-modal-section-title">Description</div>
<div>${descriptionHtml(u.description)}</div>
</div>
${tagSection('Products / area', u.buckets.product)}
${tagSection('Release type', u.buckets.release)}
${u.link ? `
<div class="au-modal-section">
<div class="au-modal-section-title">Reference</div>
<p><a href="${escapeHtml(safeUrl(u.link))}" target="_blank" rel="noopener noreferrer">View on Azure updates →</a></p>
</div>` : ''}
`;
document.getElementById('au-modal').classList.add('open');
if (window.CportalAi && window.CportalAi.isEnabled()) {
window.CportalAi.attachToModal(body, 'azure', u);
}
}
function closeUpdate() {
document.getElementById('au-modal').classList.remove('open');
}
function handleModalBackdrop(ev) {
if (ev.target.id === 'au-modal') closeUpdate();
}
document.addEventListener('keydown', (ev) => {
if (ev.key === 'Escape') closeUpdate();
});
// ════════════════════════════════════════════════
// GENERATE EXPORT MODAL
// ════════════════════════════════════════════════
const EXPORT_MODAL_CONFIG = {
getAllRows: () => allUpdates || [],
getProducts: (u) => (u && u.buckets && u.buckets.product) || [],
getDate: (u) => { const d = Date.parse(u && u.pubDate || ''); return isNaN(d) ? null : d; },
runExport: (rows, format) => exportAzureUpdatesToHtml(rows, format),
};
const EXPORT_UNCLASSIFIED = '(Unclassified)';
function getExportProducts(row) {
const arr = (EXPORT_MODAL_CONFIG.getProducts(row) || []).map(p => String(p || '').trim()).filter(Boolean);
return arr.length ? arr : [EXPORT_UNCLASSIFIED];
}
function openExportModal() {
const rows = EXPORT_MODAL_CONFIG.getAllRows() || [];
if (!rows.length) { alert('Data is still loading. Please try again in a moment.'); return; }
const set = new Set();
rows.forEach(r => getExportProducts(r).forEach(p => set.add(p)));
const products = Array.from(set).sort((a, b) => {
if (a === EXPORT_UNCLASSIFIED) return 1;
if (b === EXPORT_UNCLASSIFIED) return -1;
return a.localeCompare(b);
});
const list = document.getElementById('gen-product-list');
if (!products.length) {
list.innerHTML = '<div class="gen-empty">No products found.</div>';
} else {
list.innerHTML = products.map(p => {
const safe = p.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
return `<label data-product="${safe.toLowerCase()}"><input type="checkbox" value="${safe}" checked data-act="updateExportCount" data-on="change"> ${safe}</label>`;
}).join('');
}
document.getElementById('gen-from-date').value = '';
document.getElementById('gen-to-date').value = '';
document.getElementById('gen-product-search').value = '';
filterExportProductSearch();
updateExportCount();
document.getElementById('gen-modal').hidden = false;
if (window.trapFocus) trapFocus(document.getElementById('gen-modal'));
}
function closeExportModal() { if (window.releaseFocus) releaseFocus(); const el = document.getElementById('gen-modal'); if (el) el.hidden = true; }
function selectAllExportProducts(state) {
document.querySelectorAll('#gen-product-list input[type="checkbox"]').forEach(cb => {
const label = cb.closest('label');
if (!label || label.style.display !== 'none') cb.checked = state;
});
updateExportCount();
}
function clearExportDates() {
document.getElementById('gen-from-date').value = '';
document.getElementById('gen-to-date').value = '';
updateExportCount();
}
function applyExportPreset(days) {
const now = new Date();
const from = new Date(now); from.setDate(from.getDate() - days);
const to = new Date(now); to.setDate(to.getDate() + days);
document.getElementById('gen-from-date').value = from.toISOString().slice(0, 10);
document.getElementById('gen-to-date').value = to.toISOString().slice(0, 10);
updateExportCount();
}
function filterExportProductSearch() {
const q = (document.getElementById('gen-product-search').value || '').toLowerCase().trim();
document.querySelectorAll('#gen-product-list label').forEach(l => {
l.style.display = (!q || (l.dataset.product || '').includes(q)) ? '' : 'none';
});
}
function getSelectedExportProducts() {
return new Set(Array.from(document.querySelectorAll('#gen-product-list input[type="checkbox"]:checked')).map(cb => cb.value));
}
function computeExportRows() {
const fromVal = document.getElementById('gen-from-date').value;
const toVal = document.getElementById('gen-to-date').value;
const from = fromVal ? new Date(fromVal).getTime() : -Infinity;
const to = toVal ? (new Date(toVal).getTime() + 86399999) : Infinity;
const datesActive = !!(fromVal || toVal);
const selected = getSelectedExportProducts();
const all = EXPORT_MODAL_CONFIG.getAllRows() || [];
return all.filter(row => {
const ts = EXPORT_MODAL_CONFIG.getDate(row);
if (datesActive) {
if (ts == null) return false;
if (ts < from || ts > to) return false;
}
const prods = getExportProducts(row);
return prods.some(p => selected.has(p));
});
}
function updateExportCount() {
const n = computeExportRows().length;
const el = document.getElementById('gen-count');
if (el) el.textContent = `${n} item${n === 1 ? '' : 's'} match`;
}
function submitExportModal() {
const rows = computeExportRows();
if (!rows.length) { alert('No items match the selected filters.'); return; }
const format = (document.querySelector('input[name="gen-format"]:checked') || {}).value || 'html';
closeExportModal();
EXPORT_MODAL_CONFIG.runExport(rows, format);
}
// ════════════════════════════════════════════════
// EXPORT
// ════════════════════════════════════════════════
function exportAzureUpdatesToHtml(customRows, format) {
const rows = (customRows && customRows.length) ? customRows : (currentFiltered || []);
if (!rows.length) { alert('No updates to export with current filters.'); return; }
if (!window.ExportFormats || !window.OutlookExport) { alert('Export helper still loading. Please try again in a moment.'); return; }
const btn = document.getElementById('au-export-btn');
if (btn) { btn.disabled = true; btn.textContent = '…Exporting'; }
const tableRows = rows.map(u => {
const status = u.buckets.status || 'Unknown';
const product = (u.buckets.product || []).join(', ');
const release = (u.buckets.release || []).join(', ');
const date = formatDate(u.pubDate);
const summary = stripHtml(u.description);
const linkCell = u.link
? { html: window.OutlookExport.link(safeUrl(u.link), 'View') }
: '—';
return [
u.id || '—',
product || '—',
u.title || '—',
status,
release || '—',
date || '—',
summary || '—',
linkCell,
];
});
const now = new Date().toLocaleString();
window.ExportFormats.download({
title: 'Azure Updates',
subtitle: 'Exported ' + now + ' • ' + rows.length + ' update' + (rows.length !== 1 ? 's' : ''),
baseFilename: 'azureupdates-export-' + new Date().toISOString().slice(0,10),
columns: ['ID', 'Product / Area', 'Title', 'Status', 'Release Type', 'Published', 'Description', 'Link'],
rows: tableRows,
format: format || 'html',
});
if (btn) { btn.disabled = false; btn.textContent = '⬇ Export'; }
}
loadAzureUpdates();
// ── AI insights ──────────────────────────────────────────────────────
if (window.CportalAi) {
window.CportalAi.init({
source: 'azure',
panelMountSelector: '#au-cards-container',
onTopItemClick: (id) => openUpdate(id),
});
}
</script>
<!-- Generate Export modal -->
<div class="gen-modal" id="gen-modal" hidden>
<div class="gen-modal-backdrop" data-act="closeExportModal"></div>
<div class="gen-modal-dialog" role="dialog" aria-modal="true" aria-labelledby="gen-modal-title">
<header class="gen-modal-header">
<h3 class="gen-modal-title" id="gen-modal-title">Export</h3>
<button class="gen-modal-close" type="button" data-act="closeExportModal" aria-label="Close">×</button>
</header>
<div class="gen-modal-body">
<div class="gen-field">
<span class="gen-field-label">Format</span>
<div class="gen-format-group" role="radiogroup" aria-label="Export format">
<label><input type="radio" name="gen-format" value="html" checked> HTML</label>
<label><input type="radio" name="gen-format" value="md"> Markdown</label>
<label><input type="radio" name="gen-format" value="pdf"> PDF</label>
<label><input type="radio" name="gen-format" value="docx"> Word</label>
</div>
<p class="gen-format-note">PDF opens a print dialog (choose "Save as PDF"). Word export opens in Word / LibreOffice.</p>
</div>
<div class="gen-field">
<span class="gen-field-label">Date range (Published)</span>
<div style="display:flex;flex-wrap:wrap;gap:4px;margin-bottom:6px">
<button type="button" class="gen-quick" data-act="applyExportPreset7">±7 days</button>
<button type="button" class="gen-quick" data-act="applyExportPreset30">±30 days</button>
<button type="button" class="gen-quick" data-act="applyExportPreset60">±60 days</button>
</div>
<div class="gen-range">
<input type="date" id="gen-from-date" data-act="updateExportCount" data-on="change" aria-label="From date">
<span>to</span>
<input type="date" id="gen-to-date" data-act="updateExportCount" data-on="change" aria-label="To date">
<button type="button" class="gen-quick" data-act="clearExportDates">Clear</button>
</div>
<p class="gen-hint">Leave blank for no date limit. Items without a date are excluded when a range is set.</p>
</div>
<div class="gen-field">
<span class="gen-field-label">Products</span>
<div class="gen-product-controls">
<button type="button" class="gen-quick" data-act="selectAllExportProducts" data-state="1">Select all</button>
<button type="button" class="gen-quick" data-act="selectAllExportProducts" data-state="0">Clear</button>
<input type="search" id="gen-product-search" placeholder="Filter products…" data-act="filterExportProductSearch" data-on="input" aria-label="Filter products">
</div>
<div class="gen-product-list" id="gen-product-list"></div>
</div>
</div>
<footer class="gen-modal-footer">
<span class="gen-count" id="gen-count">0 items match</span>
<button type="button" class="gen-cancel-btn" data-act="closeExportModal">Cancel</button>
<button type="button" class="export-btn" id="gen-generate-btn" data-act="submitExportModal">Generate</button>
</footer>
</div>
</div>
<script src="/static/product-icons.js" defer></script>
<script src="/static/outlook-export.js" defer></script>
<script src="/static/export-formats.js" defer></script>
<script src="/static/ai-insights.js" defer></script>
</body>
</html>