- Add some more analytics events

- Enable business features for personal users on business plans
- Fix a bug in the credit card image view
This commit is contained in:
Joseph Schorr 2013-12-20 22:38:53 -05:00
parent 8bfc0ac48d
commit c20e7dbcf7
10 changed files with 241 additions and 121 deletions

View file

@ -969,6 +969,59 @@ quayApp.filter('visibleLogFilter', function () {
});
quayApp.directive('billingInvoices', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/billing-invoices.html',
replace: false,
transclude: false,
restrict: 'C',
scope: {
'organization': '=organization',
'user': '=user',
'visible': '=visible'
},
controller: function($scope, $element, $sce, Restangular) {
$scope.loading = false;
$scope.invoiceExpanded = {};
$scope.toggleInvoice = function(id) {
$scope.invoiceExpanded[id] = !$scope.invoiceExpanded[id];
};
var update = function() {
var hasValidUser = !!$scope.user;
var hasValidOrg = !!$scope.organization;
var isValid = hasValidUser || hasValidOrg;
if (!$scope.visible || !isValid) {
return;
}
$scope.loading = true;
var url = getRestUrl('user/invoices');
if ($scope.organization) {
url = getRestUrl('organization', $scope.organization.name, 'invoices');
}
var getInvoices = Restangular.one(url);
getInvoices.get().then(function(resp) {
$scope.invoices = resp.invoices;
$scope.loading = false;
});
};
$scope.$watch('organization', update);
$scope.$watch('user', update);
$scope.$watch('visible', update);
}
};
return directiveDefinitionObject;
});
quayApp.directive('logsView', function () {
var directiveDefinitionObject = {
priority: 0,
@ -2112,15 +2165,27 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanServi
// Check if we need to redirect based on a previously chosen plan.
PlanService.handleNotedPlan();
var changeTab = function(activeTab) {
var changeTab = function(activeTab, opt_timeout) {
var checkCount = 0;
$timeout(function() {
if (checkCount > 5) { return; }
checkCount++;
$('a[data-toggle="tab"]').each(function(index) {
var tabName = this.getAttribute('data-target').substr(1);
if (tabName == activeTab) {
this.click();
if (tabName != activeTab) {
return;
}
if (this.clientWidth == 0) {
changeTab(activeTab, 500);
return;
}
this.click();
});
});
}, opt_timeout);
};
var resetDefaultTab = function() {

View file

@ -602,8 +602,22 @@ function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, Us
$('.form-change-pw').popover();
$scope.logsShown = 0;
$scope.invoicesShown = 0;
$scope.loadLogs = function() {
if (!$scope.hasPaidBusinessPlan) { return; }
$scope.logsShown++;
};
$scope.loadInvoices = function() {
if (!$scope.hasPaidBusinessPlan) { return; }
$scope.invoicesShown++;
};
$scope.planChanged = function(plan) {
$scope.hasPaidPlan = plan && plan.price > 0;
$scope.hasPaidBusinessPlan = PlanService.isOrgCompatible(plan) && plan.price > 0;
};
$scope.showConvertForm = function() {
@ -981,11 +995,6 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
function OrgViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams) {
var orgname = $routeParams.orgname;
$('.info-icon').popover({
'trigger': 'hover',
'html': true
});
$scope.TEAM_PATTERN = TEAM_PATTERN;
$rootScope.title = 'Loading...';
@ -1053,6 +1062,11 @@ function OrgViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
$scope.organization = org;
$rootScope.title = orgname;
$rootScope.description = 'Viewing organization ' + orgname;
$('.info-icon').popover({
'trigger': 'hover',
'html': true
});
});
};
@ -1078,31 +1092,20 @@ function OrgAdminCtrl($rootScope, $scope, Restangular, $routeParams, UserService
$scope.membersFound = null;
$scope.invoiceLoading = true;
$scope.logsShown = 0;
$scope.invoicesShown = 0;
$scope.loadLogs = function() {
$scope.logsShown++;
};
$scope.loadInvoices = function() {
$scope.invoicesShown++;
};
$scope.planChanged = function(plan) {
$scope.hasPaidPlan = plan && plan.price > 0;
};
$scope.loadInvoices = function() {
if ($scope.invoices) { return; }
$scope.invoiceLoading = true;
var getInvoices = Restangular.one(getRestUrl('organization', orgname, 'invoices'));
getInvoices.get().then(function(resp) {
$scope.invoiceExpanded = {};
$scope.invoices = resp.invoices;
$scope.invoiceLoading = false;
});
};
$scope.toggleInvoice = function(id) {
$scope.invoiceExpanded[id] = !$scope.invoiceExpanded[id];
};
$scope.loadMembers = function() {
if ($scope.membersFound) { return; }
$scope.membersLoading = true;