Compare commits

...

6 Commits

13 changed files with 510 additions and 396 deletions

View File

@ -35,6 +35,7 @@ Auto backup can be configured via the web interface.
- __Restore__ : Upload backed-up snapshot to Home assistant. - __Restore__ : Upload backed-up snapshot to Home assistant.
- __Auto Stop__ : This addon can stop addons before backup and restart them after backup - __Auto Stop__ : This addon can stop addons before backup and restart them after backup
- __Web UI__ : All the configuration is based on an easy-to-use web interface, no yaml needed. - __Web UI__ : All the configuration is based on an easy-to-use web interface, no yaml needed.
- __Home Assistant State Entities__ : This addon create 2 entite in HA : `binary_sensor.nextcloud_backup_error` and `sensor.nextcloud_backup_status`
> __Info:__ > __Info:__
> Auto Clean is executed after every upload and every day at 00h30 > Auto Clean is executed after every upload and every day at 00h30

View File

@ -17,6 +17,7 @@ Easily backup your Home Assistant snapshots to Nextcloud.
- __Auto Stop__ : This addon can stop addons before backup and restart them after backup - __Auto Stop__ : This addon can stop addons before backup and restart them after backup
- __Restore__ : Upload backed-up snapshot to Home assistant. - __Restore__ : Upload backed-up snapshot to Home assistant.
- __Web UI__ : All the configuration is based on an easy-to-use web interface, no yaml needed. - __Web UI__ : All the configuration is based on an easy-to-use web interface, no yaml needed.
- __Home Assistant State Entities__ : This addon create 2 entite in HA : `binary_sensor.nextcloud_backup_error` and `sensor.nextcloud_backup_status`
[Click here for the full documentation][docs] [Click here for the full documentation][docs]

View File

@ -1 +1 @@
9.2.1 10.0.2

View File

@ -42,6 +42,8 @@ You can now configure the automatic backup.
If enabled, you can specify how much Local Snapshot and Nextcloud Backup you want to keep before deleting the older one. If enabled, you can specify how much Local Snapshot and Nextcloud Backup you want to keep before deleting the older one.
> __Info:__ > __Info:__
> Auto Clean is executed after every upload and every day at 00h30 > Auto Clean is executed after every upload and every day at 00h30
## Home Assitant Os Configuration ## Home Assitant Os Configuration
**Note**: _Remember to restart the add-on when the configuration is changed._ **Note**: _Remember to restart the add-on when the configuration is changed._

View File

@ -18,6 +18,8 @@ Easily backup your Home Assistant snapshots to Nextcloud.
- __Auto Stop__ : This addon can stop addons before backup and restart them after backup - __Auto Stop__ : This addon can stop addons before backup and restart them after backup
- __Restore__ : Upload backed-up snapshot to Home assistant. - __Restore__ : Upload backed-up snapshot to Home assistant.
- __Web UI__ : All the configuration is based on an easy-to-use web interface, no yaml needed. - __Web UI__ : All the configuration is based on an easy-to-use web interface, no yaml needed.
- __Home Assistant State Entities__ : This addon create 2 entite in HA : `binary_sensor.nextcloud_backup_error` and `sensor.nextcloud_backup_status`
[Click here for the full documentation][docs] [Click here for the full documentation][docs]

View File

