Skip to content

Commit

Permalink
chore: linting and do not run lint during npm publish
Browse files Browse the repository at this point in the history
  • Loading branch information
luandro committed Oct 24, 2024
1 parent 6674c2b commit 8d9939d
Show file tree
Hide file tree
Showing 8 changed files with 379 additions and 387 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/mapeo-migrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ jobs:
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Build package
run: npm run build
run: npm install

- name: Publish to npm
run: npm publish
Expand Down
58 changes: 29 additions & 29 deletions public/assets/js/addLine.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@

function addLine(map, id, point1, point2, color) {
map.addSource(id, {
'type': 'geojson',
'data': {
'type': 'Feature',
'properties': {},
'geometry': {
'type': 'LineString',
'coordinates': [
point1,
point2
]
}
}
});
map.addLayer({
'id': id,
'type': 'line',
'source': id,
'layout': {
'line-join': 'round',
'line-cap': 'round'
},
'paint': {
'line-color': color,
'line-width': 4,
'line-offset': 4
}
});
function addLine (map, id, point1, point2, color) {
map.addSource(id, {
type: 'geojson',
data: {
type: 'Feature',
properties: {},
geometry: {
type: 'LineString',
coordinates: [
point1,
point2
]
}
}
})
map.addLayer({
id: id,
type: 'line',
source: id,
layout: {
'line-join': 'round',
'line-cap': 'round'
},
paint: {
'line-color': color,
'line-width': 4,
'line-offset': 4
}
})
}
86 changes: 42 additions & 44 deletions public/assets/js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,69 @@ const getCloudNodes = () => api.call('lime-utils', 'get_cloud_nodes', {})

const getMetrics = (params) => api.call('lime-metrics', 'get_metrics', params)

const getAllMetrics = (params) => params.targets.map(x => getMetrics(api, { target: x }));
const getAllMetrics = (params) => params.targets.map(x => getMetrics(api, { target: x }))

const getGateway = () => api.call('lime-metrics', 'get_gateway', {});
const getGateway = () => api.call('lime-metrics', 'get_gateway', {})

const getPath = (params) => api.call('lime-metrics', 'get_path', params);
const getPath = (params) => api.call('lime-metrics', 'get_path', params)

const getLastKnownPath = (params) => api.call('lime-metrics', 'get_last_internet_path', params);
const getLastKnownPath = (params) => api.call('lime-metrics', 'get_last_internet_path', params)

const getMeshIfaces = (hostname) =>
api.call('lime-utils', 'get_mesh_ifaces', {}, hostname)
.then(res => res.ifaces);
api.call('lime-utils', 'get_mesh_ifaces', {}, hostname)
.then(res => res.ifaces)

const getAssocList = (iface, hostname) =>
api.call('iwinfo', 'assoclist', { device: iface }, hostname)
.then(res => res.results);
api.call('iwinfo', 'assoclist', { device: iface }, hostname)
.then(res => res.results)
// .then(res => mocked.results);

function getBatHost(mac, outgoingIface, hostname) {
return api.call('bat-hosts', 'get_bathost', { mac, outgoing_iface: outgoingIface }, hostname)
.then(response => new Promise((res, rej) => {
if (response.status === 'ok') {
res(response.bathost);
}
else {
rej(response.message);
}
}))
function getBatHost (mac, outgoingIface, hostname) {
return api.call('bat-hosts', 'get_bathost', { mac, outgoing_iface: outgoingIface }, hostname)
.then(response => new Promise((res, rej) => {
if (response.status === 'ok') {
res(response.bathost)
} else {
rej(response.message)
}
}))
}

function getBoardData(hostname) {
return api.call('system', 'board', {}, hostname);
function getBoardData (hostname) {
return api.call('system', 'board', {}, hostname)
}

function getSession(hostname) {
return api.call('session', 'access', {}, hostname).
then(async (result) => {
let username = null;
if (result['access-group']['root']) {
username = 'root';
} else if (result['access-group']['lime-app']) {
username = 'lime-app';
}
return ({ username })
})
.catch(async () => ({ username: null }));
function getSession (hostname) {
return api.call('session', 'access', {}, hostname)
.then(async (result) => {
let username = null
if (result['access-group'].root) {
username = 'root'
} else if (result['access-group']['lime-app']) {
username = 'lime-app'
}
return ({ username })
})
.catch(async () => ({ username: null }))
}

function getCommunitySettings(hostname) {
return api.call('lime-utils', 'get_community_settings', {})

function getCommunitySettings (hostname) {
return api.call('lime-utils', 'get_community_settings', {})
}

function reboot() {
return api.call('system', 'reboot', {}).then(() => true);
function reboot () {
return api.call('system', 'reboot', {}).then(() => true)
}

function checkInternet() {
return api.call('check-internet', 'is_connected', {});
function checkInternet () {
return api.call('check-internet', 'is_connected', {})
}

async function getChangesNeedReboot() {
return sessionStorage.getItem('need-reboot') == 'yes';
async function getChangesNeedReboot () {
return sessionStorage.getItem('need-reboot') == 'yes'
}

async function setChangesNeedReboot(value) {
sessionStorage.setItem('need-reboot', value);
return value;
async function setChangesNeedReboot (value) {
sessionStorage.setItem('need-reboot', value)
return value
}
11 changes: 6 additions & 5 deletions public/assets/js/mapbox-gl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 58 additions & 60 deletions public/assets/js/uhttpd.service.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,68 @@
const UNAUTH_SESSION_ID = '00000000000000000000000000000000';
const DEFAULT_SESSION_TIMEOUT = 5000;
const UNAUTH_SESSION_ID = '00000000000000000000000000000000'
const DEFAULT_SESSION_TIMEOUT = 5000

const parseResult = result =>
new Promise((res, rej) => {
if (result.error) { return rej(result.error); }
if (result.result[0] !== 0) { return rej(result); }
result = result.result[1];
if (result && result.status === 'error') {
return rej(result.message);
}
return res(result);
})
new Promise((res, rej) => {
if (result.error) { return rej(result.error) }
if (result.result[0] !== 0) { return rej(result) }
result = result.result[1]
if (result && result.status === 'error') {
return rej(result.message)
}
return res(result)
})

class UhttpdService {
constructor() {
const origin = window.origin
const defaultHost = `http://thisnode.info`
this.url = `${defaultHost}/ubus`;
this.jsonrpc = '2.0';
this.sec = 0;
this.requestList = [];
}
constructor () {
const origin = window.origin
const defaultHost = 'http://thisnode.info'
this.url = `${defaultHost}/ubus`
this.jsonrpc = '2.0'
this.sec = 0
this.requestList = []
}

sid() {
const sid = sessionStorage.getItem('sid');
return sid || UNAUTH_SESSION_ID;
}
sid () {
const sid = sessionStorage.getItem('sid')
return sid || UNAUTH_SESSION_ID
}

addId() {
this.sec += 1;
return Number(this.sec);
}
addId () {
this.sec += 1
return Number(this.sec)
}

async call (action, method, data, hostname, customSid = null, timeout = null) {
const url = hostname ? `http://${hostname}/ubus` : this.url // Must be dynamic to pull from other nodes
this.sec += 1
const body = {
id: this.addId(),
jsonrpc: this.jsonrpc,
method: 'call',
params: [customSid || this.sid(), action, method, data]
}
const controller = new AbortController()
const id = setTimeout(() => controller.abort(), timeout || 15000)
return fetch(url,
{ method: 'POST', body: JSON.stringify(body), signal: controller.signal })
.then(response => response.json())
.then(parseResult)
.finally(clearTimeout(id))
}

async call(action, method, data, hostname, customSid = null, timeout = null) {
const url = hostname ? `http://${hostname}/ubus` : this.url // Must be dynamic to pull from other nodes
this.sec +=1;
const body = {
id: this.addId(),
jsonrpc: this.jsonrpc,
method: 'call',
params: [customSid || this.sid(), action, method, data]
};
const controller = new AbortController();
const id = setTimeout(() => controller.abort(), timeout || 15000);
return fetch(url,
{ method: 'POST', body: JSON.stringify(body), signal: controller.signal })
.then(response => response.json())
.then(parseResult)
.finally(clearTimeout(id));
}

login(username, password, hostname) {
const data = { username, password, timeout: DEFAULT_SESSION_TIMEOUT };
return this.call('session', 'login', data, hostname, UNAUTH_SESSION_ID)
.then(response =>
new Promise((res, rej) => {
if (response.ubus_rpc_session) {
sessionStorage.setItem('sid', response.ubus_rpc_session);
res(response);
}
else {
rej(response);
}
}));
}
login (username, password, hostname) {
const data = { username, password, timeout: DEFAULT_SESSION_TIMEOUT }
return this.call('session', 'login', data, hostname, UNAUTH_SESSION_ID)
.then(response =>
new Promise((res, rej) => {
if (response.ubus_rpc_session) {
sessionStorage.setItem('sid', response.ubus_rpc_session)
res(response)
} else {
rej(response)
}
}))
}
}

const api = new UhttpdService();
const api = new UhttpdService()
Loading

0 comments on commit 8d9939d

Please sign in to comment.