channel-switch: use sys/ioctl.h instead of stropts.h
[rofl0r-MacGeiger.git] / web / grid.js
blob9de5fb19d6e43a80c96d4888a75c72cb62e811dc
1 Vue.component('search-box', {
2 template: '#searchbox-template',
3 props: {
4 hidden: Boolean,
5 query: String,
6 },
7 methods: {
8 update_parent : function(query) {
9 this.$emit('input', query);
14 Vue.component('attack-panel', {
15 template: '#apanel-template',
16 props: {
17 active: Boolean,
18 bssid: String,
19 essid: String,
20 channel: Number
22 methods : {
23 unselect: function() {
24 this.$emit('unselect_send_parent');
29 // register the grid component
30 Vue.component('demo-grid', {
31 template: '#grid-template',
32 props: {
33 data: Array,
34 columns: Array,
35 headernames: Object,
36 filterKey: String
38 data: function () {
39 var sortOrders = {}
40 this.columns.forEach(function (key) {
41 sortOrders[key] = 1
43 return {
44 sortKey: '',
45 sortOrders: sortOrders
48 computed: {
49 filteredData: function () {
50 var sortKey = this.sortKey
51 var filterKey = this.filterKey && this.filterKey.toLowerCase()
52 var order = this.sortOrders[sortKey] || 1
53 var data = this.data
54 if (filterKey) {
55 data = data.filter(function (row) {
56 return Object.keys(row).some(function (key) {
57 return String(row[key]).toLowerCase().indexOf(filterKey) > -1
61 if (sortKey) {
62 data = data.slice().sort(function (a, b) {
63 a = a[sortKey]
64 b = b[sortKey]
65 return (a === b ? 0 : a > b ? 1 : -1) * order
68 return data
71 filters: {
72 wps_version: function(x) {
73 if(!x) return "";
74 return (x >> 4).toString() + "." + (x & 0xf).toString();
76 capitalize: function (str) {
77 return str.charAt(0).toUpperCase() + str.slice(1)
80 methods: {
81 sortBy: function (key) {
82 this.sortKey = key
83 this.sortOrders[key] = this.sortOrders[key] * -1
85 select_click: function(bssid) {
86 this.$emit('select_bssid', bssid);
92 // bootstrap the demo
93 var demo = new Vue({
94 el: '#demo',
95 data: {
96 searchQuery: '',
97 oldQuery: '',
98 selected: false,
99 gridColumns: [
100 'enc',
101 'bssid',
102 'essid',
103 'channel',
104 'rssi',
105 'uptime',
106 'wps_version',
107 //'wps_state',
108 'wps_locked',
109 'wps_manufacturer',
110 'wps_model_name',
111 'wps_model_number',
112 'wps_device_name',
113 'wps_serial'
115 'wps_uuid',
116 'wps_response_type',
117 'wps_primary_device_type',
118 'wps_config_methods'
121 gridData: [
123 'enc' : '',
124 'bssid': 0, 'essid': '', 'channel':0, 'rssi':0,
125 'uptime':'',
126 'wps_version':0,
127 'wps_locked':0, 'wps_state':0,
128 'wps_manufacturer':'', 'wps_model_name':'', 'wps_model_number':'',
129 'wps_device_name':'', 'wps_serial':'', 'wps_uuid':'',
130 'wps_response_type':'', 'wps_primary_device_type': '',
131 'wps_config_methods':''
134 gridHeaders: {
135 'enc' : 'enc',
136 'bssid':'bssid',
137 'essid':'essid',
138 'channel':'ch',
139 'rssi':'dbm',
140 'uptime':'uptime',
141 'wps_version':'wps',
142 'wps_locked':'lck',
143 'wps_manufacturer':'manuf',
144 'wps_model_name':'model',
145 'wps_model_number':'model#',
146 'wps_device_name':'device',
147 'wps_serial':'serial',
149 interval: null,
151 methods: {
152 loadDataAll: function () {
153 fetch('/api/full')
154 .then(response => response.json())
155 .then(json => {
156 this.gridData = json.wifis
159 loadDataAll2: function () {
160 fetch('/api/full')
161 .then(response => response.json())
162 .then(json => {
163 this.gridData = json.wifis
166 installTimer: function (secs) {
167 console.log("ready");
168 this.loadDataAll();
169 this.interval = setInterval(function () {
170 this.loadDataAll2();
171 }.bind(this), secs*1000);
173 update_query : function(query) {
174 this.searchQuery = query;
176 select: function (bssid) {
177 this.oldQuery = this.searchQuery;
178 this.searchQuery = bssid;
179 this.selected = true;
180 fetch("/api/select/" + bssid)
182 app_unselect: function () {
183 this.searchQuery = this.oldQuery;
184 this.selected = false;
185 fetch("/api/unselect")
188 mounted: function () {
189 this.$nextTick(function () {
190 // Code that will run only after the
191 // entire view has been rendered
192 this.installTimer(2);
195 beforeDestroy: function() {
196 clearInterval(this.interval);
198 created() {
199 this.loadDataAll()