@ -37,18 +37,18 @@
} }
}, },
"node_modules/@fortawesome/fontawesome-free": { "node_modules/@fortawesome/fontawesome-free": {
"version": "5.15.3", "version": "5.15.4",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.3.tgz", "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.4.tgz",
"integrity": "sha512-rFnSUN/QOtnOAgqFRooTA3H57JLDm0QEG/jPdk+tLQNL/eWd+Aok8g3qCI+Q1xuDPWpGW/i9JySpJVsq8Q0s9w==", "integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg==",
"hasInstallScript": true, "hasInstallScript": true,
"engines": { "engines": {
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/@popperjs/core": { "node_modules/@popperjs/core": {
"version": "2.9.2", "version": "2.10.1",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.9.2.tgz", "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.10.1.tgz",
"integrity": "sha512-VZMYa7+fXHdwIq1TDhSXoVmSPEGM/aa+6Aiq3nVVJ9bXr24zScr+NlKFKC3iPljA7ho/GAZr+d2jOf5GIRC30Q==", "integrity": "sha512-HnUhk1Sy9IuKrxEMdIRCxpIqPw6BFsbYSEUO9p/hNw5sMld/+3OLMWQP80F8/db9qsv3qUjs7ZR5bS/R+iinXw==",
"peer": true, "peer": true,
"funding": { "funding": {
"type": "opencollective", "type": "opencollective",
@ -67,9 +67,9 @@
} }
}, },
"node_modules/@szmarczak/http-timer": { "node_modules/@szmarczak/http-timer": {
"version": "4.0.5", "version": "4.0.6",
"resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz", "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz",
"integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==", "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==",
"dependencies": { "dependencies": {
"defer-to-connect": "^2.0.0" "defer-to-connect": "^2.0.0"
}, },
@ -102,9 +102,9 @@
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "16.0.1", "version": "16.7.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.0.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.13.tgz",
"integrity": "sha512-hBOx4SUlEPKwRi6PrXuTGw1z6lz0fjsibcWCM378YxsSu/6+C30L6CR49zIBKHiwNWCYIcOLjg4OHKZaFeLAug==" "integrity": "sha512-pLUPDn+YG3FYEt/pHI74HmnJOWzeR+tOIQzUx93pi9M7D8OE7PSLr97HboXwk5F+JS+TLtWuzCOW97AHjmOXXA=="
}, },
"node_modules/@types/responselike": { "node_modules/@types/responselike": {
"version": "1.0.0", "version": "1.0.0",
@ -161,11 +161,11 @@
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
}, },
"node_modules/axios": { "node_modules/axios": {
"version": "0.21.1", "version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"dependencies": { "dependencies": {
"follow-redirects": "^1.10.0" "follow-redirects": "^1.14.0"
} }
}, },
"node_modules/balanced-match": { "node_modules/balanced-match": {
@ -243,15 +243,15 @@
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}, },
"node_modules/bootstrap": { "node_modules/bootstrap": {
"version": "5.0.2", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.0.2.tgz", "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.0.tgz",
"integrity": "sha512-1Ge963tyEQWJJ+8qtXFU6wgmAVj9gweEjibUdbmcCEYsn38tVwRk8107rk2vzt6cfQcRr3SlZ8aQBqaD8aqf+Q==", "integrity": "sha512-bs74WNI9BgBo3cEovmdMHikSKoXnDgA6VQjJ7TyTotU6L7d41ZyCEEelPwkYEzsG/Zjv3ie9IE3EMAje0W9Xew==",
"funding": { "funding": {
"type": "opencollective", "type": "opencollective",
"url": "https://opencollective.com/bootstrap" "url": "https://opencollective.com/bootstrap"
}, },
"peerDependencies": { "peerDependencies": {
"@popperjs/core": "^2.9.2" "@popperjs/core": "^2.9.3"
} }
}, },
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
@ -348,9 +348,9 @@
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
}, },
"node_modules/color-string": { "node_modules/color-string": {
"version": "1.5.5", "version": "1.6.0",
"resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.5.tgz", "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.6.0.tgz",
"integrity": "sha512-jgIoum0OfQfq9Whcfc2z/VhCNcmQjWbey6qBX0vqt7YICflUmBCh9E9CiQD5GSJ+Uehixm3NUwHVhqUAWRivZg==", "integrity": "sha512-c/hGS+kRWJutUBEngKKmk4iH3sD59MBkoxVapS/0wgpCz2u7XsNloxknyvBhzwEs1IbV36D9PwqLPJ2DTu3vMA==",
"dependencies": { "dependencies": {
"color-name": "^1.0.0", "color-name": "^1.0.0",
"simple-swizzle": "^0.2.2" "simple-swizzle": "^0.2.2"
@ -434,9 +434,9 @@
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
}, },
"node_modules/core-util-is": { "node_modules/core-util-is": {
"version": "1.0.2", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
}, },
"node_modules/cron": { "node_modules/cron": {
"version": "1.8.2", "version": "1.8.2",
@ -639,9 +639,9 @@
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}, },
"node_modules/fast-safe-stringify": { "node_modules/fast-safe-stringify": {
"version": "2.0.7", "version": "2.0.8",
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.8.tgz",
"integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==" "integrity": "sha512-lXatBjf3WPjmWD6DpIZxkeSsCOwqI0maYMpgDlx8g4U2qi4lbjA9oH/HD2a87G+KfsUmo5WbJFmqBZlPxtptag=="
}, },
"node_modules/fast-xml-parser": { "node_modules/fast-xml-parser": {
"version": "3.19.0", "version": "3.19.0",
@ -704,9 +704,9 @@
"integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==" "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="
}, },
"node_modules/follow-redirects": { "node_modules/follow-redirects": {
"version": "1.14.1", "version": "1.14.3",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.3.tgz",
"integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==", "integrity": "sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw==",
"funding": [ "funding": [
{ {
"type": "individual", "type": "individual",
@ -882,11 +882,14 @@
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
}, },
"node_modules/is-stream": { "node_modules/is-stream": {
"version": "2.0.0", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
"integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==",
"engines": { "engines": {
"node": ">=8" "node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/isarray": { "node_modules/isarray": {
@ -1002,19 +1005,19 @@
} }
}, },
"node_modules/mime-db": { "node_modules/mime-db": {
"version": "1.48.0", "version": "1.49.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.48.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.49.0.tgz",
"integrity": "sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==", "integrity": "sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA==",
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/mime-types": { "node_modules/mime-types": {
"version": "2.1.31", "version": "2.1.32",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.31.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.32.tgz",
"integrity": "sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==", "integrity": "sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A==",
"dependencies": { "dependencies": {
"mime-db": "1.48.0" "mime-db": "1.49.0"
}, },
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
@ -1295,9 +1298,9 @@
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
}, },
"node_modules/resolve-alpn": { "node_modules/resolve-alpn": {
"version": "1.1.2", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.1.2.tgz", "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz",
"integrity": "sha512-8OyfzhAtA32LVUsJSke3auIyINcwdh5l3cvYKdKO0nvsYSKuiLfTM5i78PJswFPT8y6cPW+L1v6/hE95chcpDA==" "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g=="
}, },
"node_modules/responselike": { "node_modules/responselike": {
"version": "2.0.0", "version": "2.0.0",
@ -1498,9 +1501,9 @@
"integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==" "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA=="
}, },
"node_modules/url-parse": { "node_modules/url-parse": {
"version": "1.5.1", "version": "1.5.3",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.1.tgz", "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.3.tgz",
"integrity": "sha512-HOfCOUJt7iSYzEx/UqgtwKRMC6EU91NFhsCHMv9oM03VJcVo2Qrp8T8kI9D7amFf1cu+/3CEhgb3rF9zL7k85Q==", "integrity": "sha512-IIORyIQD9rvj0A4CLWsHkBBJuNqWpFQe224b6j9t/ABmquIS0qDU2pY6kl6AuOrL5OkCXHMCFNe1jBcuAggjvQ==",
"dependencies": { "dependencies": {
"querystringify": "^2.1.1", "querystringify": "^2.1.1",
"requires-port": "^1.0.0" "requires-port": "^1.0.0"
@ -1528,9 +1531,9 @@
} }
}, },
"node_modules/webdav": { "node_modules/webdav": {
"version": "4.6.0", "version": "4.7.0",
"resolved": "https://registry.npmjs.org/webdav/-/webdav-4.6.0.tgz", "resolved": "https://registry.npmjs.org/webdav/-/webdav-4.7.0.tgz",
"integrity": "sha512-amL/NeZ73xe8cNC+uqAF3mOC/j5dNoNWlZswYCd7DKxhnZM7dViAVSv6gdCYeGAETjPEZVubcKDDRwGKz9ShQQ==", "integrity": "sha512-R1WZl/JeFPAmSEn1EPCmxSdPY8IxS/P0qnxAzBeRqEewpxVJ/UiCMJwXHLpyVsKYA1PIb1dYv+UTQsbNaQnLBw==",
"dependencies": { "dependencies": {
"axios": "^0.21.1", "axios": "^0.21.1",
"base-64": "^1.0.0", "base-64": "^1.0.0",
@ -1543,7 +1546,7 @@
"nested-property": "^4.0.0", "nested-property": "^4.0.0",
"path-posix": "^1.0.0", "path-posix": "^1.0.0",
"url-join": "^4.0.1", "url-join": "^4.0.1",
"url-parse": "^1.5.1" "url-parse": "^1.5.3"
} }
}, },
"node_modules/winston": { "node_modules/winston": {
@ -1600,9 +1603,9 @@
} }
}, },
"node_modules/winston/node_modules/async": { "node_modules/winston/node_modules/async": {
"version": "3.2.0", "version": "3.2.1",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", "resolved": "https://registry.npmjs.org/async/-/async-3.2.1.tgz",
"integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==" "integrity": "sha512-XdD5lRO/87udXCMC9meWdYiR+Nq6ZjUfXidViUZGu2F1MO4T3XwZ1et0hb2++BgLfhyJwy44BGB/yx80ABx8hg=="
}, },
"node_modules/wrappy": { "node_modules/wrappy": {
"version": "1.0.2", "version": "1.0.2",
@ -1622,14 +1625,14 @@
} }
}, },
"@fortawesome/fontawesome-free": { "@fortawesome/fontawesome-free": {
"version": "5.15.3", "version": "5.15.4",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.3.tgz", "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.4.tgz",
"integrity": "sha512-rFnSUN/QOtnOAgqFRooTA3H57JLDm0QEG/jPdk+tLQNL/eWd+Aok8g3qCI+Q1xuDPWpGW/i9JySpJVsq8Q0s9w==" "integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg=="
}, },
"@popperjs/core": { "@popperjs/core": {
"version": "2.9.2", "version": "2.10.1",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.9.2.tgz", "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.10.1.tgz",
"integrity": "sha512-VZMYa7+fXHdwIq1TDhSXoVmSPEGM/aa+6Aiq3nVVJ9bXr24zScr+NlKFKC3iPljA7ho/GAZr+d2jOf5GIRC30Q==", "integrity": "sha512-HnUhk1Sy9IuKrxEMdIRCxpIqPw6BFsbYSEUO9p/hNw5sMld/+3OLMWQP80F8/db9qsv3qUjs7ZR5bS/R+iinXw==",
"peer": true "peer": true
}, },
"@sindresorhus/is": { "@sindresorhus/is": {
@ -1638,9 +1641,9 @@
"integrity": "sha512-Qm9hBEBu18wt1PO2flE7LPb30BHMQt1eQgbV76YntdNk73XZGpn3izvGTYxbGgzXKgbCjiia0uxTd3aTNQrY/g==" "integrity": "sha512-Qm9hBEBu18wt1PO2flE7LPb30BHMQt1eQgbV76YntdNk73XZGpn3izvGTYxbGgzXKgbCjiia0uxTd3aTNQrY/g=="
}, },
"@szmarczak/http-timer": { "@szmarczak/http-timer": {
"version": "4.0.5", "version": "4.0.6",
"resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz", "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz",
"integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==", "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==",
"requires": { "requires": {
"defer-to-connect": "^2.0.0" "defer-to-connect": "^2.0.0"
} }
@ -1670,9 +1673,9 @@
} }
}, },
"@types/node": { "@types/node": {
"version": "16.0.1", "version": "16.7.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.0.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.13.tgz",
"integrity": "sha512-hBOx4SUlEPKwRi6PrXuTGw1z6lz0fjsibcWCM378YxsSu/6+C30L6CR49zIBKHiwNWCYIcOLjg4OHKZaFeLAug==" "integrity": "sha512-pLUPDn+YG3FYEt/pHI74HmnJOWzeR+tOIQzUx93pi9M7D8OE7PSLr97HboXwk5F+JS+TLtWuzCOW97AHjmOXXA=="
}, },
"@types/responselike": { "@types/responselike": {
"version": "1.0.0", "version": "1.0.0",
@ -1720,11 +1723,11 @@
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
}, },
"axios": { "axios": {
"version": "0.21.1", "version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"requires": { "requires": {
"follow-redirects": "^1.10.0" "follow-redirects": "^1.14.0"
} }
}, },
"balanced-match": { "balanced-match": {
@ -1795,9 +1798,9 @@
} }
}, },
"bootstrap": { "bootstrap": {
"version": "5.0.2", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.0.2.tgz", "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.0.tgz",
"integrity": "sha512-1Ge963tyEQWJJ+8qtXFU6wgmAVj9gweEjibUdbmcCEYsn38tVwRk8107rk2vzt6cfQcRr3SlZ8aQBqaD8aqf+Q==", "integrity": "sha512-bs74WNI9BgBo3cEovmdMHikSKoXnDgA6VQjJ7TyTotU6L7d41ZyCEEelPwkYEzsG/Zjv3ie9IE3EMAje0W9Xew==",
"requires": {} "requires": {}
}, },
"brace-expansion": { "brace-expansion": {
@ -1879,9 +1882,9 @@
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
}, },
"color-string": { "color-string": {
"version": "1.5.5", "version": "1.6.0",
"resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.5.tgz", "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.6.0.tgz",
"integrity": "sha512-jgIoum0OfQfq9Whcfc2z/VhCNcmQjWbey6qBX0vqt7YICflUmBCh9E9CiQD5GSJ+Uehixm3NUwHVhqUAWRivZg==", "integrity": "sha512-c/hGS+kRWJutUBEngKKmk4iH3sD59MBkoxVapS/0wgpCz2u7XsNloxknyvBhzwEs1IbV36D9PwqLPJ2DTu3vMA==",
"requires": { "requires": {
"color-name": "^1.0.0", "color-name": "^1.0.0",
"simple-swizzle": "^0.2.2" "simple-swizzle": "^0.2.2"
@ -1947,9 +1950,9 @@
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
}, },
"cron": { "cron": {
"version": "1.8.2", "version": "1.8.2",
@ -2106,9 +2109,9 @@
} }
}, },
"fast-safe-stringify": { "fast-safe-stringify": {
"version": "2.0.7", "version": "2.0.8",
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.8.tgz",
"integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==" "integrity": "sha512-lXatBjf3WPjmWD6DpIZxkeSsCOwqI0maYMpgDlx8g4U2qi4lbjA9oH/HD2a87G+KfsUmo5WbJFmqBZlPxtptag=="
}, },
"fast-xml-parser": { "fast-xml-parser": {
"version": "3.19.0", "version": "3.19.0",
@ -2163,9 +2166,9 @@
"integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==" "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="
}, },
"follow-redirects": { "follow-redirects": {
"version": "1.14.1", "version": "1.14.3",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.3.tgz",
"integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==" "integrity": "sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw=="
}, },
"form-data": { "form-data": {
"version": "4.0.0", "version": "4.0.0",
@ -2290,9 +2293,9 @@
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
}, },
"is-stream": { "is-stream": {
"version": "2.0.0", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
"integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==" "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="
}, },
"isarray": { "isarray": {
"version": "1.0.0", "version": "1.0.0",
@ -2386,16 +2389,16 @@
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
}, },
"mime-db": { "mime-db": {
"version": "1.48.0", "version": "1.49.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.48.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.49.0.tgz",
"integrity": "sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==" "integrity": "sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA=="
}, },
"mime-types": { "mime-types": {
"version": "2.1.31", "version": "2.1.32",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.31.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.32.tgz",
"integrity": "sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==", "integrity": "sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A==",
"requires": { "requires": {
"mime-db": "1.48.0" "mime-db": "1.49.0"
} }
}, },
"mimic-response": { "mimic-response": {
@ -2614,9 +2617,9 @@
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
}, },
"resolve-alpn": { "resolve-alpn": {
"version": "1.1.2", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.1.2.tgz", "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz",
"integrity": "sha512-8OyfzhAtA32LVUsJSke3auIyINcwdh5l3cvYKdKO0nvsYSKuiLfTM5i78PJswFPT8y6cPW+L1v6/hE95chcpDA==" "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g=="
}, },
"responselike": { "responselike": {
"version": "2.0.0", "version": "2.0.0",
@ -2782,9 +2785,9 @@
"integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==" "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA=="
}, },
"url-parse": { "url-parse": {
"version": "1.5.1", "version": "1.5.3",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.1.tgz", "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.3.tgz",
"integrity": "sha512-HOfCOUJt7iSYzEx/UqgtwKRMC6EU91NFhsCHMv9oM03VJcVo2Qrp8T8kI9D7amFf1cu+/3CEhgb3rF9zL7k85Q==", "integrity": "sha512-IIORyIQD9rvj0A4CLWsHkBBJuNqWpFQe224b6j9t/ABmquIS0qDU2pY6kl6AuOrL5OkCXHMCFNe1jBcuAggjvQ==",
"requires": { "requires": {
"querystringify": "^2.1.1", "querystringify": "^2.1.1",
"requires-port": "^1.0.0" "requires-port": "^1.0.0"
@ -2806,9 +2809,9 @@
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
}, },
"webdav": { "webdav": {
"version": "4.6.0", "version": "4.7.0",
"resolved": "https://registry.npmjs.org/webdav/-/webdav-4.6.0.tgz", "resolved": "https://registry.npmjs.org/webdav/-/webdav-4.7.0.tgz",
"integrity": "sha512-amL/NeZ73xe8cNC+uqAF3mOC/j5dNoNWlZswYCd7DKxhnZM7dViAVSv6gdCYeGAETjPEZVubcKDDRwGKz9ShQQ==", "integrity": "sha512-R1WZl/JeFPAmSEn1EPCmxSdPY8IxS/P0qnxAzBeRqEewpxVJ/UiCMJwXHLpyVsKYA1PIb1dYv+UTQsbNaQnLBw==",
"requires": { "requires": {
"axios": "^0.21.1", "axios": "^0.21.1",
"base-64": "^1.0.0", "base-64": "^1.0.0",
@ -2821,7 +2824,7 @@
"nested-property": "^4.0.0", "nested-property": "^4.0.0",
"path-posix": "^1.0.0", "path-posix": "^1.0.0",
"url-join": "^4.0.1", "url-join": "^4.0.1",
"url-parse": "^1.5.1" "url-parse": "^1.5.3"
} }
}, },
"winston": { "winston": {
@ -2841,9 +2844,9 @@
}, },
"dependencies": { "dependencies": {
"async": { "async": {
"version": "3.2.0", "version": "3.2.1",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", "resolved": "https://registry.npmjs.org/async/-/async-3.2.1.tgz",
"integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==" "integrity": "sha512-XdD5lRO/87udXCMC9meWdYiR+Nq6ZjUfXidViUZGu2F1MO4T3XwZ1et0hb2++BgLfhyJwy44BGB/yx80ABx8hg=="
} }
} }
}, },

