<commit_before>import React from 'react';
import ReactDOM from 'react-dom';
import {Table, Button} from 'react-bootstrap';
import {Page, PageHeader, DataTable} from 'components';

import queryUrl from 'query-url';

const loader = Promise.all([queryUrl]);

class GroupIndex extends React.Component {
  componentDidMount() {
    loader.then(() => {
      var $table = $('.js-group-table').dataTable({
        ajax: {
          url: $.queryUrl('admin/groups.json')
        },
        order: [],
        columns: [
          {
            title: '名称',
            data: 'name'
          },
          {
            title: '顺序',
            data: 'sort',
            sortable: true
          },
          {
            title: '状态',
            data: 'wechatId',
            render: function (data) {
              if (data > 0) {
                return '已同步';
              }
              return '未同步';
            }
          },
          {
            title: '操作',
            data: 'id',
            createdCell: (td, val) => {
              ReactDOM.render(<span>
                <a href={$.url('admin/groups/%s/edit', val)}>
                  编辑
                </a>
                {' '}
                <a className="text-danger delete-record" href="javascript:"
                  data-href={$.url('admin/groups/%s/destroy', val)}>
                  删除
                </a>
              </span>, td);
            }
          }
        ]
      });

      //$table.deletable();

      $('#sync-from-wechat').click(function () {
        var icon = $(this).find('.fa-refresh');
        icon.addClass('fa-spin');
        $.ajax({
          url: $.url('admin/wechat-groups/sync-from-wechat'),
          dataType: 'json',
          success: function (result) {
            if (result.code > 0) {
              $.alert(result.message);
            } else {
              $.err(result.message);
            }
            $table.reload();
          },
          complete: function () {
            icon.removeClass('fa-spin');
          }
        });
      });
    });
  }

  render() {
    return (
      <Page>
        <PageHeader>
          <Button id="sync-from-wechat">
            <i className="fa fa-refresh" /> 从微信同步分组<commit_msg>增加deletable<commit_after>import React from 'react';
import ReactDOM from 'react-dom';
import {Table, Button} from 'react-bootstrap';
import {Page, PageHeader, DataTable} from 'components';

import queryUrl from 'query-url';

const loader = Promise.all([queryUrl]);

class GroupIndex extends React.Component {
  componentDidMount() {
    loader.then(() => {
      var $table = $('.js-group-table').dataTable({
        ajax: {
          url: $.queryUrl('admin/groups.json')
        },
        order: [],
        columns: [
          {
            title: '名称',
            data: 'name'
          },
          {
            title: '顺序',
            data: 'sort',
            sortable: true
          },
          {
            title: '状态',
            data: 'wechatId',
            render: function (data) {
              if (data > 0) {
                return '已同步';
              }
              return '未同步';
            }
          },
          {
            title: '操作',
            data: 'id',
            createdCell: (td, val) => {
              ReactDOM.render(<span>
                <a href={$.url('admin/groups/%s/edit', val)}>
                  编辑
                </a>
                {' '}
                <a className="js-delete-record text-danger" href="javascript:"
                  data-href={$.url('admin/groups/%s/destroy', val)}>
                  删除
                </a>
              </span>, td);
            }
          }
        ]
      });

      $table.deletable();

      $('#sync-from-wechat').click(function () {
        var icon = $(this).find('.fa-refresh');
        icon.addClass('fa-spin');
        $.ajax({
          url: $.url('admin/wechat-groups/sync-from-wechat'),
          dataType: 'json',
          success: function (result) {
            if (result.code > 0) {
              $.alert(result.message);
            } else {
              $.err(result.message);
            }
            $table.reload();
          },
          complete: function () {
            icon.removeClass('fa-spin');
          }
        });
      });
    });
  }

  render() {
    return (
      <Page>
        <PageHeader>
          <Button id="sync-from-wechat">
            <i className="fa fa-refresh" /> 从微信同步分组
{'fraction_non_alphanumeric': 0.15534633490248823, 'fraction_numerical': 0.0008966599417171038, 'mean_word_length': 1.2221115537848606, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6322880', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1280, 'n_words': 241}