1 line
3.5 KiB
JavaScript
1 line
3.5 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{212:function(e,t,n){var content=n(214);content.__esModule&&(content=content.default),"string"==typeof content&&(content=[[e.i,content,""]]),content.locals&&(e.exports=content.locals);(0,n(75).default)("6759f5ab",content,!0,{sourceMap:!1})},213:function(e,t,n){"use strict";n(212)},214:function(e,t,n){var o=n(74)(!1);o.push([e.i,".titre-general{width:50%;margin:0 auto 50px;padding-bottom:20px;border:1px solid #000;border-top:none;font-size:40px;text-align:center}.pending{color:#ff4500}.disconnected{color:red}.connected{color:green}",""]),e.exports=o},215:function(e,t,n){"use strict";n.r(t);var o=n(4),c=(n(43),{data:function(){return{status:"pending",email:"user1@unice.fr",echo:null,messages:[],message_to_send:null}},watch:{},mounted:function(){var e=this;this.echo=window.Echo,this.echo.connector.pusher.connection.bind("connected",(function(){e.status="connected"})),this.echo.connector.pusher.connection.bind("disconnected",(function(){e.status="disconnected"})),this.getMessages(),this.echo.channel("LP-IOTIA").listen(".App\\Events\\PublicMessage",(function(data){e.messages.push(data.message.message),console.log(data)}))},methods:{getMessages:function(){var e=this;this.$axios.get("messages").catch((function(e){console.log(e)})).then((function(t){e.messages=t.data.messages}))},sendMessage:function(){var e=this;return Object(o.a)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.$axios.post("messages",{content:e.message_to_send}).catch((function(e){console.log(e)})).then((function(e){e&&e.data&&alert("Message envoyé")}));case 1:case"end":return t.stop()}}),t)})))()},login:function(){var e=this;return Object(o.a)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.$auth.loginWith("local",{data:{email:e.email,password:"demo"}}).catch((function(e){alert(e.response.data.message)})).then((function(){e.$auth.user&&alert("Connecté : "+e.$auth.user.email)}));case 2:case"end":return t.stop()}}),t)})))()}}}),r=(n(213),n(39)),component=Object(r.a)(c,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("h1",{staticClass:"titre-general"},[e._v("Statut du serveur Websocket")]),e._v(" "),n("div",{staticStyle:{"text-align":"center"}},[n("h2",[e._v("Statut : "),n("span",{class:e.echo?e.echo.connector.pusher.connection.state:e.status,staticStyle:{"font-weight":"bold"}},[e._v(e._s(e.echo?e.echo.connector.pusher.connection.state:e.status))])])]),e._v(" "),e.$auth.user?n("div",[n("p",[e._v("Connecté en tant que "+e._s(e.$auth.user.email))]),e._v(" "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.message_to_send,expression:"message_to_send"}],attrs:{type:"text"},domProps:{value:e.message_to_send},on:{input:function(t){t.target.composing||(e.message_to_send=t.target.value)}}}),e._v(" "),n("button",{on:{click:e.sendMessage}},[e._v("Envoyer")])]):n("div",{staticStyle:{"margin-top":"10px","text-align":"center"}},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.email,expression:"email"}],attrs:{type:"text"},domProps:{value:e.email},on:{input:function(t){t.target.composing||(e.email=t.target.value)}}}),e._v(" "),n("button",{on:{click:e.login}},[e._v("Se connecter")])]),e._v(" "),n("div",e._l(e.messages,(function(t){return n("p",[n("strong",[e._v("["+e._s(t.sender.name)+"]")]),e._v(" "+e._s(t.content))])})),0)])}),[],!1,null,null,null);t.default=component.exports}}]); |