Skip to content
Draft

Fe2 #13

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
341a0ae
add empty readme
Mar 24, 2020
ec50352
fix look in admin
Mar 23, 2020
05925d8
setup example build
Mar 24, 2020
37b66a1
add styles file
Mar 24, 2020
8934e60
modify output
Mar 24, 2020
ade30f8
remove unused npms
Mar 24, 2020
9f6223d
setup example build
Mar 24, 2020
e4d50d6
modify output
Mar 24, 2020
e7eb459
remove unused npms
Mar 24, 2020
a0afb35
add .nvmrc
Mar 24, 2020
91d51b0
Remove @webpack-cli/serve
Mar 24, 2020
13b8a17
remove old implmentation files
Mar 24, 2020
16b3dbb
improve gitignore
Mar 24, 2020
305a393
Add eslint
Mar 24, 2020
7025a90
clean eslint config
Mar 24, 2020
0e06eb6
Add fontawesome
Mar 25, 2020
a9f6ae7
Add bootstrap dependencies
Mar 25, 2020
d7121a2
Add basic custom elements to provide separation
Mar 25, 2020
5eb6b0a
remove unused component
Mar 25, 2020
5f8b91a
Place components in folders and add implementation
Mar 26, 2020
68614fa
Address comments
Mar 26, 2020
67f6709
update template
Mar 26, 2020
0c8dd04
Worker and Queue functionalities
Mar 26, 2020
bc3b6be
Extract web component registration and mark as side effect
groupsky Mar 26, 2020
98a6b67
fixup! Extract web component registration and mark as side effect
groupsky Mar 26, 2020
223c9c0
Update eslint config
groupsky Mar 27, 2020
13dac4b
Add js to ci validation
groupsky Mar 27, 2020
5337167
Attempt to use proper node version
groupsky Mar 27, 2020
6c74bd8
fixup! Update eslint config
groupsky Mar 27, 2020
ddf7701
Exclude node_modules from flake8
groupsky Mar 27, 2020
9b143de
Ignore old file - will be deleted
groupsky Mar 27, 2020
5161651
fix build error
May 19, 2020
b1f7da9
Migrated gantt chart to d3 v5 and skeleton components
groupsky Mar 26, 2020
2b9c456
Reorganize code
groupsky Mar 26, 2020
d9c0430
Relocate history components
groupsky Mar 27, 2020
b3abaff
Fix tab integration
groupsky Mar 27, 2020
b5eedf9
Remove test chart
groupsky Mar 27, 2020
6f0a3bc
Draw chart in provided root
groupsky Mar 27, 2020
01adb83
Integrate chart controls
groupsky Mar 27, 2020
0c3a2dd
Load data async
groupsky Mar 27, 2020
fbcd63b
Cleanup
groupsky Mar 27, 2020
5a0f9a5
fixup! Cleanup
groupsky Mar 27, 2020
96890e7
fixup! fixup! Cleanup
groupsky Mar 27, 2020
ca1fd75
Allow providing of fetch init on getHistory request
groupsky May 19, 2020
c6565b0
Style history bars in bluish color
groupsky May 19, 2020
83c003e
Style tooltip in black with white label
groupsky May 19, 2020
1f084b3
Display point tasks in history
groupsky May 19, 2020
608461f
Fix lint issues
groupsky May 19, 2020
73f7a1f
Tasks component
Mar 26, 2020
0ddda3d
Empty, Delete and cancel functionalities
Mar 27, 2020
958a0df
Separate mock api from webpackconfig
Mar 27, 2020
8d454b2
implement pager
Mar 27, 2020
189e3a3
visual indication for ccurrent page
Mar 30, 2020
fe1349a
try babel-parser for ??
Apr 1, 2020
0214b24
add babel-parser
Apr 1, 2020
cc317b7
fix linter issues??
Apr 1, 2020
aaf6d1f
Create date functions wrapper and tests
May 19, 2020
c787551
replace sugar with date-fns
May 19, 2020
0c5a43e
Fix PR comments
May 19, 2020
094816f
Fix docs
May 19, 2020
247955e
Fix build
May 19, 2020
2819e69
Remove forgotted debug log
groupsky May 19, 2020
8ca4a57
Fix date parsing issue
May 20, 2020
e4377b4
Fix pager issue when no paging info is provided
May 20, 2020
6299be4
Fix css class usage
May 20, 2020
3b216b7
Include styles from js and embed in the bundle
groupsky May 20, 2020
6e72ade
Define new route to render new frontend
groupsky May 20, 2020
73bad18
Fix integration
groupsky May 20, 2020
560d109
flake8
groupsky May 20, 2020
31c553e
add partaily automatic refresh and try to fight reflow
May 19, 2020
7505f32
Update rt_dashboard/javascript/src/components/tasks/tasks.js
May 19, 2020
9f92d6e
Fix scroll issue
May 19, 2020
e604eaf
Update workers automatically and fix dom helpers to use template and …
May 20, 2020
6038ca5
Check for changes in queue before firing event. Use poll param for re…
May 20, 2020
0ebfa3f
Rewrite api.js to use fetch
May 20, 2020
31a6c30
Remove unused import
May 20, 2020
525e76c
Fix merge issue
May 20, 2020
56dd370
Remove file from another impl
May 20, 2020
280828c
Integrate FE2
groupsky May 20, 2020
5baae40
Fix django integration link
groupsky May 27, 2020
80b6f1f
Fix lint issue
groupsky May 28, 2020
ed39856
Remove proxy
groupsky May 28, 2020
2cf61b7
Remove empty readme
May 28, 2020
0cbea6f
Wait for component upgrade (#49)
groupsky May 29, 2020
4d80037
History dev page (#50)
groupsky May 29, 2020
8012a85
Fix dev async import
groupsky May 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 80

[*.{css, scss, js, html}]
indent_size = 2
max_line_length = 140

[*.md]
trim_trailing_whitespace = false

[*.{yml, yaml}]
indent_size = 2

[*.json]
indent_size = 2
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
!.*.js
**/*.min.js
node_modules/**
rt_dashboard/templates/rt_dashboard/dashboard.js
24 changes: 24 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
extends: [
'standard',
],
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module',
},

env: {
browser: true,
es2020: true,
},

rules: {
'comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
}],
},
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ dump.rdb
/.direnv
._*
.pytest_cache
**/static
**/node_modules
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12.16.1
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ python:
- "3.6"
- "3.7"
- "3.8"
node_js: "12"
install:
- pip install -r requirements.txt
- pip install -e .
- nvm install $(cat .nvmrc) && nvm use
- yarn
script:
- pytest
- flake8 .
- yarn lint
10 changes: 0 additions & 10 deletions README.md

This file was deleted.

29 changes: 29 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
env: {
production: {
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'entry',
},
],
],
},
test: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
},
},
plugins: [
'@babel/plugin-proposal-nullish-coalescing-operator',
],
}
82 changes: 82 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"name": "rt-dashboard",
"version": "1.0.0",
"description": "Redis Tasks Dashboard simple interface to manage and observe tasks",
"main": "webpack.config.js",
"directories": {
"test": "tests"
},
"scripts": {
"test": "jest",
"build": "webpack",
"start": "webpack-dev-server --watch",
"lint": "eslint ."
},
"repository": {
"type": "git",
"url": "git+https://github.com/djangsters/rt-dashboard.git"
},
"keywords": [
"rt",
"dashboard"
],
"author": "Djangsters",
"license": "ISC",
"bugs": {
"url": "https://github.com/djangsters/rt-dashboard/issues"
},
"homepage": "https://github.com/djangsters/rt-dashboard#readme",
"dependencies": {
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
"@fortawesome/fontawesome-free": "^5.13.0",
"babel-eslint": "^10.1.0",
"bootstrap": "^4.4.1",
"command-line-args": "^5.1.1",
"css-loader": "^3.4.2",
"d3-axis": "^1.0.12",
"d3-scale": "^3.2.1",
"d3-selection": "^1.4.1",
"d3-time": "^1.1.0",
"d3-time-format": "^2.2.3",
"d3-transition": "^1.3.2",
"date-fns": "^2.14.0",
"file-loader": "^6.0.0",
"html-loader": "^1.0.0",
"jquery": "^3.4.1",
"popper.js": "^1.16.1"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@babel/preset-react": "^7.9.1",
"babel-jest": "^26.0.1",
"babel-loader": "^8.1.0",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"jest": "^26.0.1",
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^4.13.1",
"postcss-loader": "^3.0.0",
"sass-loader": "^8.0.2",
"style-loader": "^1.1.3",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
},
"sideEffects": [
"**/*.css",
"**/*.scss",
"./rt_dashboard/javascript/src/app.js",
"./rt_dashboard/javascript/src/components/*/index.js"
],
"jest": {
"verbose": true,
"transform": {
"^.+\\.js$": "babel-jest"
}
}
}
2 changes: 1 addition & 1 deletion rt_dashboard/contrib/django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def view(request):
else:
return render(request, 'rt_dashboard_admin.html', {
'title': 'RT Dashboard',
'iframe_src': base_path + '/inner/',
'iframe_src': base_path + '/inner/app',
})

