aboutsummaryrefslogtreecommitdiff
path: root/static/admin/index.html
blob: 028edc14a50dddfcdf4fcf3926e0db13e7448d40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>cState Admin</title>
  </head>
  <body>
    <!--
    To easily manage your status on Netlify,
    much like on WordPress, you need to keep
    this directory. Platforms which do not
    support Netlify CMS do not need this
    /admin/ directory.
    -->

    <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.getFullYear() === layoutPostDate.getFullYear()) {
            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>