Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pathfinder-ui

Package Overview
Dependencies
Maintainers
5
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pathfinder-ui - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

lib/browser/js/controllers/SubTabsController.js

9

lib/browser/js/controllers/TabBtnsController.js

@@ -18,9 +18,10 @@ app.controller('TabBtnsController', function($scope, HistoryFactory, RequestFactory){

};
$scope.switchTab = function(tab){
$scope.selectedIndex = tab;
}
};
$scope.$on('nodeClick', function() {
$scope.switchTab(0);
})
});

@@ -33,8 +34,8 @@ $scope.getRes = function() {

// convert response.headers() into normal object
var headers = JSON.stringify(reqResponse.headers())
var headers = JSON.stringify(reqResponse.headers());
$scope.resHeaders = JSON.parse(headers);
});
}
};
});

@@ -10,32 +10,29 @@ app.directive('history', function (HistoryFactory) {

link: function (scope) {
scope.getHistory = HistoryFactory.getHistory
//scope.history = HistoryFactory.getHistory();
//var history = scope.history;
scope.getHistory = HistoryFactory.getHistory;
scope.clearHistory = HistoryFactory.clearHistory;
scope.saveList = [];
scope.showUploadButton = false;
scope.addToSaveList = function(req) {
var idx = scope.saveList.indexOf(req);
var idx = scope.saveList.indexOf(req);
if (idx > -1) {
scope.saveList.splice(idx, 1);
} else {
scope.saveList.push(req);
}
}
if (idx > -1) {
scope.saveList.splice(idx, 1);
} else {
scope.saveList.push(req);
}
};
scope.saveToFile = function() {
var saveList = scope.saveList;
var saveList = scope.saveList;
if (saveList.length === 0) {
saveList = HistoryFactory.getHistory();
}
if (saveList.length === 0) {
saveList = HistoryFactory.getHistory();
}
saveList = angular.toJson(saveList, true); // setting true option prettifies the json
var blob = new Blob([saveList], { type: "application/json; charset=utf-8;" }); // create json array data
console.dir(blob);
var downloadLink = angular.element('<a></a>');
console.log("dllink", downloadLink);
saveList = angular.toJson(saveList, true); // setting true option prettifies the json
var blob = new Blob([saveList], { type: "application/json; charset=utf-8;" }); // create json array data
var downloadLink = angular.element('<a></a>');

@@ -45,3 +42,3 @@ downloadLink.attr('href', window.URL.createObjectURL(blob));

downloadLink[0].click();
}
};

@@ -52,3 +49,2 @@

var file = files[0];
var fr = new FileReader();

@@ -62,5 +58,4 @@

scope.$apply();
}
}
};
};

@@ -67,0 +62,0 @@ }

@@ -7,60 +7,53 @@ app.directive('reqForm', function(RequestFactory, HistoryFactory){

scope: true,
link: function(scope, elem, attr){
link: function(scope, elem, attr) {
scope.request = {};
scope.getHeaders = RequestFactory.getHeaders;
scope.removeHeader = RequestFactory.removeHeader;
scope.addHeader = RequestFactory.addHeader;
scope.addUrlParam = RequestFactory.addUrlParam;
scope.getParams = RequestFactory.getParams;
scope.getUrlParams = RequestFactory.getUrlParams;
scope.getUrl = RequestFactory.getUrl;
scope.getMethod = RequestFactory.getMethod;
scope.data = RequestFactory.getData();
scope.dataType = 'form';
scope.getHeaders = RequestFactory.getHeaders
scope.addUrlParam = RequestFactory.addUrlParam
scope.getParams = RequestFactory.getParams
scope.getUrlParams = RequestFactory.getUrlParams
scope.getUrl = RequestFactory.getUrl
scope.getMethod = RequestFactory.getMethod
scope.data = RequestFactory.getData()
scope.dataType = 'form'
scope.removeUrlParam = function(idx){
RequestFactory.removeUrlParam(idx);
}
};
scope.removeFormItem = function(idx){
scope.data.formData.splice(idx, 1)
}
scope.data.formData.splice(idx, 1);
};
scope.setDataType = function(str){
scope.dataType = str
}
scope.dataType = str;
};
scope.addFormDataItem = function(){
scope.data.formData.push({key: "", val: ""});
}
};
scope.sendReq = function(){
scope.request.method = RequestFactory.getMethod();
scope.request.url = RequestFactory.getUrl();
// set POST/PUT data
if(scope.dataType === 'form'){
scope.request.data = {}
scope.data.formData.forEach(function(item){
scope.request.data[item.key] = item.val
})
scope.data.rawData = "";
RequestFactory.setPostPutData(scope.data.formData);
} else {
scope.request.data = scope.data.rawData;
scope.data.formData = [{key: "", val: ""}]
RequestFactory.setPostPutData(scope.data.rawData);
}
//adds the composite url to the node to be saved in localstorage
var node = RequestFactory.getCurrNode()
node.historicalUrl = RequestFactory.getUrl()
//adds the composite url to the node to be saved to history (in localstorage)
var node = RequestFactory.getCurrNode();
node.historicalUrl = RequestFactory.getUrl();
HistoryFactory.addToHistory(node);
// Send request
RequestFactory.reqRoute();
scope.switchTab(2);
}
};
//do we need this anyone??
scope.del = function(){
}
}
}
})
};
});

