Skip to content

Commit

Permalink
fix front warnning and chang shell
Browse files Browse the repository at this point in the history
  • Loading branch information
zhishufei committed Nov 22, 2023
1 parent 74b000a commit 3b02e1a
Show file tree
Hide file tree
Showing 62 changed files with 725 additions and 2,303 deletions.
2 changes: 1 addition & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ HOLMES_SECRET_KEY=SEC_KEY
# allow custom js visualizations
HOLMES_FEATURE_ALLOW_CUSTOM_JS_VISUALIZATIONS=True
# Language CN/EN, only ip address ,no
WEB_LANGUAGE=LANG
WEB_LANGUAGE=LANGTYPE
# web server ip address or domain,for ai get database config option. port 5000,same with Docker
WEB_SERVER=IP:WEB_PORT
# api secret key for ai get database config option
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ client/dist
_build
.vscode
.env

dump.rdb

user_upload_files/*
node_modules
.tmp
.sass-cache
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ EXPOSE 8338 8339
ARG skip_ds_deps=true
# Controls whether to install dev dependencies. If need, set skip_dev_deps eq ''
ARG skip_dev_deps=yes
#RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list
#RUN echo "deb http://mirrors.aliyun.com/debian/ buster main" > /etc/apt/sources.list
## Create user
RUN useradd --create-home holmes
## Ubuntu use aliyun source
Expand Down Expand Up @@ -74,14 +76,14 @@ ENV PIP_NO_CACHE_DIR=1
## copy webpack build file to image
COPY --from=frontend-builder /frontend/client/dist /app/client/dist
## rollback pip version to avoid legacy resolver problem
RUN pip install pip==20.2.4;
RUN pip install pip==20.2.4
## We first copy only the requirements file, to avoid rebuilding on every file change.
RUN if [ "x$skip_dev_deps" = "x" ] ; then pip install -r requirements_dev.txt ; fi
#
RUN pip install -r requirements.txt && pip install -r requirements_ai.txt
#
## fix python 3.8.18 error import .
RUN docker /usr/local/lib/python3.8/site-packages/saml2/sigver.py && \
RUN sed -i 's/from importlib_resources import path/from importlib.resources import path/g' /usr/local/lib/python3.8/site-packages/saml2/sigver.py && \
sed -i 's/from importlib_resources import path/from importlib.resources import path/g' /usr/local/lib/python3.8/site-packages/saml2/xml/schema/__init__.py && \
chown holmes /app && chmod +x /app/ai/main.py

Expand Down
92 changes: 92 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
FROM node:14.17 as frontend-builder

RUN npm install --global --force [email protected]


# Controls whether to build the frontend assets
ARG skip_frontend_build
ENV CYPRESS_INSTALL_BINARY=0
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1

RUN useradd -m -d /frontend holmes
USER holmes

WORKDIR /frontend
COPY --chown=holmes package.json yarn.lock .yarnrc /frontend/
COPY --chown=holmes client /frontend/client
COPY --chown=holmes package.json /frontend/
COPY --chown=holmes webpack.config.js /frontend/
COPY --chown=holmes .env /frontend/

# Controls whether to instrument code for coverage information
ARG code_coverage
ENV BABEL_ENV=${code_coverage:+test}
# limit requires network concurrency to 1
# RUN yarn install --network-concurrency 1;

RUN yarn && yarn build

FROM python:3.8.18-slim
## out port
EXPOSE 8338 8339
# Controls whether to install extra dependencies needed for all data sources.
ARG skip_ds_deps=true
# Controls whether to install dev dependencies. If need, set skip_dev_deps eq ''
ARG skip_dev_deps=yes
#RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list
#RUN echo "deb http://mirrors.aliyun.com/debian/ buster main" > /etc/apt/sources.list
## Create user
RUN useradd --create-home holmes
## Ubuntu use aliyun source
RUN apt-get update
## Ubuntu packages
RUN apt-get clean && apt-get update && \
apt-get install -y --no-install-recommends \
curl \
gnupg \
build-essential \
pwgen \
libffi-dev \
sudo \
git-core \
# Postgres client
libpq-dev \
# ODBC support:
g++ unixodbc-dev \
# for SAML
xmlsec1 \
# Additional packages required for data sources:
libssl-dev \
default-libmysqlclient-dev \
freetds-dev \
libsasl2-dev \
unzip \
libsasl2-modules-gssapi-mit && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
#
# ali pip source
#CN#RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
#CN#RUN pip install --upgrade pip
COPY --chown=holmes . /app
WORKDIR /app
## Disable PIP Cache and Version Check
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PIP_NO_CACHE_DIR=1
## copy webpack build file to image
COPY --from=frontend-builder /frontend/client/dist /app/client/dist
## rollback pip version to avoid legacy resolver problem
RUN pip install pip==20.2.4
## We first copy only the requirements file, to avoid rebuilding on every file change.
RUN if [ "x$skip_dev_deps" = "x" ] ; then pip install -r requirements_dev.txt ; fi
#
RUN pip install -r requirements.txt && pip install -r requirements_ai.txt
#
## fix python 3.8.18 error import .
RUN sed -i 's/from importlib_resources import path/from importlib.resources import path/g' /usr/local/lib/python3.8/site-packages/saml2/sigver.py && \
sed -i 's/from importlib_resources import path/from importlib.resources import path/g' /usr/local/lib/python3.8/site-packages/saml2/xml/schema/__init__.py && \
chown holmes /app && chmod +x /app/ai/main.py

ENTRYPOINT ["/app/bin/docker-entrypoint"]
CMD ["server"]

13 changes: 11 additions & 2 deletions Install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/bin/bash
export LANG=en_US.UTF-8
if [ -f .env ]; then
rm .env
fi


if [ -f Dockerfile ]; then
rm Dockerfile
fi
# Install.sh, you mast have installed docker and docker-compose
# check docker support
if ! command -v docker &> /dev/null; then
Expand Down Expand Up @@ -49,6 +54,9 @@ web_port=8338
socket_port=8339
# get env_template content
env_content=$(cat .env.template)
# replace language
# shellcheck disable=SC2001
env_content=$(echo "$env_content" | sed "s/LANGTYPE/EN/g")
# replace web port
# shellcheck disable=SC2001
env_content=$(echo "$env_content" | sed "s/WEB_PORT/$web_port/g")
Expand All @@ -64,6 +72,7 @@ sec_key=$(openssl rand -hex 16)
env_content=$(echo "$env_content" | sed "s/SEC_KEY/$sec_key/g")
# save .env file
echo "$env_content" > .env
cp Dockerfile.template Dockerfile
# save env file over
echo "You setting as fellows:"
echo "--------------------------------"
Expand All @@ -90,7 +99,7 @@ echo "--------------------------------"
echo "Run: docker-compose up......"
docker-compose up -d
echo "--------------------------------"
echo "You can visit http://$ip:8338"
echo "You can visit http://$ip:$web_port"
echo "--------------------------------"


13 changes: 10 additions & 3 deletions Install_cn.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/bin/bash
export LANG=en_US.UTF-8
# 安装文件
if [ -f .env ]; then
rm .env
fi

if [ -f Dockerfile ]; then
rm Dockerfile
fi
# 检测docker
if ! command -v docker &> /dev/null; then
echo " 需要安装 docker, 参考:https://github.com/Deep-thoughtIO/holmes/InstallDockerCN.md "
Expand Down Expand Up @@ -47,7 +54,7 @@ socket_port=8339
# 复制 .env file基础内容
env_content=$(cat .env.template)
# replace language
env_content=$(echo "$env_content" | sed "s/LANG/CN/g")
env_content=$(echo "$env_content" | sed "s/LANGTYPE/CN/g")
# replace web port
# shellcheck disable=SC2001
env_content=$(echo "$env_content" | sed "s/WEB_PORT/$web_port/g")
Expand All @@ -61,7 +68,7 @@ env_content=$(echo "$env_content" | sed "s/SEC_KEY/$sec_key/g")
# save .env file,保存文件
echo "$env_content" > .env
# 修改配置 pip 为国内清华源
sed -i '' -e 's/#CN#//g' Dockerfile
sed 's/#CN#//g' Dockerfile.template > Dockerfile
# 输出说明:
echo "所有配置如下:"
echo "--------------------------------"
Expand Down Expand Up @@ -89,7 +96,7 @@ echo "--------------------------------"
echo "现在,创建并启动容器......"
docker-compose up -d
echo "--------------------------------"
echo "启动成功,你可以访问 http://$ip:5000"
echo "启动成功,你可以访问 http://$ip:$web_port"
echo "--------------------------------"
echo "谢谢,如果有问题,可以给我们提issue "

Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,23 @@ import Menu from "antd/lib/menu";
import Link from "@/components/Link";
import PlainButton from "@/components/PlainButton";
import HelpTrigger from "@/components/HelpTrigger";
import CreateDashboardDialog from "@/components/dashboards/CreateDashboardDialog";
import { useCurrentRoute } from "@/components/ApplicationArea/Router";
import { Auth, currentUser } from "@/services/auth";
import settingsMenu from "@/services/settingsMenu";
import logoUrl from "@/assets/images/icon_small.png";

import DesktopOutlinedIcon from "@ant-design/icons/DesktopOutlined";

import AlertOutlinedIcon from "@ant-design/icons/AlertOutlined";

import CommentOutlinedIcon from "@ant-design/icons/CommentOutlined";
import BarsOutlinedIcon from "@ant-design/icons/BarsOutlined";
import LineChartOutlinedIcon from "@ant-design/icons/LineChartOutlined";
import DashboardOutlinedIcon from "@ant-design/icons/DashboardOutlined";
import OrderedListOutlinedIcon from "@ant-design/icons/OrderedListOutlined";


import PlusOutlinedIcon from "@ant-design/icons/PlusOutlined";

import QuestionCircleOutlinedIcon from "@ant-design/icons/QuestionCircleOutlined";
import SettingOutlinedIcon from "@ant-design/icons/SettingOutlined";
import VersionInfo from "./VersionInfo";

// import {lockReconnect,websocket,lockReconnectEvent} from "../Dialogue/websocket.js"
import {lockReconnect,websocket,lockReconnectEvent} from "@/pages/testdialogue/components/Dialogue/websocket.js"
import {lockReconnectEvent} from "@/pages/testdialogue/components/Dialogue/websocket.js"

import "./DesktopNavbar.less";

Expand Down Expand Up @@ -83,9 +75,9 @@ export default function DesktopNavbar() {

const activeState = useNavbarActiveState();

const canCreateQuery = currentUser.hasPermission("create_query");
const canCreateDashboard = currentUser.hasPermission("create_dashboard");
const canCreateAlert = currentUser.hasPermission("list_alerts");
// const canCreateQuery = currentUser.hasPermission("create_query");
// const canCreateDashboard = currentUser.hasPermission("create_dashboard");
// const canCreateAlert = currentUser.hasPermission("list_alerts");

const [socketType,setSocketType] = useState(0)
useEffect(() => {
Expand Down Expand Up @@ -162,32 +154,6 @@ export default function DesktopNavbar() {


<NavbarSection style={{flex:"1"}}>
{/* <Menu.Item key="testdialogue" className={activeState.testdialogue ? "navbar-active-item" : null}>
<Link href="./">
<CommentOutlinedIcon aria-label="testdialogue navigation button" />
<span className="desktop-navbar-label">{window.W_L.data_analysis}</span>
</Link>
</Menu.Item>
<Menu.Item key="dialogue_list" className={activeState.dialogue_list ? "navbar-active-item" : null}>
<Link href="dialogue-list">
<OrderedListOutlinedIcon aria-label="dialogue_list navigation button" />
<span className="desktop-navbar-label">{window.W_L.dialogue_list}</span>
</Link>
</Menu.Item> */}
{/* {currentUser.hasPermission("list_dashboards") && ( */}
{/* <Menu.Item key="report_route" className={activeState.report_route ? "navbar-active-item" : null}>
<Link href="report-route">
<LineChartOutlinedIcon aria-label="report_route navigation button" />
<span className="desktop-navbar-label">{window.W_L.report_generation}</span>
</Link>
</Menu.Item>
<Menu.Item key="queries" className={activeState.queries ? "navbar-active-item" : null}>
<Link href="queries">
<BarsOutlinedIcon aria-label="Queries navigation button" />
<span className="desktop-navbar-label">{window.W_L.report_list}</span>
</Link>
</Menu.Item> */}
<Menu.Item key="dashboards" className={activeState.dashboards ? "navbar-active-item" : null}>
<Link href="dashboards">
<DashboardOutlinedIcon aria-label="dashboards navigation button" />
Expand Down Expand Up @@ -224,8 +190,8 @@ export default function DesktopNavbar() {
<span data-test="ProfileDropdown" className="desktop-navbar-profile-menu-title">
<img className="profile__image_thumb" src={currentUser.profile_image_url} alt={currentUser.name} />
<div className="profile__live__type">
<span style={{"background":socketType==0?"red":socketType==1?"green":"yellow"}}></span>
<div>{socketType==0?window.W_L.offline:socketType==1?window.W_L.online:window.W_L.pending}</div>
<span style={{"background":socketType===0?"red":socketType===1?"green":"yellow"}}></span>
<div>{socketType===0?window.W_L.offline:socketType===1?window.W_L.online:window.W_L.pending}</div>
</div>
</span>
}>
Expand Down
4 changes: 2 additions & 2 deletions client/app/components/ApplicationArea/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export default function ApplicationArea() {
}

