<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('firewalld rules list')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:params:add">
                    <i class="fa fa-plus"></i> <span th:text="#{btn.add}"></span>
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:firewalld:edit">
                    <i class="fa fa-edit"></i> <span th:text="#{btn.edit}"></span>
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:firewalld:remove">
                    <i class="fa fa-remove"></i> <span th:text="#{btn.del}"></span>
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:firewalld:export">
                    <i class="fa fa-download"></i> <span th:text="#{btn.export}"></span>
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:firewalld:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:firewalld:remove')}]];
        var prefix = ctx + "system/firewalld";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: i18n('firewalld.manage.table.modalName'),
                columns: [{
                    checkbox: true
                },
                {
                    field: 'protocol',
                    title: i18n('firewalld.manage.query.protocol'),
                    width: 150
                },
                {
                    field: 'portStart',
                    title: i18n('firewalld.manage.query.portStart'),
                    width: 150
                },
                {
                    field: 'portEnd',
                    title: i18n('firewalld.manage.table.portEnd'),
                    width: 150
                },
                {
                        field: 'fromSource',
                        title: i18n('firewalld.manage.table.fromSource'),
                        width: 150
                },
                {
                    title: i18n('params.manage.table.opra'),
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.allowEdit === 1) {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>' + i18n('btn.edit') + '</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>' + i18n('btn.del') + '</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

    </script>
</body>
</html>