diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 6fa63484..38bd72c0 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -13,12 +13,39 @@ require('./bootstrap'); window.Vue = require('vue'); -/** - * Next, we will create a fresh Vue application instance and attach it to - * the page. Then, you may begin adding components to this application - * or customize the JavaScript scaffolding to fit your unique needs. - */ +window.axios = require('axios'); -const app = new Vue({ - el: '#app' -}); +window.axios.defaults.headers.common = { + 'X-CSRF-Token': window.Global.csrfToken, + 'X-Requested-With': 'XMLHttpRequest' +}; + +((win, doc) => { + /** + * Next, we will create a fresh Vue application instance and attach it to + * the page. Then, you may begin adding components to this application + * or customize the JavaScript scaffolding to fit your unique needs. + */ + + new Vue({ + el: '#app', + data () { + return { + // TODO: Fill this with the active user. + user: null, + messages: [ + // + ], + system: { + updateAvailable: false, + } + } + }, + components: { + 'setup': require('./components/Setup.js'), + 'dashboard': require('./components/dashboard/Dashboard.js'), + 'report-incident': require('./components/dashboard/ReportIncident.js'), + 'invite-team': require('./components/dashboard/InviteTeam.js'), + } + }) +})() diff --git a/resources/assets/js/cachet.js b/resources/assets/js/cachet.js index 31ea20e6..2444940a 100644 --- a/resources/assets/js/cachet.js +++ b/resources/assets/js/cachet.js @@ -3,7 +3,7 @@ $(function () { $.ajaxPrefilter(function(options, originalOptions, jqXHR) { var token; if (! options.crossDomain) { - token = $('meta[name="token"]').attr('content'); + token = window.Global.csrfToken; if (token) { jqXHR.setRequestHeader('X-CSRF-Token', token); } @@ -232,7 +232,7 @@ $(function () { }); // Incident management - $('select[name=template]').on('change', function () { + /*$('select[name=template]').on('change', function () { var $this = $(this).find('option:selected'), slug = $this.val(); @@ -254,7 +254,7 @@ $(function () { } }); } - }); + });*/ // Banner removal JS $('#remove-banner').on('click', function (){ diff --git a/resources/assets/js/components/Setup.js b/resources/assets/js/components/Setup.js new file mode 100644 index 00000000..6bb0e73d --- /dev/null +++ b/resources/assets/js/components/Setup.js @@ -0,0 +1,49 @@ +module.exports = { + props: [], + data () { + return { + env: { + cache_driver: null, + queue_driver: null, + session_driver: null, + mail_driver: null, + }, + mail: { + host: null, + from: { + email: null, + name: 'status@cachethq.io', + }, + username: null, + password: null, + + requiresHost: true, + requiresUsername: true, + requiresPassword: true, + }, + system: { + name: null, + domain: null, + timezone: null, + language: null + } + } + }, + watch: { + 'env.mail_driver' (driver) { + if (driver === 'log' || driver === 'mail') { + this.mail.requiresHost = false + this.mail.requiresUsername = false + this.mail.requiresPassword = false + } else if (driver === 'ses' || driver === 'mandrill') { + this.mail.requiresHost = false + this.mail.requiresUsername = true + this.mail.requiresPassword = true + } else { + this.mail.requiresHost = true + this.mail.requiresUsername = true + this.mail.requiresPassword = true + } + } + } +} diff --git a/resources/assets/js/components/dashboard/Dashboard.js b/resources/assets/js/components/dashboard/Dashboard.js new file mode 100644 index 00000000..176907f7 --- /dev/null +++ b/resources/assets/js/components/dashboard/Dashboard.js @@ -0,0 +1,16 @@ +module.exports = { + props: ['welcome-user'], + mounted () { + if (this.welcomeUser) { + $('#welcome-modal').modal('show'); + } + }, + methods: { + fetchIncidentTimeline () { + // + }, + fetchSubscriberTimeline () { + // + } + } +} diff --git a/resources/assets/js/components/dashboard/InviteTeam.js b/resources/assets/js/components/dashboard/InviteTeam.js new file mode 100644 index 00000000..20812706 --- /dev/null +++ b/resources/assets/js/components/dashboard/InviteTeam.js @@ -0,0 +1,29 @@ +module.exports = { + data () { + return { + canRemove: true, + emails: [ + { email: '' }, + { email: '' }, + { email: '' }, + { email: '' }, + { email: '' }, + ] + } + }, + methods: { + add () { + this.emails.push("") + }, + remove (key) { + if (this.canRemove) { + this.$delete(this.emails, key) + } + }, + }, + watch: { + 'emails' (val) { + this.canRemove = val.length > 1 + } + } +} diff --git a/resources/assets/js/components/dashboard/ReportIncident.js b/resources/assets/js/components/dashboard/ReportIncident.js new file mode 100644 index 00000000..8d6ade64 --- /dev/null +++ b/resources/assets/js/components/dashboard/ReportIncident.js @@ -0,0 +1,43 @@ +module.exports = { + data () { + return { + template: null, + name: '', + status: null, + visible: 1, + sticky: 0, + message: '', + when: null, + notify: false, + component: { + id: null, + status: null + } + } + }, + methods: { + getTemplate (template) { + axios.get('/dashboard/api/incidents/templates', { + params: { + slug: template + } + }).then(response => { + this.name = response.data.name + this.message = response.data.template + }).catch(response => { + (new Cachet.Notifier()).notify('There was an error finding that template.'); + }) + } + }, + watch: { + 'template' (template) { + this.getTemplate(template) + }, + 'component.id' (id) { + // If we unselect a component then reset the status. + if (id === '') { + this.component.status = null + } + } + } +} diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index c800d80f..b057b053 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -215,7 +215,7 @@ return [ ], 'team' => [ 'description' => 'Invite your team members by entering their email addresses here.', - 'email' => 'Email #:id', + 'email' => 'Your Team Members Email Address', ], ], diff --git a/resources/views/dashboard/incidents/add.blade.php b/resources/views/dashboard/incidents/add.blade.php index 5e41a04c..f91c1a39 100644 --- a/resources/views/dashboard/incidents/add.blade.php +++ b/resources/views/dashboard/incidents/add.blade.php @@ -14,122 +14,124 @@