|
| 1 | +<script lang="ts"> |
| 2 | + import Pagination from './Pagination.svelte'; |
| 3 | +
|
| 4 | + import { DataHandler } from '@vincjo/datatables/legacy/remote'; |
| 5 | + import type { State } from '@vincjo/datatables/legacy/remote'; |
| 6 | + import type { CompanyOverviewApps } from '../types'; |
| 7 | +
|
| 8 | + export let entries_table: CompanyOverviewApps[]; |
| 9 | +
|
| 10 | + const totalRows = entries_table.length; |
| 11 | +
|
| 12 | + const rowsPerPage = 100; |
| 13 | +
|
| 14 | + const handler = new DataHandler<CompanyOverviewApps>([], { |
| 15 | + rowsPerPage: rowsPerPage, |
| 16 | + totalRows: totalRows |
| 17 | + }); |
| 18 | + const rows = handler.getRows(); |
| 19 | +
|
| 20 | + handler.onChange((state: State) => |
| 21 | + Promise.resolve( |
| 22 | + entries_table.slice( |
| 23 | + 0 + (state.pageNumber - 1) * state.rowsPerPage, |
| 24 | + state.rowsPerPage * state.pageNumber |
| 25 | + ) |
| 26 | + ) |
| 27 | + ); |
| 28 | +
|
| 29 | + handler.invalidate(); |
| 30 | + console.log(`TABLE Company: ${totalRows}`); |
| 31 | +
|
| 32 | + $: firstRowInstalls = |
| 33 | + entries_table && entries_table.length > 0 && entries_table[0].installs != 'N/A'; |
| 34 | +</script> |
| 35 | + |
| 36 | +<div class="table-container space-y-4"> |
| 37 | + <div class="overflow-x-auto pl-0"> |
| 38 | + <table class="md:table table-hover md:table-compact table-auto w-full text-xs"> |
| 39 | + <thead> |
| 40 | + <tr> |
| 41 | + <th class="table-cell-fit"></th> |
| 42 | + <th class="table-cell-fit">Time App Analyzed</th> |
| 43 | + <th class="table-cell-fit">Version Code</th> |
| 44 | + <th class="table-cell-fit">Crawl Result</th> |
| 45 | + <th class="table-cell-fit">App</th> |
| 46 | + <th class="table-cell-fit"> |
| 47 | + {#if firstRowInstalls} |
| 48 | + Installs |
| 49 | + {:else} |
| 50 | + Ratings |
| 51 | + {/if} |
| 52 | + </th> |
| 53 | + </tr> |
| 54 | + </thead> |
| 55 | + <tbody> |
| 56 | + {#each $rows as row, index} |
| 57 | + <tr class="px-0"> |
| 58 | + <td class="table-cell-fit"> |
| 59 | + {index + 1} |
| 60 | + </td> |
| 61 | + <td class="table-cell-fit"> |
| 62 | + {new Date(row.sdk_crawled_at).toISOString().slice(0, 16).replace('T', ' ')} |
| 63 | + </td> |
| 64 | + <td class="table-cell-fit"> |
| 65 | + {row.version_code} |
| 66 | + </td> |
| 67 | + <td class="table-cell-fit"> |
| 68 | + {row.crawl_result} |
| 69 | + </td> |
| 70 | + <td class="table-cell-fit"> |
| 71 | + <a href="/apps/{row.store_id}" style="cursor: pointer;"> |
| 72 | + {row.name} |
| 73 | + </a> |
| 74 | + </td> |
| 75 | + |
| 76 | + <td class="table-cell-fit"> |
| 77 | + {#if row.installs && row.installs != 'N/A'} |
| 78 | + {row.installs} |
| 79 | + {:else} |
| 80 | + {row.rating_count} |
| 81 | + {/if} |
| 82 | + </td> |
| 83 | + </tr> |
| 84 | + {/each} |
| 85 | + </tbody> |
| 86 | + </table> |
| 87 | + <footer class="flex justify-between"> |
| 88 | + <!-- <RowCount {handler} /> --> |
| 89 | + {#if totalRows > rowsPerPage} |
| 90 | + <Pagination {handler} /> |
| 91 | + {/if} |
| 92 | + </footer> |
| 93 | + </div> |
| 94 | +</div> |
0 commit comments