< Summary

Information
Class: AspNetCoreGeneratedDocument.Areas_OzonCards_Views_ExcelMappings_Index
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/Areas/OzonCards/Views/ExcelMappings/Index.cshtml
Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 234
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ExecuteAsync()0%2040%
<ExecuteAsync()100%210%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/Areas/OzonCards/Views/ExcelMappings/Index.cshtml

#LineLine coverage
 1@model IEnumerable<OzonDomains.ExcelMapping>
 2
 3@{
 04    ViewData["Title"] = "Управление шаблонами Excel";
 5}
 6
 7<div class="container mt-4">
 8    <div class="card">
 9        <div class="card-header bg-primary text-white">
 10            <div class="d-flex justify-content-between align-items-center">
 11                <h4 class="mb-0">
 12                    <i class="fas fa-table me-2"></i>Шаблоны Excel маппингов
 13                </h4>
 14                <a href="@Url.Action("Index", "Excel", new { area = "OzonCards" })" class="btn btn-light btn-sm">
 15                    <i class="fas fa-arrow-left me-1"></i>Назад к обработке
 16                </a>
 17            </div>
 18        </div>
 19        <div class="card-body">
 020            @if (!Model.Any())
 21            {
 22                <div class="text-center py-5">
 23                    <i class="fas fa-table fa-3x text-muted mb-3"></i>
 24                    <h5 class="text-muted">Шаблоны не найдены</h5>
 25                    <p class="text-muted">Создайте свой первый шаблон для сопоставления Excel файлов</p>
 26                    <a href="@Url.Action("Index", "Excel", new { area = "OzonCards" })" class="btn btn-primary">
 27                        <i class="fas fa-plus me-1"></i>Создать шаблон
 28                    </a>
 29                </div>
 30            }
 31            else
 32            {
 33                <div class="table-responsive">
 34                    <table class="table table-striped table-hover">
 35                        <thead class="table-dark">
 36                            <tr>
 37                                <th>Название</th>
 38                                <th>Исходный файл</th>
 39                                <th>Целевой файл</th>
 40                                <th>Листы</th>
 41                                <th>Создан</th>
 42                                <th>Автор</th>
 43                                <th>Действия</th>
 44                            </tr>
 45                        </thead>
 46                        <tbody>
 047                            @foreach (var mapping in Model)
 48                            {
 49                                <tr id="mapping-@mapping.Id">
 50                                    <td>
 051                                        <strong>@mapping.Name</strong>
 52                                    </td>
 53                                    <td>
 054                                        <small class="text-muted">@System.IO.Path.GetFileName(mapping.SourceFileName)</s
 55                                    </td>
 56                                    <td>
 057                                        <small class="text-muted">@System.IO.Path.GetFileName(mapping.DestinationFileNam
 58                                    </td>
 59                                    <td>
 060                                        <span class="badge bg-info">@mapping.SourceSheet</span>
 61                                        <i class="fas fa-arrow-right text-muted mx-1"></i>
 062                                        <span class="badge bg-success">@mapping.DestinationSheet</span>
 63                                    </td>
 64                                    <td>
 065                                        <small class="text-muted">@mapping.CreatedDate.ToString("dd.MM.yyyy HH:mm")</sma
 66                                    </td>
 67                                    <td>
 068                                        <small class="text-muted">@mapping.CreatedBy</small>
 69                                    </td>
 70                                    <td>
 71                                        <div class="btn-group btn-group-sm">
 072                                            <button class="btn btn-outline-primary load-mapping" data-id="@mapping.Id" t
 73                                                <i class="fas fa-download"></i>
 74                                            </button>
 075                                            <button class="btn btn-outline-danger delete-mapping" data-id="@mapping.Id" 
 76                                                <i class="fas fa-trash"></i>
 77                                            </button>
 78                                        </div>
 79                                    </td>
 80                                </tr>
 81                            }
 82                        </tbody>
 83                    </table>
 84                </div>
 85            }
 86        </div>
 87    </div>
 88</div>
 89
 90<div class="modal fade" id="deleteModal" tabindex="-1" aria-hidden="true">
 91    <div class="modal-dialog">
 92        <div class="modal-content">
 93            <div class="modal-header">
 94                <h5 class="modal-title">Подтверждение удаления</h5>
 95                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
 96            </div>
 97            <div class="modal-body">
 98                <p>Вы уверены, что хотите удалить шаблон "<strong id="deleteMappingName"></strong>"?</p>
 99                <p class="text-danger"><small>Это действие нельзя отменить.</small></p>
 100            </div>
 101            <div class="modal-footer">
 102                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</button>
 103                <button type="button" class="btn btn-danger" id="confirmDelete">Удалить</button>
 104            </div>
 105        </div>
 106    </div>
 107</div>
 108
 109@section Scripts {
 110    <script>
 111        $(document).ready(function() {
 112            let currentMappingId = null;
 113
 114            // Обработка загрузки шаблона
 115            $('.load-mapping').click(function() {
 116                const mappingId = $(this).data('id');
 117                window.location.href = '/OzonCards/Excel?mappingId=' + mappingId;
 118            });
 119
 120            // Обработка удаления шаблона
 121            $('.delete-mapping').click(function() {
 122                currentMappingId = $(this).data('id');
 123                const mappingName = $(this).data('name');
 124
 125                $('#deleteMappingName').text(mappingName);
 126                $('#deleteModal').modal('show');
 127            });
 128
 129            // Подтверждение удаления
 130            $('#confirmDelete').click(function() {
 131                if (currentMappingId) {
 132                    deleteMapping(currentMappingId);
 133                }
 134            });
 135
 136            // Функция загрузки шаблона
 137            function loadMapping(mappingId) {
 138                $.ajax({
 0139                    url: '@Url.Action("Load", "ExcelMappings", new { area = "OzonCards" })?id=' + mappingId,
 140                    type: 'GET',
 141                    success: function(response) {
 142                        if (response.success) {
 143                            localStorage.setItem('excelMappingTemplate', JSON.stringify(response.data));
 0144                            window.location.href = '@Url.Action("Index", "Excel", new { area = "OzonCards" })';
 145                        } else {
 146                            alert('Ошибка загрузки шаблона: ' + response.message);
 147                        }
 148                    },
 149                    error: function() {
 150                        alert('Ошибка при загрузке шаблона');
 151                    }
 152                });
 153            }
 154
 155            // Функция удаления шаблона
 156            function deleteMapping(mappingId) {
 157                $.ajax({
 0158                    url: '@Url.Action("Delete", "ExcelMappings", new { area = "OzonCards" })?id=' + mappingId,
 159                    type: 'DELETE',
 160                    success: function(response) {
 161                        if (response.success) {
 162                            // Удаляем строку из таблицы
 163                            $('#mapping-' + mappingId).remove();
 164
 165                            // Показываем уведомление
 166                            showToast('Шаблон успешно удален', 'success');
 167
 168                            // Если таблица пустая, показываем сообщение
 169                            if ($('tbody tr').length === 0) {
 170                                location.reload();
 171                            }
 172                        } else {
 173                            alert('Ошибка удаления: ' + response.message);
 174                        }
 175                    },
 176                    error: function() {
 177                        alert('Ошибка при удалении шаблона');
 178                    },
 179                    complete: function() {
 180                        $('#deleteModal').modal('hide');
 181                    }
 182                });
 183            }
 184
 185            // Функция показа уведомления
 186            function showToast(message, type = 'info') {
 187                // Простая реализация toast уведомления
 188                const toast = document.createElement('div');
 189                toast.className = `alert alert-${type} alert-dismissible fade show position-fixed`;
 190                toast.style.cssText = 'top: 20px; right: 20px; z-index: 1050; min-width: 300px;';
 191                toast.innerHTML = `
 192                    ${message}
 193                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
 194                `;
 195
 196                document.body.appendChild(toast);
 197
 198                // Автоматическое скрытие через 3 секунды
 199                setTimeout(() => {
 200                    toast.remove();
 201                }, 3000);
 202            }
 203        });
 204    </script>
 205
 206    <style>
 207        .table th {
 208            border-top: none;
 209            font-weight: 600;
 210        }
 211
 212        .badge {
 213            font-size: 0.75em;
 214        }
 215
 216        .btn-group-sm > .btn {
 217            padding: 0.25rem 0.5rem;
 218        }
 219
 220        .load-mapping:hover {
 221            background-color: #0d6efd;
 222            color: white;
 223        }
 224
 225        .delete-mapping:hover {
 226            background-color: #dc3545;
 227            color: white;
 228        }
 229
 230        .table-hover tbody tr:hover {
 231            background-color: rgba(13, 110, 253, 0.05);
 232        }
 233    </style>
 234}

Methods/Properties

ExecuteAsync()
<ExecuteAsync()