@@ -13,6 +13,5 @@ app.directive('response', function(RequestFactory){

return false;
} //Is the response data a JSON object?
}; //Is the response data a JSON object?
}//End of Link
}
};
});

@@ -19,0 +18,0 @@

@@ -9,3 +9,3 @@ app.directive('routeTable', function (DataFactory) {

DataFactory.dataPromise.then(function(data) {
console.log("data", data);
scope.table = data.routeTable;

@@ -12,0 +12,0 @@

@@ -5,10 +5,6 @@ app.factory('HistoryFactory', function($http, DataFactory){

return {
// uploadFile: uploadFile,
concatHistory: function(arr) {
history = history.concat(arr);
// console.log("arr", arr)
// console.log("concatted hist", history)
},

@@ -24,3 +20,3 @@

window.localStorage.setItem(data.appId, JSON.stringify(history));
});
});
},

@@ -37,5 +33,10 @@ //loadHistory() loads all history from local storage into the history array.

}
});
});
},
clearHistory: function() {
window.localStorage.clear();
history = [];
},
getHistory: function() {

@@ -42,0 +43,0 @@ return history;

@@ -8,2 +8,3 @@ app.factory('RequestFactory', function($http, $rootScope){

urlParams: [], // array of objects (key-value pairs)
headersArr: [],
headers: {},

@@ -14,32 +15,42 @@ data: {

}
}
};
var addToHeaders = function(key, value) {
currNode.headers[key] = value;
var getHeaders = function() {
return currNode.headersArr;
};
}
var addHeader = function() {
currNode.headersArr.push({ key: "", val: "" });
};
var getHeaders = function() {
return currNode.headers;
}
var removeHeader = function(idx) {
currNode.headersArr.splice(idx, 1);
};
var setHeaders = function(arr) {
arr.forEach(function(obj) {
currNode.headers[obj.key] = obj.val;
});
};
var setPostPutData = function(data) {
// if form data
if (this.currNode.data.formData && this.currNode.data.formData[0].key) {
data.forEach(function(obj) {
this.currNode.data[obj.key] = obj.val;
});
// else raw data
} else {
this.currNode.data = data;
}
};
var populateData = function(node){
// currNode = {
// url: "",
// method: "",
// params: {},
// urlParams: [],
// headers: {},
// data: {
// formData: [{key: "", val: ""}],
// rawData: ""
// }
// }
$rootScope.$broadcast('nodeClick');
currNode.method = node.method;
currNode.url = node.url;
currNode.params = node.params || {}
currNode.params = node.params || {};
if(Object.keys(currNode.params).length === 0) setParams();
currNode.urlParams = node.urlParams || [];
currNode.headersArr = node.headersArr || [];
currNode.headers = node.headers || {};

@@ -49,37 +60,40 @@ currNode.data = node.data || {

rawData: ""
}
};
};
}
var setParams = function(){
currNode.url.split("/").forEach(function(item){
if(item[0] === ":"){
if (item[0] === ":"){
currNode.params[item.slice(1)] = null;
}
})
}
});
};
var getUrl = function(){
var urlFinal = currNode.url.split("/").map(function(item){
if(item[0] === ":"){
var val = currNode.params[item.slice(1)]
//
if(val === null){
return item
} else{
return val
if (item[0] === ":"){
var val = currNode.params[item.slice(1)];
if (val === null) {
return item;
} else {
return val;
}
} else{
return item
} else {
return item;
}
})
.join("/")
}).join("/");
if(currNode.urlParams.length){
var query = []
if (currNode.urlParams.length) {
var query = [];
currNode.urlParams.forEach(function(obj){
if(obj.key.length){
if (obj.key.length) {
var pair = obj.key + "=" + obj.val;
query.push(pair);
}
})
if(query.length){
});
if (query.length) {
urlFinal += "?" + query.join("&");

@@ -89,32 +103,33 @@ }

return urlFinal
}
return urlFinal;
};
var addUrlParam = function(){
currNode.urlParams.push({key: "",
val: ""})
currNode.urlParams.push({
key: "",
val: ""
});
};
}
var getUrlParams = function(){
return currNode.urlParams
}
return currNode.urlParams;
};
var getParams = function(){
return currNode.params
}
return currNode.params;
};
var removeUrlParam = function(idx){
currNode.urlParams.splice(idx, 1)
}
currNode.urlParams.splice(idx, 1);
};
var responseDetails = {}
var responseDetails = {};
var setContentType = function() {
console.log('set content type');
// addToHeaders("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
addToHeaders("content-type", "multipart/form-data; boundary=----WebKitFormBoundarymNw6y72wsq8p2Bdn");
currNode.data.formData.key = "submit";
currNode.data.formData.val = "upload"
console.log("currNode", currNode);
}
currNode.data.formData.val = "upload";
};
return {

@@ -126,14 +141,27 @@ setParams: setParams,

},
currNode: currNode,
populateData: populateData,
addUrlParam: addUrlParam,
removeUrlParam: removeUrlParam,
getUrl: getUrl,
getUrlParams: getUrlParams,
getParams: getParams,
getHeaders: getHeaders,
addToHeaders: addToHeaders,
addHeader: addHeader,
removeHeader: removeHeader,
setHeaders: setHeaders,
setPostPutData: setPostPutData,
getResponse: function(){

@@ -146,21 +174,24 @@ return responseDetails;

},
getData: function(){
var data = currNode.data;
return data;
},
reqRoute: function(){
this.currNode.url = getUrl();
setHeaders(this.currNode.headersArr);
return $http(this.currNode).then(
function(response){
responseDetails = response
return response
responseDetails = response;
return response;
},
function(response){
responseDetails = response
return response
})
responseDetails = response;
return response;
});
}
}
};
})
});
var example = require('./example');
var pfroute = require('./pfroute');
// var Table = require('cli-table');
// var table = new Table({ head: ["Method", "SubRouter", "Path"] });
var table = [];
var table;
module.exports = pathfinderUI;
var expressApp = null;
function pathfinderUI (app){
expressApp = null;

@@ -16,3 +12,2 @@ var packageJsonPath = process.cwd() + '/package.json';

pfroute.request.RESTroutes = {

@@ -24,11 +19,9 @@ routes: generateRouteTree(app),

// pfroute.request.routeTable = table;
function generateRouteTree(app) {
var topLevelRouteStack = app._router.stack;
table = []
table = [];
var routeObj = {
url: packageJsonName,
children: retrieveRoutes(topLevelRouteStack)
children: retrieveRoutes(app._router.stack)
};

@@ -42,53 +35,65 @@

var allRoutes = [];
var pPath = "";
var pPath = '';
if(parentPath) {
if (parentPath) {
if (parentPath === '/'){
parentPath = '';
}
pPath = parentPath;
}
var routesArray = topLevelRouteStack.filter(function(stack){ // filter out middleware
// filter out middleware
var routesArray = topLevelRouteStack.filter(function(stack){
return stack.route || stack.handle.stack;
});
routesArray.map(function(e){
var parentName;
if (e.route){ // if no subrouter, just direct route
routesArray.forEach(function(e){
if (e.route.path instanceof RegExp) {
e.route.path = "/" + e.route.path.source.match(/\w+/ig).join("/");
// if terminal route, parse regex and add to tree/table
if (e.route) {
if (e.route.path instanceof RegExp) {
e.route.path = "/" + parse(e.route.path);
}
var route = { url: pPath + e.route.path, method: e.route.stack[0].method };
allRoutes.push(route); // add to route tree
route.subRouter = pPath; // add subrouter path
table.push(route); // add to route table
var route = {
url: pPath + e.route.path,
method: e.route.stack[0].method
};
} else if (e.handle.stack) { // if subrouter exists
parentName = '/';
if (e.regexp.test('/')){
parentName = '/';
}
else {
//
parentName = e.regexp.source.match(/\w+/ig).join("/");
}
allRoutes.push(route); // add to route tree
route.subRouter = pPath; // add subrouter path
table.push(route); // add to route table
var parentPath = pPath + "/" +parentName;
if (parentName === '/') parentPath = pPath;
var route = {
url: parentName
};
// if subrouter exists, parse path and attach subtree to tree
} else if (e.handle.stack) {
var parentName; // subRouter name/label
var parentPath; // subRouter path
route.children = retrieveRoutes(e.handle.stack, parentPath);
allRoutes.push(route);
} else {
//Missed a case
}
if (e.regexp.test('/')){
parentName = '/';
parentPath = pPath;
} else {
parentName = parse(e.regexp);
parentPath = pPath + "/" + parentName;
}
});
var subRouter = { url: parentName };
// recurse until reach all terminal routes
subRouter.children = retrieveRoutes(e.handle.stack, parentPath);
allRoutes.push(subRouter);
} else {
// Missed a case
}
});
return allRoutes;
return allRoutes;

@@ -98,2 +103,26 @@ }

function parse(regExRoute) {
var components = regExRoute.source.match(/([\w\d\.\\]+)/ig);
// filter out standalone "\" characters
var filtered = components.filter(function(component) {
return component !== "\\";
});
// filter out "\" from escaped chars (e.g. "v\.0")
var cleanRouteComponents = filtered.map(function(comp) {
if ((/\\/g).test(comp)) {
var newComp = comp.replace(/\\/g, "");
return newComp;
} else {
return comp;
}
});
return cleanRouteComponents.join("/");
}
pathfinderUI.router = pfroute;

@@ -1,5 +0,1 @@

// Created By: Sangmin Lee
// Purpose: ????
// Date: 6/29/15
var express = require('express');

@@ -10,2 +6,3 @@ var path = require('path');

pfrouter.use(express.static(path.join(__dirname, 'browser')));

@@ -18,21 +15,3 @@ pfrouter.use(express.static(path.join(__dirname, '../node_modules')));

// pfrouter.get('/table', function(req, res) {
// res.json(req.routeTable);
// })
// pfrouter.get('/history', function(req, res) {
// console.log("dirname", __dirname);
// var pathUrl = path.join(__dirname, '../history/history.json');
// console.log("pathUrl", pathUrl);
// fs.readFile(pathUrl).then(function(data) {
// console.log(data);
// res.json(data);
// }, function(err) {
// console.log(err);
// })
// })
module.exports = pfrouter;
{
"name": "pathfinder-ui",
"version": "1.0.0",
"version": "1.1.0",
"private": false,
"preferGlobal": false,
"author": "Cat, Sang, Ming, Tyler",
"author": {
"name": "Cat, Sang, Ming, Tyler"
},
"contributors": [
{
"name": "Cat Lau",
"email": "foo@foo.com"
"email": "clau.catherine@gmail.com"
},

@@ -27,3 +29,2 @@ {

"angular-ui-router": "^0.2.15",
"cli-table": "^0.3.1",
"express": "^4.13.0"

@@ -33,3 +34,3 @@ },

"type": "git",
"url": "https://github.com/smlee/pathfinder-ui"
"url": "git+https://github.com/smlee/pathfinder-ui.git"
},

@@ -45,3 +46,45 @@ "bugs": {

"analyze": true,
"license": "MIT"
"license": "MIT",
"gitHead": "46706909807a68099fa19a4220c14566cf7c7ff3",
"description": "Pathfinder-UI",
"homepage": "https://github.com/smlee/pathfinder-ui#readme",
"_id": "pathfinder-ui@1.0.0",
"scripts": {},
"_shasum": "e2564436fbf5630644b307ca0b5839ed6c930807",
"_from": "pathfinder-ui@*",
"_npmVersion": "2.10.1",
"_nodeVersion": "0.12.4",
"_npmUser": {
"name": "minglei",
"email": "NoEmail@gmail.com"
},
"dist": {
"shasum": "e2564436fbf5630644b307ca0b5839ed6c930807",
"tarball": "http://registry.npmjs.org/pathfinder-ui/-/pathfinder-ui-1.0.0.tgz"
},
"maintainers": [
{
"name": "minglei",
"email": "NoEmail@gmail.com"
},
{
"name": "mingus718",
"email": "mingus718@gmail.com"
},
{
"name": "tyler-pewarski",
"email": "tjp2122@gmail.com"
},
{
"name": "smlee",
"email": "sangmlee23@gmail.com"
},
{
"name": "cl2205",
"email": "clau.catherine@gmail.com"
}
],
"directories": {},
"_resolved": "https://registry.npmjs.org/pathfinder-ui/-/pathfinder-ui-1.0.0.tgz",
"readme": "ERROR: No README data found!"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc