HM-95. Доработки по Журналу, добавлена очистка фильтров и открытие по модалки по даблклику (#38)

This commit is contained in:
Nikolay
2020-07-30 22:49:43 +03:00
committed by GitHub
parent 6a87a97c85
commit cf045379d8
8 changed files with 102 additions and 19 deletions

View File

@ -16,6 +16,12 @@ textarea {
background: transparent; background: transparent;
} }
button {
background-color: transparent;
border: none;
border-radius: 0;
}
button, button,
button:active, button:active,
button:focus { button:focus {

View File

@ -154,26 +154,49 @@
<!-- Фильтры для таблицы серверных ошибок --> <!-- Фильтры для таблицы серверных ошибок -->
<div class="col-12 col-md-6 col-lg mb-3"> <div class="col-12 col-md-6 col-lg mb-3">
<label for="logs-filter-log-type" class="form-label">Тип записи</label> <label for="logs-filter-log-type" class="form-label">Тип записи</label>
<input type="text" class="form-control" id="logs-filter-log-type" placeholder="Введите текст"> <div class="LogsFilters__inputWrapper">
<input type="text" class="form-control" id="logs-filter-log-type"
placeholder="Введите текст">
<button type="button" class="LogsFilters__clearButton">
<i class="fas fa-times"></i>
</button>
</div>
</div> </div>
<div class="col-12 col-md-6 col-lg mb-3"> <div class="col-12 col-md-6 col-lg mb-3">
<label for="logs-filter-message" class="form-label">Сообщение</label> <label for="logs-filter-message" class="form-label">Сообщение</label>
<input type="text" class="form-control" id="logs-filter-message" placeholder="Введите текст"> <div class="LogsFilters__inputWrapper">
<input type="text" class="form-control" id="logs-filter-message"
placeholder="Введите текст">
<button type="button" class="LogsFilters__clearButton">
<i class="fas fa-times"></i>
</button>
</div>
</div> </div>
<div class="col-12 col-md-6 col-lg mb-3"> <div class="col-12 col-md-6 col-lg mb-3">
<label for="logs-filter-trace" class="form-label">Стек</label> <label for="logs-filter-trace" class="form-label">Стек</label>
<div class="LogsFilters__inputWrapper">
<input type="text" class="form-control" id="logs-filter-trace" placeholder="Введите текст"> <input type="text" class="form-control" id="logs-filter-trace" placeholder="Введите текст">
<button type="button" class="LogsFilters__clearButton">
<i class="fas fa-times"></i>
</button>
</div>
</div> </div>
<!-- Фильтры для таблицы клиентских запросов --> <!-- Фильтры для таблицы клиентских запросов -->
<div class="col-12 col-md-6 col-lg mb-3"> <div class="col-12 col-md-6 col-lg mb-3">
<label for="logs-filter-request-type" class="form-label">Результат запроса</label> <label for="logs-filter-request-type" class="form-label">Результат запроса</label>
<div class="LogsFilters__inputWrapper">
<input type="text" class="form-control" id="logs-filter-request-type" <input type="text" class="form-control" id="logs-filter-request-type"
placeholder="Введите текст"> placeholder="Введите текст">
<button type="button" class="LogsFilters__clearButton">
<i class="fas fa-times"></i>
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-xl-2 d-flex align-items-end"> <div class="col-12 col-xl-2 d-flex align-items-end">
<button type="submit" class="btn btn-primary mb-3">Поиск</button> <button type="submit" class="btn btn-primary mb-3">Поиск</button>
<button type="button" class="btn btn-secondary mb-3 ml-2 LogsFilters__resetButton">Сбросить</button>
</div> </div>
</form> </form>
</template> </template>
@ -237,8 +260,8 @@
</div> </div>
<div class="Info__controls"> <div class="Info__controls">
<button class="Button__edit"> <button class="Button__edit">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="Icon__edit bi bi-pencil" fill="currentColor" <svg width="1em" height="1em" viewBox="0 0 16 16" class="Icon__edit bi bi-pencil"
xmlns="http://www.w3.org/2000/svg"> fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" <path fill-rule="evenodd"
d="M11.293 1.293a1 1 0 0 1 1.414 0l2 2a1 1 0 0 1 0 1.414l-9 9a1 1 0 0 1-.39.242l-3 1a1 1 0 0 1-1.266-1.265l1-3a1 1 0 0 1 .242-.391l9-9zM12 2l2 2-9 9-3 1 1-3 9-9z" /> d="M11.293 1.293a1 1 0 0 1 1.414 0l2 2a1 1 0 0 1 0 1.414l-9 9a1 1 0 0 1-.39.242l-3 1a1 1 0 0 1-1.266-1.265l1-3a1 1 0 0 1 .242-.391l9-9zM12 2l2 2-9 9-3 1 1-3 9-9z" />
<path fill-rule="evenodd" <path fill-rule="evenodd"
@ -246,8 +269,8 @@
</svg> </svg>
</button> </button>
<button class="Button__delete"> <button class="Button__delete">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="Icon__delete bi bi-trash" fill="currentColor" <svg width="1em" height="1em" viewBox="0 0 16 16" class="Icon__delete bi bi-trash"
xmlns="http://www.w3.org/2000/svg"> fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path <path
d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z" /> d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z" />
<path fill-rule="evenodd" <path fill-rule="evenodd"

View File

@ -0,0 +1,29 @@
@keyframes SmoothAppearance {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.LogsFilters__inputWrapper {
position: relative;
}
.LogsFilters__clearButton {
position: absolute;
right: 8px;
top: 0;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
}
.LogsFilters__inputWrapper:hover .LogsFilters__clearButton {
opacity: 1;
animation-name: SmoothAppearance;
animation-duration: 250ms;
}

View File

@ -2,14 +2,27 @@ import Component from '../component/index';
import routeService from '../../services/RouteService'; import routeService from '../../services/RouteService';
import {createElement} from '../../utils/elementUtils'; import {createElement} from '../../utils/elementUtils';
import {LOG_TYPE, LOG_LABELS} from '../../consts'; import {LOG_TYPE, LOG_LABELS} from '../../consts';
import './LogsFilters.css';
class LogsFilters extends Component { class LogsFilters extends Component {
constructor (parentNode) { constructor (parentNode) {
super('#logs-filters', parentNode); super('#logs-filters', parentNode);
this.initFilter(); this.initFilter();
this.resetButton = this.mainNode.querySelector('.LogsFilters__resetButton');
this.addEventListener(this.mainNode, 'submit', this.submit); this.addEventListener(this.mainNode, 'submit', this.submit);
this.addEventListener(this.typeInput, 'change', this.changeType); this.addEventListener(this.typeInput, 'change', this.changeType);
this.addEventListener(this.resetButton, 'click', this.clearFilter);
}
clearFilter = () => {
this.serverInputs.concat(this.clientInputs).forEach(({input}) => {
input.value = '';
});
routeService.pushQuery({
tableType: this.typeInput.value,
}, true);
} }
changeType = () => { changeType = () => {
@ -47,10 +60,14 @@ class LogsFilters extends Component {
initInput = ({name, id}) => { initInput = ({name, id}) => {
const input = this.mainNode.querySelector(`#${id}`); const input = this.mainNode.querySelector(`#${id}`);
const clearButton = input.parentNode.querySelector('.LogsFilters__clearButton');
this.addEventListener(clearButton, 'click', () => {
input.value = '';
});
return { return {
name, name,
input, input,
parentNode: input.parentNode, parentNode: input.parentNode.parentNode,
}; };
} }

View File

@ -130,7 +130,7 @@ class LogsPage extends Component {
this.table.render(rows); this.table.render(rows);
this.addSubscribe(this.table, EVENTS.ROW_CLICK, (_, row) => { this.addSubscribe(this.table, EVENTS.ROW_DOUBLE_CLICK, (_, row) => {
const findedRow = preparedRows.find((item) => item._id === row._id); const findedRow = preparedRows.find((item) => item._id === row._id);
this.openRowForView(tableType, findedRow); this.openRowForView(tableType, findedRow);
}); });

View File

@ -80,6 +80,9 @@ class Table extends Component {
this.addSubscribe(tr, EVENTS.ROW_CLICK, (event) => { this.addSubscribe(tr, EVENTS.ROW_CLICK, (event) => {
this.next(EVENTS.ROW_CLICK, event, row); this.next(EVENTS.ROW_CLICK, event, row);
}); });
this.addSubscribe(tr, EVENTS.ROW_DOUBLE_CLICK, (event) => {
this.next(EVENTS.ROW_DOUBLE_CLICK, event, row);
});
const rowComponent = this.renderRow(tr.mainNode, this.cols, row); const rowComponent = this.renderRow(tr.mainNode, this.cols, row);
return { return {
tr, tr,

View File

@ -8,6 +8,10 @@ class TableRowWrapper extends Component {
this.addEventListener(this.mainNode, 'click', () => { this.addEventListener(this.mainNode, 'click', () => {
this.next(EVENTS.ROW_CLICK); this.next(EVENTS.ROW_CLICK);
}); });
this.addEventListener(this.mainNode, 'dblclick', () => {
this.next(EVENTS.ROW_DOUBLE_CLICK);
});
} }
} }

View File

@ -34,6 +34,7 @@ export const EVENTS = {
ROUTE_CHANGE: 'routeChange', ROUTE_CHANGE: 'routeChange',
ROUTE_SEARCH_CHANGE: 'routeSearchChange', ROUTE_SEARCH_CHANGE: 'routeSearchChange',
ROW_CLICK: 'rowClick', ROW_CLICK: 'rowClick',
ROW_DOUBLE_CLICK: 'rowDoubleClick',
}; };
export const FORM_TYPES = { export const FORM_TYPES = {