Code Monkey home page Code Monkey logo

helpdesk's Introduction

helpdesk

Development

backend

python3.7 -m venv venv
source venv/bin/activate

# edit local_config.py
cp local_config.py.example local_config.py

vi local_config.py

# init database
python -c 'from helpdesk.libs.db import init_db; init_db()'

# init default policy
PS: the ticket related approval flow(policy), Confirm whether there is a default approval process before ticket operate

# export SSL_CERT_FILE='/etc/ssl/certs/ca-certificates.crt'
uvicorn helpdesk:app --host 0.0.0.0 --port 8123 --log-level debug

Visit http://localhost:8123 on your browser. The default listening port of backend is 8123

PS: The user interface in backend web pages will be replaced by new standalone frontend in next major release, please see Standalone frontend if you want to modify the ui.

Standalone frontend

First make sure you have installed latest nodejs

cd frontend
npm install
npm run dev

Follow the link in the console.

PS: If your backend is not hosted in localhost or listening to port other than 8123, please modify the proxyTable config in frontend/config/index.js , see Vue Templates Doc for details

Add new python dependency

pip install <package>
# add to in-requirements.txt
vi in-requirements.txt
# generate new requirements.txt (lock)
pip freeze > requirements.txt

Deployment

Kubernetes

# build docker image
build -t helpdesk .

# push this image to your docker registry
docker tag helpdesk <target image>:<tag>
docker push <target image>:<tag>

# edit helm values
cp contrib/charts/helpdesk/values.yaml values.yaml
vi values.yaml

# install helm package
helm upgrade \
    --install \
    --name helpdesk contrib/charts/helpdesk \
    --namespace=helpdesk \
    -f values.yaml

Get the url from your nginx ingress and visit it.

helpdesk's People

Contributors

dependabot[bot] avatar dispensable avatar everpcpc avatar leoquote avatar qsummery avatar tclh123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

helpdesk's Issues

表单新字段类型 array (列表内的字典), 用户可以点击增加子项

场景

用户需要批量申请很多个资源, 比如需要创建很多个用户, 每个用户都有 姓名, id, 邮箱这些选项

- name: xxx
  id: 1
  email: [email protected]
- name: yyy
  id: 2
  email: [email protected]

当然这些表单也可以转成单个表单, 由用户填很多个单独的表单, 但是审核和申请起来都比较麻烦.

如何实现

前端

做一个新的 widget ,渲染出来是由单行的表单组成, 大概这样

企业微信截图_15958384618109

schema 描述应该是:

"user":{
  "description":"用户",
  "required":true,
  "type":"array",
  "fields": {
    "name": {"description": "用户名", "required":true, "type": "string"},
    "email": {"description": "email", "required":true, "type": "string"},
  }
}

传数据到后端的时候, 目前用的form 表单, 应该是类似 user[0].name = 'xxx' 这样的数据, 这样的数据给到 widge 的时候, 应该是个list , widget 根据 list 内容渲染.

后端

后端看各个provider 的支持情况, airflow 本身比较灵活, 支持应该问题不大, 其他的就不太清楚.

auth header 不合法( 格式不正确, 解析失败 ) 时, 会错误的返回 500

应该返回401 unauthorized , 代码:

try:
if "https://accounts.google.com" in self.metadata_url:
# google's certs would change from time to time, let's refetch it before every try
self.fetch_jwk()
token = jwt.decode(token, self.jwk)
except ValueError as e:
if str(e) == 'Invalid JWK kid':
logger.info(
'This token cannot be decoded with current provider, will try another provider if available.')
return None, None
else:
raise e

应该 except DecodeError

rule 引擎改为 rego?

当前的 rule 可以用来判定, 确认审批流, rule 中其实会有一些个性化的需求, 不适合开源的, 比如请求一些内部资源.

rego 理论上来说, 可以替代当前的这套审批引擎, 不过也同样复杂一些...

select 表单各种不好用, 早日换掉

  1. 使用键盘回车键选择完成后, 表单字段失去焦点, 此时需要重新点击表单字段
  2. 输入框内输入搜索的文字, 选择一个项目后, 输入的搜索文字就会被清空, 一般情况下是够用, 但是在需要输入很多个主机的情况下, 结合上一条, 输入的时候非常痛苦
  3. 单选和复选混用, 造成用户理解困难. 到底是单选还是多选还需要后端或者field 备注才能说清楚.

