Skip to content

Commit

Permalink
bug fixes move to native Javascript remove jquery in Plugings
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewiski committed Apr 18, 2024
1 parent 645dfb2 commit 2f95fa2
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 77 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.27",
"version": "0.0.28",
"description": "Tools for UISP",
"main": "server.js",
"license": "GPL-3.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion plugins/baseClientSide.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
init(){
//this is called to start the widget in motion
$.logToConsole("INFO: widget " + this.widgetFactory.namespace + " " + this.widgetname + " init");
return new Promise((resolve, reject) => {
return new Promise( (resolve, reject) => {
resolve();
});
}
Expand Down
56 changes: 50 additions & 6 deletions plugins/uisptools/serverSide.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ var uisptools = {
try {
super.bindRoutes(router);
//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/*', this.checkApiAccess.bind(this));
router.post('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/*', this.checkApiAccess.bind(this));
router.get('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/getMenuItems', this.getMenuItems.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/devices/*', this.getNMSDevices.bind(this));
router.get('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/nms/devices/*', this.getNMSDevices.bind(this));
router.post('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/nms/devices/:deviceid/iplink/redirect', this.postNMSDevices.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
Expand Down Expand Up @@ -63,9 +65,11 @@ var uisptools = {

getNMSDevices(req, res){

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


let url = 'devices'; // req.originalUrl.substring(('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/nms/').length);
let subApi = req.path.substring(('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/nms/devices/').length);
if(subApi !== "") {
url = url + "/" + subApi;
}
if(req.query){
let queryString = "";
for (const [key, value] of Object.entries(req.query)) {
Expand Down Expand Up @@ -97,6 +101,46 @@ var uisptools = {
)
}

postNMSDevices(req, res){

let url = 'devices'; // req.originalUrl.substring(('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/nms/').length);
let subApi = req.path.substring(('/' + this.uispToolsApiRequestHandler.options.urlPrefix + 'uisptools/api/nms/devices/').length);
if(subApi !== "") {
url = url + "/" + subApi;
}
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: 'POST',
accessToken : res.locals.accessToken,
data: req.body

}
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
Loading

0 comments on commit 2f95fa2

Please sign in to comment.