Skip to content

Commit

Permalink
Merge pull request #108 from JohnnyTheTank/plugin_json
Browse files Browse the repository at this point in the history
added new plugin: json-string
  • Loading branch information
JohnnyTheTank committed May 9, 2016
2 parents 12592af + 50eaef0 commit a09993f
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 41 deletions.
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = function (grunt) {
'src/aping-inputObjects.js',
'src/aping-models.js',
'src/plugin-jsonloader.js',
'src/plugin-json-string.js',
'src/plugin-ng-array.js',
'src/plugin-local-storage.js',
'src/plugin-xml.js',
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apiNG",
"version": "1.3.2",
"version": "1.3.3",
"homepage": "https://github.com/JohnnyTheTank/apiNG",
"authors": [
"Jonathan Hornung <[email protected]>"
Expand Down
1 change: 1 addition & 0 deletions demos/json-string/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var app = angular.module('app', ['jtt_aping']);
24 changes: 24 additions & 0 deletions demos/json-string/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>apiNG Demo</title>

<!-- apiNG dependencies -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>

<!-- apiNG -->
<script src="../../dist/aping.js"></script>

<!-- angular module -->
<script src="app.js"></script>

</head>
<body ng-app="app">

<aping aping-json-string='{"gender":"male","name":{"title":"mr","first":"fernando","last":"soto"},"location":{"street":"5303 calle covadonga","city":"alicante","state":"cataluña","postcode":28020},"email":"[email protected]","login":{"username":"lazyduck489","password":"1616","salt":"vptikytR","md5":"68d978f4bc562fd270bf7297565af0ad","sha1":"451c9a970f114ea76e4760b7c5d68f5c11a4221c","sha256":"885489cc2ccf54d83f5bec2f2cbfc06c2282e2cda581e21f79febb45f990d62d"},"registered":1105370272,"dob":1319579754,"phone":"932-763-620","cell":"634-690-303","id":{"name":"DNI","value":"25588238-D"},"picture":{"large":"https://randomuser.me/api/portraits/men/92.jpg","medium":"https://randomuser.me/api/portraits/med/men/92.jpg","thumbnail":"https://randomuser.me/api/portraits/thumb/men/92.jpg"},"nat":"ES"}'>
<pre>{{results | json}}</pre>
</aping>

</body>
</html>
2 changes: 1 addition & 1 deletion demos/jsonloader/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>apiNG Demo</title>

<!-- apiNG dependencies -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>

<!-- apiNG -->
<script src="../../dist/aping.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/localstorage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<!-- apiNG dependencies -->
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>

<!-- apiNG -->
<script src="../../dist/aping.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/socialwall/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<!-- apiNG dependencies -->
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>

<!-- apiNG -->
<script src="../../dist/aping.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/xml/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>apiNG Demo</title>

<!-- apiNG dependencies -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>

<!-- apiNG -->
<script src="../../dist/aping.js"></script>
Expand Down
58 changes: 45 additions & 13 deletions dist/aping.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
@name: aping
@version: 1.3.2 (22-04-2016)
@version: 1.3.3 (09-05-2016)
@author: Jonathan Hornung <[email protected]>
@url: https://github.com/JohnnyTheTank/apiNG
@license: MIT
Expand All @@ -10,6 +10,7 @@ angular.module('jtt_aping', [
'jtt_aping_xml',
'jtt_aping_ng_array',
'jtt_aping_local_storage',
'jtt_aping_json_string',
]);;"use strict";
angular.module('jtt_aping')
.config(['$provide', function ($provide) {
Expand Down Expand Up @@ -369,19 +370,23 @@ angular.module('jtt_aping')
}
var requests = [];
var tempArray = this.replaceSingleQuotesAndParseJson(_string);
angular.forEach(tempArray, function (value) {
value.platform = _platform;
if (_appSettings) {
if (angular.isUndefined(value.items) && angular.isDefined(_appSettings.items)) {
value.items = _appSettings.items;
}
if (angular.isUndefined(value.model) && angular.isDefined(_appSettings.model)) {
value.model = _appSettings.model;
if (tempArray.constructor === Array) {
angular.forEach(tempArray, function (value) {
value.platform = _platform;
if (_appSettings) {
if (angular.isUndefined(value.items) && angular.isDefined(_appSettings.items)) {
value.items = _appSettings.items;
}
if (angular.isUndefined(value.model) && angular.isDefined(_appSettings.model)) {
value.model = _appSettings.model;
}
}
}
var request = apingInputObjects.getNew("request", value);
requests.push(request);
});
var request = apingInputObjects.getNew("request", value);
requests.push(request);
});
} else {
requests.push(tempArray);
}
return requests;
};

Expand Down Expand Up @@ -1011,6 +1016,33 @@ angular.module("jtt_aping_jsonloader", [])
return jsonloaderFactory;
}]);;"use strict";

angular.module("jtt_aping_json_string", [])
.directive('apingJsonString', ['apingUtilityHelper', function (apingUtilityHelper) {
return {
require: '?aping',
restrict: 'A',
replace: 'false',
link: function (scope, element, attrs, apingController) {

var appSettings = apingController.getAppSettings();
var request = apingUtilityHelper.parseJsonFromAttributes(attrs.apingJsonString, "apingJsonString", appSettings);

var resultArray = [];

if (request) {
if (request.constructor === Array) {
resultArray = request;
} else {
resultArray.push(request);
}
if (resultArray.length > 0) {
apingController.concatToResults(resultArray);
}
}
}
}
}]);;"use strict";

angular.module("jtt_aping_ng_array", [])
.directive('apingNgArray', ['apingUtilityHelper', function (apingUtilityHelper) {
return {
Expand Down
Loading

0 comments on commit a09993f

Please sign in to comment.