Skip to content

Modular logistics and supply chain operating system (LSOS)

5.5 KB
Raw Blame
<EmberWormhole @to="next-view-section-subheader-actions">
    <div class="flex items-center gap-2">
        <div class="inline-flex overflow-hidden rounded-md border border-gray-300 shadow-sm dark:border-gray-700" role="group" aria-label="Time window" data-test-windows>
            {{#each this.windows as |option|}}
                <button
                    type="button"
                    class="border-r border-gray-300 px-2 py-1 text-xs font-medium last:border-r-0 dark:border-gray-700
                        {{if (eq option.value this.window) 'bg-blue-600 text-white' 'bg-white text-gray-700 hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700'}}"
                    aria-pressed={{if (eq option.value this.window) "true" "false"}}
                    {{on "click" (fn this.setWindow option)}}
                    data-test-window={{option.value}}
                >{{option.label}}</button>
            {{/each}}
        </div>
        <div class="inline-flex overflow-hidden rounded-md border border-gray-300 shadow-sm dark:border-gray-700" role="group" aria-label="Sort by">
            <button
                type="button"
                class="border-r border-gray-300 px-2 py-1 text-xs font-medium dark:border-gray-700
                    {{if (eq this.sort 'hits') 'bg-blue-600 text-white' 'bg-white text-gray-700 hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700'}}"
                {{on "click" (fn this.setSort "hits")}}
                data-test-sort="hits"
            >Most requests</button>
            <button
                type="button"
                class="px-2 py-1 text-xs font-medium
                    {{if (eq this.sort 'throttled') 'bg-blue-600 text-white' 'bg-white text-gray-700 hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700'}}"
                {{on "click" (fn this.setSort "throttled")}}
                data-test-sort="throttled"
            >Most throttled</button>
        </div>
        <Button @size="xs" @icon="arrows-rotate" @helpText="Refresh" @onClick={{perform this.load}} @isLoading={{this.load.isRunning}} data-test-refresh />
    </div>
</EmberWormhole>

<div class="space-y-3 p-4" ...attributes>
    {{#if this.data}}
        {{#unless this.data.available}}
            <div
                class="flex items-center rounded-md border border-yellow-400 bg-yellow-50 px-3 py-2 text-xs text-yellow-800 dark:border-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-100"
                data-test-unavailable
            >
                <FaIcon @icon="triangle-exclamation" class="mr-2" />
                Consumer metrics are unavailable: they are stored in Redis, which could not be reached.
            </div>
        {{/unless}}
        {{#unless this.data.tracking}}
            <div
                class="flex items-center rounded-md border border-blue-300 bg-blue-50 px-3 py-2 text-xs text-blue-800 dark:border-blue-700 dark:bg-blue-900/40 dark:text-blue-100"
                data-test-not-tracking
            >
                <FaIcon @icon="circle-info" class="mr-2" />
                Consumer tracking is turned off in
                <LinkTo @route="console.admin.rate-limits" class="mx-1 underline">Rate Limits</LinkTo>, so no new requests are being counted.
            </div>
        {{/unless}}

        <div
            class="grid grid-cols-2 divide-gray-200 overflow-hidden rounded-md border border-gray-200 bg-white shadow-sm sm:grid-cols-5 sm:divide-x dark:divide-gray-700 dark:border-gray-700 dark:bg-gray-800"
            data-test-stats
        >
            {{#each this.stats as |stat|}}
                <div class="px-3 py-2" data-test-stat={{stat.key}}>
                    <div class="truncate text-[10px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400">{{stat.label}}</div>
                    <div class="mt-0.5 flex items-baseline gap-1.5">
                        <span class="text-lg font-bold leading-6 tabular-nums {{if stat.isAlert 'text-rose-600 dark:text-rose-300' 'text-gray-900 dark:text-gray-100'}}">{{stat.value}}</span>
                        {{#if stat.hint}}
                            <span class="truncate text-[11px] text-gray-500 dark:text-gray-400">{{stat.hint}}</span>
                        {{/if}}
                    </div>
                </div>
            {{/each}}
        </div>

        {{#each this.charts as |chart|}}
            <div class="rounded-md border border-gray-200 bg-white p-3 shadow-sm dark:border-gray-700 dark:bg-gray-800" data-test-timeline>
                <div class="text-[10px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400">Requests over the {{this.windowDescription}}</div>
                <div class="h-48">
                    <Chart @type="line" @labels={{chart.labels}} @datasets={{chart.datasets}} @options={{chart.options}} @wrapperClass="h-full" />
                </div>
            </div>
        {{/each}}

        <div class="overflow-hidden rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800" data-test-consumers-table>
            {{#if this.consumers.length}}
                <Table @rows={{this.consumers}} @columns={{this.columns}} />
            {{else}}
                <div class="px-4 py-10 text-center text-sm text-gray-500 dark:text-gray-400" data-test-empty>No API requests in the {{this.windowDescription}}.</div>
            {{/if}}
        </div>
    {{else}}
        <div class="flex justify-center py-10"><Spinner /></div>
    {{/if}}
</div>