├── _config └── config.yml ├── .gitignore ├── _config.php ├── code-of-conduct.md ├── phpcs.xml.dist ├── phpunit.xml.dist ├── .editorconfig ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── CONTRIBUTING.md ├── README.md ├── composer.json ├── src ├── Model │ └── Status.php └── Elements │ └── ElementStatus.php ├── LICENSE.md ├── Jenkinsfile └── phpdox.xml /_config/config.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /_config.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | CodeSniffer ruleset for SilverStripe coding conventions. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | tests/ 4 | 5 | 6 | 7 | src/ 8 | 9 | tests/ 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # For more information about the properties used in this file, 2 | # please see the EditorConfig documentation: 3 | # http://editorconfig.org 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | indent_size = 4 9 | indent_style = space 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | [{*.yml,package.json,*.js,*.scss}] 14 | indent_size = 2 15 | indent_style = space 16 | 17 | # The indent size used in the package.json file cannot be changed: 18 | # https://github.com/npm/npm/pull/3180#issuecomment-16336516 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: 'FEATURE ' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: 'BUG ' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | - Maintenance on this module is a shared effort of those who use it 3 | - To contribute improvements to the code, ensure you raise a pull request and discuss with the module maintainers 4 | - Please follow the SilverStripe [code contribution guidelines](https://docs.silverstripe.org/en/contributing/code/) and [Module Standard](https://docs.silverstripe.org/en/developer_guides/extending/modules/#module-standard) 5 | - Supply documentation that follows the [GitHub Flavored Markdown](https://help.github.com/articles/markdown-basics/) conventions 6 | - When having discussions about this module in issues or pull request please adhere to the [SilverStripe Community Code of Conduct](https://docs.silverstripe.org/en/contributing/code_of_conduct/) 7 | 8 | 9 | ## Contributor license agreement 10 | By supplying code to this module in patches, tickets and pull requests, you agree to assign copyright 11 | of that code to MODULE_COPYRIGHT_HOLDER_HERE., on the condition that these code changes are released under the 12 | same BSD license as the original module. We ask for this so that the ownership in the license is clear 13 | and unambiguous. By releasing this code under a permissive license such as BSD, this copyright assignment 14 | won't prevent you from using the code in any way you see fit. 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SilverStripe Elemental Status 2 | 3 | Status block - show status of various systems - online, offline, degraded. 4 | 5 | ## Requirements 6 | 7 | * dnadesign/silverstripe-elemental: ^4.0 8 | 9 | ## Installation 10 | 11 | ``` 12 | composer require dynamic/silverstripe-elemental-status 13 | ``` 14 | 15 | ## License 16 | See [License](license.md) 17 | 18 | ## Maintainers 19 | * [Dynamic](http://www.dynamicagency.com) () 20 | 21 | ## Bugtracker 22 | Bugs are tracked in the issues section of this repository. Before submitting an issue please read over 23 | existing issues to ensure yours is unique. 24 | 25 | If the issue does look like a new bug: 26 | 27 | - Create a new issue 28 | - Describe the steps required to reproduce your issue, and the expected outcome. Unit tests, screenshots 29 | and screencasts can help here. 30 | - Describe your environment as detailed as possible: SilverStripe version, Browser, PHP version, 31 | Operating System, any installed SilverStripe modules. 32 | 33 | Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker. 34 | 35 | ## Development and contribution 36 | If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers. 37 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dynamic/silverstripe-elemental-status", 3 | "description": "Status block - show status of various systems - online, offline, degraded.", 4 | "authors": [ 5 | { 6 | "name": "Dynamic", 7 | "email": "dev@dynamicagency.com", 8 | "homepage": "http://www.dynamicagency.com" 9 | } 10 | ], 11 | "keywords": ["silverstripe", "CMS", "elemental", "status" 12 | ], 13 | "type": "silverstripe-vendormodule", 14 | "license": "BSD-3-Clause", 15 | "require": { 16 | "dnadesign/silverstripe-elemental": "^4.0" 17 | }, 18 | "require-dev": { 19 | "phpunit/phpunit": "^5.7", 20 | "squizlabs/php_codesniffer": "^3.0", 21 | "phpmd/phpmd": "^2.6", 22 | "sebastian/phpcpd": "^3.0", 23 | "phploc/phploc": "^4.0", 24 | "pdepend/pdepend": "^2.5", 25 | "theseer/phpdox": "^0.11.0" 26 | }, 27 | "config": { 28 | "process-timeout": 600 29 | }, 30 | "autoload": { 31 | "psr-4": { 32 | "Dynamic\\Elements\\Status\\": "src/", 33 | "Dynamic\\Elements\\Status\\Test\\": "tests/" 34 | } 35 | }, 36 | "extra": { 37 | "branch-alias": { 38 | "dev-master": "2.x-dev" 39 | } 40 | }, 41 | "minimum-stability": "dev", 42 | "prefer-stable": true 43 | } 44 | -------------------------------------------------------------------------------- /src/Model/Status.php: -------------------------------------------------------------------------------- 1 | 'Varchar(255)', 20 | 'Status' => 'Enum("Online,Degraded,Offline")', 21 | 'Content' => 'Text', 22 | ]; 23 | 24 | /** 25 | * @var string[] 26 | */ 27 | private static $has_one = [ 28 | 'ElementStatus' => ElementStatus::class, 29 | ]; 30 | 31 | /** 32 | * @var string[] 33 | */ 34 | private static $summary_fields = [ 35 | 'Title', 36 | 'Status', 37 | 'Content.Summary' => 'Content', 38 | ]; 39 | 40 | /** 41 | * @var string 42 | */ 43 | private static $table_name = 'ES_Status'; 44 | 45 | /** 46 | * @return FieldList 47 | */ 48 | public function getCMSFields() 49 | { 50 | $this->beforeUpdateCMSFields(function (FieldList $fields) { 51 | $fields->removeByName([ 52 | 'ElementStatusID', 53 | ]); 54 | }); 55 | 56 | return parent::getCMSFields(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) Dynamic, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent any 3 | stages { 4 | 5 | stage('Build') { 6 | steps { 7 | sh 'mkdir silverstripe-cache' 8 | sh 'composer require --prefer-dist --no-update silverstripe-themes/simple:~3.2' 9 | sh 'composer update --no-suggest --prefer-dist' 10 | } 11 | } 12 | 13 | stage('PHPUnit') { 14 | steps { 15 | sh 'vendor/bin/phpunit --log-junit=build/logs/junit.xml --coverage-xml=build/logs/coverage' 16 | } 17 | } 18 | 19 | stage('Checkstyle Report') { 20 | steps { 21 | sh 'vendor/bin/phpcs --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=phpcs.xml.dist --extensions=php,inc --ignore=autoload.php --ignore=vendor/ src/ tests/ || exit 0' 22 | } 23 | } 24 | 25 | stage('Mess Detection Report') { 26 | steps { 27 | sh 'vendor/bin/phpmd src xml codesize,unusedcode,naming --reportfile build/logs/pmd.xml --exclude vendor/ --exclude autoload.php || exit 0' 28 | } 29 | } 30 | 31 | stage('CPD Report') { 32 | steps { 33 | sh 'vendor/bin/phpcpd --log-pmd build/logs/pmd-cpd.xml --exclude vendor src/ tests/ || exit 0' 34 | } 35 | } 36 | 37 | stage('Lines of Code') { 38 | steps { 39 | sh 'vendor/bin/phploc --count-tests --exclude vendor/ --log-csv build/logs/phploc.csv --log-xml build/logs/phploc.xml src/ tests/' 40 | } 41 | } 42 | 43 | stage('Software metrics') { 44 | steps { 45 | sh 'mkdir build/pdepend' 46 | sh 'vendor/bin/pdepend --jdepend-xml=build/logs/jdepend.xml --jdepend-chart=build/pdepend/dependencies.svg --overview-pyramid=build/pdepend/overview-pyramid.svg --ignore=vendor src' 47 | } 48 | } 49 | 50 | stage('Generate documentation') { 51 | steps { 52 | sh 'vendor/bin/phpdox -f phpdox.xml' 53 | } 54 | } 55 | 56 | stage('Publish Documentation') { 57 | steps { 58 | publishHTML (target: [ 59 | allowMissing: false, 60 | alwaysLinkToLastBuild: false, 61 | keepAll: true, 62 | reportDir: 'docs/html', 63 | reportFiles: 'index.html', 64 | reportName: "API" 65 | ]) 66 | } 67 | } 68 | 69 | stage('Cleanup') { 70 | steps { 71 | sh 'rm -rf silverstripe-cache' 72 | } 73 | } 74 | } 75 | 76 | post { 77 | always { 78 | junit 'build/logs/*.xml' 79 | recordIssues enabledForFailure: true, tool: checkStyle(pattern: '**/logs/checkstyle.xml') 80 | recordIssues enabledForFailure: true, tool: cpd(pattern: '**/logs/pmd-cpd.xml') 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /src/Elements/ElementStatus.php: -------------------------------------------------------------------------------- 1 | Status::class, 23 | ]; 24 | 25 | /** 26 | * @var string 27 | */ 28 | private static $table_name = 'ElementStatus'; 29 | 30 | /** 31 | * @var bool 32 | */ 33 | private static $inline_editable = false; 34 | 35 | /** 36 | * @return FieldList 37 | */ 38 | public function getCMSFields() 39 | { 40 | $this->beforeUpdateCMSFields(function (FieldList $fields) { 41 | if ($this->ID) { 42 | $statuses = $fields->dataFieldByName('Statuses'); 43 | $fields->removeByName('Statuses'); 44 | $config = $statuses->getConfig(); 45 | $config 46 | ->removeComponentsByType([ 47 | GridFieldAddExistingAutocompleter::class, 48 | ]) 49 | ->addComponents([ 50 | 51 | ]); 52 | 53 | $fields->addFieldToTab( 54 | 'Root.Main', 55 | $statuses 56 | ); 57 | } 58 | }); 59 | 60 | return parent::getCMSFields(); 61 | } 62 | 63 | /** 64 | * @return mixed 65 | */ 66 | public function getStatusesList() 67 | { 68 | return $this->Statuses()->sort('SortOrder'); 69 | } 70 | 71 | /** 72 | * @return DBHTMLText 73 | */ 74 | public function getSummary() 75 | { 76 | if ($this->Statuses()->count() == 1) { 77 | $label = ' status'; 78 | } else { 79 | $label = ' statuses'; 80 | } 81 | return DBField::create_field('HTMLText', $this->Statuses()->count() . $label)->Summary(20); 82 | } 83 | 84 | /** 85 | * @return array 86 | */ 87 | protected function provideBlockSchema() 88 | { 89 | $blockSchema = parent::provideBlockSchema(); 90 | $blockSchema['content'] = $this->getSummary(); 91 | return $blockSchema; 92 | } 93 | 94 | /** 95 | * @return string 96 | */ 97 | public function getType() 98 | { 99 | return _t(__CLASS__ . '.BlockType', 'Status'); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /phpdox.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 |