├── .editorconfig ├── .gitignore ├── .npmignore ├── .travis.yml ├── LICENSE.md ├── README.md ├── angular.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── package.json ├── projects └── cron-editor │ ├── karma.conf.js │ ├── ng-package.json │ ├── package.json │ ├── src │ ├── lib │ │ ├── CronOptions.ts │ │ ├── Utils.ts │ │ ├── cron-editor.component.css │ │ ├── cron-editor.component.html │ │ ├── cron-editor.component.spec.ts │ │ ├── cron-editor.component.ts │ │ ├── cron-editor.module.ts │ │ ├── enums.ts │ │ └── time-picker │ │ │ ├── time-picker.component.css │ │ │ ├── time-picker.component.html │ │ │ ├── time-picker.component.spec.ts │ │ │ └── time-picker.component.ts │ ├── public_api.ts │ └── test.ts │ ├── tsconfig.lib.json │ ├── tsconfig.spec.json │ ├── tslint.json │ └── yarn.lock ├── src ├── app │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ └── app.module.ts ├── assets │ └── .gitkeep ├── browserslist ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── styles.css ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── tslint.json ├── tsconfig.json ├── tslint.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | yarn-error.log 34 | testem.log 35 | /typings 36 | 37 | # System Files 38 | .DS_Store 39 | Thumbs.db 40 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /tmp 4 | /out-tsc 5 | /aot 6 | 7 | # source 8 | src 9 | 10 | # pack 11 | *.tgz 12 | 13 | # test 14 | e2e 15 | karma.conf.js 16 | protractor.conf.js 17 | 18 | # dependencies 19 | node_modules 20 | 21 | # IDEs and editors 22 | /.idea 23 | .project 24 | .classpath 25 | .c9/ 26 | *.launch 27 | .settings/ 28 | *.sublime-workspace 29 | .editor-config 30 | 31 | # IDE - VSCode 32 | .vscode 33 | !.vscode/settings.json 34 | !.vscode/tasks.json 35 | !.vscode/launch.json 36 | !.vscode/extensions.json 37 | 38 | # misc 39 | /.sass-cache 40 | /connect.lock 41 | /coverage 42 | /libpeerconnection.log 43 | npm-debug.log 44 | testem.log 45 | /typings 46 | .gitignore 47 | 48 | # config 49 | .angular-cli.json 50 | tsconfig.json 51 | tsconfig-release.json 52 | tsconfig-aot.json 53 | tslint.json 54 | gulpfile.js 55 | .github 56 | 57 | # System Files 58 | .DS_Store 59 | Thumbs.db 60 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "11.3.0" 4 | dist: trusty 5 | sudo: false 6 | 7 | branches: 8 | only: 9 | - master 10 | 11 | cache: 12 | directories: 13 | - node_modules 14 | 15 | install: 16 | - yarn 17 | 18 | script: 19 | - yarn lint 20 | - yarn run build --base-href https://claudiuconstantin.github.io/cron-editor/ 21 | deploy: 22 | provider: pages 23 | skip_cleanup: true 24 | github_token: $GH_TOKEN 25 | local_dir: dist/cron-editor-app 26 | on: 27 | branch: master -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Vincent Pizzo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cron-editor 2 | === 3 | 4 | [![Build Status](https://travis-ci.org/claudiuconstantin/cron-editor.svg?branch=master)](https://travis-ci.org/claudiuconstantin/cron-editor) 5 | [![npm version](https://badge.fury.io/js/cron-editor.svg)](https://badge.fury.io/js/cron-editor) 6 | 7 | `cron-editor` is library that helps the user graphically build a CRON expression (quartz format only) in an Angular application. It is a fork of [angular-cron-gen](https://github.com/vincentjames501/angular-cron-gen) for AngularJS, ported to Angular 2+ and heavily improved. 8 | 9 | This project contains the library along with an app to ease development and testing. It was generated with [Angular CLI](https://github.com/angular/angular-cli), following the awesome [Ng Library Series](https://blog.angularindepth.com/creating-a-library-in-angular-6-87799552e7e5) written by Todd Palmer. 10 | 11 | To run the app just run `npm install`, then `npm run start` and go to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 12 | 13 | ## Demo 14 | 15 | A quick demo of this app can be found [here](https://claudiuconstantin.github.io/cron-editor/). 16 | 17 | ## Sample app 18 | 19 | This library is published as a [npm package](https://www.npmjs.com/package/cron-editor) you can directly include in your app. You can find a sample app [here](https://github.com/claudiuconstantin/cron-editor-sample). 20 | 21 | ## License: 22 | Licensed under the MIT license -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "cron-editor-app": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": {}, 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "outputPath": "dist/cron-editor-app", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "src/tsconfig.app.json", 21 | "assets": [ 22 | "src/favicon.ico", 23 | "src/assets" 24 | ], 25 | "styles": [ 26 | "./node_modules/bootstrap/dist/css/bootstrap.min.css", 27 | "src/styles.css" 28 | ], 29 | "scripts": [] 30 | }, 31 | "configurations": { 32 | "production": { 33 | "fileReplacements": [ 34 | { 35 | "replace": "src/environments/environment.ts", 36 | "with": "src/environments/environment.prod.ts" 37 | } 38 | ], 39 | "optimization": true, 40 | "outputHashing": "all", 41 | "sourceMap": false, 42 | "extractCss": true, 43 | "namedChunks": false, 44 | "aot": true, 45 | "extractLicenses": true, 46 | "vendorChunk": false, 47 | "buildOptimizer": true, 48 | "budgets": [ 49 | { 50 | "type": "initial", 51 | "maximumWarning": "2mb", 52 | "maximumError": "5mb" 53 | } 54 | ] 55 | } 56 | } 57 | }, 58 | "serve": { 59 | "builder": "@angular-devkit/build-angular:dev-server", 60 | "options": { 61 | "browserTarget": "cron-editor-app:build" 62 | }, 63 | "configurations": { 64 | "production": { 65 | "browserTarget": "cron-editor-app:build:production" 66 | } 67 | } 68 | }, 69 | "extract-i18n": { 70 | "builder": "@angular-devkit/build-angular:extract-i18n", 71 | "options": { 72 | "browserTarget": "cron-editor-app:build" 73 | } 74 | }, 75 | "test": { 76 | "builder": "@angular-devkit/build-angular:karma", 77 | "options": { 78 | "main": "src/test.ts", 79 | "polyfills": "src/polyfills.ts", 80 | "tsConfig": "src/tsconfig.spec.json", 81 | "karmaConfig": "src/karma.conf.js", 82 | "styles": [ 83 | "src/styles.css" 84 | ], 85 | "scripts": [], 86 | "assets": [ 87 | "src/favicon.ico", 88 | "src/assets" 89 | ] 90 | } 91 | }, 92 | "lint": { 93 | "builder": "@angular-devkit/build-angular:tslint", 94 | "options": { 95 | "tsConfig": [ 96 | "src/tsconfig.app.json", 97 | "src/tsconfig.spec.json" 98 | ], 99 | "exclude": [ 100 | "**/node_modules/**" 101 | ] 102 | } 103 | } 104 | } 105 | }, 106 | "cron-editor-app-e2e": { 107 | "root": "e2e/", 108 | "projectType": "application", 109 | "prefix": "", 110 | "architect": { 111 | "e2e": { 112 | "builder": "@angular-devkit/build-angular:protractor", 113 | "options": { 114 | "protractorConfig": "e2e/protractor.conf.js", 115 | "devServerTarget": "cron-editor-app:serve" 116 | }, 117 | "configurations": { 118 | "production": { 119 | "devServerTarget": "cron-editor-app:serve:production" 120 | } 121 | } 122 | }, 123 | "lint": { 124 | "builder": "@angular-devkit/build-angular:tslint", 125 | "options": { 126 | "tsConfig": "e2e/tsconfig.e2e.json", 127 | "exclude": [ 128 | "**/node_modules/**" 129 | ] 130 | } 131 | } 132 | } 133 | }, 134 | "cron-editor": { 135 | "root": "projects/cron-editor", 136 | "sourceRoot": "projects/cron-editor/src", 137 | "projectType": "library", 138 | "prefix": "cron", 139 | "architect": { 140 | "build": { 141 | "builder": "@angular-devkit/build-ng-packagr:build", 142 | "options": { 143 | "tsConfig": "projects/cron-editor/tsconfig.lib.json", 144 | "project": "projects/cron-editor/ng-package.json" 145 | } 146 | }, 147 | "test": { 148 | "builder": "@angular-devkit/build-angular:karma", 149 | "options": { 150 | "main": "projects/cron-editor/src/test.ts", 151 | "tsConfig": "projects/cron-editor/tsconfig.spec.json", 152 | "karmaConfig": "projects/cron-editor/karma.conf.js" 153 | } 154 | }, 155 | "lint": { 156 | "builder": "@angular-devkit/build-angular:tslint", 157 | "options": { 158 | "tsConfig": [ 159 | "projects/cron-editor/tsconfig.lib.json", 160 | "projects/cron-editor/tsconfig.spec.json" 161 | ], 162 | "exclude": [ 163 | "**/node_modules/**" 164 | ] 165 | } 166 | } 167 | } 168 | } 169 | }, 170 | "defaultProject": "cron-editor-app" 171 | } -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('workspace-project App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getTitleText()).toEqual('Welcome to cron-editor-app!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getTitleText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cron-editor-app", 3 | "description": "A cron expression generator to be used in Angular applications", 4 | "author": { 5 | "name": "Claudiu Constantin", 6 | "email": "claudiu@fastmail.com", 7 | "url": "https://claudiuconstantin.com" 8 | }, 9 | "version": "1.0.0", 10 | "license": "MIT", 11 | "repository": { 12 | "type": "git", 13 | "url": "git://github.com/claudiuconstantin/cron-editor" 14 | }, 15 | "bugs": { 16 | "url": "https://github.com/claudiuconstantin/cron-editor/issues" 17 | }, 18 | "homepage": "https://github.com/claudiuconstantin/cron-editor", 19 | "keywords": [ 20 | "angular", 21 | "cron", 22 | "cron-expression", 23 | "angular-cli", 24 | "quartz" 25 | ], 26 | "scripts": { 27 | "ng": "ng", 28 | "test": "ng test", 29 | "lint": "ng lint", 30 | "e2e": "ng e2e", 31 | "build_lib": "ng build cron-editor", 32 | "build": "ng build cron-editor && ng build --prod", 33 | "start": "yarn run build_lib && ng serve", 34 | "copy-license": "copy .\\LICENSE.md .\\dist\\cron-editor", 35 | "copy-readme": "copy .\\README.md .\\dist\\cron-editor", 36 | "copy-files": "npm run copy-license && npm run copy-readme", 37 | "pack_lib": "cd dist/cron-editor && npm pack", 38 | "package": "npm run build_lib && npm run copy-files && npm run pack_lib" 39 | }, 40 | "private": true, 41 | "dependencies": { 42 | "@angular/animations": "~7.1.1", 43 | "@angular/common": "~7.1.1", 44 | "@angular/compiler": "~7.1.1", 45 | "@angular/core": "~7.1.1", 46 | "@angular/forms": "~7.1.1", 47 | "@angular/http": "~7.1.1", 48 | "@angular/platform-browser": "~7.1.1", 49 | "@angular/platform-browser-dynamic": "~7.1.1", 50 | "@angular/router": "~7.1.1", 51 | "core-js": "^2.5.4", 52 | "rxjs": "~6.3.3", 53 | "zone.js": "~0.8.26" 54 | }, 55 | "devDependencies": { 56 | "@angular-devkit/build-angular": "~0.11.0", 57 | "@angular-devkit/build-ng-packagr": "~0.11.0", 58 | "@angular/cli": "~7.1.0", 59 | "@angular/compiler-cli": "~7.1.1", 60 | "@angular/language-service": "~7.1.1", 61 | "@types/jasmine": "~3.3.0", 62 | "@types/jasminewd2": "~2.0.3", 63 | "@types/node": "~10.12.11", 64 | "bootstrap": "~3.3.7", 65 | "codelyzer": "~4.5.0", 66 | "jasmine-core": "~3.3.0", 67 | "jasmine-spec-reporter": "~4.2.1", 68 | "karma": "~3.1.1", 69 | "karma-chrome-launcher": "~2.2.0", 70 | "karma-coverage-istanbul-reporter": "~2.0.1", 71 | "karma-jasmine": "~2.0.1", 72 | "karma-jasmine-html-reporter": "^1.4.0", 73 | "ng-packagr": "^4.2.0", 74 | "protractor": "~5.4.0", 75 | "ts-node": "~7.0.0", 76 | "tsickle": ">=0.29.0", 77 | "tslib": "^1.9.0", 78 | "tslint": "~5.11.0", 79 | "typescript": "~3.1.6" 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /projects/cron-editor/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /projects/cron-editor/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "../../dist/cron-editor", 4 | "lib": { 5 | "entryFile": "src/public_api.ts" 6 | } 7 | } -------------------------------------------------------------------------------- /projects/cron-editor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cron-editor", 3 | "description": "A cron expression generator to be used in Angular applications", 4 | "author": { 5 | "name": "Claudiu Constantin", 6 | "email": "claudiu@fastmail.com", 7 | "url": "https://claudiuconstantin.com" 8 | }, 9 | "version": "2.1.7", 10 | "license": "MIT", 11 | "repository": { 12 | "type": "git", 13 | "url": "git://github.com/claudiuconstantin/cron-editor" 14 | }, 15 | "bugs": { 16 | "url": "https://github.com/claudiuconstantin/cron-editor/issues" 17 | }, 18 | "homepage": "https://github.com/claudiuconstantin/cron-editor", 19 | "keywords": [ 20 | "angular", 21 | "cron", 22 | "cron-expression", 23 | "angular-cli", 24 | "quartz" 25 | ], 26 | "peerDependencies": { 27 | "@angular/common": "~7.1.1", 28 | "@angular/core": "^7.1.1" 29 | } 30 | } -------------------------------------------------------------------------------- /projects/cron-editor/src/lib/CronOptions.ts: -------------------------------------------------------------------------------- 1 | export interface CronOptions { 2 | formInputClass: string; 3 | formSelectClass: string; 4 | formRadioClass: string; 5 | formCheckboxClass: string; 6 | 7 | defaultTime: string; 8 | use24HourTime: boolean; 9 | 10 | hideMinutesTab: boolean; 11 | hideHourlyTab: boolean; 12 | hideDailyTab: boolean; 13 | hideWeeklyTab: boolean; 14 | hideMonthlyTab: boolean; 15 | hideYearlyTab: boolean; 16 | hideAdvancedTab: boolean; 17 | 18 | /** hides the Seconds UI form element */ 19 | hideSeconds: boolean; 20 | 21 | /** removes Seconds from the Cron expression */ 22 | removeSeconds: boolean; 23 | 24 | /** removes Years from the Cron expression */ 25 | removeYears: boolean; 26 | } 27 | -------------------------------------------------------------------------------- /projects/cron-editor/src/lib/Utils.ts: -------------------------------------------------------------------------------- 1 | // @dynamic 2 | export default class Utils { 3 | /** This returns a range of numbers. Starts from 0 if 'startFrom' is not set */ 4 | public static getRange(startFrom: number, until: number) { 5 | return Array.from({ length: (until + 1 - startFrom) }, (_, k) => k + startFrom); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /projects/cron-editor/src/lib/cron-editor.component.css: -------------------------------------------------------------------------------- 1 | .cron-editor-container { 2 | margin-top: 10px; 3 | } 4 | 5 | .cron-editor-container .cron-editor-radio { 6 | width: 20px; 7 | display: inline-block; 8 | } 9 | 10 | .cron-editor-container .cron-editor-select, 11 | .cron-editor-container .cron-editor-input, 12 | .cron-editor-container .cron-editor-checkbox { 13 | display: inline-block; 14 | } 15 | 16 | .cron-editor-container .well-time-wrapper { 17 | padding-left: 20px; 18 | } 19 | 20 | .cron-editor-container .inline-block { 21 | display: inline-block; 22 | } 23 | 24 | .cron-editor-container .minutes, 25 | .cron-editor-container .hours, 26 | .cron-editor-container .days, 27 | .cron-editor-container .seconds { 28 | width: 70px; 29 | } 30 | 31 | .cron-editor-container .months { 32 | width: 120px; 33 | } 34 | 35 | .cron-editor-container .month-days { 36 | width: 130px; 37 | } 38 | 39 | .cron-editor-container .months-small { 40 | width: 60px; 41 | } 42 | 43 | .cron-editor-container .day-order-in-month { 44 | width: 95px; 45 | } 46 | 47 | .cron-editor-container .week-days { 48 | width: 120px; 49 | } 50 | 51 | .cron-editor-container .advanced-cron-editor-input { 52 | width: 200px; 53 | } 54 | 55 | .cron-editor-container .hour-types { 56 | width: 70px; 57 | } 58 | 59 | .cron-editor-container .advanced-cron-editor-label { 60 | font-weight: 200; 61 | } 62 | 63 | .nav-tabs li a { 64 | cursor: pointer; 65 | } 66 | 67 | .form-control { 68 | height: auto; 69 | } -------------------------------------------------------------------------------- /projects/cron-editor/src/lib/cron-editor.component.html: -------------------------------------------------------------------------------- 1 | 2 | 45 | 46 | 47 |
48 |
49 |
50 |
51 | 52 |
53 |
54 | Every 55 | minute(s) 61 | on second 62 | 68 |
69 |
70 | 71 | 72 |
73 |
74 | Every 75 | hour(s) on minute 81 | 87 | and second 88 | 94 |
95 |
96 | 97 | 98 |
99 |
100 | 103 | Every 104 | day(s) at 110 | 111 | 114 | 115 |
116 | 117 |
118 | Every working day at 120 | 123 | 124 |
125 |
126 | 127 | 128 |
129 |
130 |
131 |
132 | 134 |
135 |
136 | 138 |
139 |
140 | 142 |
143 |
144 | 146 |
147 |
148 | 150 |
151 |
152 | 154 |
155 |
156 | 158 |
159 |
160 |
161 |
162 | at 163 | 166 | 167 |
168 |
169 |
170 | 171 |
172 | 173 | 174 |
175 |
176 | On the 178 | of every 184 | month(s) at 190 | 193 |   194 | 196 |
197 |
198 | 200 | On the 201 | 207 | of every 213 | month(s) starting in 219 | 225 | 226 | at 227 | 230 | 231 |
232 |
233 | 234 | 235 |
236 |
237 | 239 | Every 240 | on the 246 | at 252 | 255 |   256 | 258 |
259 |
260 | 262 | On the 263 | 270 | of 276 | at 282 | 285 | 286 |
287 |
288 | 289 | 290 |
291 | Cron Expression 292 | 294 |
295 |
296 |
297 |
298 |
299 | {{state.validation.errorMessage}} 300 |
301 |
-------------------------------------------------------------------------------- /projects/cron-editor/src/lib/cron-editor.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CronEditorComponent } from './cron-editor.component'; 4 | 5 | describe('CronEditorComponent', () => { 6 | let component: CronEditorComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ CronEditorComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(CronEditorComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /projects/cron-editor/src/lib/cron-editor.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Input, Output, EventEmitter, SimpleChanges, OnChanges } from '@angular/core'; 2 | import { CronOptions } from './CronOptions'; 3 | 4 | import { Days, MonthWeeks, Months } from './enums'; 5 | import Utils from './Utils'; 6 | 7 | @Component({ 8 | selector: 'cron-editor', 9 | templateUrl: './cron-editor.component.html', 10 | styleUrls: ['./cron-editor.component.css'] 11 | }) 12 | export class CronEditorComponent implements OnInit, OnChanges { 13 | @Input() public disabled: boolean; 14 | @Input() public options: CronOptions; 15 | 16 | @Input() get cron(): string { return this.localCron; } 17 | set cron(value: string) { 18 | this.localCron = value; 19 | this.cronChange.emit(this.localCron); 20 | } 21 | 22 | // the name is an Angular convention, @Input variable name + "Change" suffix 23 | @Output() cronChange = new EventEmitter(); 24 | 25 | public activeTab: string; 26 | public selectOptions = this.getSelectOptions(); 27 | public state: any; 28 | 29 | private localCron: string; 30 | private isDirty: boolean; 31 | 32 | public ngOnInit() { 33 | if (this.options.removeSeconds) { 34 | this.options.hideSeconds = true; 35 | } 36 | 37 | this.state = this.getDefaultState(); 38 | 39 | this.handleModelChange(this.cron); 40 | } 41 | 42 | public ngOnChanges(changes: SimpleChanges) { 43 | const newCron = changes['cron']; 44 | if (newCron && !newCron.firstChange) { 45 | this.handleModelChange(this.cron); 46 | } 47 | } 48 | 49 | public setActiveTab(tab: string) { 50 | if (!this.disabled) { 51 | this.activeTab = tab; 52 | this.regenerateCron(); 53 | } 54 | } 55 | 56 | public dayDisplay(day: string): string { 57 | return Days[day]; 58 | } 59 | 60 | public monthWeekDisplay(monthWeekNumber: number): string { 61 | return MonthWeeks[monthWeekNumber]; 62 | } 63 | 64 | public monthDisplay(month: number): string { 65 | return Months[month]; 66 | } 67 | 68 | public monthDayDisplay(month: string): string { 69 | if (month === 'L') { 70 | return 'Last Day'; 71 | } else if (month === 'LW') { 72 | return 'Last Weekday'; 73 | } else if (month === '1W') { 74 | return 'First Weekday'; 75 | } else { 76 | return `${month}${this.getOrdinalSuffix(month)} day`; 77 | } 78 | } 79 | 80 | public regenerateCron() { 81 | this.isDirty = true; 82 | 83 | switch (this.activeTab) { 84 | case 'minutes': 85 | this.cron = `0/${this.state.minutes.minutes} * 1/1 * ?`; 86 | 87 | if (!this.options.removeSeconds) { 88 | this.cron = `${this.state.minutes.seconds} ${this.cron}`; 89 | } 90 | 91 | if (!this.options.removeYears) { 92 | this.cron = `${this.cron} *`; 93 | } 94 | break; 95 | case 'hourly': 96 | this.cron = `${this.state.hourly.minutes} 0/${this.state.hourly.hours} 1/1 * ?`; 97 | 98 | if (!this.options.removeSeconds) { 99 | this.cron = `${this.state.hourly.seconds} ${this.cron}`; 100 | } 101 | 102 | if (!this.options.removeYears) { 103 | this.cron = `${this.cron} *`; 104 | } 105 | break; 106 | case 'daily': 107 | switch (this.state.daily.subTab) { 108 | case 'everyDays': 109 | // tslint:disable-next-line:max-line-length 110 | this.cron = `${this.state.daily.everyDays.minutes} ${this.hourToCron(this.state.daily.everyDays.hours, this.state.daily.everyDays.hourType)} 1/${this.state.daily.everyDays.days} * ?`; 111 | 112 | if (!this.options.removeSeconds) { 113 | this.cron = `${this.state.daily.everyDays.seconds} ${this.cron}`; 114 | } 115 | 116 | if (!this.options.removeYears) { 117 | this.cron = `${this.cron} *`; 118 | } 119 | break; 120 | case 'everyWeekDay': 121 | // tslint:disable-next-line:max-line-length 122 | this.cron = `${this.state.daily.everyWeekDay.minutes} ${this.hourToCron(this.state.daily.everyWeekDay.hours, this.state.daily.everyWeekDay.hourType)} ? * MON-FRI`; 123 | 124 | if (!this.options.removeSeconds) { 125 | this.cron = `${this.state.daily.everyWeekDay.seconds} ${this.cron}`; 126 | } 127 | 128 | if (!this.options.removeYears) { 129 | this.cron = `${this.cron} *`; 130 | } 131 | break; 132 | default: 133 | throw new Error('Invalid cron daily subtab selection'); 134 | } 135 | break; 136 | case 'weekly': 137 | const days = this.selectOptions.days 138 | .reduce((acc, day) => this.state.weekly[day] ? acc.concat([day]) : acc, []) 139 | .join(','); 140 | this.cron = `${this.state.weekly.minutes} ${this.hourToCron(this.state.weekly.hours, this.state.weekly.hourType)} ? * ${days}`; 141 | 142 | if (!this.options.removeSeconds) { 143 | this.cron = `${this.state.weekly.seconds} ${this.cron}`; 144 | } 145 | 146 | if (!this.options.removeYears) { 147 | this.cron = `${this.cron} *`; 148 | } 149 | break; 150 | case 'monthly': 151 | switch (this.state.monthly.subTab) { 152 | case 'specificDay': 153 | const day = this.state.monthly.runOnWeekday ? `${this.state.monthly.specificDay.day}W` : this.state.monthly.specificDay.day; 154 | // tslint:disable-next-line:max-line-length 155 | this.cron = `${this.state.monthly.specificDay.minutes} ${this.hourToCron(this.state.monthly.specificDay.hours, this.state.monthly.specificDay.hourType)} ${day} 1/${this.state.monthly.specificDay.months} ?`; 156 | 157 | if (!this.options.removeSeconds) { 158 | this.cron = `${this.state.monthly.specificDay.seconds} ${this.cron}`; 159 | } 160 | 161 | if (!this.options.removeYears) { 162 | this.cron = `${this.cron} *`; 163 | } 164 | break; 165 | case 'specificWeekDay': 166 | // tslint:disable-next-line:max-line-length 167 | this.cron = `${this.state.monthly.specificWeekDay.minutes} ${this.hourToCron(this.state.monthly.specificWeekDay.hours, this.state.monthly.specificWeekDay.hourType)} ? ${this.state.monthly.specificWeekDay.startMonth}/${this.state.monthly.specificWeekDay.months} ${this.state.monthly.specificWeekDay.day}${this.state.monthly.specificWeekDay.monthWeek}`; 168 | 169 | if (!this.options.removeSeconds) { 170 | this.cron = `${this.state.monthly.specificWeekDay.seconds} ${this.cron}`; 171 | } 172 | 173 | if (!this.options.removeYears) { 174 | this.cron = `${this.cron} *`; 175 | } 176 | break; 177 | default: 178 | throw new Error('Invalid cron monthly subtab selection'); 179 | } 180 | break; 181 | case 'yearly': 182 | switch (this.state.yearly.subTab) { 183 | case 'specificMonthDay': 184 | // tslint:disable-next-line:max-line-length 185 | const day = this.state.yearly.runOnWeekday ? `${this.state.yearly.specificMonthDay.day}W` : this.state.yearly.specificMonthDay.day; 186 | // tslint:disable-next-line:max-line-length 187 | this.cron = `${this.state.yearly.specificMonthDay.minutes} ${this.hourToCron(this.state.yearly.specificMonthDay.hours, this.state.yearly.specificMonthDay.hourType)} ${day} ${this.state.yearly.specificMonthDay.month} ?`; 188 | 189 | if (!this.options.removeSeconds) { 190 | this.cron = `${this.state.yearly.specificMonthDay.seconds} ${this.cron}`; 191 | } 192 | 193 | if (!this.options.removeYears) { 194 | this.cron = `${this.cron} *`; 195 | } 196 | break; 197 | case 'specificMonthWeek': 198 | // tslint:disable-next-line:max-line-length 199 | this.cron = `${this.state.yearly.specificMonthWeek.minutes} ${this.hourToCron(this.state.yearly.specificMonthWeek.hours, this.state.yearly.specificMonthWeek.hourType)} ? ${this.state.yearly.specificMonthWeek.month} ${this.state.yearly.specificMonthWeek.day}${this.state.yearly.specificMonthWeek.monthWeek}`; 200 | 201 | if (!this.options.removeSeconds) { 202 | this.cron = `${this.state.yearly.specificMonthWeek.seconds} ${this.cron}`; 203 | } 204 | 205 | if (!this.options.removeYears) { 206 | this.cron = `${this.cron} *`; 207 | } 208 | break; 209 | default: 210 | throw new Error('Invalid cron yearly subtab selection'); 211 | } 212 | break; 213 | case 'advanced': 214 | this.cron = this.state.advanced.expression; 215 | break; 216 | default: 217 | throw new Error('Invalid cron active tab selection'); 218 | } 219 | } 220 | 221 | private getAmPmHour(hour: number) { 222 | return this.options.use24HourTime ? hour : (hour + 11) % 12 + 1; 223 | } 224 | 225 | private getHourType(hour: number) { 226 | return this.options.use24HourTime ? undefined : (hour >= 12 ? 'PM' : 'AM'); 227 | } 228 | 229 | private hourToCron(hour: number, hourType: string) { 230 | if (this.options.use24HourTime) { 231 | return hour; 232 | } else { 233 | return hourType === 'AM' ? (hour === 12 ? 0 : hour) : (hour === 12 ? 12 : hour + 12); 234 | } 235 | } 236 | 237 | private handleModelChange(cron: string) { 238 | if (this.isDirty) { 239 | this.isDirty = false; 240 | return; 241 | } else { 242 | this.isDirty = false; 243 | } 244 | 245 | this.validate(cron); 246 | 247 | let cronSeven = cron; 248 | if (this.options.removeSeconds) { 249 | cronSeven = `0 ${cron}`; 250 | } 251 | 252 | if (this.options.removeYears) { 253 | cronSeven = `${cronSeven} *`; 254 | } 255 | 256 | const [seconds, minutes, hours, dayOfMonth, month, dayOfWeek] = cronSeven.split(' '); 257 | 258 | if (cronSeven.match(/\d+ 0\/\d+ \* 1\/1 \* \? \*/)) { 259 | this.activeTab = 'minutes'; 260 | 261 | this.state.minutes.minutes = Number(minutes.substring(2)); 262 | this.state.minutes.seconds = Number(seconds); 263 | } else if (cronSeven.match(/\d+ \d+ 0\/\d+ 1\/1 \* \? \*/)) { 264 | this.activeTab = 'hourly'; 265 | 266 | this.state.hourly.hours = Number(hours.substring(2)); 267 | this.state.hourly.minutes = Number(minutes); 268 | this.state.hourly.seconds = Number(seconds); 269 | } else if (cronSeven.match(/\d+ \d+ \d+ 1\/\d+ \* \? \*/)) { 270 | this.activeTab = 'daily'; 271 | 272 | this.state.daily.subTab = 'everyDays'; 273 | this.state.daily.everyDays.days = Number(dayOfMonth.substring(2)); 274 | const parsedHours = Number(hours); 275 | this.state.daily.everyDays.hours = this.getAmPmHour(parsedHours); 276 | this.state.daily.everyDays.hourType = this.getHourType(parsedHours); 277 | this.state.daily.everyDays.minutes = Number(minutes); 278 | this.state.daily.everyDays.seconds = Number(seconds); 279 | } else if (cronSeven.match(/\d+ \d+ \d+ \? \* MON-FRI \*/)) { 280 | this.activeTab = 'daily'; 281 | 282 | this.state.daily.subTab = 'everyWeekDay'; 283 | const parsedHours = Number(hours); 284 | this.state.daily.everyWeekDay.hours = this.getAmPmHour(parsedHours); 285 | this.state.daily.everyWeekDay.hourType = this.getHourType(parsedHours); 286 | this.state.daily.everyWeekDay.minutes = Number(minutes); 287 | this.state.daily.everyWeekDay.seconds = Number(seconds); 288 | } else if (cronSeven.match(/\d+ \d+ \d+ \? \* (MON|TUE|WED|THU|FRI|SAT|SUN)(,(MON|TUE|WED|THU|FRI|SAT|SUN))* \*/)) { 289 | this.activeTab = 'weekly'; 290 | this.selectOptions.days.forEach(weekDay => this.state.weekly[weekDay] = false); 291 | dayOfWeek.split(',').forEach(weekDay => this.state.weekly[weekDay] = true); 292 | const parsedHours = Number(hours); 293 | this.state.weekly.hours = this.getAmPmHour(parsedHours); 294 | this.state.weekly.hourType = this.getHourType(parsedHours); 295 | this.state.weekly.minutes = Number(minutes); 296 | this.state.weekly.seconds = Number(seconds); 297 | } else if (cronSeven.match(/\d+ \d+ \d+ (\d+|L|LW|1W) 1\/\d+ \? \*/)) { 298 | this.activeTab = 'monthly'; 299 | this.state.monthly.subTab = 'specificDay'; 300 | 301 | if (dayOfMonth.indexOf('W') !== -1) { 302 | this.state.monthly.specificDay.day = dayOfMonth.charAt(0); 303 | this.state.monthly.runOnWeekday = true; 304 | } else { 305 | this.state.monthly.specificDay.day = dayOfMonth; 306 | } 307 | 308 | this.state.monthly.specificDay.months = Number(month.substring(2)); 309 | const parsedHours = Number(hours); 310 | this.state.monthly.specificDay.hours = this.getAmPmHour(parsedHours); 311 | this.state.monthly.specificDay.hourType = this.getHourType(parsedHours); 312 | this.state.monthly.specificDay.minutes = Number(minutes); 313 | this.state.monthly.specificDay.seconds = Number(seconds); 314 | } else if (cronSeven.match(/\d+ \d+ \d+ \? \d+\/\d+ (MON|TUE|WED|THU|FRI|SAT|SUN)((#[1-5])|L) \*/)) { 315 | const day = dayOfWeek.substr(0, 3); 316 | const monthWeek = dayOfWeek.substr(3); 317 | this.activeTab = 'monthly'; 318 | this.state.monthly.subTab = 'specificWeekDay'; 319 | this.state.monthly.specificWeekDay.monthWeek = monthWeek; 320 | this.state.monthly.specificWeekDay.day = day; 321 | 322 | if (month.indexOf('/') !== -1) { 323 | const [startMonth, months] = month.split('/').map(Number); 324 | this.state.monthly.specificWeekDay.months = months; 325 | this.state.monthly.specificWeekDay.startMonth = startMonth; 326 | } 327 | 328 | const parsedHours = Number(hours); 329 | this.state.monthly.specificWeekDay.hours = this.getAmPmHour(parsedHours); 330 | this.state.monthly.specificWeekDay.hourType = this.getHourType(parsedHours); 331 | this.state.monthly.specificWeekDay.minutes = Number(minutes); 332 | this.state.monthly.specificWeekDay.seconds = Number(seconds); 333 | } else if (cronSeven.match(/\d+ \d+ \d+ (\d+|L|LW|1W) \d+ \? \*/)) { 334 | this.activeTab = 'yearly'; 335 | this.state.yearly.subTab = 'specificMonthDay'; 336 | this.state.yearly.specificMonthDay.month = Number(month); 337 | 338 | if (dayOfMonth.indexOf('W') !== -1) { 339 | this.state.yearly.specificMonthDay.day = dayOfMonth.charAt(0); 340 | this.state.yearly.runOnWeekday = true; 341 | } else { 342 | this.state.yearly.specificMonthDay.day = dayOfMonth; 343 | } 344 | 345 | const parsedHours = Number(hours); 346 | this.state.yearly.specificMonthDay.hours = this.getAmPmHour(parsedHours); 347 | this.state.yearly.specificMonthDay.hourType = this.getHourType(parsedHours); 348 | this.state.yearly.specificMonthDay.minutes = Number(minutes); 349 | this.state.yearly.specificMonthDay.seconds = Number(seconds); 350 | } else if (cronSeven.match(/\d+ \d+ \d+ \? \d+ (MON|TUE|WED|THU|FRI|SAT|SUN)((#[1-5])|L) \*/)) { 351 | const day = dayOfWeek.substr(0, 3); 352 | const monthWeek = dayOfWeek.substr(3); 353 | this.activeTab = 'yearly'; 354 | this.state.yearly.subTab = 'specificMonthWeek'; 355 | this.state.yearly.specificMonthWeek.monthWeek = monthWeek; 356 | this.state.yearly.specificMonthWeek.day = day; 357 | this.state.yearly.specificMonthWeek.month = Number(month); 358 | const parsedHours = Number(hours); 359 | this.state.yearly.specificMonthWeek.hours = this.getAmPmHour(parsedHours); 360 | this.state.yearly.specificMonthWeek.hourType = this.getHourType(parsedHours); 361 | this.state.yearly.specificMonthWeek.minutes = Number(minutes); 362 | this.state.yearly.specificMonthWeek.seconds = Number(seconds); 363 | } else { 364 | this.activeTab = 'advanced'; 365 | this.state.advanced.expression = cron; 366 | } 367 | } 368 | 369 | private validate(cron: string): void { 370 | this.state.validation.isValid = false; 371 | this.state.validation.errorMessage = ''; 372 | 373 | if (!cron) { 374 | this.state.validation.errorMessage = 'Cron expression cannot be null'; 375 | return; 376 | } 377 | 378 | const cronParts = cron.split(' '); 379 | 380 | let expected = 5; 381 | 382 | if (!this.options.removeSeconds) { 383 | expected++; 384 | } 385 | 386 | if (!this.options.removeYears) { 387 | expected++; 388 | } 389 | 390 | if (cronParts.length !== expected) { 391 | this.state.validation.errorMessage = `Invalid cron expression, there must be ${expected} segments`; 392 | return; 393 | } 394 | 395 | this.state.validation.isValid = true; 396 | return; 397 | } 398 | 399 | private getDefaultAdvancedCronExpression(): string { 400 | if (this.options.removeSeconds && !this.options.removeYears) { 401 | return '15 10 L-2 * ? 2019'; 402 | } 403 | 404 | if (!this.options.removeSeconds && this.options.removeYears) { 405 | return '0 15 10 L-2 * ?'; 406 | } 407 | 408 | if (this.options.removeSeconds && this.options.removeYears) { 409 | return '15 10 L-2 * ?'; 410 | } 411 | 412 | return '0 15 10 L-2 * ? 2019'; 413 | } 414 | 415 | private getDefaultState() { 416 | const [defaultHours, defaultMinutes, defaultSeconds] = this.options.defaultTime.split(':').map(Number); 417 | 418 | return { 419 | minutes: { 420 | minutes: 1, 421 | seconds: 0 422 | }, 423 | hourly: { 424 | hours: 1, 425 | minutes: 0, 426 | seconds: 0 427 | }, 428 | daily: { 429 | subTab: 'everyDays', 430 | everyDays: { 431 | days: 1, 432 | hours: this.getAmPmHour(defaultHours), 433 | minutes: defaultMinutes, 434 | seconds: defaultSeconds, 435 | hourType: this.getHourType(defaultHours) 436 | }, 437 | everyWeekDay: { 438 | hours: this.getAmPmHour(defaultHours), 439 | minutes: defaultMinutes, 440 | seconds: defaultSeconds, 441 | hourType: this.getHourType(defaultHours) 442 | } 443 | }, 444 | weekly: { 445 | MON: true, 446 | TUE: false, 447 | WED: false, 448 | THU: false, 449 | FRI: false, 450 | SAT: false, 451 | SUN: false, 452 | hours: this.getAmPmHour(defaultHours), 453 | minutes: defaultMinutes, 454 | seconds: defaultSeconds, 455 | hourType: this.getHourType(defaultHours) 456 | }, 457 | monthly: { 458 | subTab: 'specificDay', 459 | runOnWeekday: false, 460 | specificDay: { 461 | day: '1', 462 | months: 1, 463 | hours: this.getAmPmHour(defaultHours), 464 | minutes: defaultMinutes, 465 | seconds: defaultSeconds, 466 | hourType: this.getHourType(defaultHours) 467 | }, 468 | specificWeekDay: { 469 | monthWeek: '#1', 470 | day: 'MON', 471 | startMonth: 1, 472 | months: 1, 473 | hours: this.getAmPmHour(defaultHours), 474 | minutes: defaultMinutes, 475 | seconds: defaultSeconds, 476 | hourType: this.getHourType(defaultHours) 477 | } 478 | }, 479 | yearly: { 480 | subTab: 'specificMonthDay', 481 | runOnWeekday: false, 482 | specificMonthDay: { 483 | month: 1, 484 | day: '1', 485 | hours: this.getAmPmHour(defaultHours), 486 | minutes: defaultMinutes, 487 | seconds: defaultSeconds, 488 | hourType: this.getHourType(defaultHours) 489 | }, 490 | specificMonthWeek: { 491 | monthWeek: '#1', 492 | day: 'MON', 493 | month: 1, 494 | hours: this.getAmPmHour(defaultHours), 495 | minutes: defaultMinutes, 496 | seconds: defaultSeconds, 497 | hourType: this.getHourType(defaultHours) 498 | } 499 | }, 500 | advanced: { 501 | expression: this.getDefaultAdvancedCronExpression() 502 | }, 503 | validation: { 504 | isValid: true, 505 | errorMessage: '' 506 | } 507 | }; 508 | } 509 | 510 | private getOrdinalSuffix(value: string) { 511 | if (value.length > 1) { 512 | const secondToLastDigit = value.charAt(value.length - 2); 513 | if (secondToLastDigit === '1') { 514 | return 'th'; 515 | } 516 | } 517 | 518 | const lastDigit = value.charAt(value.length - 1); 519 | switch (lastDigit) { 520 | case '1': 521 | return 'st'; 522 | case '2': 523 | return 'nd'; 524 | case '3': 525 | return 'rd'; 526 | default: 527 | return 'th'; 528 | } 529 | } 530 | 531 | private getSelectOptions() { 532 | return { 533 | months: Utils.getRange(1, 12), 534 | monthWeeks: ['#1', '#2', '#3', '#4', '#5', 'L'], 535 | days: ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'], 536 | minutes: Utils.getRange(0, 59), 537 | fullMinutes: Utils.getRange(0, 59), 538 | seconds: Utils.getRange(0, 59), 539 | hours: Utils.getRange(1, 23), 540 | monthDays: Utils.getRange(1, 31), 541 | monthDaysWithLasts: [...Utils.getRange(1, 31).map(String), 'L'], 542 | hourTypes: ['AM', 'PM'] 543 | }; 544 | } 545 | } 546 | -------------------------------------------------------------------------------- /projects/cron-editor/src/lib/cron-editor.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { FormsModule } from '@angular/forms'; 3 | import { CommonModule } from '@angular/common'; 4 | 5 | import { CronEditorComponent } from './cron-editor.component'; 6 | import { TimePickerComponent } from './time-picker/time-picker.component'; 7 | 8 | @NgModule({ 9 | declarations: [CronEditorComponent, TimePickerComponent], 10 | imports: [CommonModule, FormsModule], 11 | exports: [CronEditorComponent] 12 | }) 13 | export class CronEditorModule { } 14 | -------------------------------------------------------------------------------- /projects/cron-editor/src/lib/enums.ts: -------------------------------------------------------------------------------- 1 | export const Days = { 2 | 'SUN': 'Sunday', 3 | 'MON': 'Monday', 4 | 'TUE': 'Tuesday', 5 | 'WED': 'Wednesday', 6 | 'THU': 'Thursday', 7 | 'FRI': 'Friday', 8 | 'SAT': 'Saturday' 9 | }; 10 | 11 | export const MonthWeeks = { 12 | '#1': 'First', 13 | '#2': 'Second', 14 | '#3': 'Third', 15 | '#4': 'Fourth', 16 | '#5': 'Fifth', 17 | 'L': 'Last' 18 | }; 19 | 20 | export enum Months { 21 | January = 1, 22 | February, 23 | March, 24 | April, 25 | May, 26 | June, 27 | July, 28 | August, 29 | September, 30 | October, 31 | November, 32 | December 33 | } 34 | -------------------------------------------------------------------------------- /projects/cron-editor/src/lib/time-picker/time-picker.component.css: -------------------------------------------------------------------------------- 1 | .timeFormControl { 2 | width: 70px; 3 | display: inline; 4 | } -------------------------------------------------------------------------------- /projects/cron-editor/src/lib/time-picker/time-picker.component.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 10 | 11 | 12 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /projects/cron-editor/src/lib/time-picker/time-picker.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { TimePickerComponent } from './time-picker.component'; 4 | 5 | describe('TimePickerComponent', () => { 6 | let component: TimePickerComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ TimePickerComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(TimePickerComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /projects/cron-editor/src/lib/time-picker/time-picker.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core'; 2 | 3 | import Utils from '../Utils'; 4 | 5 | @Component({ 6 | selector: 'cron-time-picker', 7 | templateUrl: './time-picker.component.html', 8 | styleUrls: ['./time-picker.component.css'] 9 | }) 10 | export class TimePickerComponent implements OnInit { 11 | @Output() public change = new EventEmitter(); 12 | @Input() public disabled: boolean; 13 | @Input() public time: any; 14 | @Input() public selectClass: string; 15 | @Input() public use24HourTime: boolean; 16 | @Input() public hideSeconds: boolean; 17 | 18 | public hours: number[]; 19 | public minutes: number[]; 20 | public seconds: number[]; 21 | public hourTypes: string[]; 22 | 23 | public ngOnInit() { 24 | this.hours = this.use24HourTime ? Utils.getRange(0, 23) : Utils.getRange(0, 12); 25 | this.minutes = Utils.getRange(0, 59); 26 | this.seconds = Utils.getRange(0, 59); 27 | this.hourTypes = ['AM', 'PM']; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /projects/cron-editor/src/public_api.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Public API Surface of cron-editor 3 | */ 4 | 5 | export * from './lib/cron-editor.component'; 6 | export * from './lib/cron-editor.module'; 7 | export * from './lib/CronOptions'; 8 | -------------------------------------------------------------------------------- /projects/cron-editor/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'core-js/es7/reflect'; 4 | import 'zone.js/dist/zone'; 5 | import 'zone.js/dist/zone-testing'; 6 | import { getTestBed } from '@angular/core/testing'; 7 | import { 8 | BrowserDynamicTestingModule, 9 | platformBrowserDynamicTesting 10 | } from '@angular/platform-browser-dynamic/testing'; 11 | 12 | declare const require: any; 13 | 14 | // First, initialize the Angular testing environment. 15 | getTestBed().initTestEnvironment( 16 | BrowserDynamicTestingModule, 17 | platformBrowserDynamicTesting() 18 | ); 19 | // Then we find all the tests. 20 | const context = require.context('./', true, /\.spec\.ts$/); 21 | // And load the modules. 22 | context.keys().map(context); 23 | -------------------------------------------------------------------------------- /projects/cron-editor/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../out-tsc/lib", 5 | "target": "es2015", 6 | "module": "es2015", 7 | "moduleResolution": "node", 8 | "declaration": true, 9 | "sourceMap": true, 10 | "inlineSources": true, 11 | "emitDecoratorMetadata": true, 12 | "experimentalDecorators": true, 13 | "importHelpers": true, 14 | "types": [], 15 | "lib": [ 16 | "dom", 17 | "es2018" 18 | ], 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true 21 | }, 22 | "angularCompilerOptions": { 23 | "annotateForClosureCompiler": true, 24 | "skipTemplateCodegen": true, 25 | "strictMetadataEmit": true, 26 | "fullTemplateTypeCheck": true, 27 | "strictInjectionParameters": true, 28 | "enableResourceInlining": true 29 | }, 30 | "exclude": [ 31 | "src/test.ts", 32 | "**/*.spec.ts" 33 | ] 34 | } -------------------------------------------------------------------------------- /projects/cron-editor/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts" 12 | ], 13 | "include": [ 14 | "**/*.spec.ts", 15 | "**/*.d.ts" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /projects/cron-editor/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "cron", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "cron", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /projects/cron-editor/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claudiuconstantin/cron-editor/16792d30909c6b55761d41bd6eb0592512e4a4d2/src/app/app.component.css -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Options

4 | 6 | 7 | 9 | 11 | 13 | 15 | 17 | 18 | 20 | 22 | 24 |
25 |
26 | 27 |
28 |

The resulting Cron expression:

29 |
30 | 31 |
32 |
33 |
-------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(async(() => { 6 | TestBed.configureTestingModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | }).compileComponents(); 11 | })); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.debugElement.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'cron-editor-app'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.debugElement.componentInstance; 22 | expect(app.title).toEqual('cron-editor-app'); 23 | }); 24 | 25 | it('should render title in a h1 tag', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.debugElement.nativeElement; 29 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to cron-editor-app!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { CronOptions } from 'projects/cron-editor/src/lib/CronOptions'; 3 | 4 | @Component({ 5 | selector: 'app-root', 6 | templateUrl: './app.component.html', 7 | styleUrls: ['./app.component.css'] 8 | }) 9 | export class AppComponent { 10 | // Hangfire 1.7+ compatible expression: '3 2 12 1/1 ?' 11 | // Quartz compatible expression: '4 3 2 12 1/1 ? *' 12 | public cronExpression = '0 12 1W 1/1 ?'; 13 | public isCronDisabled = false; 14 | public cronOptions: CronOptions = { 15 | formInputClass: 'form-control cron-editor-input', 16 | formSelectClass: 'form-control cron-editor-select', 17 | formRadioClass: 'cron-editor-radio', 18 | formCheckboxClass: 'cron-editor-checkbox', 19 | 20 | defaultTime: '10:00:00', 21 | use24HourTime: true, 22 | 23 | hideMinutesTab: false, 24 | hideHourlyTab: false, 25 | hideDailyTab: false, 26 | hideWeeklyTab: false, 27 | hideMonthlyTab: false, 28 | hideYearlyTab: false, 29 | hideAdvancedTab: false, 30 | 31 | hideSeconds: true, 32 | removeSeconds: true, 33 | removeYears: true 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { CommonModule } from '@angular/common'; 5 | 6 | import { AppComponent } from './app.component'; 7 | import { CronEditorModule } from 'cron-editor'; 8 | 9 | @NgModule({ 10 | declarations: [AppComponent], 11 | imports: [BrowserModule, FormsModule, CommonModule, CronEditorModule], 12 | providers: [], 13 | bootstrap: [AppComponent] 14 | }) 15 | export class AppModule { } 16 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claudiuconstantin/cron-editor/16792d30909c6b55761d41bd6eb0592512e4a4d2/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claudiuconstantin/cron-editor/16792d30909c6b55761d41bd6eb0592512e4a4d2/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Angular CRON Expression Editor - Development App 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |

Angular Cron expression editor - Development App

17 |
18 |
19 |

cron-editor is a library that helps the user graphically build a CRON expression using Angular framework

20 |
21 |
22 | 23 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** 38 | * If the application will be indexed by Google Search, the following is required. 39 | * Googlebot uses a renderer based on Chrome 41. 40 | * https://developers.google.com/search/docs/guides/rendering 41 | **/ 42 | // import 'core-js/es6/array'; 43 | 44 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 45 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 46 | 47 | /** IE10 and IE11 requires the following for the Reflect API. */ 48 | // import 'core-js/es6/reflect'; 49 | 50 | /** 51 | * Web Animations `@angular/platform-browser/animations` 52 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 53 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 54 | **/ 55 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 56 | 57 | /** 58 | * By default, zone.js will patch all possible macroTask and DomEvents 59 | * user can disable parts of macroTask/DomEvents patch by setting following flags 60 | */ 61 | 62 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 63 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 64 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 65 | 66 | /* 67 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 68 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 69 | */ 70 | // (window as any).__Zone_enable_cross_context_check = true; 71 | 72 | /*************************************************************************************************** 73 | * Zone JS is required by default for Angular itself. 74 | */ 75 | import 'zone.js/dist/zone'; // Included with Angular CLI. 76 | 77 | 78 | /*************************************************************************************************** 79 | * APPLICATION IMPORTS 80 | */ 81 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "es2015", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "target": "es5", 13 | "typeRoots": [ 14 | "node_modules/@types" 15 | ], 16 | "lib": [ 17 | "es2018", 18 | "dom" 19 | ], 20 | "paths": { 21 | "cron-editor": [ 22 | "dist/cron-editor" 23 | ], 24 | "cron-editor/*": [ 25 | "dist/cron-editor/*" 26 | ] 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-blacklist": [ 20 | true, 21 | "rxjs/Rx" 22 | ], 23 | "import-spacing": true, 24 | "indent": [ 25 | true, 26 | "spaces" 27 | ], 28 | "interface-over-type-literal": true, 29 | "label-position": true, 30 | "max-line-length": [ 31 | true, 32 | 140 33 | ], 34 | "member-access": false, 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-arg": true, 47 | "no-bitwise": true, 48 | "no-console": [ 49 | true, 50 | "debug", 51 | "info", 52 | "time", 53 | "timeEnd", 54 | "trace" 55 | ], 56 | "no-construct": true, 57 | "no-debugger": true, 58 | "no-duplicate-super": true, 59 | "no-empty": false, 60 | "no-empty-interface": true, 61 | "no-eval": true, 62 | "no-inferrable-types": [ 63 | true, 64 | "ignore-params" 65 | ], 66 | "no-misused-new": true, 67 | "no-non-null-assertion": true, 68 | "no-redundant-jsdoc": true, 69 | "no-shadowed-variable": true, 70 | "no-string-literal": false, 71 | "no-string-throw": true, 72 | "no-switch-case-fall-through": true, 73 | "no-trailing-whitespace": true, 74 | "no-unnecessary-initializer": true, 75 | "no-unused-expression": true, 76 | "no-use-before-declare": true, 77 | "no-var-keyword": true, 78 | "object-literal-sort-keys": false, 79 | "one-line": [ 80 | true, 81 | "check-open-brace", 82 | "check-catch", 83 | "check-else", 84 | "check-whitespace" 85 | ], 86 | "prefer-const": true, 87 | "quotemark": [ 88 | true, 89 | "single" 90 | ], 91 | "radix": true, 92 | "semicolon": [ 93 | true, 94 | "always" 95 | ], 96 | "triple-equals": [ 97 | true, 98 | "allow-null-check" 99 | ], 100 | "typedef-whitespace": [ 101 | true, 102 | { 103 | "call-signature": "nospace", 104 | "index-signature": "nospace", 105 | "parameter": "nospace", 106 | "property-declaration": "nospace", 107 | "variable-declaration": "nospace" 108 | } 109 | ], 110 | "unified-signatures": true, 111 | "variable-name": false, 112 | "whitespace": [ 113 | true, 114 | "check-branch", 115 | "check-decl", 116 | "check-operator", 117 | "check-separator", 118 | "check-type" 119 | ], 120 | "no-output-on-prefix": true, 121 | "use-input-property-decorator": true, 122 | "use-output-property-decorator": true, 123 | "use-host-property-decorator": true, 124 | "no-input-rename": true, 125 | "no-output-rename": true, 126 | "use-life-cycle-interface": true, 127 | "use-pipe-transform-interface": true, 128 | "component-class-suffix": true, 129 | "directive-class-suffix": true 130 | } 131 | } 132 | --------------------------------------------------------------------------------