Browse Source

cleanup and digital twin delete

ganahrhr 3 years ago
parent
commit
e1c6074c1b
7 changed files with 82 additions and 784 deletions
  1. 0 4
      Pages/Account.razor
  2. 7 0
      Pages/Account.razor.cs
  3. 0 589
      Pages/Methanol.razor
  4. 0 57
      Shared/NavMenu.razor
  5. 0 65
      Shared/NavMenu.razor.css
  6. 2 69
      Shared/Sidebar.razor
  7. 73 0
      Shared/Sidebar.razor.cs

+ 0 - 4
Pages/Account.razor

@@ -1,9 +1,5 @@
 @page "/account"
 
-@using Microsoft.AspNetCore.Identity;
-@inject AuthenticationStateProvider AuthenticationStateProvider
-@inject UserManager<IdentityUser> UserManager;
-
 @attribute [Authorize]
 
 <div class="tabs__content">

+ 7 - 0
Pages/Account.razor.cs

@@ -1,5 +1,7 @@
 using System;
 using System.Threading.Tasks;
+using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Authorization;
 using Microsoft.AspNetCore.Identity;
 using HyperCube.Models;
 
@@ -7,6 +9,11 @@ namespace HyperCube.Pages
 {
     public partial class Account
     {
+        [Inject]
+        public AuthenticationStateProvider AuthenticationStateProvider { get; set; }
+        [Inject]
+        public UserManager<IdentityUser> UserManager { get; set; }
+
         private AccountModel account = new();
         string myBalance = "";
 

+ 0 - 589
Pages/Methanol.razor

@@ -1,589 +0,0 @@
-@page "/methanol"
-@using System.Text.RegularExpressions;
-@using Console = HyperCube.Utils.AdvConsole;
-
-@using HyperCube.Data
-
-@using Microsoft.AspNetCore.Identity;
-@inject AuthenticationStateProvider AuthenticationStateProvider
-@inject UserManager<IdentityUser> UserManager
-@inject WeatherForecastService ForecastService
-<br>
-<h2>Установка в целом</h2>
-<br>
-<table class="table">
-    <thead>
-        <tr>
-            <th>Входной параметр</th>
-            <th>Значение</th>
-            <th>Выходной параметр</th>
-            <th>Значение</th>
-        </tr>
-    </thead>
-    <tbody>
-        <tr>
-            <td>
-                Расход сырьевого газа, нм3/ч
-            </td>
-            <td>
-                <select @bind="in1_gas_consumption">
-                    <option>800</option>
-                    <option>900</option>
-                    <option>1000</option>
-                    <option>1100</option>
-                    <option>1200</option>
-                    <option>1300</option>
-                    <option>1400</option>
-                    <option>1500</option>
-                    <option>1600</option>
-                    <option>1700</option>
-                </select>
-            </td>
-            <td>
-                Производительность по метанолу, кг/ч
-            </td>
-            <td>
-                @out1_methanol_output
-            </td>
-        </tr>
-
-        <tr>
-            <td>
-                Содержание метана, %об
-            </td>
-            <td>
-                <select @bind="in1_methane_percentage">
-                    <option>50</option>
-                    <option>55</option>
-                    <option>60</option>
-                    <option>65</option>
-                    <option>70</option>
-                    <option>75</option>
-                    <option>80</option>
-                    <option>85</option>
-                    <option>90</option>
-                    <option>95</option>
-                </select>
-            </td>
-            <td>
-                Содержание метанола в продукте, %
-            </td>
-            <td>
-                @out1_methanol_percentage
-            </td>
-        </tr>
-
-        <tr>
-            <td>
-                Содержание этана, %об
-            </td>
-            <td>
-                <select @bind="in1_ethane_percentage">
-                    <option>1</option>
-                    <option>2</option>
-                    <option>3</option>
-                    <option>4</option>
-                    <option>5</option>
-                    <option>6</option>
-                    <option>8</option>
-                    <option>10</option>
-                    <option>12</option>
-                    <option>14</option>
-                </select>
-            </td>
-        </tr>
-        <tr>
-            <td>
-                Содержание азота, %об
-            </td>
-            <td>
-                <select @bind="in1_nitro_percentage">
-                    <option>0</option>
-                    <option>0,5</option>
-                    <option>1</option>
-                    <option>1,5</option>
-                    <option>2</option>
-                    <option>2,5</option>
-                    <option>3</option>
-                    <option>3,5</option>
-                    <option>4</option>
-                    <option>5</option>
-                </select>
-            </td>
-        </tr>
-    </tbody>
-</table>
-<div>
-    <button @onclick="RenewOutWhole">Рассчитать</button>
-    @*<p>
-        out1_methanol_output @out1_methanol_output
-        <br />
-        out1_methanol_percentage @out1_methanol_percentage
-    </p>*@
-</div>
-
-<br />
-<br>
-<h2>Параметры блока производства синтез-газа</h2>
-<br>
-<table class="table">
-    <thead>
-        <tr>
-            <th>Входной параметр</th>
-            <th>Значение</th>
-            <th>Выходной параметр</th>
-            <th>Значение</th>
-        </tr>
-    </thead>
-    <tbody>
-        <tr>
-            <td>
-                Расход сырьевого газа, нм3/ч
-            </td>
-            <td>
-                @in2_gas_consumption
-                @*<select @bind="in2_gas_consumption">
-                    <option>800</option>
-                    <option>900</option>
-                    <option>1000</option>
-                    <option>1100</option>
-                    <option>1200</option>
-                    <option>1300</option>
-                    <option>1400</option>
-                    <option>1500</option>
-                    <option>1600</option>
-                    <option>1700</option>
-                </select>*@
-            </td>
-            <td>
-                Производительность по синтез-газу, нм3/ч
-            </td>
-            <td>
-                @out2_synthgas_output
-            </td>
-        </tr>
-
-        <tr>
-            <td>
-                Содержание метана, %об
-            </td>
-            <td>
-                @in2_methane_percentage
-                @*<select @bind="in2_methane_percentage">
-                    <option>50</option>
-                    <option>55</option>
-                    <option>60</option>
-                    <option>65</option>
-                    <option>70</option>
-                    <option>75</option>
-                    <option>80</option>
-                    <option>85</option>
-                    <option>90</option>
-                    <option>95</option>
-                </select>*@
-            </td>
-            <td>
-                Отношение Н2/СО
-            </td>
-            <td>                
-                @out2_hydrogen_carbonox_ratio
-            </td>
-        </tr>
-
-        <tr>
-            <td>
-                Содержание этана, %об
-            </td>
-            <td>
-                @in2_ethane_percentage
-                @*<select @bind="in2_ethane_percentage">
-                    <option>1</option>
-                    <option>2</option>
-                    <option>3</option>
-                    <option>4</option>
-                    <option>5</option>
-                    <option>6</option>
-                    <option>8</option>
-                    <option>10</option>
-                    <option>12</option>
-                    <option>14</option>
-                </select>*@
-            </td>
-            <td>
-                Конверсия сырьевого газа по С, %;
-            </td>
-            <td>
-                @out2_gas_conversion_percentage
-            </td>
-        </tr>
-        <tr>
-            <td>
-                Содержание азота, %об
-            </td>
-            <td>
-                @in2_nitro_percentage
-                @*<select @bind="in2_nitro_percentage">
-                    <option>0</option>
-                    <option>0,5</option>
-                    <option>1</option>
-                    <option>1,5</option>
-                    <option>2</option>
-                    <option>2,5</option>
-                    <option>3</option>
-                    <option>3,5</option>
-                    <option>4</option>
-                    <option>5</option>
-                </select>*@
-            </td>
-            <td>
-                Содержание СО2 в синтез-газе, %мол.
-            </td>
-            <td>
-                @out2_carbondiox_output
-            </td>
-        </tr>
-        <tr>
-            <td>
-                Давление сырьевого газа на входе в блок, МПа (абс.)
-            </td>
-            <td>
-                @in2_gas_pressure
-                @*<select @bind="in2_gas_pressure">
-                    <option>1.0</option>
-                    <option>1.2</option>
-                    <option>1.3</option>
-                    <option>1.4</option>
-                    <option>1.5</option>
-                    <option>1.6</option>
-                    <option>1.8</option>
-                    <option>2.0</option>
-                    <option>2.2</option>
-                    <option>2.4</option>
-                </select>*@
-            </td>
-        </tr>
-        <tr>
-            <td>
-                Мольное отношение вода:сырьевой газ
-            </td>
-            <td>
-                @in2_water_gas_ratio
-                @*<select @bind="in2_water_gas_ratio">
-                    <option>2.0</option>
-                    <option>2.1</option>
-                    <option>2.2</option>
-                    <option>2.3</option>
-                    <option>2.4</option>
-                    <option>2.5</option>
-                    <option>2.6</option>
-                    <option>2.7</option>
-                    <option>2.8</option>
-                    <option>3.0</option>
-                </select>*@
-            </td>
-        </tr>
-    </tbody>
-</table>
-<div>
-    @*<button @onclick="RenewOutSynthGas">Обновить</button>*@
-    @*<p>
-        out2_synthgas_output @out2_synthgas_output
-        <br />
-        out2_hydrogen @out2_hydrogen
-        <br />
-        out2_carbonox @out2_carbonox
-        <br />
-        out2_gas_conversion_percentage @out2_gas_conversion_percentage
-        <br />
-        out2_carbondiox_output @out2_carbondiox_output
-        <br />
-    </p>*@
-</div>
-<br>
-<h2>Параметры блока синтеза метанола</h2>
-<br>
-<table class="table">
-    <thead>
-        <tr>
-            <th>Входной параметр</th>
-            <th>Значение</th>
-            <th>Выходной параметр</th>
-            <th>Значение</th>
-        </tr>
-    </thead>
-    <tbody>
-
-        <tr>
-            <td>
-                Давление синтез-газа на входе в блок, МПа (абс.)
-            </td>
-            <td>
-                @in3_synthgas_pressure
-                @*<select @bind="in3_synthgas_pressure">
-                    <option>4.5</option>
-                    <option>4.6</option>
-                    <option>4.8</option>
-                    <option>5.0</option>
-                    <option>5.2</option>
-                    <option>5.4</option>
-                    <option>5.6</option>
-                    <option>5.8</option>
-                    <option>6.0</option>
-                    <option>6.2</option>
-                </select>*@
-            </td>
-            <td>
-                Производительность по метанолу-сырцу, кг/ч
-            </td>
-            <td>
-                @out3_methanol_output
-            </td>
-        </tr>
-        <tr>
-            <td>
-                Температура в реакторе синтеза метанола, С
-            </td>
-            <td>
-                @in3_reactor_temp
-                @*<select @bind="in3_reactor_temp">
-                    <option>220</option>
-                    <option>225</option>
-                    <option>230</option>
-                    <option>235</option>
-                    <option>240</option>
-                    <option>245</option>
-                    <option>250</option>
-                    <option>255</option>
-                    <option>260</option>
-                </select>*@
-            </td>
-            <td>
-                Содержание метанола в метаноле сырце, % масс.
-            </td>
-            <td>
-                @out3_methanol_percentage
-            </td>
-        </tr>
-        <tr>
-            <td>
-                Кратность циркуляции синтез-газа в контуре реактора Р-202
-            </td>
-            <td>
-                @in3_synthgas_reactor_circulation_multiplier
-                @*<select @bind="in3_synthgas_reactor_circulation_multiplier">
-                    <option>4.0</option>
-                    <option>4.5</option>
-                    <option>5.0</option>
-                    <option>5.5</option>
-                    <option>6.0</option>
-                    <option>6.5</option>
-                    <option>7.0</option>
-                    <option>7.5</option>
-                    <option>8.0</option>
-                </select>*@
-            </td>
-            <td>
-                Содержание этанола в метаноле-сырце, %масс.
-            </td>
-            <td>
-                @out3_ethanol_percentage
-            </td>
-        </tr>
-        <tr>
-            <td>
-            </td>
-            <td>
-            </td>
-            <td>
-                Содержание диметилового эфира в метаноле-сырце, %масс.
-            </td>
-            <td>
-                @out3_dimethylether_percentage
-            </td>
-        </tr>
-        <tr>
-            <td>
-            </td>
-            <td>
-            </td>
-            <td>
-                Содержание формальдегида в метаноле-сырце, %масс.
-            </td>
-            <td>
-                @out3_formaldehyde_percentage
-            </td>
-        </tr>
-        <tr>
-            <td>
-            </td>
-            <td>
-            </td>
-            <td>
-                Конверсия СО, %;
-            </td>
-            <td>
-                @out3_carbonox_conversion
-            </td>
-        </tr>
-        <tr>
-            <td>
-            </td>
-            <td>
-            </td>
-            <td>
-                Конверсия СО2, %мол.
-            </td>
-            <td>
-                @out3_carbondiox_conversion
-            </td>
-        </tr>
-    </tbody>
-</table>
-@*<div>
-    <button @onclick="RenewOutMethanol">Обновить</button>
-    <p>
-        out3_methanol_output @out3_methanol_output
-        <br />
-        out3_methanol_percentage @out3_methanol_percentage
-        <br />
-        out3_ethanol_percentage @out3_ethanol_percentage
-        <br />
-        out3_dimethylether_percentage @out3_dimethylether_percentage
-        <br />
-        out3_formaldehyde_percentage @out3_formaldehyde_percentage
-        <br />
-        out3_carbonox_conversion @out3_carbonox_conversion
-        <br />
-        out3_carbondiox_conversion @out3_carbondiox_conversion
-        <br />
-    </p>
-</div>*@
-<p>
-    @*@in1_gas_consumption*@
-</p>
-@code {
-    int in1_gas_consumption;
-    float in1_methane_percentage;
-    float in1_ethane_percentage;
-    float in1_nitro_percentage;
-
-    int out1_methanol_output;
-    float out1_methanol_percentage;
-
-    int in2_gas_consumption;
-    float in2_methane_percentage;
-    float in2_ethane_percentage;
-    float in2_nitro_percentage;
-    float in2_gas_pressure;
-    float in2_water_gas_ratio;
-
-    int out2_synthgas_output;
-    float out2_hydrogen;
-    float out2_carbonox;
-    float out2_gas_conversion_percentage;
-    float out2_carbondiox_output;
-
-    float out2_hydrogen_carbonox_ratio;
-
-    float in3_synthgas_pressure;
-    int in3_reactor_temp;
-    int in3_synthgas_reactor_circulation_multiplier;
-
-    int out3_methanol_output;
-    float out3_methanol_percentage;
-    float out3_ethanol_percentage;
-    float out3_dimethylether_percentage;
-    float out3_formaldehyde_percentage;
-    float out3_carbonox_conversion;
-    float out3_carbondiox_conversion;
-
-    async Task RenewOutWhole()
-    {
-        //запрос в базу с выбранными параметрами
-        var result = await MySQLConnector.Instance().SQLSelectComplex($"select * from digitaltwin where " +
-            $"in1_gas_consumption={in1_gas_consumption} and " +
-            $"in1_methane_percentage={Math.Round(in1_methane_percentage * 0.01, 3)} and " +
-            $"in1_ethane_percentage={Math.Round(in1_ethane_percentage * 0.01, 3)} and " +
-            $"in1_nitro_percentage = {Math.Round(in1_nitro_percentage * 0.01, 3)} LIMIT 1");
-
-        if (result.Count > 0)
-        {
-            foreach (var res in result)
-            {
-                out1_methanol_output = Convert.ToInt32(res["out1_methanol_output"]);
-                out1_methanol_percentage = Convert.ToSingle(res["out1_methanol_percentage"]);
-                ///
-                in2_gas_consumption = Convert.ToInt32(res["in2_gas_consumption"]);
-                in2_methane_percentage = Convert.ToSingle(res["in2_methane_percentage"]);
-                in2_ethane_percentage = Convert.ToSingle(res["in2_ethane_percentage"]);
-                in2_nitro_percentage = Convert.ToSingle(res["in2_nitro_percentage"]);
-                in2_gas_pressure = Convert.ToSingle(res["in2_gas_pressure"]);
-                in2_water_gas_ratio = Convert.ToSingle(res["in2_water_gas_ratio"]);
-                ///
-                out2_synthgas_output = Convert.ToInt32(res["out2_synthgas_output"]);
-                out2_hydrogen_carbonox_ratio = Convert.ToSingle(res["out2_hydrogen_carbonox_ratio"]);
-                //out2_carbonox = Convert.ToSingle(res["out2_carbonox"]);
-                out2_gas_conversion_percentage = Convert.ToSingle(res["out2_gas_conversion_percentage"]);
-                out2_carbondiox_output = Convert.ToSingle(res["out2_carbondiox_output"]);
-                ///
-                in3_synthgas_pressure = Convert.ToSingle(res["in3_synthgas_pressure"]);
-                in3_reactor_temp = Convert.ToInt32(res["in3_reactor_temp"]);
-                in3_synthgas_reactor_circulation_multiplier = Convert.ToInt32(res["in3_synthgas_reactor_circulation_multiplier"]);
-                ///
-                out3_methanol_output = Convert.ToInt32(res["out3_methanol_output"]);
-                out3_methanol_percentage = Convert.ToSingle(res["out3_methanol_percentage"]);
-                out3_ethanol_percentage = Convert.ToSingle(res["out3_ethanol_percentage"]);
-                out3_carbonox_conversion = Convert.ToSingle(res["out3_carbonox_conversion"]);
-                out3_dimethylether_percentage = Convert.ToSingle(res["out3_dimethylether_percentage"]);
-                out3_formaldehyde_percentage = Convert.ToSingle(res["out3_formaldehyde_percentage"]);
-                out3_carbondiox_conversion = Convert.ToSingle(res["out3_carbondiox_conversion"]);
-
-            }
-        }
-    }
-
-    async Task RenewOutSynthGas()
-    {
-        var result = await MySQLConnector.Instance().SQLSelectComplex($"select * from digitaltwin where " +
-            $"in2_gas_consumption={in2_gas_consumption} and " +
-            $"in2_methane_percentage={Math.Round(in2_methane_percentage * 0.01, 3)} and " +
-            $"in2_ethane_percentage={Math.Round(in2_ethane_percentage * 0.01, 3)} and " +
-            $"in2_nitro_percentage={Math.Round(in2_nitro_percentage * 0.01, 3)} and " +
-            $"in2_gas_pressure={in2_gas_pressure} and " +
-            $"in2_water_gas_ratio = {Math.Round(in2_water_gas_ratio * 0.01, 3)} LIMIT 1");
-
-        if (result.Count > 0)
-        {
-            foreach (var res in result)
-            {
-                out2_synthgas_output = Convert.ToInt32(res["out2_synthgas_output"]);
-                out2_hydrogen = Convert.ToSingle(res["out2_hydrogen"]);
-                out2_carbonox = Convert.ToSingle(res["out2_carbonox"]);
-                out2_gas_conversion_percentage = Convert.ToSingle(res["out2_gas_conversion_percentage"]);
-                out2_carbondiox_output = Convert.ToSingle(res["out2_carbondiox_output"]);
-            }
-        }
-    }
-
-    async Task RenewOutMethanol()
-    {
-        var result = await MySQLConnector.Instance().SQLSelectComplex($"select * from digitaltwin where " +
-        $"in3_synthgas_pressure={in3_synthgas_pressure} and " +
-        $"in3_reactor_temp={in3_reactor_temp} and " +
-        $"in3_synthgas_reactor_circulation_multiplier={in3_synthgas_reactor_circulation_multiplier} LIMIT 1");
-
-        if (result.Count > 0)
-        {
-            foreach (var res in result)
-            {
-                out3_methanol_output = Convert.ToInt32(res["out3_methanol_output"]);
-                out3_methanol_percentage = Convert.ToSingle(res["out3_methanol_percentage"]);
-                out3_ethanol_percentage = Convert.ToSingle(res["out3_ethanol_percentage"]);
-                out3_carbonox_conversion = Convert.ToSingle(res["out3_carbonox_conversion"]);
-                out3_dimethylether_percentage = Convert.ToSingle(res["out3_dimethylether_percentage"]);
-                out3_formaldehyde_percentage = Convert.ToSingle(res["out3_formaldehyde_percentage"]);
-                out3_carbondiox_conversion = Convert.ToSingle(res["out3_carbondiox_conversion"]);
-            }
-        }
-    }
-}

+ 0 - 57
Shared/NavMenu.razor

@@ -1,57 +0,0 @@
-<div class="top-row pl-4 navbar navbar-light">
-    <img src="/images/2dh_logo01.svg"/>
-    @*<button class="navbar-toggler" @onclick="ToggleNavMenu">
-        <span class="navbar-toggler-icon"></span>
-    </button>*@
-</div>
-
-<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
-    <ul class="nav flex-column">
-        <li class="nav-item px-3">
-            <NavLink class="nav-link" href="" Match="NavLinkMatch.All">
-                <span class="oi oi-home" aria-hidden="true"></span> <b>Домой</b>
-            </NavLink>
-        </li>
-        <li class="nav-item px-3">
-            <NavLink class="nav-link" href="docedit">
-                <span class="oi oi-plus" aria-hidden="true"></span> <b>Загрузка</b>
-            </NavLink>
-        </li>
-        <li class="nav-item px-3">
-            <NavLink class="nav-link" href="verifying">
-                <span class="oi oi-list" aria-hidden="true"></span> <b>Верификация</b>
-            </NavLink>
-        </li>
-        <li class="nav-item px-3">
-            <NavLink class="nav-link" href="blockchains">
-                <span class="oi oi-list-rich" aria-hidden="true"></span> <b>Blockchain</b>
-            </NavLink>
-        </li>
-        <li class="nav-item px-3">
-            <NavLink class="nav-link" href="methanol">
-                <span class="oi oi-list-rich" aria-hidden="true"></span> <b>Синтез метанола</b>
-            </NavLink>
-        </li>
-        <li class="nav-item px-3">
-            <NavLink class="nav-link" href="account">
-                <span class="oi oi-account-login" aria-hidden="true"></span> <b>Личный кабинет</b>
-            </NavLink>
-        </li>
-        @*<li class="nav-item px-3">
-            <NavLink class="nav-link" href="fetchdata">
-                <span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
-            </NavLink>
-        </li>*@
-    </ul>
-</div>
-
-@code {
-    private bool collapseNavMenu = true;
-
-    private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
-
-    private void ToggleNavMenu()
-    {
-        collapseNavMenu = !collapseNavMenu;
-    }
-}

+ 0 - 65
Shared/NavMenu.razor.css

@@ -1,65 +0,0 @@
-.navbar-toggler {
-    background-color: rgba(0, 0, 0, 1);
-}
-
-.top-row {
-    height: 5.5rem;
-    /*background-color: rgba(0,0,0,0.4);*/
-    background-color: #F4F5F7;
-    border-bottom: 5px solid #3B484E;
-}
-
-
-.navbar-brand {
-    font-size: 1.1rem;
-}
-
-.oi {
-    width: 2rem;
-    font-size: 1.1rem;
-    vertical-align: text-top;
-    top: -2px;
-}
-
-.nav-item {
-    font-size: 0.9rem;
-    padding-bottom: 0.5rem;
-}
-
-    .nav-item:first-of-type {
-        padding-top: 1rem;
-    }
-
-    .nav-item:last-of-type {
-        padding-bottom: 1rem;
-    }
-
-    .nav-item ::deep a {
-        color: #d7d7d7;
-        border-radius: 4px;
-        height: 3rem;
-        display: flex;
-        align-items: center;
-        line-height: 3rem;
-    }
-
-.nav-item ::deep a.active {
-    background-color: rgba(255,255,255,0.25);
-    color: white;
-}
-
-.nav-item ::deep a:hover {
-    background-color: rgba(255,255,255,0.1);
-    color: white;
-}
-
-@media (min-width: 641px) {
-    .navbar-toggler {
-        display: none;
-    }
-
-    .collapse {
-        /* Never collapse the sidebar for wide screens */
-        display: block;
-    }
-}

+ 2 - 69
Shared/Sidebar.razor

@@ -1,68 +1,5 @@
-@namespace HyperCube.Models
-@using Microsoft.AspNetCore.Identity;
-@inject AuthenticationStateProvider AuthenticationStateProvider
-@inject UserManager<IdentityUser> UserManager
+@attribute [Authorize]
 
-@using Console = HyperCube.Utils.AdvConsole
-
-@attribute [Authorize]
-
-@code
-{ 
-    AccountModel account;
-    List<Role> roles;
-    //string rr = "";
-    //roles = account.roles;
-
-    protected override async Task OnInitializedAsync()
-    {
-        account = await GetCurrentAcc();
-        if (account != null)
-            account.RolesChanged += Change;
-    }
-
-    public async Task InitializeAccount()
-    {
-        AccountModel.Current = await GetCurrentAcc();
-        Console.WriteLine("InitializeAccount in Sidebar " + AccountModel.Current.Name);
-        await Rerender();
-    }
-
-    private async Task<AccountModel> GetCurrentAcc()
-    {
-        AccountModel account = new();
-
-        var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
-        var user = authState.User;
-
-        if (user.Identity.IsAuthenticated)
-        {
-            var currentUser = await UserManager.GetUserAsync(user);
-            account.UUID = currentUser.Id;
-            //account.Name = currentUser.UserName;
-            //account.Email = currentUser.Email;
-
-            var acc = AccountModel.Find(account.UUID);
-            if (acc != null)
-                account = acc;
-            ///tmp
-
-            //account.AccRole = Role.User;
-            //account.Name = "test";
-            return account;
-        }
-
-        return null;
-    }
-
-    private void Change(int count)
-    {
-        Console.WriteLine($"Sidebar role changed, count: {count}");
-        Rerender();
-    }
-
-    private async Task Rerender() { StateHasChanged(); }
-}
 <sidebar class="profile-info">
     <AuthorizeView>
         <Authorized>
@@ -88,16 +25,12 @@
                         <img src="img/wallet.svg" alt="qual" class="profile-info__link-img">
                         Кошелек
                     </a>
-                    @if (account.Roles.Contains(Role.Admin))
+                    @if (account.Roles.Contains(HyperCube.Models.Role.Admin))
                     {
                         <a href="Blockchains" class="profile-info__link">
                             <img src="img/wallet.svg" alt="qual" class="profile-info__link-img">
                             Blockchains
                         </a>
-                        <a href="Methanol" class="profile-info__link">
-                            <img src="img/wallet.svg" alt="qual" class="profile-info__link-img">
-                            Синтез метанола
-                        </a>
                     }
                 </div>
                 <div class="profile-info__item">

+ 73 - 0
Shared/Sidebar.razor.cs

@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Authorization;
+using Microsoft.AspNetCore.Identity;
+using HyperCube.Models;
+using Console = HyperCube.Utils.AdvConsole;
+
+namespace HyperCube.Shared
+{
+    public partial class Sidebar
+    {
+        [Inject]
+        public AuthenticationStateProvider AuthenticationStateProvider { get; set; }
+        [Inject]
+        public UserManager<IdentityUser> UserManager { get; set; }
+
+        AccountModel account;
+        List<Role> roles;
+        //string rr = "";
+        //roles = account.roles;
+
+        protected override async Task OnInitializedAsync()
+        {
+            account = await GetCurrentAcc();
+            if (account != null)
+                account.RolesChanged += Change;
+        }
+
+        public async Task InitializeAccount()
+        {
+            AccountModel.Current = await GetCurrentAcc();
+            Console.WriteLine("InitializeAccount in Sidebar " + AccountModel.Current.Name);
+            await Rerender();
+        }
+
+        private async Task<AccountModel> GetCurrentAcc()
+        {
+            AccountModel account = new();
+
+            var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
+            var user = authState.User;
+
+            if (user.Identity.IsAuthenticated)
+            {
+                var currentUser = await UserManager.GetUserAsync(user);
+                account.UUID = currentUser.Id;
+                //account.Name = currentUser.UserName;
+                //account.Email = currentUser.Email;
+
+                var acc = AccountModel.Find(account.UUID);
+                if (acc != null)
+                    account = acc;
+                ///tmp
+
+                //account.AccRole = Role.User;
+                //account.Name = "test";
+                return account;
+            }
+
+            return null;
+        }
+
+        private void Change(int count)
+        {
+            Console.WriteLine($"Sidebar role changed, count: {count}");
+            Rerender();
+        }
+
+        private async Task Rerender() { StateHasChanged(); }
+    }
+}