Make collapsibles work again in machine view.

This commit is contained in:
2020-05-23 06:49:44 +01:00
parent 11678d9129
commit a348039ba7

View File

@@ -135,281 +135,285 @@
@{ counter = 0; } @{ counter = 0; }
@foreach (var processor in _machine.Processors) @foreach (var processor in _machine.Processors)
{ {
int currentCounter = counter;
<tr> <tr>
<td> <td>
@if (processor.Speed > 0) <Collapse Visible="@_processorVisible[currentCounter]">
{ <CollapseHeader>
@(processor.GprSize > 0 ? string.Format(L["{0} @ {1}MHz ({2} bits)"], processor.Name, processor.Speed, processor.GprSize) : string.Format(L["{0} @ {1}MHz"], processor.Name, processor.Speed)) @if (processor.Speed > 0)
}
else
{
@($"{processor.Name}")
}
<a aria-controls="@($"cpuInfo{counter}")" aria-expanded="false" class="btn btn-link" data-toggle="collapse" href="@($"#cpuInfo{counter}")">
@L["+info"]
</a>
<div class="collapse" id="@($"cpuInfo{counter}")">
<div class="card card-body">
<table>
@if (processor.ModelCode != null &&
processor.ModelCode != processor.Name)
{
<tr>
<td>@L["Model"]</td>
<td>@processor.ModelCode</td>
</tr>
}
<tr>
<td>@L["Manufacturer"]</td>
<td>
<a href="/processors/company/@processor.CompanyId">
@processor.CompanyName</a>
</td>
</tr>
@if (processor.Introduced != null)
{
<tr>
<td>@L["Introduction date"]</td>
<td>@($"{processor.Introduced:yyyy}")</td>
</tr>
}
@if (processor.InstructionSet != null)
{
<tr>
<td>@L["Instruction set"]</td>
<td>@processor.InstructionSet</td>
</tr>
}
@if (processor.Speed > 0)
{
<tr>
<td>@L["Nominal speed"]</td>
<td>@string.Format(L["{0} MHz"], processor.Speed)</td>
</tr>
}
@if (processor.Gprs > 0 ||
processor.Fprs > 0 ||
processor.SimdRegisters > 0)
{
<tr>
<td>Registers</td>
<td>
<table>
@if (processor.Gprs > 0)
{
<tr>
<td>
@if (processor.FprSize > 0 &&
processor.Fprs == 0 &&
processor.SimdSize > 0 &&
processor.SimdRegisters == 0)
{
@(string.Format(L["{0} general purpose registers of {1} bits that can be used as floating point registers of {2} bits and SIMD registers of {3} bits."],
processor.Gprs, processor.GprSize, processor.FprSize, processor.SimdSize))
}
else if (processor.FprSize > 0 &&
processor.Fprs == 0)
{
@(string.Format(L["{0} general purpose registers of {1} bits that can be used as floating point registers of {2} bits."],
processor.Gprs, processor.GprSize, processor.FprSize))
}
else if (processor.FprSize == 0 &&
processor.SimdSize > 0 &&
processor.SimdRegisters == 0)
{
@(string.Format(L["{0} general purpose registers of {1} bits that can be used as SIMD registers of {2} bits."],
processor.Gprs, processor.GprSize, processor.SimdSize))
}
else
{
@(string.Format(L["{0} general purpose registers of {1} bits."], processor.Gprs, processor.GprSize))
}
</td>
</tr>
}
@if (processor.Fprs > 0)
{
<tr>
<td>
@if (processor.SimdSize > 0 &&
processor.SimdRegisters == 0)
{
@(string.Format(L["{0} floating point registers of {1} bits that can be used as SIMD registers of {2} bits."],
processor.Fprs, processor.FprSize, processor.SimdSize))
}
else
{
@(string.Format(L["{0} floating point registers of {1} bits."],
processor.Fprs, processor.FprSize))
}
</td>
</tr>
}
@if (processor.SimdRegisters > 0)
{
<tr>
<td>
<abbr title="@L["Single instruction, multiple data"]">
@string.Format(L["{0} SIMD registers of {1} bits."], processor.SimdRegisters, processor.SimdSize)
</abbr>
</td>
</tr>
}
</table>
</td>
</tr>
}
@if (processor.Cores > 1)
{
<tr>
<td>@L["Multi-core"]</td>
<td>@string.Format(L["{0} cores."], processor.Cores)</td>
</tr>
}
@if (processor.ThreadsPerCore > 1)
{
<tr>
<td>
<abbr title="@L["Simultaneous multithreading"]">SMT</abbr>
</td>
<td>
@string.Format(processor.Cores > 1 ? L["{0} threads per core."] : L["{0} threads."], processor.ThreadsPerCore)
</td>
</tr>
}
@if (processor.DataBus > 0 ||
processor.AddrBus > 0)
{
<tr>
<td>@L["Bus"]</td>
<td>
<table>
@if (processor.DataBus > 0)
{
<tr>
<td>
@string.Format(L["{0}-bit data."], processor.DataBus)
</td>
</tr>
}
@if (processor.AddrBus > 0)
{
<tr>
<td>
@string.Format(L["{0}-bit address."], processor.AddrBus)
</td>
</tr>
}
</table>
</td>
</tr>
}
@if (processor.L1Instruction > 0 ||
processor.L1Data > 0 ||
processor.L2 > 0 ||
processor.L2 > 0)
{
<tr>
<td>@L["Cache"]</td>
<td>
<table>
@if (processor.L1Instruction > 0)
{
<tr>
<td>
@string.Format(processor.L1Data < 0 ? L["{0}KiB combined instruction-data L1"] : L["{0}KiB instruction L1"], processor.L1Instruction)
</td>
</tr>
}
@if (processor.L1Data > 0)
{
<tr>
<td>
@string.Format(L["{0}KiB data L1"], processor.L1Data)
</td>
</tr>
}
@if (processor.L2 > 0)
{
<tr>
<td>
@string.Format(L["{0}KiB L2"], processor.L2)
</td>
</tr>
}
@if (processor.L3 > 0)
{
<tr>
<td>
@string.Format(L["{0}KiB L3"], processor.L3)
</td>
</tr>
}
</table>
</td>
</tr>
}
@if (processor.Package != null)
{
<tr>
<td>@L["Package"]</td>
<td>@processor.Package</td>
</tr>
}
@if (processor.Process != null ||
processor.ProcessNm > 0)
{
<tr>
<td>@L["Manufacturing process"]</td>
<td>
@if (processor.Process != null &&
processor.ProcessNm > 0)
{ {
if (processor.ProcessNm > 100) @(processor.GprSize > 0 ? string.Format(L["{0} @ {1}MHz ({2} bits)"], processor.Name, processor.Speed, processor.GprSize) : string.Format(L["{0} @ {1}MHz"], processor.Name, processor.Speed))
{
@(string.Format(L["{0} @ {1}µm"], processor.Process, processor.ProcessNm / 100))
}
else
{
@(string.Format(L["{0} @ {1}nm"], processor.Process, processor.ProcessNm))
}
}
else if (processor.ProcessNm > 0)
{
if (processor.ProcessNm > 100)
{
@(string.Format(L["{0}µm"], processor.ProcessNm / 100))
}
else
{
@(string.Format(L["{0}nm"], processor.ProcessNm))
}
} }
else else
{ {
@processor.Process @($"{processor.Name}")
} }
</td> <span class="btn btn-link" @onclick="() => _processorVisible[currentCounter] = !_processorVisible[currentCounter]">
</tr> @L["+info"]
} </span>
@if (processor.DieSize > 0) </CollapseHeader>
{ <CollapseBody Class="card card-body">
<tr> <table>
<td>@L["Die size"]</td> @if (processor.ModelCode != null &&
<td>@string.Format(L["{0} mm&sup2;"], processor.DieSize)</td> processor.ModelCode != processor.Name)
</tr> {
} <tr>
@if (processor.Transistors > 0) <td>@L["Model"]</td>
{ <td>@processor.ModelCode</td>
<tr> </tr>
<td>@L["Transistors"]</td> }
<td>@processor.Transistors</td> <tr>
</tr> <td>@L["Manufacturer"]</td>
} <td>
</table> <a href="/processors/company/@processor.CompanyId">
</div> @processor.CompanyName</a>
</div> </td>
</tr>
@if (processor.Introduced != null)
{
<tr>
<td>@L["Introduction date"]</td>
<td>@($"{processor.Introduced:yyyy}")</td>
</tr>
}
@if (processor.InstructionSet != null)
{
<tr>
<td>@L["Instruction set"]</td>
<td>@processor.InstructionSet</td>
</tr>
}
@if (processor.Speed > 0)
{
<tr>
<td>@L["Nominal speed"]</td>
<td>@string.Format(L["{0} MHz"], processor.Speed)</td>
</tr>
}
@if (processor.Gprs > 0 ||
processor.Fprs > 0 ||
processor.SimdRegisters > 0)
{
<tr>
<td>@L["Registers"]</td>
<td>
<table>
@if (processor.Gprs > 0)
{
<tr>
<td>
@if (processor.FprSize > 0 &&
processor.Fprs == 0 &&
processor.SimdSize > 0 &&
processor.SimdRegisters == 0)
{
@(string.Format(L["{0} general purpose registers of {1} bits that can be used as floating point registers of {2} bits and SIMD registers of {3} bits."],
processor.Gprs, processor.GprSize, processor.FprSize, processor.SimdSize))
}
else if (processor.FprSize > 0 &&
processor.Fprs == 0)
{
@(string.Format(L["{0} general purpose registers of {1} bits that can be used as floating point registers of {2} bits."],
processor.Gprs, processor.GprSize, processor.FprSize))
}
else if (processor.FprSize == 0 &&
processor.SimdSize > 0 &&
processor.SimdRegisters == 0)
{
@(string.Format(L["{0} general purpose registers of {1} bits that can be used as SIMD registers of {2} bits."],
processor.Gprs, processor.GprSize, processor.SimdSize))
}
else
{
@(string.Format(L["{0} general purpose registers of {1} bits."], processor.Gprs, processor.GprSize))
}
</td>
</tr>
}
@if (processor.Fprs > 0)
{
<tr>
<td>
@if (processor.SimdSize > 0 &&
processor.SimdRegisters == 0)
{
@(string.Format(L["{0} floating point registers of {1} bits that can be used as SIMD registers of {2} bits."],
processor.Fprs, processor.FprSize, processor.SimdSize))
}
else
{
@(string.Format(L["{0} floating point registers of {1} bits."],
processor.Fprs, processor.FprSize))
}
</td>
</tr>
}
@if (processor.SimdRegisters > 0)
{
<tr>
<td>
<abbr title="@L["Single instruction, multiple data"]">
@string.Format(L["{0} SIMD registers of {1} bits."], processor.SimdRegisters, processor.SimdSize)
</abbr>
</td>
</tr>
}
</table>
</td>
</tr>
}
@if (processor.Cores > 1)
{
<tr>
<td>@L["Multi-core"]</td>
<td>@string.Format(L["{0} cores."], processor.Cores)</td>
</tr>
}
@if (processor.ThreadsPerCore > 1)
{
<tr>
<td>
<abbr title="@L["Simultaneous multithreading"]">SMT</abbr>
</td>
<td>
@string.Format(processor.Cores > 1 ? L["{0} threads per core."] : L["{0} threads."], processor.ThreadsPerCore)
</td>
</tr>
}
@if (processor.DataBus > 0 ||
processor.AddrBus > 0)
{
<tr>
<td>@L["Bus"]</td>
<td>
<table>
@if (processor.DataBus > 0)
{
<tr>
<td>
@string.Format(L["{0}-bit data."], processor.DataBus)
</td>
</tr>
}
@if (processor.AddrBus > 0)
{
<tr>
<td>
@string.Format(L["{0}-bit address."], processor.AddrBus)
</td>
</tr>
}
</table>
</td>
</tr>
}
@if (processor.L1Instruction > 0 ||
processor.L1Data > 0 ||
processor.L2 > 0 ||
processor.L2 > 0)
{
<tr>
<td>@L["Cache"]</td>
<td>
<table>
@if (processor.L1Instruction > 0)
{
<tr>
<td>
@string.Format(processor.L1Data < 0 ? L["{0}KiB combined instruction-data L1"] : L["{0}KiB instruction L1"], processor.L1Instruction)
</td>
</tr>
}
@if (processor.L1Data > 0)
{
<tr>
<td>
@string.Format(L["{0}KiB data L1"], processor.L1Data)
</td>
</tr>
}
@if (processor.L2 > 0)
{
<tr>
<td>
@string.Format(L["{0}KiB L2"], processor.L2)
</td>
</tr>
}
@if (processor.L3 > 0)
{
<tr>
<td>
@string.Format(L["{0}KiB L3"], processor.L3)
</td>
</tr>
}
</table>
</td>
</tr>
}
@if (processor.Package != null)
{
<tr>
<td>@L["Package"]</td>
<td>@processor.Package</td>
</tr>
}
@if (processor.Process != null ||
processor.ProcessNm > 0)
{
<tr>
<td>@L["Manufacturing process"]</td>
<td>
@if (processor.Process != null &&
processor.ProcessNm > 0)
{
if (processor.ProcessNm > 100)
{
@(string.Format(L["{0} @ {1}µm"], processor.Process, processor.ProcessNm / 100))
}
else
{
@(string.Format(L["{0} @ {1}nm"], processor.Process, processor.ProcessNm))
}
}
else if (processor.ProcessNm > 0)
{
if (processor.ProcessNm > 100)
{
@(string.Format(L["{0}µm"], processor.ProcessNm / 100))
}
else
{
@(string.Format(L["{0}nm"], processor.ProcessNm))
}
}
else
{
@processor.Process
}
</td>
</tr>
}
@if (processor.DieSize > 0)
{
<tr>
<td>@L["Die size"]</td>
<td>@string.Format(L["{0} mm&sup2;"], processor.DieSize)</td>
</tr>
}
@if (processor.Transistors > 0)
{
<tr>
<td>@L["Transistors"]</td>
<td>@processor.Transistors</td>
</tr>
}
</table>
</CollapseBody>
</Collapse>
</td> </td>
</tr> </tr>
@@ -497,29 +501,35 @@
@{ counter = 0; } @{ counter = 0; }
@foreach (var gpu in _machine.Gpus) @foreach (var gpu in _machine.Gpus)
{ {
int currentCounter = counter;
if (gpu.Id == -2) if (gpu.Id == -2)
{ {
<td> <td>
@L["Framebuffer"] <Collapse Visible="@_gpuVisible[currentCounter]">
<a aria-controls="@($"gpuInfo{counter}")" aria-expanded="false" class="btn btn-link" data-toggle="collapse" href="@($"#gpuInfo{counter}")"> <CollapseHeader>
@L["+info"] @L["Framebuffer"]
</a> <span class="btn btn-link" @onclick="() => _gpuVisible[currentCounter] = !_gpuVisible[currentCounter]">
<div class="collapse" id="@($"gpuInfo{counter}")"> @L["+info"]
<div class="card card-body"> </span>
</CollapseHeader>
<CollapseBody Class="card card-body">
@L["This machine directly draws pixels from software to a memory region that's converted to video output by a DAC or similar without using any specific graphics processing unit."] @L["This machine directly draws pixels from software to a memory region that's converted to video output by a DAC or similar without using any specific graphics processing unit."]
</div> </CollapseBody>
</div> </Collapse>
</td> </td>
} }
else else
{ {
<td> <td>
@($"{gpu.Name}") <Collapse Visible="@_gpuVisible[currentCounter]">
<a aria-controls="@($"gpuInfo{counter}")" aria-expanded="false" class="btn btn-link" data-toggle="collapse" href="@($"#gpuInfo{counter}")"> <CollapseHeader>
@L["+info"] @($"{gpu.Name}")
</a> <span class="btn btn-link" @onclick="() => _gpuVisible[currentCounter] = !_gpuVisible[currentCounter]">
<div class="collapse" id="@($"gpuInfo{counter}")"> @L["+info"]
<div class="card card-body"> </span>
</CollapseHeader>
<CollapseBody Class="card card-body">
<table> <table>
@if (gpu.ModelCode != null && @if (gpu.ModelCode != null &&
gpu.ModelCode != gpu.Name) gpu.ModelCode != gpu.Name)
@@ -601,8 +611,8 @@
</tr> </tr>
} }
</table> </table>
</div> </CollapseBody>
</div> </Collapse>
</td> </td>
} }
counter++; counter++;
@@ -624,30 +634,36 @@
@{ counter = 0; } @{ counter = 0; }
@foreach (var sound in _machine.SoundSynthesizers) @foreach (var sound in _machine.SoundSynthesizers)
{ {
int currentCounter = counter;
<tr> <tr>
@if (sound.Id == -2) @if (sound.Id == -2)
{ {
<td> <td>
@L["Software"] <Collapse Visible="@_soundVisible[currentCounter]">
<a aria-controls="@($"synthInfo{counter}")" aria-expanded="false" class="btn btn-link" data-toggle="collapse" href="@($"#synthInfo{counter}")"> <CollapseHeader>
@L["+info"] @L["Software"]
</a> <span class="btn btn-link" @onclick="() => _soundVisible[currentCounter] = !_soundVisible[currentCounter]">
<div class="collapse" id="@($"synthInfo{counter}")"> @L["+info"]
<div class="card card-body"> </span>
</CollapseHeader>
<CollapseBody Class="card card-body">
@L["This machine directly sends data to a DAC or similar connected to the audio output."] @L["This machine directly sends data to a DAC or similar connected to the audio output."]
</div> </CollapseBody>
</div> </Collapse>
</td> </td>
} }
else else
{ {
<td> <td>
@($"{sound.Name}") <Collapse Visible="@_soundVisible[currentCounter]">
<a aria-controls="@($"synthInfo{counter}")" aria-expanded="false" class="btn btn-link" data-toggle="collapse" href="@($"#synthInfo{counter}")"> <CollapseHeader>
@L["+info"] @($"{sound.Name}")
</a> <span class="btn btn-link" @onclick="() => _soundVisible[currentCounter] = !_soundVisible[currentCounter]">
<div class="collapse" id="@($"synthInfo{counter}")"> @L["+info"]
<div class="card card-body"> </span>
</CollapseHeader>
<CollapseBody Class="card card-body">
<table> <table>
@if (sound.ModelCode != null && @if (sound.ModelCode != null &&
sound.ModelCode != sound.Name) sound.ModelCode != sound.Name)
@@ -762,8 +778,8 @@
</tr> </tr>
} }
</table> </table>
</div> </CollapseBody>
</div> </Collapse>
</td> </td>
} }
</tr> </tr>
@@ -867,11 +883,35 @@
MachineViewModel _machine; MachineViewModel _machine;
bool _loaded; bool _loaded;
bool[] _processorVisible;
bool[] _gpuVisible;
bool[] _soundVisible;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_machine = await Service.GetMachine(Id); _machine = await Service.GetMachine(Id);
_processorVisible = new bool[_machine.Processors.Count];
_gpuVisible = new bool[_machine.Gpus.Count];
_soundVisible = new bool[_machine.SoundSynthesizers.Count];
_loaded = true; _loaded = true;
} }
} }
<style>
.card {
border: none;
}
.card-header {
padding: 0;
margin-bottom: 0;
background-color: unset;
border-bottom: none;
}
.card-body {
padding: unset;
}
</style>