├── views ├── admin.handlebars ├── scriptedit.handlebars └── schedule.handlebars ├── config.json ├── includes └── tail.DateTime │ ├── package.json │ ├── LICENSE.md │ ├── tail.datetime-default-blue.min.map │ ├── README.md │ ├── tail.datetime-default-blue.min.css │ ├── CHANGELOG.md │ └── tail.datetime.min.js ├── changelog.md ├── readme.md ├── nemongo.js ├── LICENSE ├── db.js ├── modules_meshcore └── scripttask.js └── scripttask.js /views/admin.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 14 | 15 |
16 | Nothing to see here... yet. 17 |
18 | 19 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ScriptTask", 3 | "shortName": "scripttask", 4 | "version": "0.0.20", 5 | "author": "Ryan Blenis", 6 | "description": "Script (PowerShell, BAT, Bash) runner for endpoints", 7 | "hasAdminPanel": false, 8 | "homepage": "https://github.com/ryanblenis/MeshCentral-ScriptTask", 9 | "changelogUrl": "https://raw.githubusercontent.com/ryanblenis/MeshCentral-ScriptTask/master/changelog.md", 10 | "configUrl": "https://raw.githubusercontent.com/ryanblenis/MeshCentral-ScriptTask/master/config.json", 11 | "downloadUrl": "https://github.com/ryanblenis/MeshCentral-ScriptTask/archive/master.zip", 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/ryanblenis/MeshCentral-ScriptTask.git" 15 | }, 16 | "versionHistoryUrl": "https://api.github.com/repos/ryanblenis/MeshCentral-ScriptTask/tags", 17 | "meshCentralCompat": ">=1.1.35" 18 | } -------------------------------------------------------------------------------- /includes/tail.DateTime/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tail.datetime", 3 | "version": "0.4.14", 4 | "description": "A powerful, extensive and configurable Date/Time Picker, written in Vanilla JavaScript without any dependencies!", 5 | "keywords": [ 6 | "datetime-picker", 7 | "datetime", 8 | "date", 9 | "time", 10 | "picker", 11 | "calendar", 12 | "vanilla", 13 | "tail" 14 | ], 15 | "author": "SamBrishes (https://www.pytes.net)", 16 | "license": "MIT", 17 | "homepage": "https://github.com/pytesNET/tail.DateTime", 18 | 19 | "main": "js/tail.datetime.js", 20 | "bugs": { 21 | "url": "https://github.com/pytesNET/tail.DateTime/issues", 22 | "email": "info@pytes.net" 23 | }, 24 | "repository": { 25 | "type": "git", 26 | "url": "git+ssh://git@github.com/pytesNET/tail.DateTime.git" 27 | }, 28 | "devDependencies": { 29 | "less": ">=3.5.0", 30 | "clean-css": ">=4.1.0" 31 | }, 32 | 33 | "reveal": true, 34 | "browser": "js/tail.datetime-full.js", 35 | "jsdelivr": "js/tail.datetime-full.js" 36 | } 37 | -------------------------------------------------------------------------------- /includes/tail.DateTime/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 - 2019 SamBrishes, pytesNET 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /views/scriptedit.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 36 | 37 |
38 |
Script Name:
39 |
40 | 41 | 42 |
43 |
44 | 45 |
46 |
47 | 48 | 69 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). 5 | 6 | ## [Known Issues] 7 | - None. Please feel free to submit an issue via [GitHub](https://github.com/ryanblenis/MeshCentral-ScriptTask) if you find anything. 8 | 9 | ## [0.0.20] - 2025-01-08 10 | ### Fixed 11 | - Merge PR fixing MeshCentral 1.1.35+ compatibility 12 | 13 | ## [0.0.19] - 2024-02-07 14 | ### Fixed 15 | - Merge PR fixing scroll bars and Powershell execution policy 16 | 17 | ## [0.0.18] - 2022-03-12 18 | ### Fixed 19 | - Compatibility with MeshCentral => 0.9.98 (promise requirement removed from MeshCentral, nedb moved to @yetzt/nedb) 20 | 21 | ## [0.0.17] - 2021-10-07 22 | ### Fixed 23 | - Compatibility with MeshCentral > 0.9.7 24 | 25 | ## [0.0.16] - 2021-05-18 26 | ### Fixed 27 | - Drag/drop scripts between folders 28 | 29 | ## [0.0.15] - 2020-03-07 30 | ### Fixed 31 | - Prevent race condition with conflicting plugins changing the app views directory by using absolute paths 32 | 33 | ## [0.0.14] - 2020-02-28 34 | ### Added 35 | - Add new script from ScriptTask plugin without dragging/uploading an existing script 36 | - Variables introduced. Supports global, script, mesh, and node level. Overridden in that order. 37 | 38 | ## [0.0.13] - 2020-02-15 39 | ### Fixed 40 | - Folder rename function now working as intended 41 | - Removed ability to "edit" folders as if they were a script 42 | 43 | ## [0.0.12] - 2020-02-14 44 | ### Fixed 45 | - Rename function broke when filetype tags were added 46 | 47 | ## [0.0.11] - 2020-01-24 48 | ### Added 49 | - Advanced selection of nodes based on mesh and tag membership 50 | 51 | ## [0.0.10] - 2020-01-02 52 | ### Fixed 53 | - Removed logging to MeshCentral events DB for each script run / refresh event (causing events file to grow quickly and crash NeDB instances) 54 | 55 | ## [0.0.9] - 2019-12-24 56 | ### Fixed 57 | - Native Powershell scripts now run correctly on more versions of Linux/MacOS 58 | 59 | ## [0.0.8] - 2019-12-23 60 | ### Fixed 61 | - Force strip carriage returns from bash scripts 62 | 63 | ## [0.0.7] - 2019-12-23 64 | ### Fixed 65 | - Some versions of Linux don't default the agents root to the MeshAgent's directory. Added path detection for a safe temp zone. Thanks /u/Reverent for the assist in debugging that one! 66 | 67 | ## [0.0.6] - 2019-12-23 68 | ### Added 69 | - Status return of a script as success/failure if the script does not produce output 70 | - Endpoint debugging toggle via console (plugin scripttask debug) 71 | ### Fixed 72 | - Made some endpoint calls a little safer with try/catch to stop errors from killing the process 73 | 74 | ## [0.0.5] - 2019-12-22 75 | ### Added 76 | - NeDB support 77 | ### Fixed 78 | - CSS call looking for mapping file removed 79 | - Date/time select on schedule screen might not have had the correct mimetype, thus not appeared in some instances 80 | 81 | ## [0.0.4] - 2019-12-22 82 | ### Added 83 | - Script type identifier to the script tree view 84 | ### Fixed 85 | - Prevent catch-up jobs from running every minute on long running schedules when a node is offline for a period of time. 86 | - Check for scheduled jobs 1 minute in the future to prevent schedules running 1 minute behind intended time. 87 | 88 | ## [0.0.3] - 2019-12-20 89 | ### Fixed 90 | - Typo causing installs to think Mongo is not in use 91 | 92 | ## [0.0.2] - 2019-12-20 93 | ### Added 94 | - Suppressed errors and made a nice error message for those without MongoDB (currently unsupported) 95 | 96 | ## [0.0.1] - 2019-12-20 97 | ### Added 98 | - Released initial version 99 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # MeshCentral-ScriptTask 2 | 3 | A script running plugin for the [MeshCentral2](https://github.com/Ylianst/MeshCentral) Project. The plugin supports PowerShell, BAT, and Bash scripts. Windows, MacOS, and Linux endpoints are all supported. PowerShell can be run on any OS that has PowerShell installed, not just Windows. 4 | 5 | ## Important Note 6 | **This plugin now supports NeDB and MongoDB** 7 | 8 | ## Installation 9 | 10 | Pre-requisite: First, make sure you have plugins enabled for your MeshCentral installation: 11 | > "plugins": { 12 | > "enabled": true 13 | > }, 14 | Restart your MeshCentral server after making this change. 15 | 16 | To install, simply add the plugin configuration URL when prompted: 17 | `https://raw.githubusercontent.com/ryanblenis/MeshCentral-ScriptTask/master/config.json` 18 | 19 | ## Features 20 | - Add scripts to a central store 21 | - Run scripts on single or multiple endpoints simultaneously 22 | -- Supports PowerShell, BAT, and Bash scripts 23 | - Review the return status / value of completed scripts 24 | -- Returns text or parses returned JSON for easy viewing 25 | - Schedule scripts for future runs on either a one-time or interval basis (minutes, hourly, daily, weekly) 26 | - View schedules and histories based on either node (endpoint) or script 27 | - Dead job detection with script replay 28 | 29 | ## Usage Notes 30 | - *Run* schedules and runs the job instantly. 31 | - *Schedule* puts the events into a queue. 32 | - Queues are checked / run every minute. 33 | - Scheduled jobs only show the *next* scheduled job at any given time. 34 | - History is limited to 200 events per node/script in the viewport. 35 | - Historical events that have completed will delete after 90 days. 36 | - Jobs only run when the endpoint agent is online. They do *not* queue to the agent when offline, then run at the specified time. 37 | - Scripts are cached on the clients and verified via hash at runtime for the latest version. 38 | 39 | ## Variables 40 | - Variables can be assigned to the following scopes: Global, Script, Mesh, and Node 41 | - Variables with the same name will override each other in the above order (ex. Global variable testVariable will be overridden by Script variable testVariable will be overridden by Mesh variable Test will be overridden by Node variable testVariable if they exist and apply to the node running the script) 42 | - Variables found in a script which do not correspond with a defined variable will be replaced with VAR_NOT_FOUND 43 | - Variables are assigned during job dispatch (e.g. when the job is sent to the node), so the latest script and variable values will be accounted for, should they have changed since a job or scheduled job were defined. 44 | - Variables in scripts must be defined by hashtags on both sides and not contain spaces. (E.g. #myVar#) 45 | 46 | ## Getting Started 47 | Drag and drop some of your favorite admin scripts on the file tree. You'll then be able to run them immediately on endpoints (nodes). 48 | 49 | ## Upcoming Features 50 | - Take action on the results of a script 51 | - Variable replacement 52 | 53 | ## Other Information 54 | This is fairly new and in beta. Testing was mostly done in the latest Chrome and Firefox. No attempt was made to be compatible with older IE browsers. Endpoint testing was done on Windows 10 (1903) and OS X 10.13. 55 | 56 | ## Screenshots 57 | ![Device Page](https://user-images.githubusercontent.com/1929277/71248033-f4519b00-22e7-11ea-9aa6-ef22e0b9fdb2.png) 58 | ![Script Editor](https://user-images.githubusercontent.com/1929277/71248034-f4519b00-22e7-11ea-8ab4-ccad3e959a1a.png) 59 | ![Schedule Screen](https://user-images.githubusercontent.com/1929277/71248469-e7817700-22e8-11ea-9121-a215de160e0e.png) 60 | 61 | -------------------------------------------------------------------------------- /nemongo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @description MeshCentral database abstraction layer for NeDB to be more Mongo-like 3 | * @author Ryan Blenis 4 | * @copyright Ryan Blenis 2019 5 | * @license Apache-2.0 6 | * This is by no means feature complete, just a simple abstraction layer for many commonly used DB calls. 7 | * It supplements the need to duplicate and modify all NeDB calls in the db.js file by assuming that .toArray() 8 | * will be called on MongoDB objects (as you normally would to keep the return values of NeDB / Mongo similarly for MeshCentral consumption) 9 | * and uses that information to then call a .exec() function on the supplied NeDB with the given arguments. 10 | * This does NOT handle some of Mongo's more complex arguments (yet) 11 | */ 12 | class NEMongo { 13 | constructor(nedbInst) { 14 | this.nedb = nedbInst; 15 | this._find = null; 16 | this._proj = null; 17 | this._limit = null; 18 | this._sort = null; 19 | return this; 20 | } 21 | 22 | find(args, proj) { 23 | this._find = args; 24 | this._proj = proj; 25 | return this; 26 | } 27 | 28 | project(args) { 29 | this._proj = args; 30 | 31 | return this; 32 | } 33 | 34 | sort(args) { 35 | this._sort = args; 36 | return this; 37 | } 38 | 39 | limit(limit) { 40 | this._limit = limit; 41 | return this; 42 | } 43 | 44 | toArray(callback) { 45 | var self = this; 46 | return new Promise(function(resolve, reject) { 47 | self.nedb.find( self._find, self._proj ).sort(self._sort).limit(self._limit).exec((err, docs) => { 48 | if (callback != null && typeof callback == 'function') callback(err, docs); 49 | if (err != null) reject(err); 50 | if (callback != null && typeof callback == 'function') callback(err, docs); 51 | else resolve(docs); 52 | }); 53 | }); 54 | } 55 | 56 | insertOne(args, options) { 57 | var self = this; 58 | return new Promise(function(resolve, reject) { 59 | self.nedb.insert(args, function(err, newDoc) { 60 | if (err) reject(err); 61 | newDoc.insertedId = newDoc._id; 62 | resolve({ insertedId: newDoc._id }); 63 | }); 64 | }); 65 | } 66 | 67 | deleteOne(filter, options) { 68 | var self = this; 69 | self._find = filter; 70 | return new Promise(function(resolve, reject) { 71 | self.nedb.remove(self._find, { multi: false }, function(err, numRemoved) { 72 | if (err) reject(err); 73 | resolve( { deletedCount: numRemoved } ); 74 | }); 75 | }); 76 | } 77 | 78 | deleteMany(filter, options) { 79 | var self = this; 80 | self._find = filter; 81 | return new Promise(function(resolve, reject) { 82 | self.nedb.remove(self._find, { multi: true }, function(err, numRemoved) { 83 | if (err) reject(err); 84 | resolve( { deletedCount: numRemoved } ); 85 | }); 86 | }); 87 | } 88 | 89 | updateOne(filter, update, options) { 90 | var self = this; 91 | self._find = filter; 92 | if (options == null) options = {}; 93 | if (options.upsert == null) options.upsert = false; 94 | return new Promise(function(resolve, reject) { 95 | self.nedb.update(self._find, update, { multi: false, upsert: options.upsert }, function(err, numAffected, affectedDoc) { 96 | if (err) reject(err); 97 | var retObj = { matchedCount: numAffected, modifiedCount: numAffected }; 98 | if (affectedDoc != null) retObj.upsertedId = affectedDoc._id; 99 | resolve(retObj); 100 | }); 101 | }); 102 | } 103 | 104 | updateMany(filter, update, options) { 105 | var self = this; 106 | self._find = filter; 107 | if (options == null) options = {}; 108 | if (options.upsert == null) options.upsert = false; 109 | return new Promise(function(resolve, reject) { 110 | self.nedb.update(self._find, update, { multi: true, upsert: options.upsert }, function(err, numAffected, affectedDocs) { 111 | if (err) reject(err); 112 | var retObj = { matchedCount: numAffected, modifiedCount: numAffected }; 113 | if (affectedDocs != null) retObj.upsertedId = affectedDocs[0]._id; 114 | resolve(retObj); 115 | }); 116 | }); 117 | } 118 | 119 | } 120 | 121 | module.exports = NEMongo; -------------------------------------------------------------------------------- /includes/tail.DateTime/tail.datetime-default-blue.min.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["$stdin"],"names":[],"mappings":"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"} -------------------------------------------------------------------------------- /views/schedule.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 61 | 62 | 63 |
64 |
65 | 66 | 67 |
68 |
69 |
70 | Recurrence 71 |
    72 |
  • 73 |
  • 74 |
  • 75 |
  • 76 |
  • 77 | 78 |
