Skip to content

Commit

Permalink
🎨 Add prettier for js, less, yaml, json, ...
Browse files Browse the repository at this point in the history
  • Loading branch information
foosel committed Oct 7, 2020
1 parent eb37b72 commit 6b44909
Show file tree
Hide file tree
Showing 159 changed files with 12,788 additions and 8,559 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
max_line_length = 90

[**.py]
indent_size = 4
Expand Down
30 changes: 15 additions & 15 deletions .github/fixtures/with_acl/config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
accessControl:
salt: zXmvzI3uWuTLkSPOEfA2ZLwn3f3sGUNS
salt: zXmvzI3uWuTLkSPOEfA2ZLwn3f3sGUNS
plugins:
virtual_printer:
enabled: true
tracking:
enabled: false
virtual_printer:
enabled: true
tracking:
enabled: false
server:
firstRun: false
onlineCheck:
enabled: false
pluginBlacklist:
enabled: false
secretKey: rrdHjvmeGMPSdYWg2NGdiM7mpz9pjekk
seenWizards:
backup: null
corewizard: 3
tracking: null
firstRun: false
onlineCheck:
enabled: false
pluginBlacklist:
enabled: false
secretKey: rrdHjvmeGMPSdYWg2NGdiM7mpz9pjekk
seenWizards:
backup: null
corewizard: 3
tracking: null
28 changes: 14 additions & 14 deletions .github/fixtures/with_acl/users.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
admin:
active: true
apikey: null
groups:
active: true
apikey: null
groups:
- admins
- users
password: 3033587f3b040680c77ce4fb7e8d61422878ef49a2a784227689f3b44ce66ada7f6161f8b2b037267f0d37b783a5600276eb88e1d224d24915f64e187a49a89f
permissions: []
roles:
password: 3033587f3b040680c77ce4fb7e8d61422878ef49a2a784227689f3b44ce66ada7f6161f8b2b037267f0d37b783a5600276eb88e1d224d24915f64e187a49a89f
permissions: []
roles:
- user
- admin
settings: {}
settings: {}
user:
active: true
apikey: null
groups:
active: true
apikey: null
groups:
- users
password: 3033587f3b040680c77ce4fb7e8d61422878ef49a2a784227689f3b44ce66ada7f6161f8b2b037267f0d37b783a5600276eb88e1d224d24915f64e187a49a89f
permissions: []
roles:
password: 3033587f3b040680c77ce4fb7e8d61422878ef49a2a784227689f3b44ce66ada7f6161f8b2b037267f0d37b783a5600276eb88e1d224d24915f64e187a49a89f
permissions: []
roles:
- user
settings: {}
settings: {}
21 changes: 19 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ jobs:
run: |
pre-commit run --hook-stage manual black --all-files --show-diff-on-failure
lint-prettier:
name: 🧹 prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: 🏗 Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: 🏗 Set up dev dependencies
run: |
pip install -e .[develop]
- name: 🚀 Run prettier
run: |
pre-commit run --hook-stage manual prettier --all-files --show-diff-on-failure
lint-isort:
name: 🧹 isort
runs-on: ubuntu-latest
Expand Down Expand Up @@ -156,8 +172,8 @@ jobs:
with:
working-directory: tests/cypress
browser: chrome
start: 'octoprint -b ${{ github.workspace }}/e2econfig serve --host 127.0.0.1 --port 5000'
wait-on: 'http://127.0.0.1:5000/online.txt'
start: "octoprint -b ${{ github.workspace }}/e2econfig serve --host 127.0.0.1 --port 5000"
wait-on: "http://127.0.0.1:5000/online.txt"

- name: ⬆ Upload screenshots
uses: actions/upload-artifact@v1
Expand All @@ -177,6 +193,7 @@ jobs:
if: github.event_name == 'release'
needs:
- lint-black
- lint-prettier
- lint-isort
- lint-flake8
- test-unit
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/lock.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: 'Lock outdated issues & PRs'
name: "Lock outdated issues & PRs"