View File

@ -7,51 +7,48 @@ const default_toast_timeout = 10000;
let loadingModal; let loadingModal;
let nextcloud_setting_modal; let nextcloud_setting_modal;
let backup_setting_modal; let backup_setting_modal;
document.addEventListener('DOMContentLoaded', function () { document.addEventListener("DOMContentLoaded", function () {
$.ajaxSetup({ traditional: true }); $.ajaxSetup({ traditional: true });
updateLocalSnaps(); updateLocalSnaps();
update_status(); update_status();
loadingModal = new bootstrap.Modal(document.getElementById('loading-modal'), { loadingModal = new bootstrap.Modal(document.getElementById("loading-modal"), {
keyboard: false, keyboard: false,
backdrop: 'static' backdrop: "static",
}); });
nextcloud_setting_modal = new bootstrap.Modal(document.getElementById('modal-settings-nextcloud')); nextcloud_setting_modal = new bootstrap.Modal(document.getElementById("modal-settings-nextcloud"));
backup_setting_modal = new bootstrap.Modal(document.getElementById('modal-settings-backup')); backup_setting_modal = new bootstrap.Modal(document.getElementById("modal-settings-backup"));
setInterval(update_status, 500); setInterval(update_status, 500);
setInterval(updateLocalSnaps, 5000); setInterval(updateLocalSnaps, 5000);
listeners(); listeners();
}); });
function updateDynamicListeners() { function updateDynamicListeners() {
$('.local-snap-listener').click(function () { $(".local-snap-listener").on("click", function () {
let id = this.getAttribute('data-id'); let id = this.getAttribute("data-id");
console.log(id); console.log(id);
}); });
let manual_back_list = $('.manual-back-list'); let manual_back_list = $(".manual-back-list");
manual_back_list.unbind(); manual_back_list.off();
manual_back_list.click(function () { manual_back_list.on("click", function () {
let id = this.getAttribute('data-id'); let id = this.getAttribute("data-id");
let name = this.getAttribute('data-name'); let name = this.getAttribute("data-name");
manualBackup(id, name); manualBackup(id, name);
}) });
$('.restore').click(function () { $(".restore").click(function () {
let to_restore = this.getAttribute('data-id'); let to_restore = this.getAttribute("data-id");
console.log(to_restore) console.log(to_restore);
restore(to_restore) restore(to_restore);
});
})
} }
function updateLocalSnaps() { function updateLocalSnaps() {
let needUpdate = false; let needUpdate = false;
$.get('./api/formated-local-snap', (data) => { $.get("./api/formated-local-snap", (data) => {
if (JSON.stringify(data) === last_local_snap) if (JSON.stringify(data) === last_local_snap) return;
return;
last_local_snap = JSON.stringify(data); last_local_snap = JSON.stringify(data);
needUpdate = true; needUpdate = true;
let local_snaps = $('#local_snaps'); let local_snaps = $("#local_snaps");
local_snaps.empty(); local_snaps.empty();
local_snaps.html(data); local_snaps.html(data);
}).always(() => { }).always(() => {
@ -61,15 +58,13 @@ function updateLocalSnaps() {
function updateManuBackup(prevUpdate) { function updateManuBackup(prevUpdate) {
let needUpdate = false; let needUpdate = false;
$.get('./api/formated-backup-manual', (data) => { $.get("./api/formated-backup-manual", (data) => {
if (JSON.stringify(data) === last_manu_back) if (JSON.stringify(data) === last_manu_back) return;
return;
last_manu_back = JSON.stringify(data); last_manu_back = JSON.stringify(data);
needUpdate = true; needUpdate = true;
let manual_backups = $('#manual_backups') let manual_backups = $("#manual_backups");
manual_backups.empty(); manual_backups.empty();
manual_backups.html(data); manual_backups.html(data);
}).always(() => { }).always(() => {
updateAutoBackup(prevUpdate || needUpdate); updateAutoBackup(prevUpdate || needUpdate);
}); });
@ -77,157 +72,145 @@ function updateManuBackup(prevUpdate) {
function updateAutoBackup(prevUpdate) { function updateAutoBackup(prevUpdate) {
let needUpdate = false; let needUpdate = false;
$.get('./api/formated-backup-auto', (data) => { $.get("./api/formated-backup-auto", (data) => {
if (JSON.stringify(data) === last_auto_back) if (JSON.stringify(data) === last_auto_back) return;
return;
needUpdate = true; needUpdate = true;
last_auto_back = JSON.stringify(data); last_auto_back = JSON.stringify(data);
let auto_backups = $('#auto_backups') let auto_backups = $("#auto_backups");
auto_backups.empty(); auto_backups.empty();
auto_backups.html(data); auto_backups.html(data);
}).always(() => { }).always(() => {
if (prevUpdate || needUpdate) if (prevUpdate || needUpdate) updateDynamicListeners();
updateDynamicListeners();
}); });
} }
function update_status() { function update_status() {
$.get('./api/status', (data) => { $.get("./api/status", (data) => {
if (JSON.stringify(data) !== last_status) { if (JSON.stringify(data) !== last_status) {
last_status = JSON.stringify(data); last_status = JSON.stringify(data);
let buttons = $('#btn-backup-now, #btn-clean-now'); let buttons = $("#btn-backup-now, #btn-clean-now");
switch (data.status) { switch (data.status) {
case "error": case "error":
printStatus('Error', data.message); printStatus("Error", data.message);
buttons.removeClass("disabled"); buttons.removeClass("disabled");
break; break;
case "idle": case "idle":
printStatus('Idle', "Waiting for next backup."); printStatus("Idle", "Waiting for next backup.");
buttons.removeClass("disabled"); buttons.removeClass("disabled");
break; break;
case "download": case "download":
printStatusWithBar('Downloading Snapshot', data.progress); printStatusWithBar("Downloading Snapshot", data.progress);
buttons.addClass("disabled"); buttons.addClass("disabled");
break; break;
case "download-b": case "download-b":
printStatusWithBar('Downloading Backup', data.progress); printStatusWithBar("Downloading Backup", data.progress);
buttons.addClass("disabled"); buttons.addClass("disabled");
break; break;
case "upload": case "upload":
printStatusWithBar('Uploading Snapshot', data.progress); printStatusWithBar("Uploading Snapshot", data.progress);
buttons.addClass("disabled"); buttons.addClass("disabled");
break; break;
case "upload-b": case "upload-b":
printStatusWithBar('Uploading Snapshot', data.progress); printStatusWithBar("Uploading Snapshot", data.progress);
buttons.addClass("disabled"); buttons.addClass("disabled");
break; break;
case "creating": case "creating":
printStatusWithBar('Creating Snapshot', data.progress); printStatusWithBar("Creating Snapshot", data.progress);
buttons.addClass("disabled"); buttons.addClass("disabled");
break; break;
case "stopping": case "stopping":
printStatusWithBar('Stopping addons', data.progress); printStatusWithBar("Stopping addons", data.progress);
buttons.addClass("disabled"); buttons.addClass("disabled");
break; break;
case "starting": case "starting":
printStatusWithBar('Starting addons', data.progress); printStatusWithBar("Starting addons", data.progress);
buttons.addClass("disabled"); buttons.addClass("disabled");
break; break;
} }
if (data.last_backup != null) { if (data.last_backup != null) {
let last_back_status = $('#last_back_status'); let last_back_status = $("#last_back_status");
if (last_back_status.html() !== data.last_backup) if (last_back_status.html() !== data.last_backup) last_back_status.html(data.last_backup);
last_back_status.html(data.last_backup);
} }
if (data.next_backup != null) { if (data.next_backup != null) {
let next_back_status = $('#next_back_status'); let next_back_status = $("#next_back_status");
if (next_back_status.html() !== data.next_backup) if (next_back_status.html() !== data.next_backup) next_back_status.html(data.next_backup);
next_back_status.html(data.next_backup);
} }
} }
}); });
} }
function printStatus(status, secondLine) { function printStatus(status, secondLine) {
let status_jq = $('#status'); let status_jq = $("#status");
status_jq.empty(); status_jq.empty();
status_jq.html(status); status_jq.html(status);
let status_s_l_jq = $('#status-second-line'); let status_s_l_jq = $("#status-second-line");
status_s_l_jq.empty(); status_s_l_jq.empty();
status_s_l_jq.removeClass('text-center'); status_s_l_jq.removeClass("text-center");
status_s_l_jq.html(secondLine); status_s_l_jq.html(secondLine);
$('#progress').addClass("invisible"); $("#progress").addClass("invisible");
} }
function printStatusWithBar(status, progress) { function printStatusWithBar(status, progress) {
let status_jq = $('#status') let status_jq = $("#status");
status_jq.empty(); status_jq.empty();
status_jq.html(status); status_jq.html(status);
let secondLine = $('#status-second-line') let secondLine = $("#status-second-line");
secondLine.empty(); secondLine.empty();
secondLine.html(progress === -1 ? "Waiting..." : (Math.round(progress * 100) + "%")); secondLine.html(progress === -1 ? "Waiting..." : Math.round(progress * 100) + "%");
secondLine.addClass("text-center"); secondLine.addClass("text-center");
let progressDiv = $('#progress'); let progressDiv = $("#progress");
progressDiv.removeClass("invisible"); progressDiv.removeClass("invisible");
if (progress === -1) { if (progress === -1) {
progressDiv.children().css('width', "100%"); progressDiv.children().css("width", "100%");
progressDiv.children().addClass('progress-bar-striped progress-bar-animated'); progressDiv.children().addClass("progress-bar-striped progress-bar-animated");
} else { } else {
progressDiv.children().removeClass('progress-bar-striped progress-bar-animated'); progressDiv.children().removeClass("progress-bar-striped progress-bar-animated");
progressDiv.children().css('width', (progress * 100) + "%"); progressDiv.children().css("width", progress * 100 + "%");
} }
} }
function listeners() { function listeners() {
$('#btn-backup-now').click(backupNow); $("#btn-backup-now").on("click", backupNow);
$('#btn-clean-now').click(cleanNow); $("#btn-clean-now").on("click", cleanNow);
$('#trigger-backup-settings').click(getBackupSettings); $("#trigger-backup-settings").on("click", getBackupSettings);
$('#password_protected').change(function () { $("#password_protected").on("change", function () {
if (!$(this).is(':checked')) { if (!$(this).is(":checked")) {
$('#password_protect_value').parent().parent().addClass('d-none'); $("#password_protect_value").parent().parent().addClass("d-none");
} else { } else {
$('#password_protect_value').parent().parent().removeClass('d-none'); $("#password_protect_value").parent().parent().removeClass("d-none");
}
})
$('#cron-drop-settings').change(updateDropVisibility);
$('#save-backup-settings').click(sendBackupSettings);
$('#auto_clean_local').change(function () {
if (!$(this).is(':checked')) {
$('#local-snap-keep').parent().parent().addClass("d-none");
} else {
$('#local-snap-keep').parent().parent().removeClass("d-none");
} }
}); });
$('#auto_clean_backup').change(function () { $("#cron-drop-settings").on("change", updateDropVisibility);
if (!$(this).is(':checked')) { $("#save-backup-settings").click(sendBackupSettings);
$('#backup-snap-keep').parent().parent().addClass("d-none"); $("#auto_clean_local").on("change", function () {
if (!$(this).is(":checked")) {
$("#local-snap-keep").parent().parent().addClass("d-none");
} else { } else {
$('#backup-snap-keep').parent().parent().removeClass("d-none"); $("#local-snap-keep").parent().parent().removeClass("d-none");
}
});
$("#auto_clean_backup").on("change", function () {
if (!$(this).is(":checked")) {
$("#backup-snap-keep").parent().parent().addClass("d-none");
} else {
$("#backup-snap-keep").parent().parent().removeClass("d-none");
} }
}); });
$("#trigger-nextcloud-settings").click(getNextcloudSettings);
$('#trigger-nextcloud-settings').click(getNextcloudSettings); $("#save-nextcloud-settings").click(sendNextcloudSettings);
$('#save-nextcloud-settings').click(sendNextcloudSettings); $("#ssl").on("change", function () {
$('#ssl').change(function () { let div = $("#self_signed").parent().parent();
let div = $('#self_signed').parent().parent(); if ($("#ssl").is(":checked")) div.removeClass("invisible");
if ($('#ssl').is(':checked')) else div.addClass("invisible");
div.removeClass("invisible")
else
div.addClass("invisible");
}); });
} }
function restore(id) { function restore(id) {
loadingModal.show(); loadingModal.show();
$.post('./api/restore', { path: id }) $.post("./api/restore", { path: id })
.done(() => { .done(() => {
console.log("Restore cmd send !"); console.log("Restore cmd send !");
create_toast("success", "Command sent !", default_toast_timeout); create_toast("success", "Command sent !", default_toast_timeout);
@ -236,49 +219,48 @@ function restore(id) {
console.log(error); console.log(error);
create_toast("error", "Can't send command !", default_toast_timeout); create_toast("error", "Can't send command !", default_toast_timeout);
}) })
.always(() => loadingModal.hide()) .always(() => loadingModal.hide());
} }
function sendNextcloudSettings() { function sendNextcloudSettings() {
loadingModal.show(); loadingModal.show();
nextcloud_setting_modal.hide(); nextcloud_setting_modal.hide();
let ssl = $('#ssl').is(':checked') let ssl = $("#ssl").is(":checked");
let self_signed = $('#self_signed').is(':checked') let self_signed = $("#self_signed").is(":checked");
let hostname = $('#hostname').val(); let hostname = $("#hostname").val();
let username = $('#username').val(); let username = $("#username").val();
let password = $('#password').val(); let password = $("#password").val();
let back_dir = $('#back-dir').val(); let back_dir = $("#back-dir").val();
$.post('./api/nextcloud-settings', { $.post("./api/nextcloud-settings", {
ssl: ssl, ssl: ssl,
host: hostname, host: hostname,
username: username, username: username,
password: password, password: password,
back_dir: back_dir, back_dir: back_dir,
self_signed: self_signed self_signed: self_signed,
}) })
.done(() => { .done(() => {
console.log('Saved'); console.log("Saved");
$('#nextcloud_settings_message').parent().addClass("d-none"); $("#nextcloud_settings_message").parent().addClass("d-none");
create_toast("success", "Nextcloud settings saved !", default_toast_timeout); create_toast("success", "Nextcloud settings saved !", default_toast_timeout);
0 0;
}) })
.fail((data) => { .fail((data) => {
let nextcloud_settings_message = $('#nextcloud_settings_message') let nextcloud_settings_message = $("#nextcloud_settings_message");
if (data.status === 406) { if (data.status === 406) {
console.log(data.responseJSON.message); console.log(data.responseJSON.message);
nextcloud_settings_message.html(data.responseJSON.message); nextcloud_settings_message.html(data.responseJSON.message);
} else { } else {
nextcloud_settings_message.html("Invalid Settings."); nextcloud_settings_message.html("Invalid Settings.");
} }
nextcloud_settings_message.parent().removeClass("d-none"); nextcloud_settings_message.parent().removeClass("d-none");
nextcloud_setting_modal.show(); nextcloud_setting_modal.show();
create_toast("error", "Invalid Nextcloud settings !", default_toast_timeout); create_toast("error", "Invalid Nextcloud settings !", default_toast_timeout);
console.log('Fail'); console.log("Fail");
}).always(() => {
loadingModal.hide();
}) })
.always(() => {
loadingModal.hide();
});
} }
function manualBackup(id, name) { function manualBackup(id, name) {
@ -290,40 +272,40 @@ function manualBackup(id, name) {
.fail((error) => { .fail((error) => {
console.log(error); console.log(error);
create_toast("error", "Can't send command !", default_toast_timeout); create_toast("error", "Can't send command !", default_toast_timeout);
}) });
} }
function getNextcloudSettings() { function getNextcloudSettings() {
loadingModal.show(); loadingModal.show();
$.get('./api/nextcloud-settings', (data) => { $.get("./api/nextcloud-settings", (data) => {
$('#ssl').prop("checked", data.ssl === "true"); $("#ssl").prop("checked", data.ssl === "true");
let sef_signed_jq = $('#self_signed') let sef_signed_jq = $("#self_signed");
if (data.ssl === "true") { if (data.ssl === "true") {
let div = sef_signed_jq.parent().parent(); let div = sef_signed_jq.parent().parent();
div.removeClass("invisible"); div.removeClass("invisible");
} }
sef_signed_jq.prop('checked', data.self_signed === "true") sef_signed_jq.prop("checked", data.self_signed === "true");
$('#hostname').val(data.host); $("#hostname").val(data.host);
$('#username').val(data.username); $("#username").val(data.username);
$('#password').val(data.password); $("#password").val(data.password);
$('#back-dir').val(data.back_dir); $("#back-dir").val(data.back_dir);
nextcloud_setting_modal.show();
}).fail((error) => {
if (error.status === 404)
nextcloud_setting_modal.show(); nextcloud_setting_modal.show();
})
.fail((error) => {
if (error.status === 404) nextcloud_setting_modal.show();
else { else {
console.log(error); console.log(error);
create_toast("error", "Failed to fetch Nextcloud config !", default_toast_timeout); create_toast("error", "Failed to fetch Nextcloud config !", default_toast_timeout);
} }
}).always(() => { })
.always(() => {
loadingModal.hide(); loadingModal.hide();
}); });
} }
function backupNow() { function backupNow() {
loadingModal.show(); loadingModal.show();
$.post('./api/new-backup') $.post("./api/new-backup")
.done(() => { .done(() => {
create_toast("success", "Command sent !", default_toast_timeout); create_toast("success", "Command sent !", default_toast_timeout);
}) })
@ -333,12 +315,12 @@ function backupNow() {
}) })
.always(() => { .always(() => {
loadingModal.hide(); loadingModal.hide();
}) });
} }
function cleanNow() { function cleanNow() {
loadingModal.show(); loadingModal.show();
$.post('./api/clean-now') $.post("./api/clean-now")
.done(() => { .done(() => {
create_toast("success", "Command sent !", default_toast_timeout); create_toast("success", "Command sent !", default_toast_timeout);
}) })
@ -348,141 +330,158 @@ function cleanNow() {
}) })
.always(() => { .always(() => {
loadingModal.hide(); loadingModal.hide();
}) });
} }
function getBackupSettings() { function getBackupSettings() {
loadingModal.show(); loadingModal.show();
$.get('./api/backup-settings', (data) => { $.get("./api/backup-settings", (data) => {
if (JSON.stringify(data) === "{}") { if (JSON.stringify(data) === "{}") {
data = { data = {
settings: {
cron_base: "0", cron_base: "0",
cron_hour: "00:00", cron_hour: "00:00",
cron_weekday: "0", cron_weekday: "0",
cron_month_day: "1", cron_month_day: "1",
cron_custom: "5 4 * * *",
auto_clean_local: false, auto_clean_local: false,
auto_clean_local_keep: 5, auto_clean_local_keep: 5,
auto_clean_backup: false, auto_clean_backup: false,
auto_clean_backup_keep: 5, auto_clean_backup_keep: 5,
} }
};
}
if (data.settings.cron_custom == null || data.settings.cron_custom == "") {
data.settings.cron_custom = "5 4 * * *";
} }
$('#cron-drop-settings').val(data.settings.cron_base); $("#cron-drop-settings").val(data.settings.cron_base);
$('#name-template').val(data.settings.name_template); $("#name-template").val(data.settings.name_template);
$("#timepicker").val(data.settings.cron_hour);
$("#cron-drop-day-month-read").val(data.settings.cron_month_day);
$("#cron-drop-day-month").val(data.settings.cron_month_day);
$("#cron-drop-custom").val(data.settings.cron_custom);
$('#timepicker').val(data.settings.cron_hour); $("#auto_clean_local").prop("checked", data.settings.auto_clean_local === "true");
$('#cron-drop-day-month-read').val(data.settings.cron_month_day); let local_snap_keep = $("#local-snap-keep");
$('#cron-drop-day-month').val(data.settings.cron_month_day); if (data.settings.auto_clean_local === "true") local_snap_keep.parent().parent().removeClass("d-none");
else local_snap_keep.parent().parent().addClass("d-none");
$('#auto_clean_local').prop('checked', data.settings.auto_clean_local === "true");
let local_snap_keep = $('#local-snap-keep');
if (data.settings.auto_clean_local === "true")
local_snap_keep.parent().parent().removeClass("d-none");
else
local_snap_keep.parent().parent().addClass("d-none");
local_snap_keep.val(data.settings.auto_clean_local_keep); local_snap_keep.val(data.settings.auto_clean_local_keep);
$('#auto_clean_backup').prop('checked', data.settings.auto_clean_backup === "true"); $("#auto_clean_backup").prop("checked", data.settings.auto_clean_backup === "true");
let backup_snap_keep = $('#backup-snap-keep'); let backup_snap_keep = $("#backup-snap-keep");
if (data.settings.auto_clean_backup === "true") if (data.settings.auto_clean_backup === "true") backup_snap_keep.parent().parent().removeClass("d-none");
backup_snap_keep.parent().parent().removeClass("d-none"); else backup_snap_keep.parent().parent().addClass("d-none");
else
backup_snap_keep.parent().parent().addClass("d-none");
backup_snap_keep.val(data.settings.auto_clean_backup_keep); backup_snap_keep.val(data.settings.auto_clean_backup_keep);
$('#cron-drop-day').val(data.settings.cron_weekday); $("#cron-drop-day").val(data.settings.cron_weekday);
let folder_html = "" let folder_html = "";
for (let thisFolder of data.folders) { for (let thisFolder of data.folders) {
let exclude = data.settings.exclude_folder.includes(thisFolder.slug); let exclude = data.settings.exclude_folder.includes(thisFolder.slug);
folder_html += `<li class="list-group-item"><div class="form-check"><input class="form-check-input folders-box" type="checkbox" id="${thisFolder.slug}" ${exclude ? "" : "checked"}><label class="form-label mb-0" for="${thisFolder.slug}">${thisFolder.name}</label></div></li>` folder_html += `<li class="list-group-item"><div class="form-check"><input class="form-check-input folders-box" type="checkbox" id="${
thisFolder.slug
}" ${exclude ? "" : "checked"}><label class="form-label mb-0" for="${thisFolder.slug}">${thisFolder.name}</label></div></li>`;
} }
$("#folders-div").html(folder_html); $("#folders-div").html(folder_html);
let addons_html = "" let addons_html = "";
for (let thisAddon of data.addonList) { for (let thisAddon of data.addonList) {
let exclude = data.settings.exclude_addon.includes(thisAddon.slug); let exclude = data.settings.exclude_addon.includes(thisAddon.slug);
addons_html += `<li class="list-group-item"><div class="form-check"><input class="form-check-input addons-box" type="checkbox" id="${thisAddon.slug}" ${exclude ? "" : "checked"}><label class="form-label mb-0" for="${thisAddon.slug}">${thisAddon.name}</label></div></li>` addons_html += `<li class="list-group-item"><div class="form-check"><input class="form-check-input addons-box" type="checkbox" id="${
thisAddon.slug
}" ${exclude ? "" : "checked"}><label class="form-label mb-0" for="${thisAddon.slug}">${thisAddon.name}</label></div></li>`;
} }
$("#addons-div").html(addons_html); $("#addons-div").html(addons_html);
let addons_stop_html = "" let addons_stop_html = "";
for (let thisAddon of data.addonList) { for (let thisAddon of data.addonList) {
if (thisAddon.slug !== "229cc4d7_nextcloud_backup"){ if (thisAddon.slug !== "229cc4d7_nextcloud_backup") {
let on = data.settings.auto_stop_addon.includes(thisAddon.slug); let on = data.settings.auto_stop_addon.includes(thisAddon.slug);
addons_stop_html += `<li class="list-group-item"><div class="form-check"><input class="form-check-input stop-addons-box" type="checkbox" id="${thisAddon.slug}" ${on ? "checked" : ""}><label class="form-label mb-0" for="${thisAddon.slug}">${thisAddon.name}</label></div></li>` addons_stop_html += `<li class="list-group-item"><div class="form-check"><input class="form-check-input stop-addons-box" type="checkbox" id="${
thisAddon.slug
}" ${on ? "checked" : ""}><label class="form-label mb-0" for="${thisAddon.slug}">${thisAddon.name}</label></div></li>`;
} }
} }
$("#auto-stop-addons-div").html(addons_stop_html); $("#auto-stop-addons-div").html(addons_stop_html);
updateDropVisibility(); updateDropVisibility();
backup_setting_modal.show(); backup_setting_modal.show();
})
.fail((error) => {
}).fail((error) => {
console.log(error); console.log(error);
create_toast("error", "Failed to fetch Nextcloud config !", default_toast_timeout); create_toast("error", "Failed to fetch Nextcloud config !", default_toast_timeout);
}).always(() => { })
.always(() => {
loadingModal.hide(); loadingModal.hide();
}); });
} }
function updateDropVisibility() { function updateDropVisibility() {
let cronBase = $("#cron-drop-settings").val(); let cronBase = $("#cron-drop-settings").val();
let timepicker = $('#timepicker'); let timepicker = $("#timepicker");
let cron_drop_day = $('#cron-drop-day'); let cron_drop_day = $("#cron-drop-day");
let cron_drop_day_mount = $('#cron-drop-day-month'); let cron_drop_day_mount = $("#cron-drop-day-month");
let cron_drop_custom = $("#cron-drop-custom");
switch (cronBase) { switch (cronBase) {
case "4":
timepicker.parent().parent().addClass("d-none");
cron_drop_day.parent().parent().addClass("d-none");
cron_drop_day_mount.parent().parent().addClass("d-none");
cron_drop_custom.parent().parent().removeClass("d-none");
break;
case "3": case "3":
timepicker.parent().parent().removeClass("d-none"); timepicker.parent().parent().removeClass("d-none");
cron_drop_day.parent().parent().addClass("d-none"); cron_drop_day.parent().parent().addClass("d-none");
cron_drop_day_mount.parent().parent().removeClass("d-none"); cron_drop_day_mount.parent().parent().removeClass("d-none");
cron_drop_custom.parent().parent().addClass("d-none");
break; break;
case "2": case "2":
timepicker.parent().parent().removeClass("d-none"); timepicker.parent().parent().removeClass("d-none");
cron_drop_day.parent().parent().removeClass("d-none"); cron_drop_day.parent().parent().removeClass("d-none");
cron_drop_day_mount.parent().parent().addClass("d-none"); cron_drop_day_mount.parent().parent().addClass("d-none");
cron_drop_custom.parent().parent().addClass("d-none");
break; break;
case "1": case "1":
timepicker.parent().parent().removeClass("d-none"); timepicker.parent().parent().removeClass("d-none");
cron_drop_day.parent().parent().addClass("d-none"); cron_drop_day.parent().parent().addClass("d-none");
cron_drop_day_mount.parent().parent().addClass("d-none"); cron_drop_day_mount.parent().parent().addClass("d-none");
cron_drop_custom.parent().parent().addClass("d-none");
break; break;
case "0": case "0":
timepicker.parent().parent().addClass("d-none"); timepicker.parent().parent().addClass("d-none");
cron_drop_day.parent().parent().addClass("d-none"); cron_drop_day.parent().parent().addClass("d-none");
cron_drop_day_mount.parent().parent().addClass("d-none"); cron_drop_day_mount.parent().parent().addClass("d-none");
cron_drop_custom.parent().parent().addClass("d-none");
break; break;
} }
} }
function sendBackupSettings() { function sendBackupSettings() {
let cron_month_day = $('#cron-drop-day-month').val(); let cron_month_day = $("#cron-drop-day-month").val();
let cron_weekday = $('#cron-drop-day').val(); let cron_weekday = $("#cron-drop-day").val();
let cron_hour = $('#timepicker').val(); let cron_hour = $("#timepicker").val();
let cron_base = $('#cron-drop-settings').val(); let cron_custom = $("#cron-drop-custom").val();
let auto_clean_local = $("#auto_clean_local").is(':checked'); let cron_base = $("#cron-drop-settings").val();
let auto_clean_backup = $("#auto_clean_backup").is(':checked'); let auto_clean_local = $("#auto_clean_local").is(":checked");
let auto_clean_backup = $("#auto_clean_backup").is(":checked");
let auto_clean_local_keep = $("#local-snap-keep").val(); let auto_clean_local_keep = $("#local-snap-keep").val();
let auto_clean_backup_keep = $("#backup-snap-keep").val(); let auto_clean_backup_keep = $("#backup-snap-keep").val();
let name_template = $('#name-template').val(); let name_template = $("#name-template").val();
let excluded_folders_nodes = document.querySelectorAll('.folders-box:not(:checked)'); let excluded_folders_nodes = document.querySelectorAll(".folders-box:not(:checked)");
let exclude_folder = [""]; let exclude_folder = [""];
let password_protected = $('#password_protected').is(':checked'); let password_protected = $("#password_protected").is(":checked");
let password_protect_value = $('#password_protect_value').val(); let password_protect_value = $("#password_protect_value").val();
for (let i of excluded_folders_nodes) { for (let i of excluded_folders_nodes) {
exclude_folder.push(i.id); exclude_folder.push(i.id);
} }
let excluded_addons_nodes = document.querySelectorAll('.addons-box:not(:checked)'); let excluded_addons_nodes = document.querySelectorAll(".addons-box:not(:checked)");
let exclude_addon = [""]; let exclude_addon = [""];
for (let i of excluded_addons_nodes) { for (let i of excluded_addons_nodes) {
exclude_addon.push(i.id); exclude_addon.push(i.id);
} }
let stop_addons_nodes = document.querySelectorAll('.stop-addons-box:checked'); let stop_addons_nodes = document.querySelectorAll(".stop-addons-box:checked");
let stop_addon = [""]; let stop_addon = [""];
for (let i of stop_addons_nodes) { for (let i of stop_addons_nodes) {
stop_addon.push(i.id); stop_addon.push(i.id);
@ -490,13 +489,13 @@ function sendBackupSettings() {
loadingModal.show(); loadingModal.show();
backup_setting_modal.hide(); backup_setting_modal.hide();
$.post('./api/backup-settings', $.post("./api/backup-settings", {
{
name_template: name_template, name_template: name_template,
cron_base: cron_base, cron_base: cron_base,
cron_hour: cron_hour, cron_hour: cron_hour,
cron_weekday: cron_weekday, cron_weekday: cron_weekday,
cron_month_day: cron_month_day, cron_month_day: cron_month_day,
cron_custom: cron_custom,
auto_clean_local: auto_clean_local, auto_clean_local: auto_clean_local,
auto_clean_local_keep: auto_clean_local_keep, auto_clean_local_keep: auto_clean_local_keep,
auto_clean_backup: auto_clean_backup, auto_clean_backup: auto_clean_backup,
@ -505,14 +504,14 @@ function sendBackupSettings() {
exclude_folder: exclude_folder, exclude_folder: exclude_folder,
auto_stop_addon: stop_addon, auto_stop_addon: stop_addon,
password_protected: password_protected, password_protected: password_protected,
password_protect_value: password_protect_value password_protect_value: password_protect_value,
}) })
.done(() => { .done(() => {
create_toast("success", "Backup settings saved !", default_toast_timeout); create_toast("success", "Backup settings saved !", default_toast_timeout);
}) })
.fail(() => { .fail((data) => {
create_toast("error", "Can't save backup settings !", default_toast_timeout); debugger
create_toast("error", `Can't save backup settings ! <br> Error: ${data.responseText}`, default_toast_timeout);
backup_setting_modal.show(); backup_setting_modal.show();
}) })
.always(() => { .always(() => {

View File

@ -188,13 +188,14 @@ router.get("/backup-settings", function (req, res, next) {
}); });
router.post("/backup-settings", function (req, res, next) { router.post("/backup-settings", function (req, res, next) {
if (settingsTools.check(req.body)) { let [result, message] = settingsTools.check(req.body)
if (result) {
settingsTools.setSettings(req.body); settingsTools.setSettings(req.body);
cronTools.startCron(); cronTools.startCron();
res.send(); res.send();
} else { } else {
res.status(400); res.status(400);
res.send(); res.send(message);
} }
}); });

View File

@ -64,6 +64,10 @@ class CronContainer {
cronStr = "" + splited[1] + " " + splited[0] + " " + settings.cron_month_day + " * *"; cronStr = "" + splited[1] + " " + splited[0] + " " + settings.cron_month_day + " * *";
break; break;
} }
case "4": {
cronStr = settings.cron_custom;
break;
}
} }
logger.info("Starting Cron..."); logger.info("Starting Cron...");
this.cronJob = new CronJob(cronStr, this._createBackup, null, false, Intl.DateTimeFormat().resolvedOptions().timeZone); this.cronJob = new CronJob(cronStr, this._createBackup, null, false, Intl.DateTimeFormat().resolvedOptions().timeZone);

View File

@ -457,7 +457,7 @@ function startAddons() {
let promises = []; let promises = [];
let token = process.env.HASSIO_TOKEN; let token = process.env.HASSIO_TOKEN;
let option = { let option = {
headers: { "X-HASSIO-KEY": token }, headers: { "Authorization": `Bearer ${token}` },
responseType: "json", responseType: "json",
}; };
let addons_slug = settingsTools.getSettings().auto_stop_addon let addons_slug = settingsTools.getSettings().auto_stop_addon
@ -494,6 +494,76 @@ function startAddons() {
})); }));
} }
function publish_state(state){
let data_error_sensor = {
state: state.status == "error" ? "on" : "off",
attributes: {
friendly_name: "Nexcloud Backup Error",
device_class: "problem",
error_code: state.error_code,
message: state.message,
icon: state.status == "error" ? "mdi:cloud-alert" : "mdi:cloud-check"
},
}
let token = process.env.HASSIO_TOKEN;
let option = {
headers: { "Authorization": `Bearer ${token}` },
responseType: "json",
json: data_error_sensor
};
got.post(`http://hassio/core/api/states/binary_sensor.nextcloud_backup_error`, option)
.then((result) => {
logger.debug('Home assistant sensor updated (error status)');
})
.catch((error) => {
logger.error(error);
});
let icon = ""
switch(state.status){
case "error":
icon = "mdi:cloud-alert";
break;
case "download":
case "download-b":
icon = "mdi:cloud-download";
break;
case "upload":
case "upload-b":
icon = "mdi:cloud-upload";
break;
case "idle":
icon = "mdi:cloud-check";
break;
default:
icon = "mdi:cloud-sync";
break;
}
let data_state_sensor = {
state: state.status,
attributes: {
friendly_name: "Nexcloud Backup Status",
error_code: state.error_code,
message: state.message,
icon: icon,
last_backup: state.last_backup == null ? "" : new Date(state.last_backup).toISOString(),
next_backup: state.next_backup == null ? "" : new Date(state.next_backup).toISOString()
},
}
option.json = data_state_sensor
got.post(`http://hassio/core/api/states/sensor.nextcloud_backup_status`, option)
.then((result) => {
logger.debug('Home assistant sensor updated (status)');
})
.catch((error) => {
logger.error(error);
});
}
exports.getVersion = getVersion; exports.getVersion = getVersion;
exports.getAddonList = getAddonList; exports.getAddonList = getAddonList;
exports.getFolderList = getFolderList; exports.getFolderList = getFolderList;
@ -504,3 +574,4 @@ exports.uploadSnapshot = uploadSnapshot;
exports.stopAddons = stopAddons; exports.stopAddons = stopAddons;
exports.startAddons = startAddons; exports.startAddons = startAddons;
exports.clean = clean; exports.clean = clean;
exports.publish_state = publish_state;

View File

@ -1,6 +1,7 @@
const fs = require("fs"); const fs = require("fs");
const logger = require("../config/winston"); const logger = require("../config/winston");
const moment = require('moment') const moment = require("moment");
const CronJob = require("cron").CronJob;
const settingsPath = "/data/backup_conf.json"; const settingsPath = "/data/backup_conf.json";
@ -20,149 +21,158 @@ function check_cron(conf) {
return conf.cron_month_day != null && conf.cron_month_day >= 1 && conf.cron_month_day <= 28; return conf.cron_month_day != null && conf.cron_month_day >= 1 && conf.cron_month_day <= 28;
} }
if (conf.cron_base === "4") {
if (conf.cron_custom != null) {
try {
new CronJob(conf.cron_custom, () => {});
return true;
} catch(e) {
return false;
}
}else return false;
}
if (conf.cron_base === "0") return true; if (conf.cron_base === "0") return true;
} else return false; } else return false;
return false; return false;
} }
function check(conf, fallback = false) { function check(conf, fallback = false) {
let needSave = false; let needSave = false;
if (!check_cron(conf)) { if (!check_cron(conf)) {
if (fallback) { if (fallback) {
logger.warn("Bad value for cron settings, fallback to default ") logger.warn("Bad value for cron settings, fallback to default ");
conf.cron_base = "0"; conf.cron_base = "0";
conf.cron_hour = "00:00", conf.cron_hour = "00:00";
conf.cron_weekday = "0", conf.cron_weekday = "0";
conf.cron_month_day = "1" conf.cron_month_day = "1";
conf.cron_custom = "5 4 * * *";
} else { } else {
logger.error("Bad value for cron settings") logger.error("Bad value for cron settings");
return false; return [false, "Bad cron settings"];
} }
} }
if (conf.name_template == null) { if (conf.name_template == null) {
if (fallback) { if (fallback) {
logger.warn("Bad value for 'name_template', fallback to default ") logger.warn("Bad value for 'name_template', fallback to default ");
conf.name_template = "{type}-{ha_version}-{date}_{hour}" conf.name_template = "{type}-{ha_version}-{date}_{hour}";
} else { } else {
logger.error("Bad value for 'name_template'") logger.error("Bad value for 'name_template'");
return false; return [false, "Bad value for 'name_template'"];
} }
} }
if (conf.auto_clean_local_keep == null || !/^\d+$/.test(conf.auto_clean_local_keep)) { if (conf.auto_clean_local_keep == null || !/^\d+$/.test(conf.auto_clean_local_keep)) {
if (fallback) { if (fallback) {
logger.warn("Bad value for 'auto_clean_local_keep', fallback to 5 ") logger.warn("Bad value for 'auto_clean_local_keep', fallback to 5 ");
conf.auto_clean_local_keep = "5" conf.auto_clean_local_keep = "5";
} else { } else {
logger.error("Bad value for 'auto_clean_local_keep'") logger.error("Bad value for 'auto_clean_local_keep'");
return false; return [false, "Bad value for 'auto_clean_local_keep'"];
} }
} }
if (conf.auto_clean_backup_keep == null || !/^\d+$/.test(conf.auto_clean_backup_keep)) { if (conf.auto_clean_backup_keep == null || !/^\d+$/.test(conf.auto_clean_backup_keep)) {
if (fallback) { if (fallback) {
logger.warn("Bad value for 'auto_clean_backup_keep', fallback to 5 ") logger.warn("Bad value for 'auto_clean_backup_keep', fallback to 5 ");
conf.auto_clean_backup_keep = "5" conf.auto_clean_backup_keep = "5";
} else { } else {
logger.error("Bad value for 'auto_clean_backup_keep'") logger.error("Bad value for 'auto_clean_backup_keep'");
return false; return [false, "Bad value for 'auto_clean_backup_keep'"];
} }
} }
if (conf.auto_clean_local == null) { if (conf.auto_clean_local == null) {
if (fallback) { if (fallback) {
logger.warn("Bad value for 'auto_clean_local', fallback to false ") logger.warn("Bad value for 'auto_clean_local', fallback to false ");
conf.auto_clean_local = "false" conf.auto_clean_local = "false";
} else { } else {
logger.error("Bad value for 'auto_clean_local'") logger.error("Bad value for 'auto_clean_local'");
return false; return [false, "Bad value for 'auto_clean_local'"];
} }
} }
if (conf.auto_clean_backup == null) { if (conf.auto_clean_backup == null) {
if (fallback) { if (fallback) {
logger.warn("Bad value for 'auto_clean_backup', fallback to false ") logger.warn("Bad value for 'auto_clean_backup', fallback to false ");
conf.auto_clean_backup = "false" conf.auto_clean_backup = "false";
} else { } else {
logger.error("Bad value for 'auto_clean_backup'") logger.error("Bad value for 'auto_clean_backup'");
return false; return [false, "Bad value for 'auto_clean_backup'"];
} }
} }
if (conf.exclude_addon == null) { if (conf.exclude_addon == null) {
if (fallback) { if (fallback) {
logger.warn("Bad value for 'exclude_addon', fallback to [] ") logger.warn("Bad value for 'exclude_addon', fallback to [] ");
conf.exclude_addon = [] conf.exclude_addon = [];
} else { } else {
logger.error("Bad value for 'exclude_addon'") logger.error("Bad value for 'exclude_addon'");
return false; return [false, "Bad value for 'exclude_addon'"];
} }
} }
if (conf.exclude_folder == null) { if (conf.exclude_folder == null) {
if (fallback) { if (fallback) {
logger.warn("Bad value for 'exclude_folder', fallback to [] ") logger.warn("Bad value for 'exclude_folder', fallback to [] ");
conf.exclude_folder = [] conf.exclude_folder = [];
} else { } else {
logger.error("Bad value for 'exclude_folder'") logger.error("Bad value for 'exclude_folder'");
return false; return [false, "Bad value for 'exclude_folder'"];
} }
} }
if (conf.auto_stop_addon == null) { if (conf.auto_stop_addon == null) {
if (fallback) { if (fallback) {
logger.warn("Bad value for 'auto_stop_addon', fallback to [] ") logger.warn("Bad value for 'auto_stop_addon', fallback to [] ");
conf.auto_stop_addon = [] conf.auto_stop_addon = [];
} else { } else {
logger.error("Bad value for 'auto_stop_addon'") logger.error("Bad value for 'auto_stop_addon'");
return false; return [false, "Bad value for 'auto_stop_addon'"];
} }
} }
if (!Array.isArray(conf.exclude_folder)) { if (!Array.isArray(conf.exclude_folder)) {
logger.debug("exclude_folder is not array (Empty value), reset..."); logger.debug("exclude_folder is not array (Empty value), reset...");
conf.exclude_folder = [] conf.exclude_folder = [];
needSave = true; needSave = true;
} }
if (!Array.isArray(conf.exclude_addon)) { if (!Array.isArray(conf.exclude_addon)) {
logger.debug("exclude_addon is not array (Empty value), reset..."); logger.debug("exclude_addon is not array (Empty value), reset...");
conf.exclude_addon = [] conf.exclude_addon = [];
needSave = true; needSave = true;
} }
if(conf.password_protected == null){ if (conf.password_protected == null) {
if (fallback) { if (fallback) {
logger.warn("Bad value for 'password_protected', fallback to false "); logger.warn("Bad value for 'password_protected', fallback to false ");
conf.password_protected = 'false'; conf.password_protected = "false";
} else { } else {
logger.error("Bad value for 'password_protect_value'"); logger.error("Bad value for 'password_protect_value'");
return false; return [false, "Bad value for 'password_protect_value'"];
} }
} }
if(conf.password_protect_value == null){ if (conf.password_protect_value == null) {
if (fallback) { if (fallback) {
logger.warn("Bad value for 'password_protect_value', fallback to '' "); logger.warn("Bad value for 'password_protect_value', fallback to '' ");
conf.password_protect_value = ''; conf.password_protect_value = "";
} else { } else {
logger.error("Bad value for 'password_protect_value'"); logger.error("Bad value for 'password_protect_value'");
return false; return [false, "Bad value for 'password_protect_value'"];
} }
} }
if (fallback || needSave) { if (fallback || needSave) {
setSettings(conf); setSettings(conf);
} }
return true return [true, null];
} }
function getFormatedName(is_manual, ha_version) { function getFormatedName(is_manual, ha_version) {
let setting = getSettings(); let setting = getSettings();
let template = setting.name_template; let template = setting.name_template;
template = template.replace('{type_low}', is_manual ? 'manual' : 'auto'); template = template.replace("{type_low}", is_manual ? "manual" : "auto");
template = template.replace('{type}', is_manual ? 'Manual' : 'Auto'); template = template.replace("{type}", is_manual ? "Manual" : "Auto");
template = template.replace('{ha_version}', ha_version); template = template.replace("{ha_version}", ha_version);
let mmt = moment() let mmt = moment();
template = template.replace('{hour_12}', mmt.format('hhmmA')); template = template.replace("{hour_12}", mmt.format("hhmmA"));
template = template.replace('{hour}', mmt.format('HHmm')); template = template.replace("{hour}", mmt.format("HHmm"));
template = template.replace('{date}', mmt.format('YYYY-MM-DD')); template = template.replace("{date}", mmt.format("YYYY-MM-DD"));
return template return template;
} }
function getSettings() { function getSettings() {

View File

@ -1,4 +1,5 @@
const fs = require("fs"); const fs = require("fs");
const hassioApiTools = require("./hassioApiTools");
const statusPath = "/data/status.json"; const statusPath = "/data/status.json";
@ -33,11 +34,14 @@ function setStatus(state) {
let old_state_str = fs.readFileSync(statusPath).toString(); let old_state_str = fs.readFileSync(statusPath).toString();
if(old_state_str !== JSON.stringify(state)){ if(old_state_str !== JSON.stringify(state)){
fs.writeFileSync(statusPath, JSON.stringify(state)); fs.writeFileSync(statusPath, JSON.stringify(state));
hassioApiTools.publish_state(state);
} }
}else{ }else{
fs.writeFileSync(statusPath, JSON.stringify(state)); fs.writeFileSync(statusPath, JSON.stringify(state));
hassioApiTools.publish_state(state);
} }
} }
exports.init = init; exports.init = init;

View File

@ -88,6 +88,7 @@
<option value="1">Daily</option> <option value="1">Daily</option>
<option value="2">Weekly</option> <option value="2">Weekly</option>
<option value="3">Monthly</option> <option value="3">Monthly</option>
<option value="4">Custom</option>
</select> </select>
</div> </div>
</div> </div>
@ -120,6 +121,21 @@
<input type="number" class="form-control" id="cron-drop-day-month" min="1" max="28"> <input type="number" class="form-control" id="cron-drop-day-month" min="1" max="28">
</div> </div>
</div> </div>
<div class="row d-none mt-2">
<div class="col-12 col-lg-10 offset-lg-1">
<label for="cron-drop-custom" class="form-label">Custom Cron Pattern</label>
<input type="text" class="form-control" id="cron-drop-custom">
<span id="help-cron-custom"" class="form-text">
Only '*', ranges (1-3,5), steps (*/2) are allowed.
<a target="_blank"
href="https://crontab.guru/">
Generator
</a>
</span>
</div>
</div>
<div class="row my-3"> <div class="row my-3">
<div class="col-12 text-center border-secondary border"></div> <div class="col-12 text-center border-secondary border"></div>
</div> </div>