79 |
80 | 109 |
110 |
111 | 112 | 236 | -------------------------------------------------------------------------------- /includes/tail.DateTime/README.md: -------------------------------------------------------------------------------- 1 | tail.DateTime 2 | ============= 3 | [![npm Version](https://s.pytes.me/a7034683)](https://s.pytes.me/64a7f3a3) 4 | [![npm Downloads](https://s.pytes.me/e3024ed7)](https://s.pytes.me/64a7f3a3) 5 | [![Support Me](https://s.pytes.me/4a1717aa)](https://buymeacoffee.com/pytesNET) 6 | [![plainJS](https://s.pytes.me/3fd80118)](https://s.pytes.me/e0b6ce86) 7 | [![License](https://s.pytes.me/8257ac72)](LICENSE.md) 8 | 9 | The perfect Date/Time Picker for your perfect Website / Web-Application! 10 | 11 |

12 | 13 |

14 | 15 | The **tail.DateTime** script is an extensive and fully-featured Date/Time Picker, written in vanilla 16 | JavaScfript and without any dependency. It is compatible with all major browsers, starting with 17 | **IE 10** and above, and is optimized for a direct use in the browser, as AMD (using requireJS) or 18 | as browserify module. 19 | 20 | ---------------------------- 21 | 22 | [Wanna see **tail.DateTime** in action?](https://github.pytes.net/tail.DateTime) 23 | 24 | [Wanna translate **tail.DateTime** in your language?](https://github.com/pytesNET/tail.DateTime/wiki/Help-Translating) 25 | 26 | Support 27 | ------- 28 |

29 | You really like my tail.DateTime script and want to support me and all of my projects?
30 | Then I would be extremely grateful for a coffee! (Thanks to all Supporters)

31 | Buy Me A Coffee 32 |

33 | 34 | Features 35 | -------- 36 | - **Beautiful**. 2 different Designs in 4 / 2 color schemes... 37 | - **Extensive**. 38 | - Define Black- or Whitelists... 39 | - Use colorizable tooltips... 40 | - Restrict the date/time selection... 41 | - ... and way more ... 42 | - **Configurable**. 30 settings and 4 bindable events... 43 | - **Translatable**. Already available in 17 languages... 44 | - **Zero Dependencies**. And written in vanilla JavaScript... 45 | - **Free/To/Use**. Because it's MIT licensed <3 46 | 47 | Install & Embed 48 | --------------- 49 | The master branch will always contain the latest Release, which you can download directly here 50 | as [.tar](https://github.com/pytesNET/tail.DateTime/tarball/master) or as [.zip](https://github.com/pytesNET/tail.DateTime/zipball/master) 51 | archive, or just visit the [Releases](https://github.com/pytesNET/tail.DateTime/releases) Page 52 | on GitHub directly. You can also be cool and using NPM (or YARN): 53 | 54 | ```markup 55 | npm install tail.datetime --save 56 | ``` 57 | 58 | ```markup 59 | yarn add tail.datetime --save 60 | ``` 61 | 62 | ```markup 63 | bower install tail.datetime --save 64 | ``` 65 | 66 | ### Using a CDN 67 | You can also use the awesome CDN services from jsDelivr or UNPKG. 68 | 69 | ```markup 70 | https://cdn.jsdelivr.net/npm/tail.datetime@latest/ 71 | ``` 72 | 73 | ```markup 74 | https://unpkg.com/tail.datetime/ 75 | ``` 76 | 77 | Thanks To 78 | --------- 79 | - [MrGuiseppe](https://github.com/MrGuiseppe) for the Inspiration 80 | - [Octicons](https://octicons.github.com/) for the cute Icons 81 | - [jsCompress](https://jscompress.com/) for the Compressor 82 | - [prismJS](https://prismjs.com) for the Syntax highlighting library _[used on the demo]_ 83 | - [MenuSpy](https://github.com/lcdsantos/menuspy) for the Menu Navigation _[used on the demo]_ 84 | 85 | ### Translations 86 | - [Mohammed Alsiddeeq Ahmed](https://github.com/mosid) / [Arabic Translation](https://github.com/pytesNET/tail.DateTime/issues/1) 87 | - [Júnior Garcia](https://github.com/juniorgarcia) / [Brazilian Portuguese Translation](https://github.com/pytesNET/tail.DateTime/issues/13) 88 | - [mickeybyte](https://github.com/mickeybyte) / [Dutch Translation](https://github.com/pytesNET/tail.DateTime/issues/15) 89 | - [noxludio](https://github.com/noxludio) / [Finnish Translation](https://github.com/pytesNET/tail.DateTime/pull/17) 90 | - [FlashPanther](https://github.com/FlashPanther) / [French Translation](https://github.com/pytesNET/tail.DateTime/pull/19) 91 | - [Fabio Di Stasio](https://github.com/Fabio286) / [Italian Translation](https://github.com/pytesNET/tail.DateTime/issues/10) 92 | - [Murat Pala](https://github.com/Prozexis) / [Turkish Translation](https://github.com/pytesNET/tail.DateTime/pull/30) 93 | - [Lars Athle Larsen](https://github.com/larsathle) / [Norwegian Translation](https://github.com/pytesNET/tail.DateTime/pull/31) 94 | - [Jacob273](https://github.com/Jacob273) / [Polish Translation](https://github.com/pytesNET/tail.DateTime/pull/32) 95 | - [elPesecillo](https://github.com/elPesecillo) / [Spanish Mexican Translation](https://github.com/pytesNET/tail.DateTime/issue/34) 96 | - [Milan Kyncl](https://github.com/milankyncl) / [Czech Translation](https://github.com/pytesNET/tail.DateTime/pill/39) 97 | - [tsakal](https://github.com/tsakal) / [Greek Translation](https://github.com/pytesNET/tail.DateTime/issues/41) 98 | 99 | Documentation 100 | ------------- 101 | The Documentation has been moved to [GitHubs Wiki Pages](https://github.com/pytesNET/tail.DateTime/wiki), 102 | but I will keep a table of contents list here and some basic instructions. 103 | 104 | - [Install & Embed](https://www.github.com/pytesNET/tail.DateTime/wiki/instructions) 105 | - [Default Usage](https://www.github.com/pytesNET/tail.DateTime/wiki/default-usage) 106 | - [Public Options](https://www.github.com/pytesNET/tail.DateTime/wiki/public-options) 107 | - [Public Methods](https://www.github.com/pytesNET/tail.DateTime/wiki/public-methods) 108 | - [Events & Callbacks](https://www.github.com/pytesNET/tail.DateTime/wiki/events-callbacks) 109 | - [Internal Variables & Methods](https://www.github.com/pytesNET/tail.DateTime/wiki/internal) 110 | 111 | ### Basic Instructions 112 | You can pass up to 2 arguments to the **tail.DateTime** constructor, the first parameter is required 113 | and need to be an `Element`, a `NodeList`, a `HTMLCollection`, an Array with `Element` objects or 114 | just a single selector as `string`, which calls the `querySelectorAll()` method on its own. The 115 | second parameter is optional and, if set, MUST be an object with your **tail.DateTime** options. 116 | 117 | ```html 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 137 | 138 | 139 | ``` 140 | 141 | ### Default Settings 142 | Please check out [GitHubs Wiki Pages](https://github.com/pytesNET/tail.DateTime/wiki) to read more 143 | about each single option! 144 | 145 | ```javascript 146 | tail.DateTime(".tail-datetime-field", { 147 | animate: true, // [0.4.0] Boolean 148 | classNames: false, // [0.3.0] Boolean, String, Array, null 149 | closeButton: true, // [0.4.5] Boolean 150 | dateFormat: "YYYY-mm-dd", // [0.1.0] String (PHP similar Date) 151 | dateStart: false, // [0.4.0] String, Date, Integer, False 152 | dateRanges: [], // [0.3.0] Array 153 | dateBlacklist: true, // [0.4.0] Boolean 154 | dateEnd: false, // [0.4.0] String, Date, Integer, False 155 | locale: "en", // [0.4.0] String 156 | position: "bottom", // [0.1.0] String 157 | rtl: "auto", // [0.4.1] String, Boolean 158 | startOpen: false, // [0.3.0] Boolean 159 | stayOpen: false, // [0.3.0] Boolean 160 | time12h: false, // [0.4.13][NEW] Boolean 161 | timeFormat: "HH:ii:ss", // [0.1.0] String (PHP similar Date) 162 | timeHours: true, // [0.4.13][UPD] Integer, Boolean, null 163 | timeMinutes: true, // [0.4.13][UPD] Integer, Boolean, null 164 | timeSeconds: 0, // [0.4.13][UPD] Integer, Boolean, null 165 | timeIncrement: true, // [0.4.5] Boolean 166 | timeStepHours: 1, // [0.4.3] Integer 167 | timeStepMinutes: 5, // [0.4.3] Integer 168 | timeStepSeconds: 5, // [0.4.3] Integer 169 | today: true, // [0.4.0] Boolean 170 | tooltips: [], // [0.4.0] Array 171 | viewDefault: "days", // [0.4.0] String 172 | viewDecades: true, // [0.4.0] Boolean 173 | viewYears: true, // [0.4.0] Boolean 174 | viewMonths: true, // [0.4.0] Boolean 175 | viewDays: true, // [0.4.0] Boolean 176 | weekStart: 0 // [0.1.0] String, Integer 177 | }); 178 | ``` 179 | 180 | Copyright & License 181 | ------------------- 182 | Published under the MIT-License; Copyright © 2018 - 2019 SamBrishes, pytesNET 183 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2019 Ryan Blenis 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /db.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @description MeshCentral-ScriptTask database module 3 | * @author Ryan Blenis 4 | * @copyright Ryan Blenis 2019 5 | * @license Apache-2.0 6 | */ 7 | 8 | "use strict"; 9 | var Datastore = null; 10 | var formatId = null; 11 | 12 | module.exports.CreateDB = function(meshserver) { 13 | var obj = {}; 14 | var NEMongo = require(__dirname + '/nemongo.js'); 15 | module.paths.push(require('path').join(meshserver.parentpath, 'node_modules')); // we need to push the node_modules folder for nedb 16 | obj.dbVersion = 1; 17 | 18 | obj.initFunctions = function () { 19 | obj.updateDBVersion = function(new_version) { 20 | return obj.scriptFile.updateOne({type: "db_version"}, { $set: {version: new_version} }, {upsert: true}); 21 | }; 22 | 23 | obj.getDBVersion = function() { 24 | return new Promise(function(resolve, reject) { 25 | obj.scriptFile.find( { type: "db_version" } ).project( { _id: 0, version: 1 } ).toArray(function(err, vers){ 26 | if (vers.length == 0) resolve(1); 27 | else resolve(vers[0]['version']); 28 | }); 29 | }); 30 | }; 31 | 32 | obj.addScript = function(name, content, path, filetype) { 33 | if (path == null) path = "Shared" 34 | if (filetype == 'bash') content = content.split('\r\n').join('\n').split('\r').join('\n'); 35 | var sObj = { 36 | type: 'script', 37 | path: path, 38 | name: name, 39 | content: content, 40 | contentHash: require('crypto').createHash('sha384').update(content).digest('hex'), 41 | filetype: filetype 42 | }; 43 | return obj.scriptFile.insertOne(sObj); 44 | }; 45 | 46 | obj.addFolder = function(name, path) { 47 | var sObj = { 48 | type: 'folder', 49 | path: path, 50 | name: name 51 | }; 52 | return obj.scriptFile.insertOne(sObj); 53 | }; 54 | 55 | obj.getScriptTree = function() { 56 | return obj.scriptFile.find( 57 | { type: 58 | { $in: [ 'script', 'folder' ] } 59 | } 60 | ).sort( 61 | { path: 1, type: 1, name: 1 } 62 | ).project( 63 | { name: 1, path: 1, type: 1, filetype: 1 } 64 | ).toArray(); 65 | }; 66 | 67 | obj.update = function(id, args) { 68 | id = formatId(id); 69 | if (args.type == 'script' && args.content !== null) { 70 | if (args.filetype == 'bash') { 71 | args.content = args.content = split('\r\n').join('\n').split('\r').join('\n'); 72 | } 73 | args.contentHash = require('crypto').createHash('sha384').update(args.content).digest('hex'); 74 | } 75 | return obj.scriptFile.updateOne( { _id: id }, { $set: args } ); 76 | }; 77 | obj.delete = function(id) { 78 | id = formatId(id); 79 | return obj.scriptFile.deleteOne( { _id: id } ); 80 | }; 81 | obj.deleteByPath = function(path) { 82 | return obj.scriptFile.deleteMany( { path: path, type: { $in: ['script', 'folder'] } } ); 83 | }; 84 | obj.deleteSchedulesForScript = function(id) { 85 | id = formatId(id); 86 | return obj.scriptFile.deleteMany( { type: 'jobSchedule', scriptId: id } ); 87 | }; 88 | obj.getByPath = function(path) { 89 | return obj.scriptFile.find( { type: { $in: [ 'script', 'folder' ] }, path: path }).toArray(); 90 | }; 91 | obj.get = function(id) { 92 | if (id == null || id == 'null') return new Promise(function(resolve, reject) { resolve([]); }); 93 | id = formatId(id); 94 | return obj.scriptFile.find( { _id: id } ).toArray(); 95 | }; 96 | obj.addJob = function(passedObj) { 97 | var nowTime = Math.floor(new Date() / 1000); 98 | var defaultObj = { 99 | type: 'job', 100 | queueTime: nowTime, 101 | dontQueueUntil: nowTime, 102 | dispatchTime: null, 103 | completeTime: null, 104 | node: null, 105 | scriptId: null, 106 | scriptName: null, // in case the original reference is deleted in the future 107 | replaceVars: null, 108 | returnVal: null, 109 | errorVal: null, 110 | returnAct: null, 111 | runBy: null, 112 | jobSchedule: null 113 | }; 114 | var jObj = {...defaultObj, ...passedObj}; 115 | 116 | if (jObj.node == null || jObj.scriptId == null) { console.log('PLUGIN: SciptTask: Could not add job'); return false; } 117 | 118 | return obj.scriptFile.insertOne(jObj); 119 | }; 120 | obj.addJobSchedule = function(schedObj) { 121 | schedObj.type = 'jobSchedule'; 122 | if (schedObj.node == null || schedObj.scriptId == null) { console.log('PLUGIN: SciptTask: Could not add job schedule'); return false; } 123 | return obj.scriptFile.insertOne(schedObj); 124 | }; 125 | obj.removeJobSchedule = function (id) { 126 | return obj.delete(id); 127 | }; 128 | obj.getSchedulesDueForJob = function(scheduleId) { 129 | var nowTime = Math.floor(new Date() / 1000); 130 | var scheduleIdLimiter = {}; 131 | if (scheduleId != null) { 132 | scheduleIdLimiter._id = scheduleId; 133 | } 134 | return obj.scriptFile.find( { 135 | type: 'jobSchedule', 136 | // startAt: { $gte: nowTime }, 137 | $or: [ 138 | { endAt: null }, 139 | { endAt: { $lte: nowTime } } 140 | ], 141 | $or: [ 142 | { nextRun: null }, 143 | { nextRun: { $lte: (nowTime + 60) } } // check a minute into the future 144 | ], 145 | ...scheduleIdLimiter 146 | }).toArray(); 147 | }; 148 | obj.deletePendingJobsForNode = function(node) { 149 | return obj.scriptFile.deleteMany({ 150 | type: 'job', 151 | node: node, 152 | completeTime: null, 153 | }); 154 | }; 155 | obj.getPendingJobs = function(nodeScope) { 156 | if (nodeScope == null || !Array.isArray(nodeScope)) { 157 | return false; 158 | } 159 | // return jobs that has online nodes and queue time requirements have been met 160 | return obj.scriptFile.find( { 161 | type: 'job', 162 | node: { $in: nodeScope }, 163 | completeTime: null, 164 | //dispatchTime: null, 165 | $or: [ 166 | { dontQueueUntil: null }, 167 | { dontQueueUntil: { $lte: Math.floor(new Date() / 1000) } } 168 | ] 169 | }).toArray(); 170 | }; 171 | obj.getJobNodeHistory = function(nodeId) { 172 | return obj.scriptFile.find( { 173 | type: 'job', 174 | node: nodeId, 175 | }).sort({ queueTime: -1 }).limit(200).toArray(); 176 | }; 177 | obj.getJobScriptHistory = function(scriptId) { 178 | return obj.scriptFile.find( { 179 | type: 'job', 180 | scriptId: scriptId, 181 | }).sort({ completeTime: -1, queueTime: -1 }).limit(200).toArray(); 182 | }; 183 | obj.updateScriptJobName = function(scriptId, scriptName) { 184 | return obj.scriptFile.updateMany({ type: 'job', scriptId: scriptId }, { $set: { scriptName: scriptName } }); 185 | }; 186 | obj.getJobSchedulesForScript = function(scriptId) { 187 | return obj.scriptFile.find( { type: 'jobSchedule', scriptId: scriptId } ).toArray(); 188 | }; 189 | obj.getJobSchedulesForNode = function (nodeId) { 190 | return obj.scriptFile.find( { type: 'jobSchedule', node: nodeId } ).toArray(); 191 | }; 192 | obj.getIncompleteJobsForSchedule = function (schedId) { 193 | return obj.scriptFile.find( { type: 'job', jobSchedule: schedId, completeTime: null } ).toArray(); 194 | }; 195 | obj.deletePendingJobsForSchedule = function (schedId) { 196 | return obj.scriptFile.deleteMany( { type: 'job', jobSchedule: schedId, completeTime: null } ); 197 | }; 198 | obj.deleteOldHistory = function() { 199 | var nowTime = Math.floor(new Date() / 1000); 200 | var oldTime = nowTime - (86400 * 90); // 90 days 201 | return obj.scriptFile.deleteMany( { type: 'job', completeTime: { $lte: oldTime } } ); 202 | }; 203 | obj.addVariable = function(name, scope, scopeTarget, value) { 204 | var vObj = { 205 | type: 'variable', 206 | name: name, 207 | scope: scope, 208 | scopeTarget: scopeTarget, 209 | value: value 210 | }; 211 | return obj.scriptFile.insertOne(vObj); 212 | }; 213 | obj.getVariables = function(limiters) { 214 | if (limiters != null) { 215 | var find = { 216 | type: 'variable', 217 | name: { $in: limiters.names }, 218 | $or: [ 219 | { scope: 'global' }, 220 | { $and: [ 221 | { scope: 'script' }, 222 | { scopeTarget: limiters.scriptId } 223 | ] 224 | }, 225 | { $and: [ 226 | { scope: 'mesh' }, 227 | { scopeTarget: limiters.meshId } 228 | ] 229 | }, 230 | { $and: [ 231 | { scope: 'node' }, 232 | { scopeTarget: limiters.nodeId } 233 | ] 234 | } 235 | ] 236 | }; 237 | return obj.scriptFile.find(find).sort({ name: 1 }).toArray(); 238 | } 239 | else { 240 | return obj.scriptFile.find({ type: 'variable' }).sort({ name: 1 }).toArray(); 241 | } 242 | }; 243 | obj.checkDefaults = function() { 244 | obj.scriptFile.find( { type: 'folder', name: 'Shared', path: 'Shared' } ).toArray() 245 | .then(found => { 246 | if (found.length == 0) obj.addFolder('Shared', 'Shared'); 247 | }) 248 | .catch(e => { console.log('PLUGIN: ScriptTask: Default folder check failed. Error was: ', e); }); 249 | }; 250 | 251 | obj.checkDefaults(); 252 | }; 253 | 254 | if (meshserver.args.mongodb) { // use MongDB 255 | require('mongodb').MongoClient.connect(meshserver.args.mongodb, { useNewUrlParser: true, useUnifiedTopology: true }, function (err, client) { 256 | if (err != null) { console.log("Unable to connect to database: " + err); process.exit(); return; } 257 | 258 | var dbname = 'meshcentral'; 259 | if (meshserver.args.mongodbname) { dbname = meshserver.args.mongodbname; } 260 | const db = client.db(dbname); 261 | 262 | obj.scriptFile = db.collection('plugin_scripttask'); 263 | obj.scriptFile.indexes(function (err, indexes) { 264 | // Check if we need to reset indexes 265 | var indexesByName = {}, indexCount = 0; 266 | for (var i in indexes) { indexesByName[indexes[i].name] = indexes[i]; indexCount++; } 267 | if ((indexCount != 6) || (indexesByName['ScriptName1'] == null) || (indexesByName['ScriptPath1'] == null) || (indexesByName['JobTime1'] == null) || (indexesByName['JobNode1'] == null) || (indexesByName['JobScriptID1'] == null)) { 268 | // Reset all indexes 269 | console.log('Resetting plugin (ScriptTask) indexes...'); 270 | obj.scriptFile.dropIndexes(function (err) { 271 | obj.scriptFile.createIndex({ name: 1 }, { name: 'ScriptName1' }); 272 | obj.scriptFile.createIndex({ path: 1 }, { name: 'ScriptPath1' }); 273 | obj.scriptFile.createIndex({ queueTime: 1 }, { name: 'JobTime1' }); 274 | obj.scriptFile.createIndex({ node: 1 }, { name: 'JobNode1' }); 275 | obj.scriptFile.createIndex({ scriptId: 1 }, { name: 'JobScriptID1' }); 276 | }); 277 | } 278 | }); 279 | 280 | 281 | if (typeof require('mongodb').ObjectID == 'function') { 282 | formatId = require('mongodb').ObjectID; 283 | } else { 284 | formatId = require('mongodb').ObjectId; 285 | } 286 | obj.initFunctions(); 287 | }); 288 | } else { // use NeDb 289 | try { Datastore = require('@seald-io/nedb'); } catch (ex) { } // This is the NeDB with Node 23 support. 290 | if (Datastore == null) { 291 | try { Datastore = require('@yetzt/nedb'); } catch (ex) { } // This is the NeDB with fixed security dependencies. 292 | if (Datastore == null) { Datastore = require('nedb'); } // So not to break any existing installations, if the old NeDB is present, use it. 293 | } 294 | if (obj.scriptFilex == null) { 295 | obj.scriptFilex = new Datastore({ filename: meshserver.getConfigFilePath('plugin-scripttask.db'), autoload: true }); 296 | obj.scriptFilex.setAutocompactionInterval(40000); 297 | obj.scriptFilex.ensureIndex({ fieldName: 'name' }); 298 | obj.scriptFilex.ensureIndex({ fieldName: 'path' }); 299 | obj.scriptFilex.ensureIndex({ fieldName: 'queueTime' }); 300 | obj.scriptFilex.ensureIndex({ fieldName: 'node' }); 301 | obj.scriptFilex.ensureIndex({ fieldName: 'scriptId' }); 302 | } 303 | obj.scriptFile = new NEMongo(obj.scriptFilex); 304 | formatId = function(id) { return id; }; 305 | obj.initFunctions(); 306 | } 307 | 308 | return obj; 309 | } 310 | -------------------------------------------------------------------------------- /includes/tail.DateTime/tail.datetime-default-blue.min.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; /* pytesNET/tail.DateTime v.0.4.14 */ 2 | /* @author SamBrishes, pytesNET | @license MIT */ 3 | .tail-datetime-calendar,.tail-datetime-calendar *,.tail-datetime-calendar :after,.tail-datetime-calendar :before{box-sizing:border-box;-webkit-box-sizing:border-box}.tail-datetime-calendar{top:0;left:0;width:275px;height:auto;margin:15px;padding:0;z-index:3000;display:block;position:absolute;visibility:hidden;direction:ltr;border-collapse:separate;font-family:"Open Sans",Calibri,Arial,sans-serif;background-color:#fff;border-width:0;border-style:solid;border-color:transparent;border-radius:3px;box-shadow:0 1px 3px rgba(0,0,0,.3125);-webkit-box-shadow:0 1px 3px rgba(0,0,0,.3125)}.tail-datetime-calendar:after{clear:both;content:"";display:block;font-size:0;visibility:hidden}.tail-datetime-calendar.calendar-static{top:auto;left:auto;margin-left:auto;margin-right:auto;position:static;visibility:visible}.tail-datetime-calendar button.calendar-close{top:100%;right:15px;color:#303438;width:35px;height:25px;margin:1px 0 0 0;padding:5px 10px;opacity:.5;outline:0;display:inline-block;position:absolute;font-size:14px;line-height:1.125em;text-shadow:none;background-color:#fff;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDEyIDE2Ij48cGF0aCBmaWxsPSIjMzAzNDM4IiBkPSJNNy40OCA4bDMuNzUgMy43NS0xLjQ4IDEuNDhMNiA5LjQ4bC0zLjc1IDMuNzUtMS40OC0xLjQ4TDQuNTIgOCAuNzcgNC4yNWwxLjQ4LTEuNDhMNiA2LjUybDMuNzUtMy43NSAxLjQ4IDEuNDhMNy40OCA4eiIvPjwvc3ZnPg==");background-repeat:no-repeat;background-position:center center;border-width:0;border-style:solid;border-color:transparent;border-radius:0 0 3px 3px;box-shadow:0 1px 3px rgba(0,0,0,.3125);-webkit-box-shadow:0 1px 3px rgba(0,0,0,.3125);transition:opacity 142ms linear;-webkit-transition:opacity 142ms linear}.tail-datetime-calendar button.calendar-close:hover{opacity:1}.tail-datetime-calendar .calendar-tooltip{color:#fff;width:auto;margin:0;padding:0;display:block;position:absolute;background-color:#202428;border-radius:3px}.tail-datetime-calendar .calendar-tooltip:before{top:-7px;left:50%;width:0;height:0;margin:0 0 0 -6px;content:"";display:block;position:absolute;border-width:0 7px 7px 7px;border-style:solid;border-color:transparent transparent #202428 transparent}.tail-datetime-calendar .calendar-tooltip .tooltip-inner{width:auto;margin:0;padding:4px 7px;display:block;font-size:12px;line-height:14px}.tail-datetime-calendar .calendar-actions{color:#fff;width:100%;height:36px;margin:0;padding:0;display:table;overflow:hidden;border-spacing:0;border-collapse:separate;background-color:#149be6;border-width:0;border-style:solid;border-color:transparent;border-radius:3px 3px 0 0}.tail-datetime-calendar .calendar-actions span{margin:0;padding:0;display:table-cell;position:relative;text-align:center;line-height:36px;text-shadow:-1px -1px 0 #0e6ca0;background-repeat:no-repeat;background-position:center center}.tail-datetime-calendar .calendar-actions span[data-action]{cursor:pointer}.tail-datetime-calendar .calendar-actions span.action{width:36px;font-size:22px}.tail-datetime-calendar .calendar-actions span.label{width:auto}.tail-datetime-calendar .calendar-actions span:first-child:before,.tail-datetime-calendar .calendar-actions span:last-child:before{top:5px;bottom:5px;width:1px;height:auto;margin:0;padding:0;content:"";display:inline-block;position:absolute;background-color:#107bb7}.tail-datetime-calendar .calendar-actions span:first-child:before{right:-1px}.tail-datetime-calendar .calendar-actions span:last-child:before{left:-1px}.tail-datetime-calendar .calendar-actions span:first-child:hover:before,.tail-datetime-calendar .calendar-actions span:last-child:hover:before{display:none}.tail-datetime-calendar .calendar-actions span[data-action]:hover{background-color:#107bb7}.tail-datetime-calendar .calendar-actions span.action-prev{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2IiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgNiAxNiI+PHBhdGggZmlsbD0iI2ZmZmZmZiIgZD0iTTYgMkwwIDhsNiA2VjJ6Ii8+PC9zdmc+")}.tail-datetime-calendar .calendar-actions span.action-next{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2IiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgNiAxNiI+PHBhdGggZmlsbD0iI2ZmZmZmZiIgZD0iTTAgMTRsNi02LTYtNnYxMnoiLz48L3N2Zz4=")}.tail-datetime-calendar .calendar-actions span.action-submit{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDEyIDE2Ij48cGF0aCBmaWxsPSIjZmZmZmZmIiBkPSJNMTIgNWwtOCA4LTQtNCAxLjUtMS41TDQgMTBsNi41LTYuNUwxMiA1eiIvPjwvc3ZnPg==")}.tail-datetime-calendar .calendar-actions span.action-cancel{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDEyIDE2Ij48cGF0aCBmaWxsPSIjZmZmZmZmIiBkPSJNNy40OCA4bDMuNzUgMy43NS0xLjQ4IDEuNDhMNiA5LjQ4bC0zLjc1IDMuNzUtMS40OC0xLjQ4TDQuNTIgOCAuNzcgNC4yNWwxLjQ4LTEuNDhMNiA2LjUybDMuNzUtMy43NSAxLjQ4IDEuNDhMNy40OCA4eiIvPjwvc3ZnPg==")}.tail-datetime-calendar .calendar-datepicker{width:100%;margin:0;padding:0;display:block;position:relative}.tail-datetime-calendar .calendar-datepicker table{width:100%;margin:0;padding:0;border-spacing:0;border-collapse:separate}.tail-datetime-calendar .calendar-datepicker table tr td,.tail-datetime-calendar .calendar-datepicker table tr th{color:#303438;height:30px;padding:0;position:relative;font-size:13px;text-align:center;font-weight:400;text-shadow:none;line-height:30px;background-color:transparent;border-width:0;border-style:solid;border-color:transparent;border-radius:0}.tail-datetime-calendar .calendar-datepicker table tr th{color:#fff;background-color:#303438}.tail-datetime-calendar .calendar-datepicker table tr td{cursor:pointer}.tail-datetime-calendar .calendar-datepicker table tr td span.inner{margin:0;padding:0;display:inline-block}.tail-datetime-calendar .calendar-datepicker table tr td.date-disabled{cursor:not-allowed;color:#909498;background-color:#f0f0f0}.tail-datetime-calendar .calendar-datepicker table tr td.date-disabled:after{left:3px;bottom:3px;width:35px;height:1px;margin:0;padding:0;content:"";display:inline-block;position:absolute;background-color:#bfbfbf;transform-origin:2px -5px;transform:rotate(-45deg);-moz-transform:rotate(-45deg);-webkit-transform:rotate(-45deg)}.tail-datetime-calendar .calendar-datepicker table tr td.date-next,.tail-datetime-calendar .calendar-datepicker table tr td.date-previous{color:#909498;background-color:#f0f0f0}.tail-datetime-calendar .calendar-datepicker table tr td .tooltip-tick,.tail-datetime-calendar .calendar-datepicker table tr td.date-today:before{top:5px;width:5px;height:5px;margin:0;padding:0;z-index:20;content:"";display:inline-block;position:absolute;border-width:0;border-style:solid;border-color:transparent;border-radius:50%}.tail-datetime-calendar .calendar-datepicker table tr td.date-today:before{left:5px;background-color:#32b93c}.tail-datetime-calendar .calendar-datepicker table tr td .tooltip-tick{right:5px;background-color:#202428}.tail-datetime-calendar .calendar-datepicker table tr td .tooltip-tick:after,.tail-datetime-calendar .calendar-datepicker table tr td .tooltip-tick:before{display:none}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-day,.tail-datetime-calendar .calendar-datepicker table tr th.calendar-week{width:14.28571429%;height:35px}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-day span.inner,.tail-datetime-calendar .calendar-datepicker table tr th.calendar-week span.inner{width:31px;height:31px;line-height:29px;border-width:1px;border-style:solid;border-color:transparent;border-radius:50%}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-day:hover span.inner,.tail-datetime-calendar .calendar-datepicker table tr th.calendar-week:hover span.inner{border-color:#ccc}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-day.date-disabled span.inner,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-day.date-disabled:hover span.inner,.tail-datetime-calendar .calendar-datepicker table tr th.calendar-week.date-disabled span.inner,.tail-datetime-calendar .calendar-datepicker table tr th.calendar-week.date-disabled:hover span.inner{border-color:transparent}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-day.date-select span.inner,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-day.date-select:hover span.inner,.tail-datetime-calendar .calendar-datepicker table tr th.calendar-week.date-select span.inner,.tail-datetime-calendar .calendar-datepicker table tr th.calendar-week.date-select:hover span.inner{color:#32b93c;border-color:#32b93c}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-decade,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-month,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-year{width:33.33333333%;height:40px;transition:color 142ms linear;-webkit-transition:color 142ms linear}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-decade.date-today:before,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-month.date-today:before,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-year.date-today:before{left:50%;margin-left:-2.5px}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-decade span.inner,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-month span.inner,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-year span.inner{width:auto;height:31px;line-height:29px}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-decade span.inner:after,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-decade span.inner:before,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-month span.inner:after,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-month span.inner:before,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-year span.inner:after,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-year span.inner:before{width:20px;height:20px;content:"";z-index:15;display:inline-block;position:absolute;border-width:1px;border-style:solid;border-color:transparent;transition:all 142ms linear;-webkit-transition:all 142ms linear}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-decade span.inner:before,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-month span.inner:before,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-year span.inner:before{top:0;left:0}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-decade:hover span.inner:before,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-month:hover span.inner:before,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-year:hover span.inner:before{top:6px;left:6px;border-top-color:#ccc;border-left-color:#ccc}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-decade span.inner:after,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-month span.inner:after,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-year span.inner:after{right:0;bottom:0}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-decade:hover span.inner:after,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-month:hover span.inner:after,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-year:hover span.inner:after{right:6px;bottom:6px;border-right-color:#ccc;border-bottom-color:#ccc}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-decade,.tail-datetime-calendar .calendar-datepicker table tr td.calendar-year{width:25%}.tail-datetime-calendar .calendar-datepicker table tr td.calendar-decade span.inner{height:54px;padding:7px 15px;text-align:left;line-height:20px}.tail-datetime-calendar .calendar-timepicker{width:100%;margin:0;padding:0;display:block;text-align:center;border-width:1px 0 0 0;border-style:solid;border-color:#d9d9d9}.tail-datetime-calendar .calendar-timepicker .timepicker-field{width:28%;margin:0;padding:15px 0 7px 0;display:inline-block;position:relative;text-align:center}.tail-datetime-calendar .calendar-timepicker .timepicker-field:first-of-type{text-align:right}.tail-datetime-calendar .calendar-timepicker .timepicker-field:last-of-type{text-align:left}.tail-datetime-calendar .calendar-timepicker .timepicker-field input[type=text]{color:#303438;width:100%;height:29px;margin:0;z-index:4;padding:3px 20px 3px 5px;outline:0;display:inline-block;position:relative;font-size:12px;text-align:center;line-height:23px;appearance:textfield;-moz-appearance:textfield;-webkit-appearance:textfield;background-color:#f0f0f0;border-width:0;border-style:solid;border-color:transparent;border-radius:3px;box-shadow:none;-webkit-box-shadow:none;transition:color 142ms linear,border 142ms linear,background 142ms linear;-webkit-transition:color 142ms linear,border 142ms linear,background 142ms linear}.tail-datetime-calendar .calendar-timepicker .timepicker-field input[type=text]:hover{color:#303438;background-color:#e0e0e0}.tail-datetime-calendar .calendar-timepicker .timepicker-field input[type=text]:focus{color:#fff;background-color:#32b93c}.tail-datetime-calendar .calendar-timepicker .timepicker-field input[type=text]:disabled{cursor:not-allowed;color:#a0a4a8;background-color:#f6f6f6}.tail-datetime-calendar .calendar-timepicker .timepicker-field button.picker-step{width:20px;height:15px;right:0;margin:0;padding:0;z-index:15;display:inline-block;position:absolute;background-color:#f0f0f0;box-shadow:none;-webkit-box-shadow:none;transition:border 142ms linear,background 142ms linear;-webkit-transition:border 142ms linear,background 142ms linear}.tail-datetime-calendar .calendar-timepicker .timepicker-field button.picker-step:before{top:4px;left:50%;width:0;height:0;margin:0 0 0 -4px;padding:0;content:"";display:inline-block;position:absolute;transition:border 142ms linear;-webkit-transition:border 142ms linear}.tail-datetime-calendar .calendar-timepicker .timepicker-field button.picker-step.step-up{top:15px;border-width:0 0 1px 1px;border-style:solid;border-color:#fff;border-radius:0 2px 0 0}.tail-datetime-calendar .calendar-timepicker .timepicker-field button.picker-step.step-up:hover{background-color:#e0e0e0}.tail-datetime-calendar .calendar-timepicker .timepicker-field button.picker-step.step-up:before{border-width:0 4px 5px 4px;border-style:solid;border-color:transparent transparent #303438 transparent}.tail-datetime-calendar .calendar-timepicker .timepicker-field button.picker-step.step-down{top:29px;border-width:1px 0 0 1px;border-style:solid;border-color:#fff;border-radius:0 0 2px 0}.tail-datetime-calendar .calendar-timepicker .timepicker-field button.picker-step.step-down:hover{background-color:#e0e0e0}.tail-datetime-calendar .calendar-timepicker .timepicker-field button.picker-step.step-down:before{border-width:5px 4px 0 4px;border-style:solid;border-color:#303438 transparent transparent transparent}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:focus+button.step-up{border-color:rgba(255,255,255,.8);background-color:#32b93c}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:focus+button.step-up:hover{background-color:#27912f}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:focus+button.step-up:before{border-bottom-color:#fff}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:focus+button+button.step-down{border-color:rgba(255,255,255,.8);background-color:#32b93c}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:focus+button+button.step-down:hover{background-color:#27912f}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:focus+button+button.step-down:before{border-top-color:#fff}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:disabled+button.step-up{cursor:not-allowed;border-color:rgba(255,255,255,.8);background-color:#f6f6f6}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:disabled+button.step-up:hover{background-color:#f6f6f6}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:disabled+button.step-up:before{border-bottom-color:#a0a4a8}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:disabled+button+button.step-down{cursor:not-allowed;border-color:rgba(255,255,255,.8);background-color:#f6f6f6}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:disabled+button+button.step-down:hover{background-color:#f6f6f6}.tail-datetime-calendar .calendar-timepicker .timepicker-field input:disabled+button+button.step-down:before{border-top-color:#a0a4a8}.tail-datetime-calendar .calendar-timepicker .timepicker-field label{color:#303438;margin:0;padding:0;display:block;font-size:12px;text-align:center}.tail-datetime-calendar .calendar-timepicker label.timepicker-switch{cursor:pointer;margin:15px 0 -5px 0;display:block;text-align:center;vertical-align:top}.tail-datetime-calendar .calendar-timepicker label.timepicker-switch:after,.tail-datetime-calendar .calendar-timepicker label.timepicker-switch:before{width:auto;margin:0;padding:0 5px;font-size:12px;line-height:16px;vertical-align:top}.tail-datetime-calendar .calendar-timepicker label.timepicker-switch:before{content:attr(data-am)}.tail-datetime-calendar .calendar-timepicker label.timepicker-switch:after{content:attr(data-pm)}.tail-datetime-calendar .calendar-timepicker label.timepicker-switch input[type=checkbox]{display:none}.tail-datetime-calendar .calendar-timepicker label.timepicker-switch input[type=checkbox]+span{display:inline-block;position:relative;vertical-align:top}.tail-datetime-calendar .calendar-timepicker label.timepicker-switch input[type=checkbox]+span:before{width:50px;height:16px;content:"";display:inline-block;vertical-align:top;border-width:1px;border-style:solid;border-color:#149be6;border-radius:14px;transition:border 284ms linear;-webkit-transition:border 284ms linear}.tail-datetime-calendar .calendar-timepicker label.timepicker-switch input[type=checkbox]+span:after{top:3px;left:4px;right:30px;width:auto;height:10px;margin:0;padding:0;content:"";display:inline-block;position:absolute;background-color:#149be6;border-radius:15px;vertical-align:top;transition:left 284ms linear,right 284ms linear 284ms,background 284ms linear;-webkit-transition:left 284ms linear,right 284ms linear 284ms,background 284ms linear}.tail-datetime-calendar .calendar-timepicker label.timepicker-switch input[type=checkbox]:checked+span:before{border-color:#32b93c}.tail-datetime-calendar .calendar-timepicker label.timepicker-switch input[type=checkbox]:checked+span:after{left:30px;right:4px;background-color:#32b93c;transition:right 284ms linear,left 284ms linear 284ms,background 284ms linear;-webkit-transition:right 284ms linear,left 284ms linear 284ms,background 284ms linear}.tail-datetime-calendar .calendar-actions+.calendar-timepicker{border-width:0}.tail-datetime-calendar.rtl{direction:rtl}.tail-datetime-calendar.rtl .calendar-actions span.action-next,.tail-datetime-calendar.rtl .calendar-actions span.action-prev{transform:rotate(180deg);-moz-transform:rotate(180deg);-webkit-transform:rotate(180deg)}.tail-datetime-calendar.rtl .calendar-datepicker table tr td.date-disabled:after{right:3px;transform:rotate(45deg);-moz-transform:rotate(45deg);-webkit-transform:rotate(45deg)}.tail-datetime-calendar.rtl .calendar-datepicker table tr td.date-today:before{right:5px}.tail-datetime-calendar.rtl .calendar-datepicker table tr td .tooltip-tick{left:5px}.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-decade.date-today:before,.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-month.date-today:before,.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-year.date-today:before{right:50%;margin-right:-2.5px}.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-decade:hover span.inner:before,.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-month:hover span.inner:before,.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-year:hover span.inner:before{right:6px;border-right-color:#ccc}.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-decade span.inner:after,.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-month span.inner:after,.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-year span.inner:after{left:0}.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-decade:hover span.inner:after,.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-month:hover span.inner:after,.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-year:hover span.inner:after{left:6px;border-left-color:#ccc}.tail-datetime-calendar.rtl .calendar-datepicker table tr td.calendar-decade span.inner{text-align:right}.tail-datetime-calendar.rtl .calendar-timepicker .timepicker-field:first-child{text-align:left;padding-left:0;padding-right:25px}.tail-datetime-calendar.rtl .calendar-timepicker .timepicker-field:last-child{text-align:right;padding-left:25px;padding-right:0}.tail-datetime-calendar.rtl .calendar-timepicker .timepicker-field:first-child input[type=text]{margin-left:-1px;margin-right:0;border-radius:0 3px 3px 0}.tail-datetime-calendar.rtl .calendar-timepicker .timepicker-field:last-child input[type=text]{margin-left:0;margin-right:-1px;border-radius:3px 0 0 3px} -------------------------------------------------------------------------------- /includes/tail.DateTime/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | ========= 3 | 4 | Version 0.4.14 - Beta 5 | --------------------- 6 | - Add: The new Indonesian Translation. 7 | - Thanks to [thenewzhugeliang](https://github.com/thenewzhugeliang) 8 | @ [#53](https://github.com/pytesNET/tail.DateTime/issues/53). 9 | - Add: The new Korean Translation. 10 | - Thanks to [huhushow](https://github.com/huhushow) 11 | @ [#49](https://github.com/pytesNET/tail.DateTime/issues/49). 12 | - Bugfix: Calendar won't go back a month from July 2019. 13 | - Thanks to [#54](https://github.com/pytesNET/tail.DateTime/issues/54). 14 | - Bugfix: Changing the Hours increases the Date (per Step). 15 | - Thanks to [#43](https://github.com/pytesNET/tail.DateTime/issues/43), 16 | - Thanks to [#46](https://github.com/pytesNET/tail.DateTime/issues/46). 17 | - Bugfix: Multiple `dateRanges` aren't possible on some situations. 18 | - Thanks to [#55](https://github.com/pytesNET/tail.DateTime/issues/55), 19 | - Thanks to [#48](https://github.com/pytesNET/tail.DateTime/pull/48). 20 | 21 | Version 0.4.13 - Beta 22 | --------------------- 23 | - Add: The new Polish Translation. 24 | - Thanks to [Jacob273](https://github.com/Jacob273) 25 | @ [#32](https://github.com/pytesNET/tail.DateTime/pull/32). 26 | - Add: The new Spanish Mexican Translation. 27 | - Thanks to [elPesecillo](https://github.com/elPesecillo) 28 | @ [#34](https://github.com/pytesNET/tail.DateTime/issue/34). 29 | - Add: The new Czech Translation. 30 | - Thanks to [Milan Kyncl](https://github.com/milankyncl) 31 | @ [#39](https://github.com/pytesNET/tail.DateTime/pull/39). 32 | - Add: The new Greek Translation. 33 | - Thanks to [tsakal](https://github.com/tsakal) 34 | @ [#41](https://github.com/pytesNET/tail.DateTime/issues/41). 35 | - Add: The new option `time12h` to use the AM/PM selector instead of the 24-h format. 36 | - Thanks to [#23](https://github.com/pytesNET/tail.DateTime/issues/23). 37 | - Add: Custom "stepUp" and "stepDown" buttons for the new time picker input fields. 38 | - Add: The new internal methods `this.prepare()` and `this.handleStep()`. 39 | - Update: The helper methods `cHAS()`, `cADD()` and `cREM()`. 40 | - Update: Time Selector fields are now `text` fields instead of number, using `inputmode` to force 41 | the number-selectors on mobile browsers (weak support). 42 | - Update: Remove the initial inline styling of the DateTime container (use CSS instead). 43 | - Update: Define factory-global `w` and `d` variables within the factory parameter declaration. 44 | - Update: The options `timeHours`, `timeMinutes` and `timeSeconds` calculates now the time number 45 | using the current time and the respective `timeStep*` value if `true` is passed. 46 | - Update: The options `timeHours`, `timeMinutes` and `timeSeconds` hides the respective field if 47 | `false` is used or just "disables" them by using `null`. 48 | - Thanks to [#23](https://github.com/pytesNET/tail.DateTime/issues/23). 49 | - Update: Use leading Zeros on the single time selectors. 50 | - Thanks to [#23](https://github.com/pytesNET/tail.DateTime/issues/23). 51 | - Remove: The `name` attributes from the Time input fields. 52 | - Bugfix: The helper method `clone` use an IE-unsupported function called `Object.assign`. 53 | - Bugfix: Webpack issue in VueJS. 54 | - Thanks to [#35](https://github.com/pytesNET/tail.DateTime/issues/35). 55 | - Bugfix: The `timeIncrement` function doesn't work by using the Arrow buttons on the respective 56 | time input[type=number] fields. 57 | - Bugfix: Dates before 1970-01-01 are disabled. 58 | - Thanks to [#40](https://github.com/pytesNET/tail.DateTime/issues/40). 59 | 60 | ### CSS / Less Environment 61 | - Add: A "not-allowed" cursor on disabled time fields / custom buttons. 62 | - Add: Minified Stylesheets and Source Maps (for both types). 63 | - Add: A node.js script to compile the Less stylesheets into CSS. 64 | - Add: New design parts for the custom time buttons and the AM/PM switch. 65 | - Update: The complete Less stylesheet structure. 66 | - Update: A few design changes on both designs. 67 | - Update: Each single CSS Color scheme contains now the complete styles instead of "imports". 68 | - Update: Move `direction: rtl;` from inline CSS to CSS stylesheet property. 69 | - Remove: All obsolete (not required) `-o-` and `-moz-` prefixed CSS properties. 70 | - Bugfix: Date picker is not positioned properly in a child scrollable container. 71 | - Thanks to [#33](https://github.com/pytesNET/tail.DateTime/issues/33). 72 | 73 | Version 0.4.12 - Beta 74 | --------------------- 75 | - Bugfix: The new `classList` helper methods didn't worked as expected. 76 | - Bugfix: Add correct file to the `main` bower variable. 77 | - Bugfix: Add correct file to the `jsdelivr` package variable. 78 | 79 | Version 0.4.11 - Beta 80 | --------------------- 81 | - Info: This is the first version, which drops IE 9 support. 82 | - Add: The new Norwegian Translation. 83 | - Thanks to [Lars Athle Larsen](https://github.com/larsathle) 84 | @ [#31](https://github.com/pytesNET/tail.DateTime/pull/31). 85 | - Add: Support for MooTools. 86 | - Add: Global `window` implementation using `datetime`, next to the existing `DateTime`, variable. 87 | - Update: Using `classList` to add / remove / check class names. 88 | - Update: Using `Object.assign` only to merge / clone object properties. 89 | - Update: Clone language strings (with the english ones, for backward compatibilities). 90 | - Rename: The internal `tailDateTime` variable has been renamed into `datetime`. 91 | - Remove: Support for Internet Explorer 9. 92 | - Remove: The jQuery `jQuery().tail("DateTime")` method (this was just a test). 93 | 94 | Version 0.4.10 - Beta 95 | --------------------- 96 | - Add: The new French Translation. 97 | - Thanks to [Murat Pala](https://github.com/Prozexis) 98 | @ [#30](https://github.com/pytesNET/tail.DateTime/pull/30). 99 | - Bugfix: Use of undefined variable `datePart` in the `convertDate` method. 100 | - Bugfix: The jQuery implementation has been fixed. 101 | 102 | Version 0.4.9 - Beta 103 | -------------------- 104 | - Add: Support for module exporting, using browserfy. 105 | - Add: A jQuery implementation using `jQuery().DateTime()` or `jQuery().tail("DateTime")`. 106 | - Update: Remove Parentheses on the `typeof` oeprator ('cause, it isn't a function). 107 | - Update: Should close (or test with stayopen) after submit time. 108 | - Thanks to [#24](https://github.com/pytesNET/tail.DateTime/issues/24). 109 | - Bugfix: Can't resolve '../tail.datetime-default.css'. 110 | - Thanks to [#25](https://github.com/pytesNET/tail.DateTime/issues/25). 111 | 112 | Version 0.4.8 - Beta 113 | -------------------- 114 | - Add: The new French Translation. 115 | - Thanks to [FlashPanther](https://github.com/FlashPanther) 116 | @ [#19](https://github.com/pytesNET/tail.DateTime/pull/19). 117 | - Bugfix: Tooltips doesn't support date range. 118 | - Thanks to [FlashPanther](https://github.com/FlashPanther) 119 | @ [#20](https://github.com/pytesNET/tail.DateTime/issues/20). 120 | 121 | Version 0.4.7 - Beta 122 | -------------------- 123 | - Add: The new Finish Translation. 124 | - Thanks to [noxludio](https://github.com/noxludio) 125 | @ [#17](https://github.com/pytesNET/tail.DateTime/pull/17). 126 | 127 | Version 0.4.6 - Beta 128 | -------------------- 129 | - Add: An `@import` rule on the single colors, so only one file need to be included. 130 | - Update: the `bower.json` and `package.json` files 131 | - Update: Add 2019 to all Copyright notes. 132 | - Bugfix: When showing only time picker, the calendar label says undefined. 133 | - Thanks to [#16](https://github.com/pytesNET/tail.DateTime/issues/16). 134 | 135 | Version 0.4.5 - Beta 136 | -------------------- 137 | - Add: The new Dutch Translation. 138 | - Thanks to [mickeybyte](https://github.com/mickeybyte) 139 | @ [#15](https://github.com/pytesNET/tail.DateTime/issues/15). 140 | - Add: Increase and Loop the Time fields by clicking Up and Down. 141 | - Add: The new option `timeIncrement`, which increase the next unit on loop of the previous one. 142 | - Add: The new option `closeButton`, which adds a close Button to the DateTime picker. 143 | - Add: The new internal method `handleTime()` which handles the time events. 144 | - Update: The `time*` options allows now also `false` as parameter to disable the field. 145 | 146 | Version 0.4.4 - Beta 147 | -------------------- 148 | - Remove: The `project.synder` file until the new Synder Format is finished. 149 | - Bugfix: CDN / NPM Hotfix (because I uploaded the wrong branch to NPM). 150 | 151 | Version 0.4.3 - Beta 152 | -------------------- 153 | - Add: The new Italian Translation. 154 | - Thanks to [Fabio Di Stasio](https://github.com/Fabio286) 155 | @ [#10](https://github.com/pytesNET/tail.DateTime/issues/10). 156 | - Add: The new Brazilian Portuguese Translation. 157 | - Thanks to [Júnior Garcia](https://github.com/juniorgarcia) 158 | @ [#13](https://github.com/pytesNET/tail.DateTime/issues/13). 159 | - Add: The new options `timeStep*` to change the step size of the input fields. 160 | - Thanks to [#9](https://github.com/pytesNET/tail.DateTime/issues/9). 161 | - Bugfix: Error in dateRanges visualization 162 | - Thanks to [#12](https://github.com/pytesNET/tail.DateTime/issues/12). 163 | 164 | Version 0.4.2 - Beta 165 | -------------------- 166 | - Add: The new `modify()` method on the string Storage to change the strings globally. 167 | - Update: The `.register()` method checks now if locale is a string and object a object. 168 | - Update: The `.register()` method returns now `true` on success and `false` on failure. 169 | - Bugfix: The `.selectTime()` method didn't used the "already select / current viewed" date. 170 | - Bugfix: Changing time has no effect. 171 | - Thanks to [#5](https://github.com/pytesNET/tail.DateTime/issues/5). 172 | - Bugfix: Calculations are wrong in some Environments. 173 | - Thanks to [AndrewDRX](https://github.com/AndrewDRX) 174 | @ [#6](https://github.com/pytesNET/tail.DateTime/issues/6). 175 | 176 | Version 0.4.1 - Beta 177 | -------------------- 178 | - Add: The new Arabic Translation. 179 | - Thanks to [Mohammed Alsiddeeq Ahmed](https://github.com/mosid) 180 | @ [#1](https://github.com/pytesNET/tail.DateTime/issues/1). 181 | - Add: The new option `rtl`, which allows to display the DateTime picker in an RTL style. 182 | - Add: The new event `view`. 183 | - Update: The new RTL supported Stylesheets. 184 | - Update: The default tooltip tick color depends now on the used theme. 185 | - Update: The "Enter/Escape" Key listener now also works when the cursor is within an input field. 186 | - Update: The events now gets fired AFTER the DateTime picker has done his actions. 187 | - Bugfix: Disabled dates could still be selected / clicked. 188 | - Bugfix: The `keyup` document event listener has fired per instance. 189 | - Bugfix: The "Enter" Key listener doesn't notice / used already selected dates. 190 | - Bugfix: You cannot go back farther than to February of the displayed year. 191 | - Thanks to [#3](https://github.com/pytesNET/tail.DateTime/issues/3). 192 | - Bugfix: Issue with Date Selection with Update to 0.4.0. 193 | - Thanks to [#2](https://github.com/pytesNET/tail.DateTime/issues/2). 194 | 195 | Version 0.4.0 - Beta 196 | -------------------- 197 | - Info: This is the first BETA version. :3 198 | - Info: This Repository is now completely independent, due to the removal of the last original 199 | lines of MrGuiseppes pureJSCalendar script. 200 | - Add: Russian translation (Thanks to my workmate). 201 | - Add: Designs in LESS Format (I'm new at this Pre-Processing Stuff :/). 202 | - Add: Support as Asynchronous Module Definition. 203 | - Add: The default design has 3 new, and the "harx" design has one additional color schemes. 204 | - Add: The new option `animate` to enable and disable the fade and tooltip animations. 205 | - Add: The new option `dateBlacklist` to turn the `dateRange` from a blacklist to a whitelist. 206 | - Add: The new option `dateStart` to limit the calendar. 207 | - Add: The new option `dateEnd` to limit the calendar. 208 | - Add: The new option `locale` to change the used locale by the calendar. 209 | - Add: The new option `timeHours` to set the default Hours on init (pass null for current). 210 | - Add: The new option `timeMintes` to set the default Minutes on init (pass null for current). 211 | - Add: The new option `timeSeconds` to set the default Seconds on init (pass null for current). 212 | - Add: The new option `today` to mark the current day within the calendar script. 213 | - Add: The new option `tooltips` to create tooltips on specific dates. 214 | - Add: The new option `viewDefault` to select the default view, when the calendar gets opened. 215 | - Add: The new option `viewDecades` enables the view "Decades" (Show different Decades). 216 | - Add: The new option `viewYears` enables the view "Years" (Show 12 Years - One Decade). 217 | - Add: The new option `viewMonths` enables the view "Months" (January - December). 218 | - Add: The new option `viewDays` enables the view "Days" (01 - 28|29|30|31). 219 | - Add: The new internal event trigger method `.trigger()`. 220 | - Add: A new custom event listener, using `.on()` and `.trigger()`. 221 | - Add: The new internal render and view methods `.renderCalendar()`, `.renderDatePicker()`, 222 | `.renderTimePicker()`,`.viewDecades()`, `.viewYears()`, `.viewMonths()`, `.viewDays()`, 223 | `.handleLabel()`, `.showTooltip()` and `.hideTooltip()`. 224 | - Add: The new public method `.config()` to get and set settings during the runtime. 225 | - Add: The new public methods `.switchView()`, `.browseView()`, `.switchDate()` and `.fetchDate()` 226 | to control the calendar interface and fetch the current Date. 227 | - Add: The new public methods `.appendTooltip()` and `.appendRange()` to append tooltips and date 228 | ranges during the runtime. 229 | - Update: The translations itself, as well as the translation / locale system behind. 230 | - Update: Both designs has been updated to the new structure. 231 | - Update: The main helper methods. 232 | - Update: The calendar render process has been re-written, now it will always show 6 rows of dates, 233 | including days from the previous and next month. 234 | - Update: The locale system is now usable per instance, the strings doesn't get replaced. 235 | - Update: The option `classNames` allows now `true` to copy the class names from the main element 236 | and false, to do nothing. 237 | - Update: The option `position` and `static` has been merged, so use "top", "left", "right" 238 | or "bottom" to show the calendar on an absolute position relative to the passed element or pass 239 | any selector, which should be used as container. 240 | - Update: The option `weekStart` supports now also numbers (SUN = 0, MON = 1, ... SAT = 6). 241 | - Update: The option `dateRange` requires now a new range format, the old one is NOT supported. 242 | - Update: The public methods `.switchMonth()` and `switchYear()` now just aliases for the main 243 | public method `.switchDate()`. 244 | - Update: The public methods `.open()` and `.close()` now using `setTimeout()` instead of an 245 | interval. 246 | - Update: The public methods `.reload()` reloads the same instance instead of creating a new one. 247 | - Update: The public event method `.on()` has been updated and supports now a third argument. 248 | - Remove: The option `static` has been removed (use `position` instead). 249 | - Remove: The option `zeroSeconds` has been removed (use `timeSeconds` instead). 250 | - Remove: The option `static` has been removed (use `position` instead). 251 | - Remove: The `isIE11` and `tail.IE` variables. 252 | - Remove: The old render functions `.renderDay()`, `.renderMonth()` and `.renderTime()` has been 253 | replaced by the new `.view*()` and `.render*()` methods. 254 | - Remove: The `.createCalendar()` method has been replaced by the new `.view*()` methods. 255 | - Bugfix: The `tbdy` typo has been fixed. 256 | - Bugfix: Incorrect `colspan` value on the thead element (on the Months View). 257 | 258 | Version 0.3.4 - Alpha 259 | --------------------- 260 | - Info: Official support for IE >= 9 starts now :( 261 | - Add: New `clone()` helper function as Fallback for IE >= 9. 262 | - Add: New `.IE` helper variable for Fallback use for IE >= 9. 263 | - Bugfix: Almost complete IE >= 9 support. 264 | 265 | Version 0.3.3 - Alpha 266 | --------------------- 267 | - Add: A new internal translate / string function called `__()`. 268 | - Add: New `reload()` method, which calls `remove()` and re-inits the DateTime Calendar. 269 | - Update: Use `this` to call the main DateTime IIFE function. 270 | - Update: Update the selected date when the input field has been filled out manually. 271 | - BugFix: Fix Typo and wrong attribute name in `remove()` method. 272 | - BugFix: `Enter` / `Return` executes all events, even if just one field is in focus. 273 | - Removed: The `dateRange` fallback option has been removed, to clean the source up for the next 274 | major version. 275 | 276 | Version 0.3.2 - Alpha 277 | --------------------- 278 | - Info: npmJS Version Fix. 279 | - Add: Spanish translation (Thanks to my workmate). 280 | 281 | Version 0.3.1 - Alpha 282 | --------------------- 283 | - BugFix: Position Absolute doesn't recalculate. 284 | - Thanks to [#2](https://github.com/pytesNET/tail.DateTime/issues/2). 285 | - BugFix: Today on every Year. 286 | - Thanks to [#1](https://github.com/pytesNET/tail.DateTime/issues/1). 287 | 288 | Version 0.3.0 - Alpha 289 | --------------------- 290 | - Info: Uses now some Vectors from GitHubs [Octicons](https://octicons.github.com/). 291 | - Add: A minified version, minified with [jsCompress](https://jscompress.com/). 292 | - Add: A new "white" design, used with `tail.datetime.white.css` (together with the main style 293 | sheet). 294 | - Add: A new `span` HTML element wraps each single day number. 295 | - Add: Events for `open`, `close` and `select` (used with `tail.DateTime::` prefix). 296 | - Add: New helper methos `trigger` to trigger tail.DateTime specific CustomEvents. 297 | - Add: New Option `static`, which allows a selector or an element as wrapper for a static view. 298 | - Add: New option `classNames`, which adds additional class names to the DateTime container. 299 | - Add: New option `startOpen`, which opens the picker after init. 300 | - Add: New option `stayOpen`, which disables some auto-closing events. 301 | - Add: New option `zeroSeconds`, which sets the seconds to 0 on init. 302 | - Add: New method `remove()` to remove the DateTime Picker. 303 | - Add: Current selected date class name and color. 304 | - Add: A colon between hours, minutes and seconds (That was really important!). 305 | - Add: The language strings für `de` (German) and `de_AT` (Austrian German) 306 | - Update: The SVG arrows on the default theme has been changed into angle images (Octicon). 307 | - Update: All SVG images has been changed into the Octicon vector graphics. 308 | - Update: The constructor allows now `NodeList`s and `HTMLCollection`s and uses `querySelectorAll` 309 | on strings. 310 | - Update: Renamed any `data-fox-*` attribute names into `data-tail-*`. 311 | - Update: The internal `element` input variable has renamed into `e`. 312 | - Update: The internal `calendar` DateTime Picker variable has renamed into `dt`. 313 | - Update: The internal `options` configuration variable has renamed into `con`. 314 | - Update: The internal `view` / `current` variables has been merged under `view`. 315 | - Update: The internal `select` variable holds the last (current) selected Date and Time as Date 316 | object. 317 | - Update: The option `dateRange` has renamed into `dateRanges` and allows multiple arrays with 318 | Date Objects, Date Values (YYYY-mm-dd) and Week-Day names. 319 | - BugFix: Current Date object has been shared between each prototype instance. 320 | 321 | Version 0.2.0 - Alpha 322 | --------------------- 323 | - Info: Project has been renamed to `tail.DateTime` and adapted to the tail implementation. 324 | 325 | Version 0.1.2 - Alpha 326 | --------------------- 327 | - Add: Use the `data-fox-value` attribute for pre-defined dates, before trying to parse the input value. 328 | - Add: Helper Methods `Fox.hasClass`, `Fox.addClass`, `Fox.removeClass`. 329 | - Add: Calendar Class Names `calendar-close`, `calendar-idle`, `calendar-open`. 330 | - Update: Changed `‹` and `›` into SVG background images. 331 | - Update: Stores now a (current) Date Object instead of the year / month number. 332 | - Update: Some minimalistic style and script changes. 333 | - BugFix: Double Use of the `data-fox-calendar` attribute. 334 | - BugFix: Calendar closes after selecting a month. 335 | - BugFix: The `switchYear()` method doesn't supported a year argument. 336 | 337 | Version 0.1.1 - Alpha 338 | --------------------- 339 | - Update: Change Calendar Counter Calculation (CCCC). 340 | - Update: Return `this` on the public methods. 341 | 342 | Version 0.1.0 - Alpha 343 | --------------------- 344 | - Initial Release (Fork of [Pure JS Calendar](https://github.com/MrGuiseppe/pureJSCalendar)). 345 | -------------------------------------------------------------------------------- /modules_meshcore/scripttask.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @description MeshCentral ScriptTask plugin 3 | * @author Ryan Blenis 4 | * @copyright 5 | * @license Apache-2.0 6 | */ 7 | 8 | "use strict"; 9 | var mesh; 10 | var obj = this; 11 | var _sessionid; 12 | var isWsconnection = false; 13 | var wscon = null; 14 | var db = require('SimpleDataStore').Shared(); 15 | var pendingDownload = []; 16 | var debug_flag = false; 17 | var runningJobs = []; 18 | var runningJobPIDs = {}; 19 | 20 | var dbg = function(str) { 21 | if (debug_flag !== true) return; 22 | var fs = require('fs'); 23 | var logStream = fs.createWriteStream('scripttask.txt', {'flags': 'a'}); 24 | // use {'flags': 'a'} to append and {'flags': 'w'} to erase and write a new file 25 | logStream.write('\n'+new Date().toLocaleString()+': '+ str); 26 | logStream.end('\n'); 27 | } 28 | 29 | Array.prototype.remove = function(from, to) { 30 | var rest = this.slice((to || from) + 1 || this.length); 31 | this.length = from < 0 ? this.length + from : from; 32 | return this.push.apply(this, rest); 33 | }; 34 | 35 | function consoleaction(args, rights, sessionid, parent) { 36 | isWsconnection = false; 37 | wscon = parent; 38 | var _sessionid = sessionid; 39 | if (typeof args['_'] == 'undefined') { 40 | args['_'] = []; 41 | args['_'][1] = args.pluginaction; 42 | args['_'][2] = null; 43 | args['_'][3] = null; 44 | args['_'][4] = null; 45 | isWsconnection = true; 46 | } 47 | 48 | var fnname = args['_'][1]; 49 | mesh = parent; 50 | 51 | switch (fnname) { 52 | case 'triggerJob': 53 | var jObj = { 54 | jobId: args.jobId, 55 | scriptId: args.scriptId, 56 | replaceVars: args.replaceVars, 57 | scriptHash: args.scriptHash, 58 | dispatchTime: args.dispatchTime 59 | }; 60 | //dbg('jObj args is ' + JSON.stringify(jObj)); 61 | var sObj = getScriptFromCache(jObj.scriptId); 62 | //dbg('sobj = ' + JSON.stringify(sObj) + ', shash = ' + jObj.scriptHash); 63 | if (sObj == null || sObj.contentHash != jObj.scriptHash) { 64 | // get from the server, then run 65 | //dbg('Getting and caching script '+ jObj.scriptId); 66 | mesh.SendCommand({ 67 | "action": "plugin", 68 | "plugin": "scripttask", 69 | "pluginaction": "getScript", 70 | "scriptId": jObj.scriptId, 71 | "sessionid": _sessionid, 72 | "tag": "console" 73 | }); 74 | pendingDownload.push(jObj); 75 | } else { 76 | // ready to run 77 | runScript(sObj, jObj); 78 | } 79 | break; 80 | case 'cacheScript': 81 | var sObj = args.script; 82 | cacheScript(sObj); 83 | var setRun = []; 84 | if (pendingDownload.length) { 85 | pendingDownload.forEach(function(pd, k) { 86 | if (pd.scriptId == sObj._id && pd.scriptHash == sObj.contentHash) { 87 | if (setRun.indexOf(pd) === -1) { 88 | runScript(sObj, pd); 89 | setRun.push(pd); 90 | } 91 | pendingDownload.remove(k); 92 | } 93 | }); 94 | } 95 | break; 96 | case 'clearAll': 97 | clearCache(); 98 | mesh.SendCommand({ 99 | "action": "plugin", 100 | "plugin": "scripttask", 101 | "pluginaction": "clearAllPendingJobs", 102 | "sessionid": _sessionid, 103 | "tag": "console" 104 | }); 105 | return 'Cache cleared. All pending jobs cleared.'; 106 | break; 107 | case 'clearCache': 108 | clearCache(); 109 | return 'The script cache has been cleared'; 110 | break; 111 | case 'debug': 112 | debug_flag = (debug_flag) ? false : true; 113 | var str = (debug_flag) ? 'on' : 'off'; 114 | return 'Debugging is now ' + str; 115 | break; 116 | case 'getPendingJobs': 117 | var ret = ''; 118 | if (pendingDownload.length == 0) return "No jobs pending script download"; 119 | pendingDownload.forEach(function(pd, k) { 120 | ret += 'Job ' + k + ': ' + 'JobID: ' + pd.jobId + ' ScriptID: ' + pd.scriptId; 121 | }); 122 | return ret; 123 | break; 124 | default: 125 | dbg('Unknown action: '+ fnname + ' with data ' + JSON.stringify(args)); 126 | break; 127 | } 128 | } 129 | 130 | function finalizeJob(job, retVal, errVal) { 131 | if (errVal != null && errVal.stack != null) errVal = errVal.stack; 132 | runningJobs.remove(runningJobs.indexOf(job.jobId)); 133 | if (typeof runningJobPIDs[job.jobId] != 'undefined') delete runningJobPIDs[job.jobId]; 134 | mesh.SendCommand({ 135 | "action": "plugin", 136 | "plugin": "scripttask", 137 | "pluginaction": "jobComplete", 138 | "jobId": job.jobId, 139 | "scriptId": job.scriptId, 140 | "retVal": retVal, 141 | "errVal": errVal, 142 | "dispatchTime": job.dispatchTime, // include original run time (long running tasks could have tried a re-send) 143 | "sessionid": _sessionid, 144 | "tag": "console" 145 | }); 146 | } 147 | //@TODO Test powershell on *nix devices with and without powershell installed 148 | function runPowerShell(sObj, jObj) { 149 | if (process.platform != 'win32') return runPowerShellNonWin(sObj, jObj); 150 | const fs = require('fs'); 151 | var rand = Math.random().toString(32).replace('0.', ''); 152 | 153 | var oName = 'st' + rand + '.txt'; 154 | var pName = 'st' + rand + '.ps1'; 155 | var pwshout = '', pwsherr = '', cancontinue = false; 156 | try { 157 | fs.writeFileSync(pName, sObj.content); 158 | var outstr = '', errstr = ''; 159 | var child = require('child_process').execFile(process.env['windir'] + '\\system32\\WindowsPowerShell\\v1.0\\powershell.exe', ['-NoLogo', '-NoProfile', '-ExecutionPolicy Bypass'] ); 160 | child.stderr.on('data', function (chunk) { errstr += chunk; }); 161 | child.stdout.on('data', function (chunk) { }); 162 | runningJobPIDs[jObj.jobId] = child.pid; 163 | child.stdin.write('.\\' + pName + ' | Out-File ' + oName + ' -Encoding UTF8\r\n'); 164 | child.on('exit', function(procRetVal, procRetSignal) { 165 | dbg('Exiting with '+procRetVal + ', Signal: ' + procRetSignal); 166 | if (errstr != '') { 167 | finalizeJob(jObj, null, errstr); 168 | try { 169 | fs.unlinkSync(oName); 170 | fs.unlinkSync(pName); 171 | } catch (e) { dbg('Could not unlink files, error was: ' + e); } 172 | return; 173 | } 174 | if (procRetVal == 1) { 175 | finalizeJob(jObj, null, 'Process terminated unexpectedly.'); 176 | try { 177 | fs.unlinkSync(oName); 178 | fs.unlinkSync(pName); 179 | } catch (e) { dbg('Could not unlink files, error was: ' + e); } 180 | return; 181 | } 182 | try { 183 | outstr = fs.readFileSync(oName, 'utf8').toString(); 184 | } catch (e) { outstr = (procRetVal) ? 'Failure' : 'Success'; } 185 | if (outstr) { 186 | //outstr = outstr.replace(/[^\x20-\x7E]/g, ''); 187 | try { outstr = outstr.trim(); } catch (e) { } 188 | } else { 189 | outstr = (procRetVal) ? 'Failure' : 'Success'; 190 | } 191 | dbg('Output is: ' + outstr); 192 | finalizeJob(jObj, outstr); 193 | try { 194 | fs.unlinkSync(oName); 195 | fs.unlinkSync(pName); 196 | } catch (e) { } 197 | }); 198 | child.stdin.write('exit\r\n'); 199 | //child.waitExit(); // this was causing the event loop to stall on long-running scripts, switched to '.on exit' 200 | 201 | } catch (e) { 202 | dbg('Error block was (PowerShell): ' + e); 203 | finalizeJob(jObj, null, e); 204 | } 205 | } 206 | 207 | function runPowerShellNonWin(sObj, jObj) { 208 | const fs = require('fs'); 209 | var rand = Math.random().toString(32).replace('0.', ''); 210 | 211 | var path = ''; 212 | var pathTests = [ 213 | '/usr/local/mesh', 214 | '/tmp', 215 | '/usr/local/mesh_services/meshagent', 216 | '/var/tmp' 217 | ]; 218 | pathTests.forEach(function(p) { 219 | if (path == '' && fs.existsSync(p)) { path = p; } 220 | }); 221 | dbg('Path chosen is: ' + path); 222 | path = path + '/'; 223 | 224 | var oName = 'st' + rand + '.txt'; 225 | var pName = 'st' + rand + '.ps1'; 226 | var pwshout = '', pwsherr = '', cancontinue = false; 227 | try { 228 | var childp = require('child_process').execFile('/bin/sh', ['sh']); 229 | childp.stderr.on('data', function (chunk) { pwsherr += chunk; }); 230 | childp.stdout.on('data', function (chunk) { pwshout += chunk; }); 231 | childp.stdin.write('which pwsh' + '\n'); 232 | childp.stdin.write('exit\n'); 233 | childp.waitExit(); 234 | } catch (e) { finalizeJob(jObj, null, "Couldn't determine pwsh in env: " + e); } 235 | if (pwsherr != '') { 236 | finalizeJob(jObj, null, "PowerShell env determination error: " + pwsherr); 237 | return; 238 | } 239 | if (pwshout.trim() != '') { 240 | cancontinue = true; 241 | } 242 | if (cancontinue === false) { finalizeJob(jObj, null, "PowerShell is not installed"); return; } 243 | try { 244 | fs.writeFileSync(path + pName, '#!' + pwshout + '\n' + sObj.content.split('\r\n').join('\n').split('\r').join('\n')); 245 | var outstr = '', errstr = ''; 246 | var child = require('child_process').execFile('/bin/sh', ['sh']); 247 | child.stderr.on('data', function (chunk) { errstr += chunk; }); 248 | child.stdout.on('data', function (chunk) { }); 249 | runningJobPIDs[jObj.jobId] = child.pid; 250 | 251 | child.stdin.write('cd ' + path + '\n'); 252 | child.stdin.write('chmod a+x ' + pName + '\n'); 253 | child.stdin.write('./' + pName + ' > ' + oName + '\n'); 254 | child.on('exit', function(procRetVal, procRetSignal) { 255 | if (errstr != '') { 256 | finalizeJob(jObj, null, errstr); 257 | try { 258 | fs.unlinkSync(path + oName); 259 | fs.unlinkSync(path + pName); 260 | } catch (e) { dbg('Could not unlink files, error was: ' + e + ' for path ' + path); } 261 | return; 262 | } 263 | if (procRetVal == 1) { 264 | finalizeJob(jObj, null, 'Process terminated unexpectedly.'); 265 | try { 266 | fs.unlinkSync(path + oName); 267 | fs.unlinkSync(path + pName); 268 | } catch (e) { dbg('Could not unlink files1, error was: ' + e + ' for path ' + path); } 269 | return; 270 | } 271 | try { 272 | outstr = fs.readFileSync(path + oName, 'utf8').toString(); 273 | } catch (e) { outstr = (procRetVal) ? 'Failure' : 'Success'; } 274 | if (outstr) { 275 | //outstr = outstr.replace(/[^\x20-\x7E]/g, ''); 276 | try { outstr = outstr.trim(); } catch (e) { } 277 | } else { 278 | outstr = (procRetVal) ? 'Failure' : 'Success'; 279 | } 280 | dbg('Output is: ' + outstr); 281 | finalizeJob(jObj, outstr); 282 | try { 283 | fs.unlinkSync(path + oName); 284 | fs.unlinkSync(path + pName); 285 | } catch (e) { dbg('Could not unlink files2, error was: ' + e + ' for path ' + path); } 286 | }); 287 | child.stdin.write('exit\n'); 288 | } catch (e) { 289 | dbg('Error block was (PowerShellNonWin): ' + e); 290 | finalizeJob(jObj, null, e); 291 | } 292 | } 293 | 294 | function runBat(sObj, jObj) { 295 | if (process.platform != 'win32') { 296 | finalizeJob(jObj, null, 'Platform not supported.'); 297 | return; 298 | } 299 | const fs = require('fs'); 300 | var rand = Math.random().toString(32).replace('0.', ''); 301 | var oName = 'st' + rand + '.txt'; 302 | var pName = 'st' + rand + '.bat'; 303 | try { 304 | fs.writeFileSync(pName, sObj.content); 305 | var outstr = '', errstr = ''; 306 | var child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe'); 307 | child.stderr.on('data', function (chunk) { errstr += chunk; }); 308 | child.stdout.on('data', function (chunk) { }); 309 | runningJobPIDs[jObj.jobId] = child.pid; 310 | child.stdin.write(pName + ' > ' + oName + '\r\n'); 311 | child.stdin.write('exit\r\n'); 312 | 313 | child.on('exit', function(procRetVal, procRetSignal) { 314 | if (errstr != '') { 315 | try { 316 | fs.unlinkSync(oName); 317 | fs.unlinkSync(pName); 318 | } catch (e) { dbg('Could not unlink files, error was: ' + e); } 319 | finalizeJob(jObj, null, errstr); 320 | return; 321 | } 322 | if (procRetVal == 1) { 323 | try { 324 | fs.unlinkSync(oName); 325 | fs.unlinkSync(pName); 326 | } catch (e) { dbg('Could not unlink files, error was: ' + e); } 327 | finalizeJob(jObj, null, 'Process terminated unexpectedly.'); 328 | return; 329 | } 330 | try { 331 | outstr = fs.readFileSync(oName, 'utf8').toString(); 332 | } catch (e) { outstr = (procRetVal) ? 'Failure' : 'Success'; } 333 | if (outstr) { 334 | //outstr = outstr.replace(/[^\x20-\x7E]/g, ''); 335 | try { outstr = outstr.trim(); } catch (e) { } 336 | } else { 337 | outstr = (procRetVal) ? 'Failure' : 'Success'; 338 | } 339 | dbg('Output is: ' + outstr); 340 | try { 341 | fs.unlinkSync(oName); 342 | fs.unlinkSync(pName); 343 | } catch (e) { dbg('Could not unlink files, error was: ' + e); } 344 | finalizeJob(jObj, outstr); 345 | }); 346 | } catch (e) { 347 | dbg('Error block was (BAT): ' + e); 348 | finalizeJob(jObj, null, e); 349 | } 350 | } 351 | 352 | function runBash(sObj, jObj) { 353 | if (process.platform == 'win32') { 354 | finalizeJob(jObj, null, 'Platform not supported.'); 355 | return; 356 | } 357 | //dbg('proc is ' + JSON.stringify(process)); 358 | const fs = require('fs'); 359 | var path = ''; 360 | var pathTests = [ 361 | '/usr/local/mesh', 362 | '/tmp', 363 | '/usr/local/mesh_services/meshagent', 364 | '/var/tmp' 365 | ]; 366 | pathTests.forEach(function(p) { 367 | if (path == '' && fs.existsSync(p)) { path = p; } 368 | }); 369 | dbg('Path chosen is: ' + path); 370 | path = path + '/'; 371 | //var child = require('child_process'); 372 | //child.execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'RunDll32.exe user32.dll,LockWorkStation'], { type: 1 }); 373 | 374 | var rand = Math.random().toString(32).replace('0.', ''); 375 | var oName = 'st' + rand + '.txt'; 376 | var pName = 'st' + rand + '.sh'; 377 | try { 378 | fs.writeFileSync(path + pName, sObj.content); 379 | var outstr = '', errstr = ''; 380 | var child = require('child_process').execFile('/bin/sh', ['sh']); 381 | child.stderr.on('data', function (chunk) { errstr += chunk; }); 382 | child.stdout.on('data', function (chunk) { }); 383 | runningJobPIDs[jObj.jobId] = child.pid; 384 | child.stdin.write('cd ' + path + '\n'); 385 | child.stdin.write('chmod a+x ' + pName + '\n'); 386 | child.stdin.write('./' + pName + ' > ' + oName + '\n'); 387 | child.stdin.write('exit\n'); 388 | 389 | child.on('exit', function(procRetVal, procRetSignal) { 390 | if (errstr != '') { 391 | try { 392 | fs.unlinkSync(path + oName); 393 | fs.unlinkSync(path + pName); 394 | } catch (e) { dbg('Could not unlink files, error was: ' + e + ' for path ' + path); } 395 | finalizeJob(jObj, null, errstr); 396 | return; 397 | } 398 | if (procRetVal == 1) { 399 | try { 400 | fs.unlinkSync(path + oName); 401 | fs.unlinkSync(path + pName); 402 | } catch (e) { dbg('Could not unlink files1, error was: ' + e + ' for path ' + path); } 403 | finalizeJob(jObj, null, 'Process terminated unexpectedly.'); 404 | return; 405 | } 406 | try { 407 | outstr = fs.readFileSync(path + oName, 'utf8').toString(); 408 | } catch (e) { outstr = (procRetVal) ? 'Failure' : 'Success'; } 409 | if (outstr) { 410 | //outstr = outstr.replace(/[^\x20-\x7E]/g, ''); 411 | try { outstr = outstr.trim(); } catch (e) { } 412 | } else { 413 | outstr = (procRetVal) ? 'Failure' : 'Success'; 414 | } 415 | dbg('Output is: ' + outstr); 416 | try { 417 | fs.unlinkSync(path + oName); 418 | fs.unlinkSync(path + pName); 419 | } catch (e) { dbg('Could not unlink files2, error was: ' + e + ' for path ' + path); } 420 | finalizeJob(jObj, outstr); 421 | }); 422 | } catch (e) { 423 | dbg('Error block was (bash): ' + e); 424 | finalizeJob(jObj, null, e); 425 | } 426 | } 427 | 428 | function jobIsRunning(jObj) { 429 | if (runningJobs.indexOf(jObj.jobId) === -1) return false; 430 | return true; 431 | } 432 | 433 | function runScript(sObj, jObj) { 434 | // get current processes and clean running jobs if they are no longer running (computer fell asleep, user caused process to stop, etc.) 435 | if (process.platform != 'linux' && runningJobs.length) { // linux throws errors here in the meshagent for some reason 436 | require('process-manager').getProcesses(function (plist) { 437 | dbg('Got process list'); 438 | dbg('There are currently ' + runningJobs.length + ' running jobs.'); 439 | if (runningJobs.length) { 440 | runningJobs.forEach(function (jobId, idx) { 441 | dbg('Checking for running job: ' + jobId + ' with PID ' + runningJobPIDs[jobId]); 442 | if (typeof plist[runningJobPIDs[jobId]] == 'undefined' || typeof plist[runningJobPIDs[jobId]].cmd != 'string') { 443 | dbg('Found job with no process. Removing running status.'); 444 | delete runningJobPIDs[jobId]; 445 | runningJobs.remove(runningJobs.indexOf(idx)); 446 | //dbg('RunningJobs: ' + JSON.stringify(runningJobs)); 447 | //dbg('RunningJobsPIDs: ' + JSON.stringify(runningJobPIDs)); 448 | } 449 | }); 450 | } 451 | }); 452 | } 453 | if (jobIsRunning(jObj)) { dbg('Job already running job id [' + jObj.jobId + ']. Skipping.'); return; } 454 | if (jObj.replaceVars != null) { 455 | Object.getOwnPropertyNames(jObj.replaceVars).forEach(function(key) { 456 | var val = jObj.replaceVars[key]; 457 | sObj.content = sObj.content.replace(new RegExp('#'+key+'#', 'g'), val); 458 | dbg('replacing var '+ key + ' with ' + val); 459 | }); 460 | sObj.content = sObj.content.replace(new RegExp('#(.*?)#', 'g'), 'VAR_NOT_FOUND'); 461 | } 462 | runningJobs.push(jObj.jobId); 463 | dbg('Running Script '+ sObj._id); 464 | switch (sObj.filetype) { 465 | case 'ps1': 466 | runPowerShell(sObj, jObj); 467 | break; 468 | case 'bat': 469 | runBat(sObj, jObj); 470 | break; 471 | case 'bash': 472 | runBash(sObj, jObj); 473 | break; 474 | default: 475 | dbg('Unknown filetype: '+ sObj.filetype); 476 | break; 477 | } 478 | } 479 | function getScriptFromCache(id) { 480 | var script = db.Get('pluginScriptTask_script_' + id); 481 | if (script == '' || script == null) return null; 482 | try { 483 | script = JSON.parse(script); 484 | } catch (e) { return null; } 485 | return script; 486 | } 487 | function cacheScript(sObj) { 488 | db.Put('pluginScriptTask_script_' + sObj._id, sObj); 489 | } 490 | function clearCache() { 491 | db.Keys.forEach(function(k) { 492 | if (k.indexOf('pluginScriptTask_script_') === 0) { 493 | db.Put(k, null); 494 | db.Delete(k); 495 | } 496 | }); 497 | } 498 | 499 | function sendConsoleText(text, sessionid) { 500 | if (typeof text == 'object') { text = JSON.stringify(text); } 501 | mesh.SendCommand({ "action": "msg", "type": "console", "value": text, "sessionid": sessionid }); 502 | } 503 | 504 | module.exports = { consoleaction : consoleaction }; 505 | -------------------------------------------------------------------------------- /includes/tail.DateTime/tail.datetime.min.js: -------------------------------------------------------------------------------- 1 | /* pytesNET/tail.DateTime v.0.4.14 | Basic Version | @author SamBrishes, pytesNET | @license MIT */ 2 | !function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t,t.document)}):"object"==typeof module&&module.exports?module.exports=e(t,t.document):(void 0===t.tail&&(t.tail={}),t.tail.DateTime=t.tail.datetime=e(t,t.document),"undefined"!=typeof jQuery&&(jQuery.fn.DateTime=jQuery.fn.datetime=function(t){var e,i=[];return this.each(function(){!1!==(e=tail.DateTime(this,t))&&i.push(e)}),1===i.length?i[0]:0!==i.length&&i}),"undefined"!=typeof MooTools&&(Element.implement({DateTime:function(t){return new tail.DateTime(this,t)}}),Element.implement({datetime:function(t){return new tail.DateTime(this,t)}})))}(window,function(h,d){"use strict";function u(t,e){return!!(t&&"classList"in t)&&t.classList.contains(e)}function a(t,e){return t&&"classList"in t?t.classList.add(e):void 0}function n(t,e){return t&&"classList"in t?t.classList.remove(e):void 0}function s(t,e,i){if(CustomEvent&&CustomEvent.name)var a=new CustomEvent(e,i);else(a=d.createEvent("CustomEvent")).initCustomEvent(e,!!i.bubbles,!!i.cancelable,i.detail);return t.dispatchEvent(a)}function o(t,e){if("function"==typeof Object.assign)return Object.assign({},t,e||{});var i=Object.constructor();for(var a in t)i[a]=a in e?e[a]:t[a];return i}function p(t,e){var i=d.createElement(t);return i.className=e&&e.join?e.join(" "):e||"",i}function r(t){return t.charAt(0).toUpperCase()+t.slice(1)}function c(t,e,i){var a=t instanceof Date?t:!!t&&new Date(t);return a instanceof Date&&!isNaN(a.getDate())&&(i&&a.setHours(0,0,0,0),!0===e?a.getTime():a)}d.forms.inputmode=!0;var l=function(t,e){if((t="string"==typeof t?d.querySelectorAll(t):t)instanceof NodeList||t instanceof HTMLCollection||t instanceof Array){for(var i=[],a=t.length,n=0;n\n\n";for(var e=0;e<7;e++)this.weekdays+=''+t[e]+"";this.weekdays+="\n\n",this.select=c(this.e.getAttribute("data-value")||this.e.value),(!this.select||this.selectthis.con.dateEnd)&&(this.select=null),null==this.view&&(this.view={type:this.con.viewDefault,date:this.select||new Date});var i=["Hours","Minutes","Seconds"];for(e=0;e<3;e++)if("number"==typeof this.con["time"+i[e]])this.view.date["set"+i[e]](this.con["time"+i[e]]);else for(;this.view.date["get"+i[e]]()%this.con["timeStep"+i[e]]!=0;)this.view.date["set"+i[e]](this.view.date["get"+i[e]]()+1);return this.ampm=!!this.con.time12h&&12n[i].end?[n[i].end,n[i].end=n[i].start][0]:n[i].start),n[i].days=!("days"in n[i])||n[i].days,n[i].days="boolean"!=typeof n[i].days?function(t){for(var e=[],i=t.length,a=0;a'+s[i].text||"Tooltip",r)}));this.con.tooltips=t}var r;return this},bind:function(){var e=this;return void 0===this._bind&&(this.e.addEventListener("focusin",function(t){e.open.call(e)}),this.e.addEventListener("keyup",function(t){e.callback.call(e,t)}),d.addEventListener("keyup",function(t){e.dt.contains(t.target)&&e.callback.call(e,t)}),d.addEventListener("click",function(t){e.dt.contains(t.target)?e.callback.call(e,t):!e.e.contains(t.target)&&u(e.dt,"calendar-open")&&(t.target==e.dt||t.target==e.e||e.con.stayOpen||e.close.call(e))}),d.addEventListener("mouseover",function(t){e.dt.contains(t.target)&&e.callback.call(e,t)}),this._bind=!0),this},callback:function(t){var e,i=t.target,a="getAttribute",n="data-action",s=i[a](n)?i:i.parentElement[a](n)?i.parentElement:i,r="data-tooltip";if("mouseover"==t.type&&(!1!==(e=i[a](r)?i:!!s[a](r)&&s)?this.dt.querySelector("#tooltip-"+e[a](r)+"-"+e[a](r+"-time"))||this.showTooltip(e[a](r),e,e[a](r+"-time")):this.dt.querySelector(".calendar-tooltip:not(.remove)")&&this.hideTooltip(this.dt.querySelector(".calendar-tooltip").id.slice(8))),"click"==t.type){if(!s||1!=t.buttons&&1!=(t.which||t.button))return;if(s.hasAttribute("data-disabled"))return;switch(s[a](n)){case"prev":case"next":return this.browseView(s[a](n));case"cancel":this.con.stayOpen||this.close();break;case"submit":return this.con.stayOpen||this.close(),this.selectDate(this.fetchDate(parseInt(s[a]("data-date"))));case"view":return this.switchDate(s[a]("data-year")||null,s[a]("data-month")||null,s[a]("data-day")||null),this.switchView(s[a]("data-view"))}}if("keyup"==t.type){if("INPUT"!=t.target.tagName&&t.target!==this.e&&/calendar-(static|close)/i.test(this.dt.className))return!1;13==(t.keyCode||t.which)&&(this.selectDate(this.fetchDate(this.select)),t.stopPropagation(),this.con.stayOpen||this.close()),27==(t.keyCode||t.which)&&(this.con.stayOpen||this.close())}},trigger:function(t){var e={bubbles:!1,cancelable:!0,detail:{args:arguments,self:this}};"change"==t&&(s(this.e,"input",e),s(this.e,"change",e)),s(this.dt,"tail::"+t,e);for(var i=(this.events[t]||[]).length,a=0;a':this.con.timeFormat&&(n=''),a.innerHTML=n?'
'+n+"
":"",this.con.dateFormat&&this.renderDatePicker(a,this.con.viewDefault),this.con.timeFormat&&this.renderTimePicker(a),this.con.closeButton&&!i){var s=p("BUTTON","calendar-close"),r=this;s.addEventListener("click",function(t){t.preventDefault(),r.close()}),a.appendChild(s)}return(i||d.body).appendChild(a),a},renderDatePicker:function(t,e){if((!e||["decades","years","months","days"].indexOf(e)<0)&&(e=this.con.viewDays?"days":this.con.viewMonths?"months":this.con.viewYears?"years":!!this.con.viewDecades&&"decades"),!e||!this.con["view"+r(e)]||!this.con.dateFormat)return!1;var i=d.createElement("DIV");return i.className="calendar-datepicker calendar-view-"+e,i.innerHTML=this["view"+r(e)](),t.querySelector(".calendar-datepicker")?t.replaceChild(i,t.querySelector(".calendar-datepicker")):t.appendChild(i),this.view.type=e,this.handleLabel(t)},renderTimePicker:function(t){if(!this.con.timeFormat)return!1;var e,i,a=[],n=0;if(this.con.time12h){var s=12")}for(var r in{Hours:0,Minutes:0,Seconds:0})!1!==this.con["time"+r]?((e=d.createElement("INPUT")).type="text",e.disabled=null===this.con["time"+r],e.setAttribute("min","Hours"===r&&this.con.time12h?"01":"00"),e.setAttribute("max","Hours"!==r?"60":this.con.time12h?"13":"24"),e.setAttribute("step",this.con["timeStep"+r]),e.setAttribute("value",(i=this.view.date["get"+r]())<10?"0"+i:i),e.setAttribute("pattern","d*"),e.setAttribute("inputmode","numeric"),e.setAttribute("data-input",r.toLowerCase()),a.push('
'+e.outerHTML+'
")):a.push((n++,null));var o=p("DIV","calendar-timepicker"),c=this;o.innerHTML=a.join("\n");var l=o.querySelectorAll("input");for(n=0;n=e.getYear()&&i<=e.getYear()+10?" date-today":""),n='data-action="view" data-view="down" data-year="'+e.getFullYear()+'"',s.push(''+e.getFullYear()+" - "+(e.getFullYear()+10)+""),4<=o&&o%4==0&&(r.push("\n"+s.join("\n")+"\n"),s=[]),e.setFullYear(e.getFullYear()+10);return'"+r.join("\n")+"
'+this.__.header[2]+"
"},viewYears:function(){var t=this.view.date.getFullYear(),e=new Date(this.view.date.getTime()),i=this.con.today?(new Date).getYear():0;e.setFullYear(t-parseInt(t.toString()[3])-2);for(var a,n,s=[],r=[],o=1;o<=16;o++)a="calendar-year"+(e.getYear()==i?" date-today":""),n='data-action="view" data-view="down" data-year="'+e.getFullYear()+'"',s.push(''+e.getFullYear()+""),4<=o&&o%4==0&&(r.push("\n"+s.join("\n")+"\n"),s=[]),e.setFullYear(e.getFullYear()+1);return'"+r.join("\n")+"
'+this.__.header[1]+"
"},viewMonths:function(){var t=this.__.months,e=this.con.today?(new Date).getMonth():-1;e=this.view.date.getYear()==(new Date).getYear()?e:-1;for(var i,a,n=[],s=[],r=0;r<12;r++)i="calendar-month"+(e==r?" date-today":""),a='data-action="view" data-view="down" data-month="'+r+'"',n.push(''+t[r]+""),3==n.length&&(s.push("\n"+n.join("\n")+"\n"),n=[]);return'"+s.join("\n")+"
'+this.__.header[0]+"
"},viewDays:function(){var i,t,e,a,n,s,r=new Date(this.view.date.getTime()),o=(new Date).toDateString(),c=r.getMonth(),l=[],h=[],d=[0,[]],u=([].concat(this.con.tooltips),[0,0]);for(r.setHours(0,0,0,0),r.setDate(1),r.setDate(1-(r.getDay()-this.con.weekStart));h.length<6;)i=r.getTime(),s=[].concat(this.con.dateRanges),e='data-action="submit" data-date="'+r.getTime()+'"',t="calendar-day date-"+(r.getMonth()>c?"next":r.getMonth()this.con.dateEnd)?d=[i=t.start&&i<=t.end?!(d=[t.end,t.days]):t.start>i},this):3==d.length&&(d=[0,[0,1,2,3,4,5,6]]),0=i&&(u=[t.date[1],e,t.color]):t.date==i&&(u=[t.date,e,t.color])},this),u[0]=i&&0<=d[1].indexOf(r.getDay()))&&this.con.dateBlacklist||!n&&!this.con.dateBlacklist?(t+=" date-disabled",e+=' data-disabled="true"'):0!==d[0]&&d[0]<=i&&(d=[0,[]]),this.select&&this.select.toDateString()==r.toDateString()&&(t+=" date-select"),a=''+r.getDate()+"",0':a+=''),l.push('"+a+""),7==l.length&&(h.push("\n"+l.join("\n")+"\n"),l=[]),r.setDate(r.getDate()+1);return h=""+h.join("\n")+"",''+this.weekdays+h+"
"},showTooltip:function(t,e,i){var a,n=this.con.tooltips[t].element,s=n.style,r=this.dt.querySelector(".calendar-datepicker");s.cssText="opacity:0;visibility:hidden;",n.id="tooltip-"+t+"-"+i,r.appendChild(n),a=n.offsetWidth,n.offsetHeight,s.top=e.offsetTop+e.offsetHeight+"px",s.left=e.offsetLeft+e.offsetWidth/2-a/2+"px",s.visibility="visible",this.con.animate?(n.setAttribute("data-top",parseInt(s.top)),s.top=parseInt(s.top)+5+"px",function t(){parseFloat(s.top)>n.getAttribute("data-top")&&(s.top=parseFloat(s.top)-.5+"px"),(s.opacity=parseFloat(s.opacity)+.125)<1&&setTimeout(t,20)}()):s.opacity=1},hideTooltip:function(t){var e=this.dt.querySelector("#tooltip-"+t),i=e.style;this.con.animate?(e.className+=" remove",function t(){if(parseFloat(i.top)'); 49 | }; 50 | // may not be needed, saving for later. Can be called to resize iFrame 51 | obj.resizeContent = function() { 52 | var iFrame = document.getElementById('pluginIframeScriptTask'); 53 | var newHeight = 700; 54 | //var sHeight = iFrame.contentWindow.document.body.scrollHeight; 55 | //if (sHeight > newHeight) newHeight = sHeight; 56 | //if (newHeight > 1600) newHeight = 1600; 57 | iFrame.style.height = newHeight + 'px'; 58 | }; 59 | 60 | obj.queueRun = async function() { 61 | var onlineAgents = Object.keys(obj.meshServer.webserver.wsagents); 62 | //obj.debug('ScriptTask', 'Queue Running', Date().toLocaleString(), 'Online agents: ', onlineAgents); 63 | 64 | obj.db.getPendingJobs(onlineAgents) 65 | .then((jobs) => { 66 | if (jobs.length == 0) return; 67 | //@TODO check for a large number and use taskLimiter to queue the jobs 68 | jobs.forEach(job => { 69 | obj.db.get(job.scriptId) 70 | .then(async (script) => { 71 | script = script[0]; 72 | var foundVars = script.content.match(/#(.*?)#/g); 73 | var replaceVars = {}; 74 | if (foundVars != null && foundVars.length > 0) { 75 | var foundVarNames = []; 76 | foundVars.forEach(fv => { 77 | foundVarNames.push(fv.replace(/^#+|#+$/g, '')); 78 | }); 79 | 80 | var limiters = { 81 | scriptId: job.scriptId, 82 | nodeId: job.node, 83 | meshId: obj.meshServer.webserver.wsagents[job.node]['dbMeshKey'], 84 | names: foundVarNames 85 | }; 86 | var finvals = await obj.db.getVariables(limiters); 87 | var ordering = { 'global': 0, 'script': 1, 'mesh': 2, 'node': 3 } 88 | finvals.sort((a, b) => { 89 | return (ordering[a.scope] - ordering[b.scope]) 90 | || a.name.localeCompare(b.name); 91 | }); 92 | finvals.forEach(fv => { 93 | replaceVars[fv.name] = fv.value; 94 | }); 95 | replaceVars['GBL:meshId'] = obj.meshServer.webserver.wsagents[job.node]['dbMeshKey']; 96 | replaceVars['GBL:nodeId'] = job.node; 97 | //console.log('FV IS', finvals); 98 | //console.log('RV IS', replaceVars); 99 | } 100 | var dispatchTime = Math.floor(new Date() / 1000); 101 | var jObj = { 102 | action: 'plugin', 103 | plugin: 'scripttask', 104 | pluginaction: 'triggerJob', 105 | jobId: job._id, 106 | scriptId: job.scriptId, 107 | replaceVars: replaceVars, 108 | scriptHash: script.contentHash, 109 | dispatchTime: dispatchTime 110 | }; 111 | //obj.debug('ScriptTask', 'Sending job to agent'); 112 | try { 113 | obj.meshServer.webserver.wsagents[job.node].send(JSON.stringify(jObj)); 114 | obj.db.update(job._id, { dispatchTime: dispatchTime }); 115 | } catch (e) { } 116 | }) 117 | .catch(e => console.log('PLUGIN: ScriptTask: Could not dispatch job.', e)); 118 | }); 119 | }) 120 | .then(() => { 121 | obj.makeJobsFromSchedules(); 122 | obj.cleanHistory(); 123 | }) 124 | .catch(e => { console.log('PLUGIN: ScriptTask: Queue Run Error: ', e); }); 125 | }; 126 | 127 | obj.cleanHistory = function() { 128 | if (Math.round(Math.random() * 100) == 99) { 129 | //obj.debug('Plugin', 'ScriptTask', 'Running history cleanup'); 130 | obj.db.deleteOldHistory(); 131 | } 132 | }; 133 | 134 | obj.downloadFile = function(req, res, user) { 135 | var id = req.query.dl; 136 | obj.db.get(id) 137 | .then(found => { 138 | if (found.length != 1) { res.sendStatus(401); return; } 139 | var file = found[0]; 140 | res.setHeader('Content-disposition', 'attachment; filename=' + file.name); 141 | res.setHeader('Content-type', 'text/plain'); 142 | //var fs = require('fs'); 143 | res.send(file.content); 144 | }); 145 | }; 146 | 147 | obj.updateFrontEnd = async function(ids){ 148 | if (ids.scriptId != null) { 149 | var scriptHistory = null; 150 | obj.db.getJobScriptHistory(ids.scriptId) 151 | .then((sh) => { 152 | scriptHistory = sh; 153 | return obj.db.getJobSchedulesForScript(ids.scriptId); 154 | }) 155 | .then((scriptSchedule) => { 156 | var targets = ['*', 'server-users']; 157 | obj.meshServer.DispatchEvent(targets, obj, { nolog: true, action: 'plugin', plugin: 'scripttask', pluginaction: 'historyData', scriptId: ids.scriptId, nodeId: null, scriptHistory: scriptHistory, nodeHistory: null, scriptSchedule: scriptSchedule }); 158 | }); 159 | } 160 | if (ids.nodeId != null) { 161 | var nodeHistory = null; 162 | obj.db.getJobNodeHistory(ids.nodeId) 163 | .then((nh) => { 164 | nodeHistory = nh; 165 | return obj.db.getJobSchedulesForNode(ids.nodeId); 166 | }) 167 | .then((nodeSchedule) => { 168 | var targets = ['*', 'server-users']; 169 | obj.meshServer.DispatchEvent(targets, obj, { nolog: true, action: 'plugin', plugin: 'scripttask', pluginaction: 'historyData', scriptId: null, nodeId: ids.nodeId, scriptHistory: null, nodeHistory: nodeHistory, nodeSchedule: nodeSchedule }); 170 | }); 171 | } 172 | if (ids.tree === true) { 173 | obj.db.getScriptTree() 174 | .then((tree) => { 175 | var targets = ['*', 'server-users']; 176 | obj.meshServer.DispatchEvent(targets, obj, { nolog: true, action: 'plugin', plugin: 'scripttask', pluginaction: 'newScriptTree', tree: tree }); 177 | }); 178 | } 179 | if (ids.variables === true) { 180 | obj.db.getVariables() 181 | .then((vars) => { 182 | var targets = ['*', 'server-users']; 183 | obj.meshServer.DispatchEvent(targets, obj, { nolog: true, action: 'plugin', plugin: 'scripttask', pluginaction: 'variableData', vars: vars }); 184 | }); 185 | } 186 | }; 187 | 188 | obj.handleAdminReq = function(req, res, user) { 189 | if ((user.siteadmin & 0xFFFFFFFF) == 1 && req.query.admin == 1) 190 | { 191 | // admin wants admin, grant 192 | var vars = {}; 193 | res.render(obj.VIEWS + 'admin', vars); 194 | return; 195 | } else if (req.query.admin == 1 && (user.siteadmin & 0xFFFFFFFF) == 0) { 196 | // regular user wants admin 197 | res.sendStatus(401); 198 | return; 199 | } else if (req.query.user == 1) { 200 | // regular user wants regular access, grant 201 | if (req.query.dl != null) return obj.downloadFile(req, res, user); 202 | var vars = {}; 203 | 204 | if (req.query.edit == 1) { // edit script 205 | if (req.query.id == null) return res.sendStatus(401); 206 | obj.db.get(req.query.id) 207 | .then((scripts) => { 208 | if (scripts[0].filetype == 'proc') { 209 | vars.procData = JSON.stringify(scripts[0]); 210 | res.render(obj.VIEWS + 'procedit', vars); 211 | } else { 212 | vars.scriptData = JSON.stringify(scripts[0]); 213 | res.render(obj.VIEWS + 'scriptedit', vars); 214 | } 215 | }); 216 | return; 217 | } else if (req.query.schedule == 1) { 218 | var vars = {}; 219 | res.render(obj.VIEWS + 'schedule', vars); 220 | return; 221 | } 222 | // default user view (tree) 223 | vars.scriptTree = 'null'; 224 | obj.db.getScriptTree() 225 | .then(tree => { 226 | vars.scriptTree = JSON.stringify(tree); 227 | res.render(obj.VIEWS + 'user', vars); 228 | }); 229 | return; 230 | } else if (req.query.include == 1) { 231 | switch (req.query.path.split('/').pop().split('.').pop()) { 232 | case 'css': res.contentType('text/css'); break; 233 | case 'js': res.contentType('text/javascript'); break; 234 | } 235 | res.sendFile(__dirname + '/includes/' + req.query.path); // don't freak out. Express covers any path issues. 236 | return; 237 | } 238 | res.sendStatus(401); 239 | return; 240 | }; 241 | 242 | obj.historyData = function (message) { 243 | if (typeof pluginHandler.scripttask.loadHistory == 'function') pluginHandler.scripttask.loadHistory(message); 244 | if (typeof pluginHandler.scripttask.loadSchedule == 'function') pluginHandler.scripttask.loadSchedule(message); 245 | }; 246 | 247 | obj.variableData = function (message) { 248 | if (typeof pluginHandler.scripttask.loadVariables == 'function') pluginHandler.scripttask.loadVariables(message); 249 | }; 250 | 251 | obj.determineNextJobTime = function(s) { 252 | var nextTime = null; 253 | var nowTime = Math.floor(new Date() / 1000); 254 | 255 | // special case: we've reached the end of our run 256 | if (s.endAt !== null && s.endAt <= nowTime) { 257 | return nextTime; 258 | } 259 | 260 | switch (s.recur) { 261 | case 'once': 262 | if (s.nextRun == null) nextTime = s.startAt; 263 | else nextTime = null; 264 | break; 265 | case 'minutes': 266 | /*var lRun = s.nextRun || nowTime; 267 | if (lRun == null) lRun = nowTime; 268 | nextTime = lRun + (s.interval * 60); 269 | if (s.startAt > nextTime) nextTime = s.startAt;*/ 270 | if (s.nextRun == null) { // hasn't run yet, set to start time 271 | nextTime = s.startAt; 272 | break; 273 | } 274 | nextTime = s.nextRun + (s.interval * 60); 275 | // this prevents "catch-up" tasks being scheduled if an endpoint is offline for a long period of time 276 | // e.g. always make sure the next scheduled time is relevant to the scheduled interval, but in the future 277 | if (nextTime < nowTime) { 278 | // initially I was worried about this causing event loop lockups 279 | // if there was a long enough time gap. Testing over 50 years of backlog for a 3 min interval 280 | // still ran under a fraction of a second. Safe to say this approach is safe! (~8.5 million times) 281 | while (nextTime < nowTime) { 282 | nextTime = nextTime + (s.interval * 60); 283 | } 284 | } 285 | if (s.startAt > nextTime) nextTime = s.startAt; 286 | break; 287 | case 'hourly': 288 | if (s.nextRun == null) { // hasn't run yet, set to start time 289 | nextTime = s.startAt; 290 | break; 291 | } 292 | nextTime = s.nextRun + (s.interval * 60 * 60); 293 | if (nextTime < nowTime) { 294 | while (nextTime < nowTime) { 295 | nextTime = nextTime + (s.interval * 60 * 60); 296 | } 297 | } 298 | if (s.startAt > nextTime) nextTime = s.startAt; 299 | break; 300 | case 'daily': 301 | if (s.nextRun == null) { // hasn't run yet, set to start time 302 | nextTime = s.startAt; 303 | break; 304 | } 305 | nextTime = s.nextRun + (s.interval * 60 * 60 * 24); 306 | if (nextTime < nowTime) { 307 | while (nextTime < nowTime) { 308 | nextTime = nextTime + (s.interval * 60 * 60 * 24); 309 | } 310 | } 311 | if (s.startAt > nextTime) nextTime = s.startAt; 312 | break; 313 | case 'weekly': 314 | var tempDate = new Date(); 315 | var nowDate = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate()); 316 | 317 | if (s.daysOfWeek.length == 0) { 318 | nextTime = null; 319 | break; 320 | } 321 | s.daysOfWeek = s.daysOfWeek.map(el => Number(el)); 322 | var baseTime = s.startAt; 323 | //console.log('dow is ', s.daysOfWeek); 324 | var lastDayOfWeek = Math.max(...s.daysOfWeek); 325 | var startX = 0; 326 | //console.log('ldow is ', lastDayOfWeek); 327 | if (s.nextRun != null) { 328 | baseTime = s.nextRun; 329 | //console.log('basetime 2: ', baseTime); 330 | if (nowDate.getDay() == lastDayOfWeek) { 331 | baseTime = baseTime + ( s.interval * 604800 ) - (lastDayOfWeek * 86400); 332 | //console.log('basetime 3: ', baseTime); 333 | } 334 | startX = 0; 335 | } else if (s.startAt < nowTime) { 336 | baseTime = Math.floor(nowDate.getTime() / 1000); 337 | //console.log('basetime 4: ', baseTime); 338 | } 339 | //console.log('startX is: ', startX); 340 | //var secondsFromMidnight = nowTimeDate.getSeconds() + (nowTimeDate.getMinutes() * 60) + (nowTimeDate.getHours() * 60 * 60); 341 | //console.log('seconds from midnight: ', secondsFromMidnight); 342 | //var dBaseTime = new Date(0); dBaseTime.setUTCSeconds(baseTime); 343 | //var dMidnight = new Date(dBaseTime.getFullYear(), dBaseTime.getMonth(), dBaseTime.getDate()); 344 | //baseTime = Math.floor(dMidnight.getTime() / 1000); 345 | for (var x = startX; x <= 7; x++){ 346 | var checkDate = baseTime + (86400 * x); 347 | var d = new Date(0); d.setUTCSeconds(checkDate); 348 | var dm = new Date(d.getFullYear(), d.getMonth(), d.getDate()); 349 | 350 | console.log('testing date: ', dm.toLocaleString()); // dMidnight.toLocaleString()); 351 | //console.log('if break check :', (s.daysOfWeek.indexOf(d.getDay()) !== -1 && checkDate >= nowTime)); 352 | //console.log('checkDate vs nowTime: ', (checkDate - nowTime), ' if positive, nowTime is less than checkDate'); 353 | if (s.nextRun == null && s.daysOfWeek.indexOf(dm.getDay()) !== -1 && dm.getTime() >= nowDate.getTime()) break; 354 | if (s.daysOfWeek.indexOf(dm.getDay()) !== -1 && dm.getTime() > nowDate.getTime()) break; 355 | //if (s.daysOfWeek.indexOf(d.getDay()) !== -1 && Math.floor(d.getTime() / 1000) >= nowTime) break; 356 | } 357 | var sa = new Date(0); sa.setUTCSeconds(s.startAt); 358 | var sad = new Date(sa.getFullYear(), sa.getMonth(), sa.getDate()); 359 | var diff = (sa.getTime() - sad.getTime()) / 1000; 360 | nextTime = Math.floor(dm.getTime() / 1000) + diff; 361 | //console.log('next schedule is ' + d.toLocaleString()); 362 | break; 363 | default: 364 | nextTime = null; 365 | break; 366 | } 367 | 368 | if (s.endAt != null && nextTime > s.endAt) nextTime = null; // if the next time reaches the bound of the endAt time, nullify 369 | 370 | return nextTime; 371 | }; 372 | 373 | obj.makeJobsFromSchedules = function(scheduleId) { 374 | //obj.debug('ScriptTask', 'makeJobsFromSchedules starting'); 375 | return obj.db.getSchedulesDueForJob(scheduleId) 376 | .then(schedules => { 377 | //obj.debug('ScriptTask', 'Found ' + schedules.length + ' schedules to process. Current time is: ' + Math.floor(new Date() / 1000)); 378 | if (schedules.length) { 379 | schedules.forEach(s => { 380 | var nextJobTime = obj.determineNextJobTime(s); 381 | var nextJobScheduled = false; 382 | if (nextJobTime === null) { 383 | //obj.debug('ScriptTask', 'Removing Job Schedule for', JSON.stringify(s)); 384 | obj.db.removeJobSchedule(s._id); 385 | } else { 386 | //obj.debug('ScriptTask', 'Scheduling Job for', JSON.stringify(s)); 387 | obj.db.get(s.scriptId) 388 | .then(scripts => { 389 | // if a script is scheduled to run, but a previous run hasn't completed, 390 | // don't schedule another job for the same (device probably offline). 391 | // results in the minimum jobs running once an agent comes back online. 392 | return obj.db.getIncompleteJobsForSchedule(s._id) 393 | .then((jobs) => { 394 | if (jobs.length > 0) { /* obj.debug('Plugin', 'ScriptTask', 'Skipping job creation'); */ return Promise.resolve(); } 395 | else { /* obj.debug('Plugin', 'ScriptTask', 'Creating new job'); */ nextJobScheduled = true; return obj.db.addJob( { scriptId: s.scriptId, scriptName: scripts[0].name, node: s.node, runBy: s.scheduledBy, dontQueueUntil: nextJobTime, jobSchedule: s._id } ); } 396 | }); 397 | }) 398 | .then(() => { 399 | 400 | if (nextJobScheduled) { /* obj.debug('Plugin', 'ScriptTask', 'Updating nextRun time'); */ return obj.db.update(s._id, { nextRun: nextJobTime }); } 401 | else { /* obj.debug('Plugin', 'ScriptTask', 'NOT updating nextRun time'); */ return Promise.resolve(); } 402 | }) 403 | .then(() => { 404 | obj.updateFrontEnd( { scriptId: s.scriptId, nodeId: s.node } ); 405 | }) 406 | .catch((e) => { console.log('PLUGIN: ScriptTask: Error managing job schedules: ', e); }); 407 | } 408 | }); 409 | } 410 | }); 411 | }; 412 | 413 | obj.deleteElement = function (command) { 414 | var delObj = null; 415 | obj.db.get(command.id) 416 | .then((found) => { 417 | var file = found[0]; 418 | delObj = {...{}, ...found[0]}; 419 | return file; 420 | }) 421 | .then((file) => { 422 | if (file.type == 'folder') return obj.db.deleteByPath(file.path); //@TODO delete schedules for scripts within folders 423 | if (file.type == 'script') return obj.db.deleteSchedulesForScript(file._id); 424 | if (file.type == 'jobSchedule') return obj.db.deletePendingJobsForSchedule(file._id); 425 | }) 426 | .then(() => { 427 | return obj.db.delete(command.id) 428 | }) 429 | .then(() => { 430 | var updateObj = { tree: true }; 431 | if (delObj.type == 'jobSchedule') { 432 | updateObj.scriptId = delObj.scriptId; 433 | updateObj.nodeId = delObj.node; 434 | } 435 | return obj.updateFrontEnd( updateObj ); 436 | }) 437 | .catch(e => { console.log('PLUGIN: ScriptTask: Error deleting ', e.stack); }); 438 | }; 439 | 440 | obj.serveraction = function(command, myparent, grandparent) { 441 | switch (command.pluginaction) { 442 | case 'addScript': 443 | obj.db.addScript(command.name, command.content, command.path, command.filetype) 444 | .then(() => { 445 | obj.updateFrontEnd( { tree: true } ); 446 | }); 447 | break; 448 | case 'new': 449 | var parent_path = ''; 450 | var new_path = ''; 451 | obj.db.get(command.parent_id) 452 | .then(found => { 453 | if (found.length > 0) { 454 | var file = found[0]; 455 | parent_path = file.path; 456 | } else { 457 | parent_path = 'Shared'; 458 | } 459 | }) 460 | .then(() => { 461 | obj.db.addScript(command.name, '', parent_path, command.filetype) 462 | }) 463 | .then(() => { 464 | obj.updateFrontEnd( { tree: true } ); 465 | }); 466 | break; 467 | case 'rename': 468 | obj.db.get(command.id) 469 | .then((docs) => { 470 | var doc = docs[0]; 471 | if (doc.type == 'folder') { 472 | console.log('old', doc.path, 'new', doc.path.replace(doc.path, command.name)); 473 | return obj.db.update(command.id, { path: doc.path.replace(doc.name, command.name) }) 474 | .then(() => { // update sub-items 475 | return obj.db.getByPath(doc.path) 476 | }) 477 | .then((found) => { 478 | if (found.length > 0) { 479 | var proms = []; 480 | found.forEach(f => { 481 | proms.push(obj.db.update(f._id, { path: doc.path.replace(doc.name, command.name) } )); 482 | }) 483 | return Promise.all(proms); 484 | } 485 | }) 486 | } else { 487 | return Promise.resolve(); 488 | } 489 | }) 490 | .then(() => { 491 | obj.db.update(command.id, { name: command.name }) 492 | }) 493 | .then(() => { 494 | return obj.db.updateScriptJobName(command.id, command.name); 495 | }) 496 | .then(() => { 497 | obj.updateFrontEnd( { scriptId: command.id, nodeId: command.currentNodeId, tree: true } ); 498 | }); 499 | break; 500 | case 'move': 501 | var toPath = null, fromPath = null, parentType = null; 502 | obj.db.get(command.to) 503 | .then(found => { // get target data 504 | if (found.length > 0) { 505 | var file = found[0]; 506 | toPath = file.path; 507 | } else throw Error('Target destination not found'); 508 | }) 509 | .then(() => { // get item to be moved 510 | return obj.db.get(command.id); 511 | }) 512 | .then((found) => { // set item to new location 513 | var file = found[0]; 514 | if (file.type == 'folder') { 515 | fromPath = file.path; 516 | toPath += '/' + file.name; 517 | parentType = 'folder'; 518 | if (file.name == 'Shared' && file.path == 'Shared') throw Error('Cannot move top level directory: Shared'); 519 | } 520 | return obj.db.update(command.id, { path: toPath } ); 521 | }) 522 | .then(() => { // update sub-items 523 | return obj.db.getByPath(fromPath) 524 | }) 525 | .then((found) => { 526 | if (found.length > 0) { 527 | var proms = []; 528 | found.forEach(f => { 529 | proms.push(obj.db.update(f._id, { path: toPath } )); 530 | }) 531 | return Promise.all(proms); 532 | } 533 | }) 534 | .then(() => { 535 | return obj.updateFrontEnd( { tree: true } ); 536 | }) 537 | .catch(e => { console.log('PLUGIN: ScriptTask: Error moving ', e.stack); }); 538 | break; 539 | case 'newFolder': 540 | var parent_path = ''; 541 | var new_path = ''; 542 | 543 | obj.db.get(command.parent_id) 544 | .then(found => { 545 | if (found.length > 0) { 546 | var file = found[0]; 547 | parent_path = file.path; 548 | } else { 549 | parent_path = 'Shared'; 550 | } 551 | }) 552 | .then(() => { 553 | new_path = parent_path + '/' + command.name; 554 | }) 555 | .then(() => { 556 | return obj.db.addFolder(command.name, new_path); 557 | }) 558 | .then(() => { 559 | return obj.updateFrontEnd( { tree: true } ); 560 | }) 561 | .catch(e => { console.log('PLUGIN: ScriptTask: Error creating new folder ', e.stack); }); 562 | break; 563 | case 'delete': 564 | obj.deleteElement(command); 565 | break; 566 | case 'addScheduledJob': 567 | /* { 568 | scriptId: scriptId, 569 | node: s, 570 | scheduledBy: myparent.user.name, 571 | recur: command.recur, // [once, minutes, hourly, daily, weekly, monthly] 572 | interval: x, 573 | daysOfWeek: x, // only used for weekly recur val 574 | // onTheXDay: x, // only used for monthly 575 | startAt: x, 576 | endAt: x, 577 | runCountLimit: x, 578 | lastRun: x, 579 | nextRun: x, 580 | type: "scheduledJob" 581 | } */ 582 | var sj = command.schedule; 583 | 584 | var sched = { 585 | scriptId: command.scriptId, 586 | node: null, 587 | scheduledBy: myparent.user.name, 588 | recur: sj.recur, 589 | interval: sj.interval, 590 | daysOfWeek: sj.dayVals, 591 | startAt: sj.startAt, 592 | endAt: sj.endAt, 593 | lastRun: null, 594 | nextRun: null, 595 | type: "jobSchedule" 596 | }; 597 | var sel = command.nodes; 598 | var proms = []; 599 | if (Array.isArray(sel)) { 600 | sel.forEach((s) => { 601 | var sObj = {...sched, ...{ 602 | node: s 603 | }}; 604 | proms.push(obj.db.addJobSchedule( sObj )); 605 | }); 606 | } else { test.push(sObj); 607 | proms.push(obj.db.addJobSchedule( sObj )); 608 | } 609 | Promise.all(proms) 610 | .then(() => { 611 | obj.makeJobsFromSchedules(); 612 | return Promise.resolve(); 613 | }) 614 | .catch(e => { console.log('PLUGIN: ScriptTask: Error adding schedules. The error was: ', e); }); 615 | break; 616 | case 'runScript': 617 | var scriptId = command.scriptId; 618 | var sel = command.nodes; 619 | var proms = []; 620 | if (Array.isArray(sel)) { 621 | sel.forEach((s) => { 622 | proms.push(obj.db.addJob( { scriptId: scriptId, node: s, runBy: myparent.user.name } )); 623 | }); 624 | } else { 625 | proms.push(obj.db.addJob( { scriptId: scriptId, node: sel, runBy: myparent.user.name } )); 626 | } 627 | Promise.all(proms) 628 | .then(() => { 629 | return obj.db.get(scriptId); 630 | }) 631 | .then(scripts => { 632 | return obj.db.updateScriptJobName(scriptId, scripts[0].name); 633 | }) 634 | .then(() => { 635 | obj.resetQueueTimer(); 636 | obj.queueRun(); 637 | obj.updateFrontEnd( { scriptId: scriptId, nodeId: command.currentNodeId } ); 638 | }); 639 | break; 640 | case 'getScript': 641 | //obj.debug('ScriptTask', 'getScript Triggered', JSON.stringify(command)); 642 | obj.db.get(command.scriptId) 643 | .then(script => { 644 | myparent.send(JSON.stringify({ 645 | action: 'plugin', 646 | plugin: 'scripttask', 647 | pluginaction: 'cacheScript', 648 | nodeid: myparent.dbNodeKey, 649 | rights: true, 650 | sessionid: true, 651 | script: script[0] 652 | })); 653 | }); 654 | break; 655 | case 'jobComplete': 656 | //obj.debug('ScriptTask', 'jobComplete Triggered', JSON.stringify(command)); 657 | var jobNodeHistory = null, scriptHistory = null; 658 | var jobId = command.jobId, retVal = command.retVal, errVal = command.errVal, dispatchTime = command.dispatchTime; 659 | var completeTime = Math.floor(new Date() / 1000); 660 | obj.db.update(jobId, { 661 | completeTime: completeTime, 662 | returnVal: retVal, 663 | errorVal: errVal, 664 | dispatchTime: dispatchTime 665 | }) 666 | .then(() => { 667 | return obj.db.get(jobId) 668 | .then(jobs => { 669 | return Promise.resolve(jobs[0].jobSchedule); 670 | }) 671 | .then(sId => { 672 | if (sId == null) return Promise.resolve(); 673 | return obj.db.update(sId, { lastRun: completeTime } ) 674 | .then(() => { 675 | obj.makeJobsFromSchedules(sId); 676 | }); 677 | }); 678 | }) 679 | .then(() => { 680 | obj.updateFrontEnd( { scriptId: command.scriptId, nodeId: myparent.dbNodeKey } ); 681 | }) 682 | .catch(e => { console.log('PLUGIN: ScriptTask: Failed to complete job. ', e); }); 683 | // update front end by eventing 684 | break; 685 | case 'loadNodeHistory': 686 | obj.updateFrontEnd( { nodeId: command.nodeId } ); 687 | break; 688 | case 'loadScriptHistory': 689 | obj.updateFrontEnd( { scriptId: command.scriptId } ); 690 | break; 691 | case 'editScript': 692 | obj.db.update(command.scriptId, { type: command.scriptType, name: command.scriptName, content: command.scriptContent }) 693 | .then(() => { 694 | obj.updateFrontEnd( { scriptId: command.scriptId, tree: true } ); 695 | }); 696 | break; 697 | case 'clearAllPendingJobs': 698 | obj.db.deletePendingJobsForNode(myparent.dbNodeKey); 699 | break; 700 | case 'loadVariables': 701 | obj.updateFrontEnd( { variables: true } ); 702 | break; 703 | case 'newVar': 704 | obj.db.addVariable(command.name, command.scope, command.scopeTarget, command.value) 705 | .then(() => { 706 | obj.updateFrontEnd( { variables: true } ); 707 | }) 708 | break; 709 | case 'editVar': 710 | obj.db.update(command.id, { 711 | name: command.name, 712 | scope: command.scope, 713 | scopeTarget: command.scopeTarget, 714 | value: command.value 715 | }) 716 | .then(() => { 717 | obj.updateFrontEnd( { variables: true } ); 718 | }) 719 | break; 720 | case 'deleteVar': 721 | obj.db.delete(command.id) 722 | .then(() => { 723 | obj.updateFrontEnd( { variables: true } ); 724 | }) 725 | break; 726 | default: 727 | console.log('PLUGIN: ScriptTask: unknown action'); 728 | break; 729 | } 730 | }; 731 | 732 | return obj; 733 | } 734 | --------------------------------------------------------------------------------