// moment.locale('zh-cn')
window.W_L.language_mode=="CN"?moment.locale('zh-cn'):moment.locale('en')
window.W_L.language_mode==="CN"?moment.locale('zh-cn'):moment.locale('en')
return (
<ConfigProvider locale={window.W_L.language_mode=="CN"?zh_CN:""}>
<ConfigProvider locale={window.W_L.language_mode==="CN"?zh_CN:""}>
<Router routes={routes.items} onRouteChange={setCurrentRoute} />
</ConfigProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { formatDateTime } from "@/lib/utils";
import Link from "@/components/Link";
import Parameters from "@/components/Parameters";
import TimeAgo from "@/components/TimeAgo";
import Modal from "antd/lib/modal";
// import Modal from "antd/lib/modal";
import Timer from "@/components/Timer";
import { Moment } from "@/components/proptypes";
import QueryLink from "@/components/QueryLink";
Expand Down Expand Up @@ -79,29 +79,29 @@ function visualizationWidgetMenuOptions({ widget, canEditDashboard, onParameters
]);
}

function HandleFullScreen({href}){
const [visible, setVisible] = useState(false);
const handleOk = () => {
// function HandleFullScreen({href}){
// const [visible, setVisible] = useState(false);
// const handleOk = () => {

setVisible(true);
};
return(
<>
<span onClick={handleOk}>{window.W_L.edit_query}</span>
<Modal
wrapClassName="ant-modal-fullscreen"
title=""
footer={
[]
}
onClose={()=>setVisible(false)}
visible={visible}
>
<iframe style={{width:"100%",height:"100%"}} title="Report Display" src={href} frameborder="0"></iframe>
</Modal>
</>
)
}
// setVisible(true);
// };
// return(
// <>
// <span onClick={handleOk}>{window.W_L.edit_query}</span>
// <Modal
// wrapClassName="ant-modal-fullscreen"
// title=""
// footer={
// []
// }
// onClose={()=>setVisible(false)}
// visible={visible}
// >
// <iframe style={{width:"100%",height:"100%"}} title="Report Display" src={href} frameborder="0"></iframe>
// </Modal>
// </>
// )
// }
function RefreshIndicator({ refreshStartedAt }) {
return (
<div className="refresh-indicator">
Expand Down
1 change: 0 additions & 1 deletion client/app/components/empty-state/EmptyState.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import CloseOutlinedIcon from "@ant-design/icons/CloseOutlined";
import Link from "@/components/Link";
import PlainButton from "@/components/PlainButton";
import CreateDashboardDialog from "@/components/dashboards/CreateDashboardDialog";
import HelpTrigger from "@/components/HelpTrigger";
import { currentUser } from "@/services/auth";
import organizationStatus from "@/services/organizationStatus";

Expand Down
Loading

0 comments on commit 3b02e1a

Please sign in to comment.