github-team-viewer
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -1,2 +0,2 @@ | ||
var teamViewerApp = angular.module('teamViewerApp', ['flash']); | ||
var teamViewerApp = angular.module('teamViewerApp', ['flash', 'ngProgress']); | ||
@@ -3,0 +3,0 @@ teamViewerApp.constant('GITHUB_URI', { |
/* Controllers */ | ||
/**/ | ||
function AppCtrl($scope, $http, $log, flash, OrganizationModel, UserModel) { | ||
function AppCtrl($scope, $http, $log, flash, CollectionHandler, XhrStateHandler) { | ||
var resetExcept = function (exceptions) { | ||
_.each(["user","members","repos","commits"], function(attr){ | ||
if( !_.contains(exceptions, attr)) { | ||
$scope[attr] = []; | ||
} | ||
}); | ||
$scope.current_member = null; | ||
$scope.current_repo = null; | ||
}, | ||
var resetExcept, | ||
fatalConnection, | ||
getMembers, | ||
@@ -20,8 +13,11 @@ getUser, | ||
var defineScope = function() { | ||
$scope.loading = true; | ||
$scope.finding = false; | ||
$scope.xhrState = new XhrStateHandler(); | ||
$scope.xhrState.setAllMessages(["Intializing","Fetching Data","Loading Data","Fetched","Retry","Fatal"]); | ||
$scope.xhrState.idle(); | ||
$scope.organization = 'github'; | ||
$scope.Organization = new OrganizationModel(); | ||
$scope.User = new UserModel(); | ||
$scope.Organization = new CollectionHandler('getOrganization'); | ||
$scope.User = new CollectionHandler('getUser'); | ||
$scope.Project = new CollectionHandler('getUserRepos'); | ||
@@ -38,6 +34,5 @@ // Functions | ||
getMembers = function (organization) { | ||
$scope.xhrState.initiate(); | ||
resetExcept(null); | ||
$scope.company = false; | ||
// check if the entered value is org or not! | ||
@@ -47,24 +42,12 @@ $log.log("Getting " + organization + ", for you, hold tight!"); | ||
var organizationInvalid = function(organization){ | ||
$scope.xhrState.error(); | ||
flash('error', 'Please enter correct Organization name'); | ||
}; | ||
var organizationFound = function(organization){ | ||
flash('success', 'Organization found, Looking for additional information', 200); | ||
}; | ||
var organizationDetailFound = function(data){ | ||
$scope.members = data.data; | ||
$scope.loading = false; | ||
$scope.company = true; | ||
$scope.finding = true; | ||
$scope.xhrState.success(); | ||
flash('success', 'Organization information loaded', 200); | ||
}; | ||
var fatalConnection = function(data, status){ | ||
$log.log("Oops Something went wrong!"); | ||
$log.log(data); | ||
$log.log(status); | ||
}; | ||
$scope.Organization.findOrganization(organization, organizationFound, organizationDetailFound, organizationInvalid, fatalConnection); | ||
$scope.Organization.findObject(organization, organizationDetailFound, organizationInvalid, fatalConnection); | ||
}; | ||
@@ -74,15 +57,13 @@ | ||
getUser = function (user) { | ||
resetExcept(["members"]); | ||
$scope.xhrState.initiate(); | ||
resetExcept(["Organization"]); | ||
$scope.current_member = null; | ||
$scope.current_repo = null; | ||
$log.log("Getting " + user + "'s data."); | ||
var onUserFound = function(data){ | ||
$scope.user = data.data; | ||
$scope.loading = false; | ||
$scope.xhrState.success(); | ||
flash('success', 'User information loaded', 200); | ||
}; | ||
$scope.User.findUser(user, onUserFound); | ||
$scope.User.findObject(user, onUserFound, null, fatalConnection); | ||
}; | ||
@@ -92,23 +73,32 @@ | ||
getRepos = function (user) { | ||
resetExcept(["user", "members"]); | ||
$scope.xhrState.initiate(); | ||
resetExcept(["User", "Organization"]); | ||
$scope.current_member = null; | ||
$scope.current_repo = null; | ||
$log.log("Fetching projects of " + user); | ||
var onProjectsFound = function(data){ | ||
angular.element('#flash-messages').css('display', 'none'); | ||
$scope.repos = data.data; | ||
$scope.xhrState.success(); | ||
flash('success', 'Project information loaded', 200); | ||
}; | ||
var onFatal = function(data){ | ||
flash('error', 'User does not have any projects!', 200); | ||
}; | ||
$scope.Project.findObject(user, onProjectsFound, null, fatalConnection); | ||
}; | ||
$scope.User.findProjects(user, onProjectsFound, onFatal); | ||
resetExcept = function (exceptions) { | ||
_.each(["User","Organization","Project"], function(attr){ | ||
if( !_.contains(exceptions, attr)) { | ||
$scope[attr].resetCurrent(); | ||
} | ||
}); | ||
}; | ||
fatalConnection = function(data, status){ | ||
$scope.xhrState.fatal(); | ||
$log.log("Oops Something went wrong!"); | ||
$log.log(data); | ||
$log.log(status); | ||
}; | ||
defineScope(); | ||
} | ||
//MyCtrl1.$inject = []; |
angular.module('flash', []) | ||
.factory('flash', ['$rootScope', '$timeout', function($rootScope, $timeout) { | ||
var messages = []; | ||
var messageTimeout = 3000; | ||
var reset; | ||
var cleanup = function() { | ||
$timeout.cancel(reset); | ||
reset = $timeout(function() { messages = []; }); | ||
reset = $timeout(function() { messages = []; $rootScope.$emit('flash:hide') }, messageTimeout); | ||
}; | ||
@@ -45,4 +45,5 @@ | ||
var directive = { restrict: 'EA', replace: true }; | ||
directive.template = | ||
'<div id="flash-messages">' + | ||
'<div id="flash-messages" data-ng-show="shown">' + | ||
'<span ng-repeat="m in messages" class="{{m.level}}">{{m.text}}</li>' + | ||
@@ -52,6 +53,13 @@ '</div>'; | ||
directive.controller = ['$scope', '$rootScope', function($scope, $rootScope) { | ||
$rootScope.$on('flash:message', function(_, messages, done) { | ||
$rootScope.$on('flash:message', function(_, messages, done){ | ||
$scope.shown = true; | ||
$scope.messages = messages; | ||
done(); | ||
}); | ||
$rootScope.$on('flash:hide', function(){ | ||
$scope.shown = false; | ||
}); | ||
}]; | ||
@@ -58,0 +66,0 @@ |
{ | ||
"name": "github-team-viewer", | ||
"author": "Vinit Kumar", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
#Github Team Viewer | ||
[![Build Status](https://travis-ci.org/vinitkumar/github-team-viewer.svg?branch=v1.1.2)](https://travis-ci.org/vinitkumar/github-team-viewer) | ||
Github Team Viewer is a handy application built with Angular.js which helps | ||
@@ -4,0 +6,0 @@ you find developers from any organization on github. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2860700
71
47428
38
4