on:
schedule:
- cron: '0 0 * * *'
- cron: "0 0 * * *"

jobs:
lock:
Expand All @@ -12,5 +12,5 @@ jobs:
uses: dessant/lock-threads@v2
with:
github-token: ${{ github.token }}
issue-lock-comment: ''
pr-lock-comment: ''
issue-lock-comment: ""
pr-lock-comment: ""
10 changes: 5 additions & 5 deletions .github/workflows/test_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- master
workflow_dispatch:
schedule:
- cron: '0 */12 * * *'
- cron: "0 */12 * * *"

jobs:
install-branch:
Expand Down Expand Up @@ -35,14 +35,14 @@ jobs:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
uses: Ilshidur/action-discord@master
with:
args: '☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ matrix.branch }}` was successful'
args: "☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ matrix.branch }}` was successful"
- name: 📧 Discord failure notification
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
uses: Ilshidur/action-discord@master
with:
args: '🚫 Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ matrix.branch }}` failed'
args: "🚫 Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ matrix.branch }}` failed"

install-latest:
name: Install latest release
Expand All @@ -69,11 +69,11 @@ jobs:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
uses: Ilshidur/action-discord@master
with:
args: '☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ steps.latest.outputs.release }}` was successful'
args: "☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ steps.latest.outputs.release }}` was successful"
- name: 📧 Discord failure notification
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
uses: Ilshidur/action-discord@master
with:
args: '🚫 Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ steps.latest.outputs.release }}` failed'
args: "🚫 Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ steps.latest.outputs.release }}` failed"
2 changes: 1 addition & 1 deletion .github/workflows/trigger_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jobs:
with:
token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
repository: ${{ github.repository_owner }}/octoprint-docker
event-type: 'release'
event-type: "release"
client-payload: '{"tag_name": "${{ github.event.release.tag_name }}"}'
18 changes: 11 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ repos:
rev: main
hooks:
- id: codemod_dict_to_literal
args: ['--ignore', 'src/octoprint/vendor']
stages: ['manual']
args: ["--ignore", "src/octoprint/vendor"]
stages: ["manual"]
- id: codemod_set_to_literal
args: ['--ignore', 'src/octoprint/vendor']
stages: ['manual']
args: ["--ignore", "src/octoprint/vendor"]
stages: ["manual"]
- id: codemod_not_in
args: ['--ignore', 'src/octoprint/vendor']
stages: ['manual']
args: ["--ignore", "src/octoprint/vendor"]
stages: ["manual"]
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.5.4
hooks:
Expand All @@ -27,8 +27,12 @@ repos:
rev: stable
hooks:
- id: black
args: ['--config', 'black.toml']
args: ["--config", "black.toml"]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.1
hooks:
- id: flake8
- repo: https://github.com/prettier/prettier
rev: master
hooks:
- id: prettier
15 changes: 15 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
src/octoprint/static/js/lib
src/octoprint/static/vendor
src/octoprint/static/less/bootstrap
src/octoprint/static/less/font-awesome.less
*.md
*.css
**/package.json
**/package-lock.json
**/*.min.js
docs
build
dist
venv
venv2
venv3
11 changes: 11 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
printWidth: 90
tabWidth: 4
semi: true
trailingComma: "none"
singleQuote: false
quoteProps: consistent
bracketSpacing: false
overrides:
- files: ["*.yaml", "*.yml", "*.json", "*.less"]
options:
tabWidth: 2
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# OctoPrint


![GitHub release](https://img.shields.io/github/v/release/OctoPrint/OctoPrint?logo=github&logoColor=white)
![PyPI](https://img.shields.io/pypi/v/OctoPrint?logo=python&logoColor=white)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/octoprint.svg)](https://pypi.python.org/pypi/octoprint/)
![Build status](https://img.shields.io/github/workflow/status/OctoPrint/OctoPrint/Build)
[![Community Forum](https://img.shields.io/discourse/users?logo=discourse&logoColor=white&server=https%3A%2F%2Fcommunity.octoprint.org)](https://community.octoprint.org)
[![Discord](https://img.shields.io/discord/704958479194128507?label=discord&logo=discord&logoColor=white)](https://discord.octoprint.org)
[![Twitter Follow](https://img.shields.io/twitter/follow/OctoPrint3d.svg?style=social&label=Follow)](https://twitter.com/OctoPrint3d)

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1)](https://pycqa.github.io/isort/)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@
} else {
factory(global.OctoPrintClient);
}
})(this, function(OctoPrintClient) {
var OctoPrintActionCommandNotificationClient = function(base) {
})(this, function (OctoPrintClient) {
var OctoPrintActionCommandNotificationClient = function (base) {
this.base = base;
};

OctoPrintActionCommandNotificationClient.prototype.get = function(refresh, opts) {
return this.base.get(this.base.getSimpleApiUrl("action_command_notification"), opts);
OctoPrintActionCommandNotificationClient.prototype.get = function (refresh, opts) {
return this.base.get(
this.base.getSimpleApiUrl("action_command_notification"),
opts
);
};

OctoPrintActionCommandNotificationClient.prototype.clear = function(opts) {
return this.base.simpleApiCommand("action_command_notification", "clear", {}, opts);
OctoPrintActionCommandNotificationClient.prototype.clear = function (opts) {
return this.base.simpleApiCommand(
"action_command_notification",
"clear",
{},
opts
);
};

OctoPrintClient.registerPluginComponent("action_command_notification", OctoPrintActionCommandNotificationClient);
OctoPrintClient.registerPluginComponent(
"action_command_notification",
OctoPrintActionCommandNotificationClient
);
return OctoPrintActionCommandNotificationClient;
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(function() {
$(function () {
function ActionCommandNotificationViewModel(parameters) {
var self = this;

Expand All @@ -8,40 +8,57 @@ $(function() {

self.notifications = ko.observableArray([]);

self.toDateTimeString = function(timestamp) {
self.toDateTimeString = function (timestamp) {
return formatDate(timestamp);
};

self.requestData = function() {
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_SHOW)) return;
self.requestData = function () {
if (
!self.loginState.hasPermission(
self.access.permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_SHOW
)
)
return;

OctoPrint.plugins.action_command_notification.get()
.done(self.fromResponse)
OctoPrint.plugins.action_command_notification.get().done(self.fromResponse);
};

self.fromResponse = function(response) {
self.fromResponse = function (response) {
self.notifications(response.notifications);
};

self.clear = function() {
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_CLEAR)) return;
self.clear = function () {
if (
!self.loginState.hasPermission(
self.access.permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_CLEAR
)
)
return;

OctoPrint.plugins.action_command_notification.clear();
};

self.onStartup = self.onUserLoggedIn = self.onUserLoggedOut = function() {
self.onStartup = self.onUserLoggedIn = self.onUserLoggedOut = function () {
self.requestData();
};

self.onDataUpdaterPluginMessage = function(plugin, data) {
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_SHOW)) return;
self.onDataUpdaterPluginMessage = function (plugin, data) {
if (
!self.loginState.hasPermission(
self.access.permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_SHOW
)
)
return;
if (plugin !== "action_command_notification") {
return;
}

self.requestData();

if (data.message && self.settings.settings.plugins.action_command_notification.enable_popups()) {
if (
data.message &&
self.settings.settings.plugins.action_command_notification.enable_popups()
) {
new PNotify({
title: gettext("Printer Notification"),
text: data.message,
Expand All @@ -54,7 +71,6 @@ $(function() {
});
}
};

}

OCTOPRINT_VIEWMODELS.push({
Expand Down
Loading

0 comments on commit 6b44909

Please sign in to comment.