From 3aa25da75b8f1c0bb1000d26327f0992f044b746 Mon Sep 17 00:00:00 2001 From: Xinhao Yuan Date: Mon, 26 Jun 2023 10:17:56 +0800 Subject: [PATCH] feat: add .eslintrc and format all code (#11) --- web/.eslintrc | 112 ++++++++++++++++++++ web/src/App.js | 141 +++++++++++++------------ web/src/App.test.js | 10 +- web/src/AuthCallback.js | 12 +-- web/src/ClusteringPage.js | 4 +- web/src/Conf.js | 2 +- web/src/DataChart.js | 36 +++---- web/src/FileTable.js | 66 ++++++------ web/src/FileTree.js | 150 +++++++++++++-------------- web/src/HomePage.js | 4 +- web/src/LabelTable.js | 104 +++++++++---------- web/src/PermissionUtil.js | 4 +- web/src/Setting.js | 64 ++++++------ web/src/SigninPage.js | 4 +- web/src/StoreEditPage.js | 46 ++++---- web/src/StoreListPage.js | 60 +++++------ web/src/VectorTable.js | 68 ++++++------ web/src/VectorsetEditPage.js | 66 ++++++------ web/src/VectorsetListPage.js | 92 ++++++++-------- web/src/Video.js | 24 ++--- web/src/VideoDataChart.js | 46 ++++---- web/src/VideoEditPage.js | 98 ++++++++--------- web/src/VideoListPage.js | 112 ++++++++++---------- web/src/WordsetEditPage.js | 60 +++++------ web/src/WordsetGraph.js | 110 ++++++++++---------- web/src/WordsetGraphPage.js | 4 +- web/src/WordsetListPage.js | 86 +++++++-------- web/src/backend/AccountBackend.js | 24 ++--- web/src/backend/FileBackend.js | 20 ++-- web/src/backend/PermissionBackend.js | 24 ++--- web/src/backend/StoreBackend.js | 24 ++--- web/src/backend/VectorsetBackend.js | 26 ++--- web/src/backend/VideoBackend.js | 26 ++--- web/src/backend/WordsetBackend.js | 28 ++--- web/src/i18n.js | 30 +++--- web/src/index.js | 26 ++--- web/src/serviceWorker.js | 30 +++--- 37 files changed, 976 insertions(+), 867 deletions(-) create mode 100644 web/.eslintrc diff --git a/web/.eslintrc b/web/.eslintrc new file mode 100644 index 0000000..26aa391 --- /dev/null +++ b/web/.eslintrc @@ -0,0 +1,112 @@ +{ + "env": { + "browser": true, + "es6": true, + "node": true + }, + "parser": "@babel/eslint-parser", + "parserOptions": { + "ecmaVersion": 12, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + }, + "requireConfigFile": false, + "babelOptions": { + "babelrc": false, + "configFile": false, + "presets": ["@babel/preset-react"] + } + }, + "settings": { + "react": { + "version": "detect" + } + }, + "plugins": ["unused-imports"], + "extends": ["eslint:recommended", "plugin:react/recommended"], + "rules": { + "semi": ["error", "always"], + "indent": ["error", 2], + // follow antd's style guide + "quotes": ["error", "double"], + "jsx-quotes": ["error", "prefer-double"], + "space-in-parens": ["error", "never"], + "object-curly-spacing": ["error", "never"], + "array-bracket-spacing": ["error", "never"], + "comma-spacing": ["error", { "before": false, "after": true }], + "react/jsx-curly-spacing": [ + "error", + { "when": "never", "allowMultiline": true, "children": true } + ], + "arrow-spacing": ["error", { "before": true, "after": true }], + "space-before-blocks": ["error", "always"], + "spaced-comment": ["error", "always"], + "react/jsx-tag-spacing": ["error", { "beforeSelfClosing": "always" }], + "block-spacing": ["error", "never"], + "space-before-function-paren": ["error", "never"], + "no-trailing-spaces": ["error", { "ignoreComments": true }], + "eol-last": ["error", "always"], + "no-var": ["error"], + "prefer-const": [ + "error", + { + "destructuring": "all" + } + ], + "curly": ["error", "all"], + "brace-style": ["error", "1tbs", { "allowSingleLine": true }], + "no-mixed-spaces-and-tabs": "error", + "sort-imports": [ + "error", + { + "ignoreDeclarationSort": true + } + ], + "no-multiple-empty-lines": [ + "error", + { "max": 1, "maxBOF": 0, "maxEOF": 0 } + ], + "space-unary-ops": ["error", { "words": true, "nonwords": false }], + "space-infix-ops": "error", + "key-spacing": ["error", { "beforeColon": false, "afterColon": true }], + "comma-style": ["error", "last"], + "comma-dangle": [ + "error", + { + "arrays": "always-multiline", + "objects": "always-multiline", + "imports": "never", + "exports": "never", + "functions": "never" + } + ], + "no-multi-spaces": ["error", { "ignoreEOLComments": true }], + "react/no-unknown-property": [ + "error", + { + "ignore": ["css"] + } + ], + "unused-imports/no-unused-imports": "error", + "unused-imports/no-unused-vars": [ + "error", + { + "vars": "all", + "varsIgnorePattern": "^_", + "args": "none", + "argsIgnorePattern": "^_" + } + ], + "no-unused-vars": "off", + "react/no-deprecated": "error", + "react/jsx-key": "error", + "no-console": "error", + "eqeqeq": "error", + "keyword-spacing": "error", + "react/prop-types": "off", + "react/display-name": "off", + "react/react-in-jsx-scope": "off", + "no-case-declarations": "off" + } +} \ No newline at end of file diff --git a/web/src/App.js b/web/src/App.js index 0107f0d..224c025 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -1,8 +1,8 @@ -import React, {Component} from 'react'; -import {Switch, Redirect, Route, withRouter, Link} from 'react-router-dom'; -import {Avatar, BackTop, Dropdown, Layout, Menu} from 'antd'; -import {createFromIconfontCN, DownOutlined, LogoutOutlined, SettingOutlined} from '@ant-design/icons'; -import './App.less'; +import React, {Component} from "react"; +import {Link, Redirect, Route, Switch, withRouter} from "react-router-dom"; +import {Avatar, BackTop, Dropdown, Layout, Menu} from "antd"; +import {DownOutlined, LogoutOutlined, SettingOutlined, createFromIconfontCN} from "@ant-design/icons"; +import "./App.less"; import * as Setting from "./Setting"; import * as AccountBackend from "./backend/AccountBackend"; import AuthCallback from "./AuthCallback"; @@ -25,7 +25,7 @@ import i18next from "i18next"; const {Header, Footer} = Layout; const IconFont = createFromIconfontCN({ - scriptUrl: '//at.alicdn.com/t/font_2680620_ffij16fkwdg.js', + scriptUrl: "//at.alicdn.com/t/font_2680620_ffij16fkwdg.js", }); class App extends Component { @@ -61,32 +61,32 @@ class App extends Component { this.setState({ uri: uri, }); - if (uri === '/home') { - this.setState({selectedMenuKey: '/home'}); - } else if (uri.includes('/stores')) { - this.setState({ selectedMenuKey: '/stores' }); - } else if (uri.includes('/clustering')) { - this.setState({ selectedMenuKey: '/clustering' }); - } else if (uri.includes('/wordsets')) { - this.setState({ selectedMenuKey: '/wordsets' }); - } else if (uri.includes('/vectorsets')) { - this.setState({ selectedMenuKey: '/vectorsets' }); - } else if (uri.includes('/videos')) { - this.setState({ selectedMenuKey: '/videos' }); + if (uri === "/home") { + this.setState({selectedMenuKey: "/home"}); + } else if (uri.includes("/stores")) { + this.setState({selectedMenuKey: "/stores"}); + } else if (uri.includes("/clustering")) { + this.setState({selectedMenuKey: "/clustering"}); + } else if (uri.includes("/wordsets")) { + this.setState({selectedMenuKey: "/wordsets"}); + } else if (uri.includes("/vectorsets")) { + this.setState({selectedMenuKey: "/vectorsets"}); + } else if (uri.includes("/videos")) { + this.setState({selectedMenuKey: "/videos"}); } else { - this.setState({selectedMenuKey: 'null'}); + this.setState({selectedMenuKey: "null"}); } } onUpdateAccount(account) { this.setState({ - account: account + account: account, }); } setLanguage(account) { // let language = account?.language; - let language = localStorage.getItem("language"); + const language = localStorage.getItem("language"); if (language !== "" && language !== i18next.language) { Setting.setLanguage(language); } @@ -95,7 +95,7 @@ class App extends Component { getAccount() { AccountBackend.getAccount() .then((res) => { - let account = res.data; + const account = res.data; if (account !== null) { this.setLanguage(account); } @@ -109,12 +109,12 @@ class App extends Component { signout() { AccountBackend.signout() .then((res) => { - if (res.status === 'ok') { + if (res.status === "ok") { this.setState({ - account: null + account: null, }); - Setting.showMessage("success", `Successfully signed out, redirected to homepage`); + Setting.showMessage("success", "Successfully signed out, redirected to homepage"); Setting.goToLink("/"); // this.props.history.push("/"); } else { @@ -124,9 +124,9 @@ class App extends Component { } handleRightDropdownClick(e) { - if (e.key === '/account') { + if (e.key === "/account") { Setting.openLink(Setting.getMyProfileUrl(this.state.account)); - } else if (e.key === '/logout') { + } else if (e.key === "/logout") { this.signout(); } } @@ -134,16 +134,16 @@ class App extends Component { renderAvatar() { if (this.state.account.avatar === "") { return ( - + {Setting.getShortName(this.state.account.name)} - ) + ); } else { return ( - + {Setting.getShortName(this.state.account.name)} - ) + ); } } @@ -163,7 +163,7 @@ class App extends Component { return ( -
+
    { @@ -177,24 +177,24 @@ class App extends Component {  
- ) + ); } renderAccount() { - let res = []; + const res = []; if (this.state.account === undefined) { return null; } else if (this.state.account === null) { res.push( - + {i18next.t("account:Sign Up")} ); res.push( - + {i18next.t("account:Sign In")} @@ -203,19 +203,19 @@ class App extends Component { } else { res.push(this.renderRightDropdown()); return ( -
+
{ res }
- ) + ); } return res; } renderMenu() { - let res = []; + const res = []; if (this.state.account === null || this.state.account === undefined) { return []; @@ -298,7 +298,7 @@ class App extends Component { renderHomeIfSignedIn(component) { if (this.state.account !== null && this.state.account !== undefined) { - return + return ; } else { return component; } @@ -307,11 +307,10 @@ class App extends Component { renderSigninIfNotSignedIn(component) { if (this.state.account === null) { sessionStorage.setItem("from", window.location.pathname); - return + return ; } else if (this.state.account === undefined) { return null; - } - else { + } else { return component; } } @@ -319,7 +318,7 @@ class App extends Component { renderContent() { return (
-
+
{ Setting.isMobile() ? null : ( @@ -331,7 +330,7 @@ class App extends Component { // theme="dark" mode={"horizontal"} selectedKeys={[`${this.state.selectedMenuKey}`]} - style={{lineHeight: '64px'}} + style={{lineHeight: "64px"}} > { this.renderMenu() @@ -339,8 +338,8 @@ class App extends Component { { this.renderAccount() } - -
{Setting.changeLanguage("en");}}> + +
{Setting.changeLanguage("en");}}>        English @@ -348,8 +347,8 @@ class App extends Component {  
- -
{Setting.changeLanguage("zh");}}> + +
{Setting.changeLanguage("zh");}}>        中文 @@ -360,24 +359,24 @@ class App extends Component {
- - this.renderHomeIfSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> - this.renderSigninIfNotSignedIn()}/> + + this.renderHomeIfSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} /> + this.renderSigninIfNotSignedIn()} />
- ) + ); } renderFooter() { @@ -387,20 +386,20 @@ class App extends Component { return (
- Made with ❤️ by Casibase, { Setting.isMobile() ? "Mobile" : "Desktop" } View + Made with ❤️ by Casibase, {Setting.isMobile() ? "Mobile" : "Desktop"} View
- ) + ); } render() { return (
- +
{ this.renderContent() diff --git a/web/src/App.test.js b/web/src/App.test.js index a754b20..23c181f 100644 --- a/web/src/App.test.js +++ b/web/src/App.test.js @@ -1,9 +1,9 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import App from './App'; +import React from "react"; +import ReactDOM from "react-dom"; +import App from "./App"; -it('renders without crashing', () => { - const div = document.createElement('div'); +it("renders without crashing", () => { + const div = document.createElement("div"); ReactDOM.render(, div); ReactDOM.unmountComponentAtNode(div); }); diff --git a/web/src/AuthCallback.js b/web/src/AuthCallback.js index ab4bc46..d18c5d1 100644 --- a/web/src/AuthCallback.js +++ b/web/src/AuthCallback.js @@ -1,6 +1,6 @@ import React from "react"; -import { Button, Result, Spin } from "antd"; -import { withRouter } from "react-router-dom"; +import {Button, Result, Spin} from "antd"; +import {withRouter} from "react-router-dom"; import * as Setting from "./Setting"; class AuthCallback extends React.Component { @@ -27,7 +27,7 @@ class AuthCallback extends React.Component { login() { Setting.signin().then((res) => { if (res.status === "ok") { - Setting.showMessage("success", `Logged in successfully`) + Setting.showMessage("success", "Logged in successfully"); const link = this.getFromLink(); Setting.goToLink(link); @@ -41,15 +41,15 @@ class AuthCallback extends React.Component { render() { return ( -
+
{this.state.msg === null ? ( ) : ( -
+
- ) + + ); } } diff --git a/web/src/Conf.js b/web/src/Conf.js index be308f1..23ae748 100644 --- a/web/src/Conf.js +++ b/web/src/Conf.js @@ -13,4 +13,4 @@ export const DefaultWordsetName = "word"; export const ForceLanguage = ""; export const DefaultLanguage = "en"; -export const AppUrl = "" +export const AppUrl = ""; diff --git a/web/src/DataChart.js b/web/src/DataChart.js index 72e13ec..0c3044d 100644 --- a/web/src/DataChart.js +++ b/web/src/DataChart.js @@ -12,13 +12,13 @@ class DataChart extends React.Component { componentWillMount() { fetch(this.props.url, { - method: 'GET', + method: "GET", }).then(res => res.text()) .then((text) => { - if (this.props.filename.startsWith("Impedance_")) { - this.processImpedanceFile(text); - } - }); + if (this.props.filename.startsWith("Impedance_")) { + this.processImpedanceFile(text); + } + }); } getY(y) { @@ -34,7 +34,7 @@ class DataChart extends React.Component { lines = lines.filter((line, index) => index % 20 === 0); let data = lines.map(line => { - let res = []; + const res = []; const tokens = line.split(" "); tokens.forEach((token, index) => { if (index !== 0) { @@ -48,7 +48,7 @@ class DataChart extends React.Component { data = data.map(element => { element[0] = (new Date("0000-01-01 " + element[0]).getTime() - startTime) / 1000 / 60; return element; - }) + }); this.setState({ data: data, @@ -62,11 +62,11 @@ class DataChart extends React.Component { const option = { title: { - text: 'Impedance' + text: "Impedance", }, tooltip: { - trigger: 'axis', - formatter: function (params) { + trigger: "axis", + formatter: function(params) { return JSON.stringify(params.value); }, axisPointer: { @@ -74,31 +74,31 @@ class DataChart extends React.Component { }, }, xAxis: { - type: 'value', + type: "value", splitLine: { show: false, }, }, yAxis: { - type: 'value', - boundaryGap: [0, '100%'], + type: "value", + boundaryGap: [0, "100%"], splitLine: { show: false, }, }, series: [ { - name: 'Fake Data', - type: 'line', + name: "Fake Data", + type: "line", showSymbol: false, data: this.state.data, }, - ] + ], }; return ( - - ) + + ); } } diff --git a/web/src/FileTable.js b/web/src/FileTable.js index fde9c17..6ae9b65 100644 --- a/web/src/FileTable.js +++ b/web/src/FileTable.js @@ -1,5 +1,5 @@ import React from "react"; -import {Button, Popconfirm, Table} from 'antd'; +import {Button, Popconfirm, Table} from "antd"; import {DeleteOutlined, DownloadOutlined, FileDoneOutlined} from "@ant-design/icons"; import * as Setting from "./Setting"; import i18next from "i18next"; @@ -38,7 +38,7 @@ class FileTable extends React.Component { } addRow(table) { - let row = {no: table.length, name: `New Vector - ${table.length}`, data: []}; + const row = {no: table.length, name: `New Vector - ${table.length}`, data: []}; if (table === undefined) { table = []; } @@ -66,7 +66,7 @@ class FileTable extends React.Component { FileBackend.deleteFile(storeId, file.key, isLeaf) .then((res) => { if (res === true) { - Setting.showMessage("success", `File deleted successfully`); + Setting.showMessage("success", "File deleted successfully"); this.props.onRefresh(); } else { Setting.showMessage("error", `File failed to delete: ${res}`); @@ -81,19 +81,19 @@ class FileTable extends React.Component { const columns = [ { title: i18next.t("vectorset:File name"), - dataIndex: 'title', - key: 'title', + dataIndex: "title", + key: "title", // width: '200px', sorter: (a, b) => a.title.localeCompare(b.title), render: (text, record, index) => { return text; - } + }, }, { title: i18next.t("store:Category"), - dataIndex: 'isLeaf', - key: 'isLeaf', - width: '110px', + dataIndex: "isLeaf", + key: "isLeaf", + width: "110px", sorter: (a, b) => a.isLeaf - b.isLeaf, filters: Setting.getDistinctArray(table.map(record => Setting.getFileCategory(record))) .map(fileType => { @@ -102,13 +102,13 @@ class FileTable extends React.Component { onFilter: (value, record) => Setting.getFileCategory(record) === value, render: (text, record, index) => { return Setting.getFileCategory(record); - } + }, }, { title: i18next.t("store:File type"), - dataIndex: 'fileType', - key: 'fileType', - width: '140px', + dataIndex: "fileType", + key: "fileType", + width: "140px", sorter: (a, b) => Setting.getExtFromPath(a.title).localeCompare(Setting.getExtFromPath(b.title)), filters: Setting.getDistinctArray(table.map(record => Setting.getExtFromFile(record))) .filter(fileType => fileType !== "") @@ -118,13 +118,13 @@ class FileTable extends React.Component { onFilter: (value, record) => Setting.getExtFromFile(record) === value, render: (text, record, index) => { return Setting.getExtFromFile(record); - } + }, }, { title: i18next.t("vectorset:File size"), - dataIndex: 'size', - key: 'size', - width: '120px', + dataIndex: "size", + key: "size", + width: "120px", sorter: (a, b) => a.size - b.size, render: (text, record, index) => { if (!record.isLeaf) { @@ -132,38 +132,38 @@ class FileTable extends React.Component { } return Setting.getFriendlyFileSize(text); - } + }, }, { title: i18next.t("general:Created time"), - dataIndex: 'createdTime', - key: 'createdTime', - width: '160px', + dataIndex: "createdTime", + key: "createdTime", + width: "160px", sorter: (a, b) => a.createdTime.localeCompare(b.createdTime), render: (text, record, index) => { return Setting.getFormattedDate(text); - } + }, }, { title: i18next.t("store:Collected time"), - dataIndex: 'collectedTime', - key: 'collectedTime', - width: '160px', + dataIndex: "collectedTime", + key: "collectedTime", + width: "160px", sorter: (a, b) => a.collectedTime.localeCompare(b.collectedTime), render: (text, record, index) => { const collectedTime = Setting.getCollectedTime(record.title); return Setting.getFormattedDate(collectedTime); - } + }, }, { title: i18next.t("store:Subject"), - dataIndex: 'subject', - key: 'subject', - width: '90px', + dataIndex: "subject", + key: "subject", + width: "90px", sorter: (a, b) => a.subject.localeCompare(b.subject), render: (text, record, index) => { return Setting.getSubject(record.title); - } + }, }, // { // title: i18next.t("store:Path"), @@ -206,14 +206,14 @@ class FileTable extends React.Component {
- ) + ); } }} /> ); @@ -226,7 +226,7 @@ class FileTable extends React.Component { this.renderTable(this.props.file.children) }
- ) + ); } } diff --git a/web/src/FileTree.js b/web/src/FileTree.js index c9c096a..5089ce1 100644 --- a/web/src/FileTree.js +++ b/web/src/FileTree.js @@ -1,11 +1,11 @@ import React from "react"; -import {Button, Col, DatePicker, Descriptions, Empty, Input, Modal, Popconfirm, Radio, Row, Select, Spin, Tooltip, Tree, Upload} from 'antd'; -import {CloudUploadOutlined, createFromIconfontCN, DeleteOutlined, DownloadOutlined, FileDoneOutlined, FolderAddOutlined, InfoCircleTwoTone} from "@ant-design/icons"; +import {Button, Col, DatePicker, Descriptions, Empty, Input, Modal, Popconfirm, Radio, Row, Select, Spin, Tooltip, Tree, Upload} from "antd"; +import {CloudUploadOutlined, DeleteOutlined, DownloadOutlined, FileDoneOutlined, FolderAddOutlined, InfoCircleTwoTone, createFromIconfontCN} from "@ant-design/icons"; import moment from "moment"; import * as Setting from "./Setting"; import * as FileBackend from "./backend/FileBackend"; -import DocViewer, { DocViewerRenderers } from "@cyntler/react-doc-viewer"; -import FileViewer from 'react-file-viewer'; +import DocViewer, {DocViewerRenderers} from "@cyntler/react-doc-viewer"; +import FileViewer from "react-file-viewer"; import i18next from "i18next"; import * as PermissionBackend from "./backend/PermissionBackend"; import * as PermissionUtil from "./PermissionUtil"; @@ -17,11 +17,11 @@ import "codemirror/lib/codemirror.css"; // require("codemirror/theme/material-darker.css"); // require("codemirror/mode/javascript/javascript"); -const { Search } = Input; -const { Option } = Select; +const {Search} = Input; +const {Option} = Select; const IconFont = createFromIconfontCN({ - scriptUrl: 'https://cdn.open-ct.com/icon/iconfont.js', + scriptUrl: "https://cdn.open-ct.com/icon/iconfont.js", }); class FileTree extends React.Component { @@ -29,7 +29,7 @@ class FileTree extends React.Component { super(props); this.state = { classes: props, - expandedKeys: ['0-0', '0-0-0', '0-0-0-0'], + expandedKeys: ["0-0", "0-0-0", "0-0-0-0"], checkedKeys: [], checkedFiles: [], selectedKeys: [], @@ -55,7 +55,7 @@ class FileTree extends React.Component { } getPermissionMap(permissions) { - let permissionMap = {}; + const permissionMap = {}; permissions.forEach((permission, index) => { if (permissionMap[permission.resources[0]] === undefined) { permissionMap[permission.resources[0]] = []; @@ -98,14 +98,14 @@ class FileTree extends React.Component { {" " + i18next.t("store:Please choose the type of your data")}
} - visible={this.state.isUploadFileModalVisible} - onCancel={() => { - this.setState({ - isUploadFileModalVisible: false, - }); - }} - width={"360px"} - footer={null} > + visible={this.state.isUploadFileModalVisible} + onCancel={() => { + this.setState({ + isUploadFileModalVisible: false, + }); + }} + width={"360px"} + footer={null} > { this.setState({ uploadFileType: e.target.value, @@ -116,7 +116,7 @@ class FileTree extends React.Component { console.log(this.state.file); console.log(this.state.info); - let newInfo = Setting.deepCopy(this.state.info); + const newInfo = Setting.deepCopy(this.state.info); if (uploadFileType !== "Other") { for (let i = 0; i < newInfo.fileList.length; i++) { const filename = newInfo.fileList[i].name; @@ -129,11 +129,11 @@ class FileTree extends React.Component { }} value={this.state.uploadFileType}> ECG Impedance - {/*EEG*/} + {/* EEG*/} {i18next.t("store:Other")} - ) + ); } uploadFile(file, info) { @@ -152,19 +152,19 @@ class FileTree extends React.Component { Promise.all(promises) .then((values) => { - Setting.showMessage("success", `File uploaded successfully`); + Setting.showMessage("success", "File uploaded successfully"); this.props.onRefresh(); }) .catch(error => { Setting.showMessage("error", `File failed to upload: ${error}`); }); - }; + } addFile(file, newFolder) { const storeId = `${this.props.store.owner}/${this.props.store.name}`; FileBackend.addFile(storeId, file.key, false, newFolder, null) .then((res) => { - Setting.showMessage("success", `File added successfully`); + Setting.showMessage("success", "File added successfully"); this.props.onRefresh(); }) .catch(error => { @@ -177,7 +177,7 @@ class FileTree extends React.Component { FileBackend.deleteFile(storeId, file.key, isLeaf) .then((res) => { if (res === true) { - Setting.showMessage("success", `File deleted successfully`); + Setting.showMessage("success", "File deleted successfully"); this.props.onRefresh(); } else { Setting.showMessage("error", `File failed to delete: ${res}`); @@ -199,9 +199,9 @@ class FileTree extends React.Component { return ( { - Setting.openLink(Setting.getMyProfileUrl(this.props.account).replace("/account", `/permissions/${permission.owner}/${permission.name}`)); - e.stopPropagation(); - }} + Setting.openLink(Setting.getMyProfileUrl(this.props.account).replace("/account", `/permissions/${permission.owner}/${permission.name}`)); + e.stopPropagation(); + }} > { permission.users.map(user => { @@ -212,11 +212,11 @@ class FileTree extends React.Component { Setting.getTag(username, permission.actions[0], permission.state) } - ) + ); }) } - ) + ); } renderPermissions(permissions, isReadable) { @@ -263,11 +263,11 @@ class FileTree extends React.Component { } isFileReadable(file) { - return this.isFileOk(file, "Read") + return this.isFileOk(file, "Read"); } isFileWritable(file) { - return this.isFileOk(file, "Write") + return this.isFileOk(file, "Write"); } isFileAdmin(file) { @@ -275,7 +275,7 @@ class FileTree extends React.Component { return true; } - return this.isFileOk(file, "Admin") + return this.isFileOk(file, "Admin"); } renderSearch() { @@ -287,7 +287,7 @@ class FileTree extends React.Component { selectedFile: null, }); }} /> - ) + ); } getCacheApp(filename) { @@ -317,7 +317,7 @@ class FileTree extends React.Component { loading: true, }); - fetch(url, {method: 'GET'}) + fetch(url, {method: "GET"}) .then(res => res.text()) .then(res => { this.setState({ @@ -327,7 +327,7 @@ class FileTree extends React.Component { }); } } - } + }; const key = info.node.key; const filename = info.node.title; @@ -418,31 +418,31 @@ class FileTree extends React.Component { { !isWritable ? null : ( - {/**/} + {/* */} {/*