diff options
author | Mantas <11616378+mistermantas@users.noreply.github.com> | 2019-01-24 19:23:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-24 19:23:35 +0200 |
commit | 4a968698e45ece04b25f41783298b9b397a191a1 (patch) | |
tree | 57ae06a3d7344f234ba71a12b7962144b8eb5472 /static/admin/index.html | |
parent | 8a1aaf4737e90406119bdf5770937eea924729aa (diff) |
cState is now stable on v3.0 - 2019-01-24 (info: #41)
Diffstat (limited to 'static/admin/index.html')
-rw-r--r-- | static/admin/index.html | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/static/admin/index.html b/static/admin/index.html index f650db5..03fce04 100644 --- a/static/admin/index.html +++ b/static/admin/index.html @@ -14,8 +14,84 @@ /admin/ directory. --> - <script>console.log('You are using cState v2.0: https://github.com/cstate/cstate')</script> + <script>console.log('You are using cState. The version can be looked at from the console on the homepage or incidents view.+ https://github.com/cstate')</script> <script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script> <script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script> + <script> + var IssuePreview = createClass({ + render: function() { + var entry = this.props.entry; + + var layoutPostDate = entry.getIn(['data', 'date']); + var layoutPostDateEnd = entry.getIn(['data', 'resolvedWhen']); + const layoutDaysInEnglish = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; + + var resultOfStateProps = {"class": "warning"}; + var resultOfState = 'This incident has not yet been resolved.'; + + if (entry.getIn(['data', 'resolved']) === true) { + var resultOfStateProps = {"class": "green"}; + var resultOfState = 'This incident has been resolved.'; + } + + if (layoutPostDateEnd.getYear() === layoutPostDate.getYear()) { + if (layoutPostDateEnd.getHours() === layoutPostDate.getHours()) { + if (layoutPostDateEnd.getMinutes() === layoutPostDate.getMinutes()) { + var resultOfStateProps = {"class": "red"}; + var resultOfState = 'It looks like you haven\'t defined when this incident was resolved. Please double-check.'; + } + } + } + + return h('div', {}, + h('h1', {}, entry.getIn(['data', 'title'])), + h('div', {}, + h('small', {}, layoutDaysInEnglish[layoutPostDate.getMonth()] + ' ' + layoutPostDate.getDate() + ', ' + layoutPostDate.getFullYear() + ' at ' + layoutPostDate.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true }) ) + ), + h('p', {}, + h('strong', resultOfStateProps, resultOfState) + ), + h('div', {"className": "text"}, this.props.widgetFor('body')) + ); + } + }); + CMS.registerPreviewTemplate("issues", IssuePreview, { raw: true }); + + const previewStyles = ` + html, + body { + padding: 16px; + color: #444; + background: #fff; + font: 100%/1.5 BlinkMacSystemFont, -apple-system, "San Francisco Text", "Roboto", "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + } + + h1 { + line-height: 1; + margin: 0; + color: #000; + font-weight: normal; + font-size: 40px; + font-family: "Segoe UI", BlinkMacSystemFont, -apple-system, "San Francisco Text", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + } + + small { + margin-top: 12px; + color: #666; + font-variant: small-caps; + display: block; + } + + .text { + padding-top: 12px; + border-top: 1px solid #ccc; + } + + .green { color: #228B22; } + .red { color: #DC143C; } + .warning { color: #EE7600; } + `; + CMS.registerPreviewStyle(previewStyles, { raw: true }); + </script> </body> </html> |