Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewiski committed Feb 25, 2024
1 parent 496a604 commit 0a81b84
Show file tree
Hide file tree
Showing 11 changed files with 473 additions and 55 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uisp-tools",
"version": "0.0.25",
"version": "0.0.26",
"description": "Tools for UISP",
"main": "server.js",
"license": "GPL-3.0-or-later",
Expand Down
34 changes: 18 additions & 16 deletions plugins/baseClientSide.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@
init(){
//this is where if we needed to excute some one time code would go only called first time widgetFactory is created
$.logToConsole("INFO: widgetfactory " + this.namespace + " " + this.widgetFactoryJSPath + " init");
let self = this;
return new Promise((resolve, reject) => {
resolve();
$.uisptools.ajax("scriptsettings.json").then(
function(scriptSettings){
self.scriptSettings = scriptSettings;
resolve();
},
function(err){
reject(err);
}
);
});

}
Expand All @@ -37,9 +46,7 @@
return widgetFactoryFolder;
}

getBaseUrlPath(){
return '/' + this.scriptSettings.urlPrefix;
}

},

/** The widget class for the UISPTools framework
Expand All @@ -64,26 +71,21 @@
//this is called to start the widget in motion
$.logToConsole("INFO: widget " + this.widgetFactory.namespace + " " + this.widgetname + " init");
return new Promise((resolve, reject) => {
$.uisptools.ajax("scriptsettings.json").then(
function(scriptSettings){
this.scriptSettings = scriptSettings;
resolve();
},
function(err){
reject(err);
}
);

resolve();
});
}

getPluginUserData(options){
if(options && options.pluginId) {
return $.uisptools.ajax("/" + this.uispToolsApiRequestHandler.options.urlPrefix + "/api/pluginUserData/" + options.pluginId);
return $.uisptools.ajax("/" + this.widgetFactory.scriptSettings.urlPrefix + "api/pluginUserData/" + options.pluginId);
}else{
return $.uisptools.ajax("/" + this.uispToolsApiRequestHandler.options.urlPrefix + "/api/pluginUserData/" + this.widgetFactory.namespace + "." + this.widgetname);
return $.uisptools.ajax("/" + this.widgetFactory.scriptSettings.urlPrefix + "api/pluginUserData/" + this.widgetFactory.namespace + "." + this.widgetname);
}
}

getBaseUrlPath(){
return this.widgetFactory.scriptSettings.urlPrefix;
}

}

Expand Down
10 changes: 8 additions & 2 deletions plugins/baseServerSide.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
this.uispToolsApiRequestHandler.checkSuperAdminApiAccess (req, res, next)
}




getPluginUserData = function(res){
try {
let options = {
Expand All @@ -96,8 +99,11 @@
}
}

getPluginData(){
let options = {pluginName : this.namespace}
getPluginData(options){
if (options == null) {
options = {pluginName : this.namespace}
}
//let options = {pluginName : this.namespace}
this.uispToolsApiRequestHandler.getPluginData(options);
}

Expand Down
65 changes: 65 additions & 0 deletions plugins/uisptools/serverSide.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,76 @@ var uisptools = {
//Any Routes above this line are not Checked for Auth and are Public
router.get('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/*', this.checkApiAccess);
router.get('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/getMenuItems', this.getMenuItems);
router.get('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/nms/devices', this.getNMSDevices.bind(this));
router.get('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/nms/devices/*', this.getNMSDevices.bind(this));
router.get('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/nms/sites', this.getNMSSites.bind(this));
//router.get('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/nms/devices/airmaxes/:deviceid/config/wireless', this.getNMSDevices.bind(this));
///airos/" + deviceId + "/configuration
///airmaxes/" + deviceId + "/config/wireless
} catch (ex) {
this.debug("error", ex.msg, ex.stack);
}
}


getNMSSites(req, res){

let url = 'sites?type=site';


var options = {
url: url,
method: 'GET',
accessToken : res.locals.accessToken
}
this.uispToolsApiRequestHandler.nmsApiQuery(options).then(
function(data){
//clean the data so only Site Lat Lon and Names are returned
res.json(data);
},
function(err){
res.status(500).json({ "msg": "An Error Occured!", "error": err });
}
)
}

getNMSDevices(req, res){

let url = req.orginalUrl.substring(('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/nms/').length);


if(req.query){
let queryString = "";
for (const [key, value] of Object.entries(req.query)) {
if(key === "_"){

}else{
if(queryString ===""){
queryString = queryString + "?";
}else{
queryString = queryString + "&";
}
queryString = queryString + key + "=" + encodeURIComponent(value);
}
}
url = url + queryString;
}
var options = {
url: url,
method: 'GET',
accessToken : res.locals.accessToken
}
this.uispToolsApiRequestHandler.nmsApiQuery(options).then(
function(data){
res.json(data);
},
function(err){
res.status(500).json({ "msg": "An Error Occured!", "error": err });
}
)
}


getMenuItems(siteId){
return $.uisptools.ajax("/" + this.uispToolsApiRequestHandler.options.urlPrefix + "uisptools/api/nms/sites/" + siteId + "/clients");
}
Expand Down
97 changes: 97 additions & 0 deletions plugins/uisptools/widgets/coveragearea/coveragearea.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<div>
<div class="container-fluid">
<div class="row">
<div class="col-3">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Name</th>

<th scope="col">Frequency</th>

</tr>
</thead>
<tbody class="deviceList">

</tbody>
</table>
</div>
<div class="col-9" style="height:800px">
<div id="map" style="flex-basis: 0;flex-grow: 4;height: 100%;"></div>
</div>
</div>

</div>
<div class="deviceMapList" style="display:none">

</div>

<div class="templates" style="display:none">



<div class="deviceTemplate">
<table>
<tr class="table deviceItem">
<td class="deviceName"></td>
<td class="deviceFrequency"></td>
<td style="display:none">
<div class="container-fluid">
<div class="row">
<div class="col-12 deviceIpAddressRow"><a class="btnDeviceOpen" href="javascript:void(0)"><span class="deviceIpAddress"><span></a></div>
</div>
<div class="row">
<div class="col-12"><span class="deviceType"><span></div>
</div>
<div class="row">
<div class="col-12"><span class="deviceModel"><span></div>
</div>
<div class="row">
<div class="col-12"><span class="deviceLinkName"><span></div>
</div>
<div class="row">
<div class="col-12"><span class="deviceStationCount"><span></div>
</div>
<div class="row">
<div class="col-12"><span class="deviceLinkScore"><span></div>
</div>
<div class="row">
<div class="col-12">
<div class="deviceStatus">
<i class="fa-solid fa-check text-success deviceStatusOk" role="status" style="display:none"></i>
<div class="spinner-border text-primary deviceStatusRefresh" role="status" style="display:none">
<span class="sr-only">Loading...</span>
</div>
<i class="fa-solid fa-circle-exclamation text-warning deviceStatusWarning" role="status" style="display:none"></i>
<i class="fa-solid fa-circle-exclamation text-danger deviceStatusError" role="status" style="display:none"></i>
<i class="fa-solid fa-circle-exclamation text-danger deviceStatusOffline" role="status" style="display:none"></i>
</div>
</div>
</div>
<div class="row">
<div class="deviceAction">
<div class="btn-group" role="group" aria-label="Device Actions">
<button type="button" class="btn btn-small btn-outline-success btnDeviceRefresh"> <i class="fa-solid fa-arrow-rotate-right"></i></button>
<button type="button" class="btn btn-small btn-outline-danger btnDeviceRestart"><i class="fa-solid fa-power-off"></i></button>
</div>
</div>
</div>
</div>
</td>


</tr>
</table>
</div>

<div class="deviceMapTemplate">
<table class="table deviceMapItem">
<tr>
<td class="deviceName"></td>
<td class="deviceFrequency"></td>
</tr>
</table>
</div>

</div>
</div>
Loading

0 comments on commit 0a81b84

Please sign in to comment.