2 lines
5.2 KiB
JavaScript
2 lines
5.2 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d20faf8"],{b54c:function(t,e,a){"use strict";a.r(e);var s=function(){var t=this,e=t._self._c;return e("div",{staticClass:"backend-content",attrs:{id:"content"}},[e("div",{staticClass:"column col-8 col-xs-12"},[e("h3",{staticClass:"s-title"},[t._v("Manage watchers instances")]),e("ul",{staticClass:"tab tab-block"},[e("li",{staticClass:"tab-item"},[e("a",{class:{active:t.tabs.addwatcher},attrs:{href:"#"},on:{click:function(e){return t.switch_tab("addwatcher")}}},[t._v("Add watcher")])]),e("li",{staticClass:"tab-item"},[e("a",{class:{active:t.tabs.instances},attrs:{href:"#"},on:{click:function(e){return t.switch_tab("instances")}}},[t._v("Existing watchers")])])]),t.tabs.addwatcher?e("div",[e("div",{staticClass:"misp-form"},[e("label",{staticClass:"misp-label"},[t._v("Watcher name")]),e("span"),e("input",{directives:[{name:"model",rawName:"v-model",value:t.watcher.name,expression:"watcher.name"}],ref:"watcher_name",staticClass:"form-input",attrs:{type:"text",placeholder:"My incredible watcher",required:""},domProps:{value:t.watcher.name},on:{input:function(e){e.target.composing||t.$set(t.watcher,"name",e.target.value)}}}),e("label",{staticClass:"misp-label"},[t._v("Watcher URL")]),e("span"),e("input",{directives:[{name:"model",rawName:"v-model",value:t.watcher.url,expression:"watcher.url"}],ref:"watcher_url",staticClass:"form-input",attrs:{type:"text",placeholder:"https://url.of.my.watcher.com/watcher.json",required:""},domProps:{value:t.watcher.url},on:{input:function(e){e.target.composing||t.$set(t.watcher,"url",e.target.value)}}}),e("label",{staticClass:"misp-label"},[t._v("Watcher Type")]),e("span"),e("select",{directives:[{name:"model",rawName:"v-model",value:t.watcher.type,expression:"watcher.type"}],staticClass:"form-select width-full",attrs:{placeholder:"test"},on:{change:function(e){var a=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){var e="_value"in t?t._value:t.value;return e}));t.$set(t.watcher,"type",e.target.multiple?a:a[0])}}},[e("option",{attrs:{value:"iocs"}},[t._v("IOCs")]),e("option",{attrs:{value:"whitelist"}},[t._v("Whitelist")])])]),e("button",{staticClass:"btn-primary btn col-12",on:{click:function(e){return t.add_instance()}}},[t._v("Add watcher")]),t.added?e("div",{staticClass:"form-group"},[e("div",{staticClass:"toast toast-success"},[t._v(" ✓ Watcher added successfully. Redirecting to watchers in 2 seconds. ")])]):t._e(),t.error?e("div",{staticClass:"form-group"},[e("div",{staticClass:"toast toast-error"},[t._v(" ✗ Watcher not added. "+t._s(t.error)+" ")])]):t._e()]):t._e(),t.tabs.instances?e("div",{staticClass:"form-group"},[t.instances.length?e("div",[e("table",{staticClass:"table table-striped table-hover"},[t._m(0),e("tbody",t._l(t.instances,(function(a){return e("tr",{key:a.id},[e("td",[t._v(t._s(a.type.toUpperCase()))]),e("td",[t._v(t._s(a.name))]),e("td",[a.status?e("span",{staticClass:"instance-online"},[t._v("✓ ONLINE")]):e("span",{staticClass:"instance-offline"},[t._v("⚠ OFFLINE")])]),e("td",[e("button",{staticClass:"btn btn-sm",on:{click:function(e){return t.delete_instance(a)}}},[t._v("Delete")])])])})),0)])]):e("div",[e("div",{staticClass:"empty"},[t.loading?e("div",[t._m(1),e("p",{staticClass:"empty-subtitle"},[t._v("Testing and loading the watchers.")])]):e("div",[e("p",{staticClass:"empty-title h5"},[t._v("No watcher found.")]),e("p",{staticClass:"empty-subtitle"},[t._v("Do not hesitate to add a watcher.")])])])])]):t._e()])])},i=[function(){var t=this,e=t._self._c;return e("thead",[e("tr",[e("th",[t._v("Type")]),e("th",[t._v("Name")]),e("th",[t._v("Status")]),e("th",[t._v("Action")])])])},function(){var t=this,e=t._self._c;return e("p",{staticClass:"empty-title h5"},[e("span",{staticClass:"loading loading-lg"})])}],n=a("bc3a"),c=a.n(n),r={name:"managewatchers",data(){return{error:!1,loading:!1,added:!1,watcher:{name:"",url:"",type:"iocs"},instances:[],tabs:{addwatcher:!0,instances:!1},jwt:""}},props:{},methods:{add_instance:function(){this.added=!1,this.error=!1,this.watcher.name&&this.watcher.url&&this.watcher.type&&c.a.post("/api/watchers/add",{data:{instance:this.watcher}},{headers:{"X-Token":this.jwt}}).then(t=>{t.data.status?(this.added=!0,setTimeout(function(){this.switch_tab("instances"),this.watcher={name:"",url:""},this.added=!1}.bind(this),2e3)):this.error=t.data.message}).catch(t=>console.log(t))},delete_instance(t){c.a.get("/api/watchers/delete/"+t.id,{timeout:1e4,headers:{"X-Token":this.jwt}}).then(e=>{e.data.status&&(this.instances=this.instances.filter((function(e){return e!=t})))}).catch(t=>console.log(t))},get_watchers_instances(){this.loading=!0,this.instances=[],c.a.get("/api/watchers/get_all",{timeout:1e4,headers:{"X-Token":this.jwt}}).then(t=>{t.data.results&&(this.instances=t.data.results),this.loading=!1}).catch(t=>console.log(t))},switch_tab:function(t){Object.keys(this.tabs).forEach(e=>{e==t?(this.tabs[e]=!0,"instances"==e&&this.get_watchers_instances()):this.tabs[e]=!1})},get_jwt(){c.a.get("/api/get-token",{timeout:1e4}).then(t=>{t.data.token&&(this.jwt=t.data.token)}).catch(t=>console.log(t))}},created:function(){this.get_jwt()}},l=r,o=a("2877"),d=Object(o["a"])(l,s,i,!1,null,null,null);e["default"]=d.exports}}]);
|
|
//# sourceMappingURL=chunk-2d20faf8.c983e105.js.map
|