return view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block content %}

<iframe id='rt_iframe' src="{{ iframe_src }}"
style="width: 100%; height: 600px; margin-top: -120px">
style="width: 100%; height: 600px; border: none;">
</iframe>
<style>
.content h1 {
Expand Down
11 changes: 11 additions & 0 deletions rt_dashboard/javascript/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import './styles/main.scss'
import 'bootstrap/dist/js/bootstrap.min.js'

// load web components
import './src/components/dashboard'
import './src/components/history'
import './src/components/queues'
import './src/components/rt-dashboard'
import './src/components/workers'
import './src/components/tasks'
import './src/components/pager'
93 changes: 93 additions & 0 deletions rt_dashboard/javascript/src/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
const DOCUMENT_SCRIPT_NAME = 'app.js'
const API_URL_PARAM_NAME = 'apiUrl'
const POLL_PARAM_NAME = 'poll'

const requestErrorHandler = error => {
console.error(error)
alert('Error with network request')
}

/**
*
* @param {Promise<Response>?} requestPromise
* @returns {Promise<any>|null}
*/
const executeRequest = async (requestPromise) => {
try {
const response = await requestPromise
if (response.ok) {
return response.json()
}
requestErrorHandler(response.statusText)
} catch (error) {
requestErrorHandler(error)
}
}

export const getParams = (scriptName) => {
var scripts = document.getElementsByTagName('script')

for (var i = 0; i < scripts.length; i++) {
if (scripts[i].src.indexOf('/' + scriptName) > -1) {
var pa = scripts[i].src.split('?').pop().split('&')
var p = {}
for (var j = 0; j < pa.length; j++) {
var kv = pa[j].split('=')
p[kv[0]] = kv[1]
}
return p
}
}

return {}
}

export const getPollInterval = () => {
const pollInterval = getParams(DOCUMENT_SCRIPT_NAME)[POLL_PARAM_NAME]
if (!pollInterval) {
return null
}
return parseInt(pollInterval)
}

export const getApiUrl = () => {
return getParams(DOCUMENT_SCRIPT_NAME)[API_URL_PARAM_NAME]
}

export const urlFor = (name, param) => {
var url = getApiUrl()
if (name === 'queues') {
url += 'queues.json'
} else if (name === 'workers') {
url += 'workers.json'
} else if (name === 'cancel_job') {
url += 'job/' + encodeURIComponent(param) + '/cancel'
} else if (name === 'history') {
url += 'history.json'
}
return url
}

export const urlForJobs = (param, page) => {
var url = getApiUrl() + 'jobs/' + encodeURIComponent(param) + '/' + page + '.json'
return url
}

export const getQueues = () => executeRequest(fetch(urlFor('queues')))

export const getJobs = (queueName, page) => executeRequest(fetch(urlForJobs(queueName, page)))

export const getWorkers = async () => executeRequest(fetch(urlFor('workers')))

/**
*
* @param {RequestInit?} init
* @returns {Promise<Response>}
*/
export const getHistory = (init) => executeRequest(fetch(urlFor('history'), init))

export const cancelJob = (jobId) => executeRequest(fetch(getApiUrl() + `job/${jobId}/cancel`, { method: 'POST' }))

export const deleteQueue = (queue) => executeRequest(fetch(getApiUrl() + `queue/${queue}/delete`, { method: 'POST' }))

export const emptyQueue = (queue) => executeRequest(fetch(getApiUrl() + `queue/${queue}/empty`, { method: 'POST' }))
15 changes: 15 additions & 0 deletions rt_dashboard/javascript/src/components/dashboard/dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="row">
<div class="col-6">
<queues-component></queues-component>
</div>

<div class="col-6">
<workers-component></workers-component>
</div>
</div>

<div class="row">
<div class="col-12">
<tasks-component></tasks-component>
</div>
</div>
41 changes: 41 additions & 0 deletions rt_dashboard/javascript/src/components/dashboard/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import templateHtml from './dashboard.html'
import styles from '../../../styles/main.scss'
import { loadTemplate } from '../../utils/dom'
import { getPollInterval } from '../../api'

const REFRESH_INTERVAL = getPollInterval() || 3000

export default class Dashboard extends HTMLElement {
constructor () {
super()

loadTemplate(this.attachShadow({ mode: 'open' }), templateHtml, styles)

this.selectedQueueChange = this.selectedQueueChange.bind(this)
}

connectedCallback () {
const queuesComponent = this.shadowRoot.querySelector('queues-component')
queuesComponent.addEventListener('selectedQueueChange', this.selectedQueueChange)

this.intervalId = setInterval(this.refreshInterval.bind(this), REFRESH_INTERVAL)
}

disconnectedCallback () {
this.removeEventListener('selectedQueueChange', this.selectedQueueChange)

clearInterval(this.intervalId)
}

selectedQueueChange (event) {
const { detail: { queueName, count } } = event
const tasksComponent = this.shadowRoot.querySelector('tasks-component')
tasksComponent.queueInfo = { queue: queueName, count }
}

refreshInterval () {
document.dispatchEvent(
new CustomEvent('refresh'),
)
}
}
3 changes: 3 additions & 0 deletions rt_dashboard/javascript/src/components/dashboard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Dashboard from './dashboard'

window.customElements.define('dashboard-component', Dashboard)
Loading