当初用 antd 的表单, 但是 antd 的表单有性能问题, 所以换成了另一个 select, 结果这个select 也有上面的问题....

真的有点生气了. 看看升级能不能解决, 不能解决就立项前端组件全换了重写算了, 看 antd 不爽很长时间了 🤯

airflow升级到stable rest api

ref: https://airflow.apache.org/docs/apache-airflow/stable/upgrading-from-1-10/index.html#migration-guide-from-experimental-api-to-stable-api-v1

目前的experimental api是手工开启的,可能哪天再升级就没有了。我们用到的很少,应该只有这两个:

url=f'{self.server_url}/api/experimental/dags/{dag_id}/dag_runs',

url=f'{self.server_url}/api/experimental/dags/{dag_id}/dag_runs/{execution_date}', headers=api_headers)

说起来helpdesk的airflow provider plugin也应该放进来,不然其实这个provider是用不了的。

openid auth provider

Add support for multiple openid providers, then resetting ldap password is acceptable when authorized with google.

TemplateNotFound for ticket

Internal error, please contact webadmin500: File "/usr/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 159, in __call__ await self.app(scope, receive, _send) File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 82, in __call__ raise exc from None File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 71, in __call__ await self.app(scope, receive, sender) File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 550, in __call__ await route.handle(scope, receive, send) File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 227, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 41, in app response = await func(request) File "/app/app/libs/rest.py", line 19, in _ ret = await func(*args, **kwargs) File "/app/app/views/api/index.py", line 128, in action ticket, msg = await action.run(provider, form, is_admin=is_admin) File "/app/app/models/action.py", line 110, in run await ticket_added.notify('request') File "/app/app/models/db/ticket.py", line 230, in notify title, content = render_notification('ticket_%s.html' % phase, context=dict(ticket=self, config=config)) File "/app/app/libs/template.py", line 87, in render_notification jinja_template = notification_templates.get_template(template) File "/app/app/libs/template.py", line 51, in get_template return self.env.get_template(name) File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 883, in get_template return self._load_template(name, self.make_globals(globals)) File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 857, in _load_template template = self.loader.load(self, name, globals) File "/usr/local/lib/python3.7/site-packages/jinja2/loaders.py", line 115, in load source, filename, uptodate = self.get_source(environment, name) File "/usr/local/lib/python3.7/site-packages/jinja2/loaders.py", line 197, in get_source raise TemplateNotFound(template)

审批流实现

需要的新功能点如下:

  1. 有一个后端的审批流处理引擎, 可以在不同的审批节点中流转, 流转到节点时通知节点内的所有人, 该节点通过后自动进入下一个节点, 如果不通过工单直接结束
  2. 审批节点支持 用户组, dae app contact (owner 或 pm), 用户 等的组合
  3. 支持一个工单关联多个审批流, 在审批流开始前用某种条件判断, 根据工单内容自动确认使用的审批流, 审批流本身应该是可复用的, 这样多个类似的工单不用重复配置.
  4. 有一个编辑审批流的前端

数据结构

  1. 审批流policy id , name, display, created_by, created_at, updated_by, updated_at, definition definition 内部是一个带版本的 yaml 或 json 串, 方便后续再升级改造 (maybe
  2. 工单 无需更改, 审批流的 id 放在 工单 annotation 内
  3. 工单和审批流的关联表, id, ticket_name, policy_id

接口清单

  1. 工单 approve, 调用后根据用户的鉴权信息确认是否有权限 approve, approve 后改变工单的状态, 根据工单关联的审批流, 通知下一节点的审批人
  2. 审批流增删查改接口.
  3. 工单发起接口, 调用时查询工单关联的策略, 选取到合适的策略, 将策略 id 写入工单的annotation 内, 然后根据工单的内容, 审批流确认通知的人.
  4. 工单和审批流关联接口, 关联时, 需要关联的工单 name, 关联条件(可选)

前端功能清单

  1. 审批流编辑页面, 需要能自己增加, 删除, 更改节点, 点击保存后可以保存到后端
  2. 工单和审批流关联页面, 一个工单应该可以关联多个工单.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.