ccusage-ui 0.1.15 → 0.1.17

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/index.html +22 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccusage-ui",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "main": "server.js",
5
5
  "bin": {
6
6
  "ccusage-ui": "server.js"
package/public/index.html CHANGED
@@ -327,6 +327,9 @@
327
327
  <tbody></tbody>
328
328
  </table>
329
329
  </div>
330
+ <button id="showMoreBtn" onclick="toggleTableRows()" style="margin-top: 16px; padding: 8px 16px; background: #f5f5f7; border: 1px solid #e5e5e7; border-radius: 8px; cursor: pointer; font-size: 13px; color: #0071e3; width: 100%;">
331
+ Show More (30 days)
332
+ </button>
330
333
  </div>
331
334
 
332
335
  <footer style="text-align: center; margin-top: 40px; padding: 30px 20px; color: var(--text-secondary); font-size: 13px; border-top: 1px solid #e5e5e7;">
@@ -703,9 +706,9 @@
703
706
  const ctx = document.getElementById('modelChart').getContext('2d');
704
707
  if (modelChart) modelChart.destroy();
705
708
 
706
- // Aggregate costs by model from the last 30 days of daily data
709
+ // Aggregate costs by model from the most recent 30 days
707
710
  const modelCosts = {};
708
- dailyData.slice(-30).forEach(day => {
711
+ [...dailyData].sort((a, b) => b.date.localeCompare(a.date)).slice(0, 30).forEach(day => {
709
712
  if (day.modelBreakdowns) {
710
713
  day.modelBreakdowns.forEach(m => {
711
714
  const name = m.modelName.split('-').slice(0, 2).join(' ');
@@ -732,12 +735,15 @@
732
735
  });
733
736
  }
734
737
 
738
+ let showAllDays = false;
739
+
735
740
  function renderTable() {
736
741
  const tbody = document.querySelector('#dataTable tbody');
737
742
  tbody.innerHTML = '';
738
- // Show last 10 days reversed
739
- const recent = [...dailyData].reverse().slice(0, 10);
740
-
743
+ // Sort by date descending (newest first), show 7 or 30 days
744
+ const count = showAllDays ? 30 : 7;
745
+ const recent = [...dailyData].sort((a, b) => b.date.localeCompare(a.date)).slice(0, count);
746
+
741
747
  recent.forEach(d => {
742
748
  const tr = document.createElement('tr');
743
749
  tr.innerHTML = `
@@ -749,6 +755,17 @@
749
755
  `;
750
756
  tbody.appendChild(tr);
751
757
  });
758
+
759
+ // Update button text
760
+ const btn = document.getElementById('showMoreBtn');
761
+ if (btn) {
762
+ btn.textContent = showAllDays ? 'Show Less (7 days)' : 'Show More (30 days)';
763
+ }
764
+ }
765
+
766
+ function toggleTableRows() {
767
+ showAllDays = !showAllDays;
768
+ renderTable();
752
769
  }
753
770
 
754
771