@@ -8,15 +8,36 @@ |
||
| 8 | 8 |
* Controller of the domainManagerApp |
| 9 | 9 |
*/ |
| 10 | 10 |
angular.module('domainManagerApp.addPost', ['firebase', 'domainManagerApp.userData'])
|
| 11 |
- .controller('AddPostController', ['$scope', 'UserData', '$firebase', function ($scope, UserData, $firebase) {
|
|
| 11 |
+ .controller('AddPostController', ['$scope', 'UserData', '$firebase', '$http', function ($scope, UserData, $firebase, $http) {
|
|
| 12 | 12 |
$scope.AddDomain = function() {
|
| 13 |
- var firebaseObj = new Firebase("https://j1x-cpanel.firebaseio.com/");
|
|
| 13 |
+ console.log('Creating domain ' + $scope.domain.name);
|
|
| 14 |
+ $scope.whoisLookup(); |
|
| 15 |
+ } |
|
| 14 | 16 |
|
| 15 |
- var domainsRef = firebaseObj.child("domains");
|
|
| 17 |
+ $scope.whoisLookup = function() {
|
|
| 18 |
+ // Whois domain lookup |
|
| 19 |
+ console.log("Whois lookup...");
|
|
| 20 |
+ var whoisUrl = 'http://api.who.pm/' + $scope.domain.name; |
|
| 21 |
+ $http({
|
|
| 22 |
+ method: 'GET', |
|
| 23 |
+ url: whoisUrl |
|
| 24 |
+ }).success(function(data) {
|
|
| 25 |
+ console.log("Whois lookup successfull");
|
|
| 26 |
+ $scope.domain.whois = data; |
|
| 27 |
+ $scope.saveToFirebase(); |
|
| 28 |
+ }).error(function(data, status, headers, config) {
|
|
| 29 |
+ console.log("Whois lookup error");
|
|
| 30 |
+ }); |
|
| 31 |
+ } |
|
| 16 | 32 |
|
| 33 |
+ $scope.saveToFirebase = function() {
|
|
| 34 |
+ // Save to Firebase |
|
| 35 |
+ var firebaseObj = new Firebase("https://j1x-cpanel.firebaseio.com/");
|
|
| 36 |
+ var domainsRef = firebaseObj.child("domains");
|
|
| 17 | 37 |
domainsRef.push({
|
| 18 | 38 |
name: $scope.domain.name, |
| 19 |
- userId: UserData.getUser() |
|
| 39 |
+ userId: UserData.getUser(), |
|
| 40 |
+ whois: $scope.domain.whois |
|
| 20 | 41 |
}, function(error) {
|
| 21 | 42 |
if (error) {
|
| 22 | 43 |
console.log('Error - Domain not created');
|
@@ -24,6 +45,28 @@ |
||
| 24 | 45 |
console.log('Domain created');
|
| 25 | 46 |
} |
| 26 | 47 |
}); |
| 48 |
+ } |
|
| 27 | 49 |
|
| 50 |
+ $scope.parseWhoisData = function(data) {
|
|
| 51 |
+ var new_data = []; |
|
| 52 |
+ console.log(data); |
|
| 53 |
+ for (var i = 0; i < data.length; i++) {
|
|
| 54 |
+ var keys = {};
|
|
| 55 |
+ if (data[i] != ""){
|
|
| 56 |
+ keys = data[i].split(": ")
|
|
| 57 |
+ console.log(data[i]); |
|
| 58 |
+ console.log(keys); |
|
| 59 |
+ if(keys.length >= 2){
|
|
| 60 |
+ var hash = new Array(); |
|
| 61 |
+ hash[keys[0]] = keys[1]; |
|
| 62 |
+ hash[0].replace(/\s+/g,"_").replace(/\.+/g,"_").replace(/\#+/g,"_").replace(/\$+/g,"_").replace(/\//g,"_").replace(/\[+/g,"_").replace(/\[+/g,"_"); |
|
| 63 |
+ console.log(hash); |
|
| 64 |
+ new_data.push(hash); |
|
| 65 |
+ } |
|
| 66 |
+ } |
|
| 67 |
+ } |
|
| 68 |
+ console.log(new_data); |
|
| 69 |
+ return new_data; |
|
| 28 | 70 |
} |
| 71 |
+ |
|
| 29 | 72 |
}]); |
@@ -14,8 +14,6 @@ angular.module('domainManagerApp.domains', ['ui.bootstrap'])
|
||
| 14 | 14 |
url: '/scripts/data.json' |
| 15 | 15 |
}).success(function(data) {
|
| 16 | 16 |
$scope.domains = data.domains; |
| 17 |
- |
|
| 18 |
- |
|
| 19 | 17 |
}); |
| 20 | 18 |
|
| 21 | 19 |
$scope.oneAtATime = false; |
@@ -13,12 +13,11 @@ angular.module('domainManagerApp.header', ['domainManagerApp.userData'])
|
||
| 13 | 13 |
return viewLocation === $location.path(); |
| 14 | 14 |
}; |
| 15 | 15 |
$scope.isAuthenticated = UserData.isAuthenticated(); |
| 16 |
- console.log($scope.isAuthenticated) |
|
| 17 | 16 |
|
| 18 | 17 |
$rootScope.$on('user:isAuthenticated', function(data, isAuthenticated) {
|
| 19 |
- // you could inspect the data to see if what you care about changed, or just update your own scope |
|
| 20 |
- $scope.isAuthenticated = isAuthenticated; |
|
| 21 |
- console.log($scope.isAuthenticated) |
|
| 22 |
- }); |
|
| 18 |
+ // you could inspect the data to see if what you care about changed, or just update your own scope |
|
| 19 |
+ $scope.isAuthenticated = isAuthenticated; |
|
| 20 |
+ console.log($scope.isAuthenticated) |
|
| 21 |
+ }); |
|
| 23 | 22 |
|
| 24 | 23 |
}]); |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 |
<div class="form-group"> |
| 20 | 20 |
<label class="col-md-4 control-label"for="singlebutton"></label> |
| 21 | 21 |
<div class="col-md-4"> |
| 22 |
- <input id="singlebutton" ng-disabled="!domain.name" name="singlebutton"class="btn btn-primary"type="submit"value="Add"/> |
|
| 22 |
+ <input id="singlebutton" ng-disabled="!domain.name" name="singlebutton"class="btn btn-primary"type="submit"value="Add"> |
|
| 23 | 23 |
</div> |
| 24 | 24 |
</div> |
| 25 | 25 |
|