From 867935306d8d4cacb6592198e8f1ac203fa0cd4d Mon Sep 17 00:00:00 2001 From: Tanshu Date: Fri, 17 May 2013 23:56:48 +0530 Subject: [PATCH] Changed the toasts to Growl notifications which floats. --- brewman/brewman/static/offline.appcache | 3 +- .../static/scripts/angular_directive.js | 94 ++++---- .../brewman/static/scripts/growl-service.js | 64 ++++++ brewman/brewman/static/scripts/overlord.js | 207 +++++++++--------- brewman/brewman/templates/angular_base.mako | 110 +++++----- 5 files changed, 278 insertions(+), 200 deletions(-) create mode 100644 brewman/brewman/static/scripts/growl-service.js diff --git a/brewman/brewman/static/offline.appcache b/brewman/brewman/static/offline.appcache index f1d05535..3304c41b 100644 --- a/brewman/brewman/static/offline.appcache +++ b/brewman/brewman/static/offline.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# version 2013-05-16.1 +# version 2013-05-17.1 CACHE: /partial/404.html @@ -82,6 +82,7 @@ CACHE: /script/employee-functions.js /script/employee.js /script/group.js +/script/growl-service.js /script/issue.js /script/journal.js /script/ledger.js diff --git a/brewman/brewman/static/scripts/angular_directive.js b/brewman/brewman/static/scripts/angular_directive.js index 73317321..283648e8 100644 --- a/brewman/brewman/static/scripts/angular_directive.js +++ b/brewman/brewman/static/scripts/angular_directive.js @@ -3,17 +3,17 @@ var overlord_directive = angular.module('overlord.directive', []); overlord_directive.directive('ngAutocomplete', ['$q', '$parse', 'DeepLabel', function ($q, $parse, DeepLabel) { return { - restrict:'A', - link:function (scope, element, attrs, ngModel) { + restrict: 'A', + link: function (scope, element, attrs, ngModel) { var labels = [], mapped = {}, deepLabel = DeepLabel; element.typeahead({ - source:function (query, process) { + source: function (query, process) { var Entity = angular.injector(['overlord.service']).get(attrs.resource); - Entity.autocomplete({term:query, count:20}, function (result) { + Entity.autocomplete({term: query, count: 20}, function (result) { labels = []; mapped = {}; $.each(result, function (i, item) { @@ -24,12 +24,12 @@ overlord_directive.directive('ngAutocomplete', ['$q', '$parse', 'DeepLabel', fun process(labels) }); }, - minLength:1, - items:20, - matcher:function (item) { - return true; + minLength: 1, + items: 20, + matcher: function (item) { + return true; }, - updater:function (item) { + updater: function (item) { var model = $parse(attrs.model); var modelSetter = model.assign; modelSetter(scope, mapped[item]); @@ -43,16 +43,16 @@ overlord_directive.directive('ngAutocomplete', ['$q', '$parse', 'DeepLabel', fun overlord_directive.directive('datepicker', ['$parse', function ($parse) { return { - restrict:'E', - replace:true, - transclude:true, - template:'', - link:function (scope, element, attrs) { + restrict: 'E', + replace: true, + transclude: true, + template: '', + link: function (scope, element, attrs) { element.datepicker({ - dateFormat:'dd-M-yy', - showOtherMonths:true, - selectOtherMonths:true, - onSelect:function (dateText, inst) { + dateFormat: 'dd-M-yy', + showOtherMonths: true, + selectOtherMonths: true, + onSelect: function (dateText, inst) { var model = $parse(attrs.model); var modelSetter = model.assign; modelSetter(scope, dateText); @@ -65,8 +65,8 @@ overlord_directive.directive('datepicker', ['$parse', function ($parse) { overlord_directive.directive('fadey', function () { return { - restrict:'A', - link:function (scope, element, attrs) { + restrict: 'A', + link: function (scope, element, attrs) { var duration = 500; element = jQuery(element); element.hide(); @@ -86,8 +86,8 @@ overlord_directive.directive('fadey', function () { overlord_directive.directive('ngConfirm', ['modal', '$parse', function (modal, $parse) { return { - restrict:'A', - link:function postLink(scope, element, attrs) { + restrict: 'A', + link: function postLink(scope, element, attrs) { // Could have custom or boostrap modal options here var options = {}; if (typeof attrs.url !== 'undefined') { @@ -102,8 +102,8 @@ overlord_directive.directive('ngConfirm', ['modal', '$parse', function (modal, $ }); } else { element.bind("click", function () { - var actionButton = {text:attrs["actionButtonText"], click:attrs["actionFunction"], class:attrs['class']}; - var cancelButton = {text:attrs["cancelButtonText"], click:attrs["cancelFunction"]}; + var actionButton = {text: attrs["actionButtonText"], click: attrs["actionFunction"], class: attrs['class']}; + var cancelButton = {text: attrs["cancelButtonText"], click: attrs["cancelFunction"]}; modal.confirm(attrs["title"], attrs["actionText"], actionButton, cancelButton, scope, options); }); } @@ -118,10 +118,10 @@ overlord_directive.directive('ngConfirm', ['modal', '$parse', function (modal, $ * an ng-switch element in the dom, e.g. between ul and li. */ var ngIfDirective = { - transclude:'element', - priority:1000, - terminal:true, - compile:function (element, attr, linker) { + transclude: 'element', + priority: 1000, + terminal: true, + compile: function (element, attr, transclude) { return function (scope, iterStartElement, attr) { iterStartElement[0].doNotMove = true; var expression = attr.ngmIf; @@ -135,7 +135,7 @@ overlord_directive.directive('ngConfirm', ['modal', '$parse', function (modal, $ lastScope && lastScope.$destroy(); if (newValue) { lastScope = scope.$new(); - linker(lastScope, function (clone) { + transclude(lastScope, function (clone) { lastElement = clone; iterStartElement.after(clone); }); @@ -155,14 +155,14 @@ overlord_directive.directive('ngConfirm', ['modal', '$parse', function (modal, $ overlord_directive.directive('journal-edit', function () { return { - restrict:'A', - replace:true, - transclude:true, - templateUrl:'/partial/journal-modal.html', - link:function (scope, element, attrs) { + restrict: 'A', + replace: true, + transclude: true, + templateUrl: '/partial/journal-modal.html', + link: function (scope, element, attrs) { element.bind("click", function () { - var actionButton = {text:attrs["actionButtonText"], click:attrs["actionFunction"], class:attrs['class']}; - var cancelButton = {text:attrs["cancelButtonText"], click:attrs["cancelFunction"]}; + var actionButton = {text: attrs["actionButtonText"], click: attrs["actionFunction"], class: attrs['class']}; + var cancelButton = {text: attrs["cancelButtonText"], click: attrs["cancelFunction"]}; modal.confirm(attrs["title"], attrs["actionText"], actionButton, cancelButton, scope, options); }); } @@ -171,8 +171,8 @@ overlord_directive.directive('journal-edit', function () { overlord_directive.directive('ngEditRepeat', ['modal', '$parse', function (modal, $parse) { return { - restrict:'E', - template:'' + + restrict: 'E', + template: '' + '
' + ' Delete' + ' ' + @@ -181,7 +181,7 @@ overlord_directive.directive('ngEditRepeat', ['modal', '$parse', function (modal ' ' + '
', - link:function postLink(scope, element, attrs) { + link: function postLink(scope, element, attrs) { // Could have custom or boostrap modal options here var options = {}; if (typeof attrs.url !== 'undefined') { @@ -196,8 +196,8 @@ overlord_directive.directive('ngEditRepeat', ['modal', '$parse', function (modal }); } else { element.bind("click", function () { - var actionButton = {text:attrs["actionButtonText"], click:attrs["actionFunction"], class:attrs['class']}; - var cancelButton = {text:attrs["cancelButtonText"], click:attrs["cancelFunction"]}; + var actionButton = {text: attrs["actionButtonText"], click: attrs["actionFunction"], class: attrs['class']}; + var cancelButton = {text: attrs["cancelButtonText"], click: attrs["cancelFunction"]}; modal.confirm(attrs["title"], attrs["actionText"], actionButton, cancelButton, scope, options); }); } @@ -205,3 +205,15 @@ overlord_directive.directive('ngEditRepeat', ['modal', '$parse', function (modal }; }]); +overlord_directive.directive('ngGrowl', ['growl', '$parse', function (growl, $parse) { + return { + restrict: 'A', + link: function (scope, element, attrs) { + var options = { + dismiss_function: attrs["toClose"] + }; + growl.show(element, scope, options); + } + }; + +}]); diff --git a/brewman/brewman/static/scripts/growl-service.js b/brewman/brewman/static/scripts/growl-service.js new file mode 100644 index 00000000..fcea14be --- /dev/null +++ b/brewman/brewman/static/scripts/growl-service.js @@ -0,0 +1,64 @@ +'use strict'; + +overlord_service.factory('growl', ['$http', '$compile', '$timeout', function ($http, $compile, $timeout) { + var growl = {}; + growl.default_options = { + offset: { + from: "top", + amount: 20 + }, + align: "right", + width: 250, + duration:500, + delay: 4000, + stackup_spacing: 10 + }; + + growl.show = function (element, scope, options) { + var options = jQuery.extend({}, growl.default_options, options); + if (options.top_offset) { + options.offset = { + from: "top", + amount: options.top_offset + }; + } + var offsetAmount = options.offset.amount; + jQuery(".bootstrap-growl").each(function (index) { + var offset = parseInt($(this).css(options.offset.from)) + $(this).outerHeight() + options.stackup_spacing; + if (isNaN(offset)) { + offset = 0; + } + return offsetAmount = Math.max(offsetAmount, offset); + }); + element.css("position", "fixed"); + element.css("margin", 0); + element.css("z-index", "9999"); + element.css("display", "none"); + element.css(options.offset.from, offsetAmount + "px"); + if (options.width !== "auto") { + element.css("width", options.width + "px"); + } + switch (options.align) { + case "center": + element.css("left", "50%"); + element.css("margin-left", "-" + (element.outerWidth() / 2) + "px"); + break; + case "left": + element.css("left", "20px"); + break; + default: + element.css("right", "20px"); + } + element.fadeIn(options.duration); + if (options.delay > 0) { + $timeout(function () { + element.fadeOut(options.duration, function() { + scope.$eval(options.dismiss_function); + }); + }, options.delay); + } + return element; + }; + return growl; +}]) +; diff --git a/brewman/brewman/static/scripts/overlord.js b/brewman/brewman/static/scripts/overlord.js index 00a80bf0..59ca1ae0 100644 --- a/brewman/brewman/static/scripts/overlord.js +++ b/brewman/brewman/static/scripts/overlord.js @@ -2,137 +2,137 @@ var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filter', 'overlord.service', 'ngCookies']) .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { - $routeProvider. - when('/', {templateUrl:'/partial/home.html'}). - when('/login', {templateUrl:'/partial/login.html', controller:LoginCtrl}). - when('/logout', {templateUrl:'/partial/home.html', controller:LogoutCtrl}). + $routeProvider. + when('/', {templateUrl: '/partial/home.html'}). + when('/login', {templateUrl: '/partial/login.html', controller: LoginCtrl}). + when('/logout', {templateUrl: '/partial/home.html', controller: LogoutCtrl}). - when('/Journal', {templateUrl:'/partial/journal.html', controller:JournalCtrl, resolve:JournalCtrl.resolve}). - when('/Journal/:id', {templateUrl:'/partial/journal.html', controller:JournalCtrl, resolve:JournalCtrl.resolve}). + when('/Journal', {templateUrl: '/partial/journal.html', controller: JournalCtrl, resolve: JournalCtrl.resolve}). + when('/Journal/:id', {templateUrl: '/partial/journal.html', controller: JournalCtrl, resolve: JournalCtrl.resolve}). - when('/Payment', {templateUrl:'/partial/payment.html', controller:PaymentCtrl, resolve:PaymentCtrl.resolve}). - when('/Payment/:id', {templateUrl:'/partial/payment.html', controller:PaymentCtrl, resolve:PaymentCtrl.resolve}). + when('/Payment', {templateUrl: '/partial/payment.html', controller: PaymentCtrl, resolve: PaymentCtrl.resolve}). + when('/Payment/:id', {templateUrl: '/partial/payment.html', controller: PaymentCtrl, resolve: PaymentCtrl.resolve}). - when('/Receipt', {templateUrl:'/partial/receipt.html', controller:ReceiptCtrl, resolve:ReceiptCtrl.resolve}). - when('/Receipt/:id', {templateUrl:'/partial/receipt.html', controller:ReceiptCtrl, resolve:ReceiptCtrl.resolve}). + when('/Receipt', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl, resolve: ReceiptCtrl.resolve}). + when('/Receipt/:id', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl, resolve: ReceiptCtrl.resolve}). - when('/Purchase', {templateUrl:'/partial/purchase.html', controller:PurchaseCtrl, resolve:PurchaseCtrl.resolve}). - when('/Purchase/:id', {templateUrl:'/partial/purchase.html', controller:PurchaseCtrl, resolve:PurchaseCtrl.resolve}). + when('/Purchase', {templateUrl: '/partial/purchase.html', controller: PurchaseCtrl, resolve: PurchaseCtrl.resolve}). + when('/Purchase/:id', {templateUrl: '/partial/purchase.html', controller: PurchaseCtrl, resolve: PurchaseCtrl.resolve}). - when('/Return', {templateUrl:'/partial/purchase-return.html', controller:PurchaseReturnCtrl, resolve:PurchaseReturnCtrl.resolve}). - when('/Return/:id', {templateUrl:'/partial/purchase-return.html', controller:PurchaseReturnCtrl, resolve:PurchaseReturnCtrl.resolve}). + when('/Return', {templateUrl: '/partial/purchase-return.html', controller: PurchaseReturnCtrl, resolve: PurchaseReturnCtrl.resolve}). + when('/Return/:id', {templateUrl: '/partial/purchase-return.html', controller: PurchaseReturnCtrl, resolve: PurchaseReturnCtrl.resolve}). - when('/Issue', {templateUrl:'/partial/issue.html', controller:IssueCtrl, resolve:IssueCtrl.resolve}). - when('/Issue/:id', {templateUrl:'/partial/issue.html', controller:IssueCtrl, resolve:IssueCtrl.resolve}). + when('/Issue', {templateUrl: '/partial/issue.html', controller: IssueCtrl, resolve: IssueCtrl.resolve}). + when('/Issue/:id', {templateUrl: '/partial/issue.html', controller: IssueCtrl, resolve: IssueCtrl.resolve}). - when('/SalaryDeduction', {templateUrl:'/partial/salary-deduction.html', controller:SalaryDeductionCtrl, resolve:SalaryDeductionCtrl.resolve}). - when('/SalaryDeduction/:id', {templateUrl:'/partial/salary-deduction.html', controller:SalaryDeductionCtrl, resolve:SalaryDeductionCtrl.resolve}). + when('/SalaryDeduction', {templateUrl: '/partial/salary-deduction.html', controller: SalaryDeductionCtrl, resolve: SalaryDeductionCtrl.resolve}). + when('/SalaryDeduction/:id', {templateUrl: '/partial/salary-deduction.html', controller: SalaryDeductionCtrl, resolve: SalaryDeductionCtrl.resolve}). - when('/Ledger', {templateUrl:'/partial/ledger.html', controller:LedgerCtrl, resolve:LedgerCtrl.resolve}). - when('/Ledger/:id', {templateUrl:'/partial/ledger.html', controller:LedgerCtrl, resolve:LedgerCtrl.resolve}). + when('/Ledger', {templateUrl: '/partial/ledger.html', controller: LedgerCtrl, resolve: LedgerCtrl.resolve}). + when('/Ledger/:id', {templateUrl: '/partial/ledger.html', controller: LedgerCtrl, resolve: LedgerCtrl.resolve}). - when('/ProductLedger', {templateUrl:'/partial/product-ledger.html', controller:ProductLedgerCtrl, resolve:ProductLedgerCtrl.resolve}). - when('/ProductLedger/:id', {templateUrl:'/partial/product-ledger.html', controller:ProductLedgerCtrl, resolve:ProductLedgerCtrl.resolve}). + when('/ProductLedger', {templateUrl: '/partial/product-ledger.html', controller: ProductLedgerCtrl, resolve: ProductLedgerCtrl.resolve}). + when('/ProductLedger/:id', {templateUrl: '/partial/product-ledger.html', controller: ProductLedgerCtrl, resolve: ProductLedgerCtrl.resolve}). - when('/CashFlow', {templateUrl:'/partial/cash-flow.html', controller:CashFlowCtrl, resolve:CashFlowCtrl.resolve}). - when('/CashFlow/:id', {templateUrl:'/partial/cash-flow.html', controller:CashFlowCtrl, resolve:CashFlowCtrl.resolve}). + when('/CashFlow', {templateUrl: '/partial/cash-flow.html', controller: CashFlowCtrl, resolve: CashFlowCtrl.resolve}). + when('/CashFlow/:id', {templateUrl: '/partial/cash-flow.html', controller: CashFlowCtrl, resolve: CashFlowCtrl.resolve}). - when('/RawMaterialCost', {templateUrl:'/partial/raw-material-cost.html', controller:RawMaterialCostCtrl, resolve:RawMaterialCostCtrl.resolve}). - when('/RawMaterialCost/:id', {templateUrl:'/partial/raw-material-cost-detail.html', controller:RawMaterialCostCtrl, resolve:RawMaterialCostCtrl.resolve}). + when('/RawMaterialCost', {templateUrl: '/partial/raw-material-cost.html', controller: RawMaterialCostCtrl, resolve: RawMaterialCostCtrl.resolve}). + when('/RawMaterialCost/:id', {templateUrl: '/partial/raw-material-cost-detail.html', controller: RawMaterialCostCtrl, resolve: RawMaterialCostCtrl.resolve}). - when('/Attendance', {templateUrl:'/partial/attendance.html', controller:AttendanceCtrl, resolve:AttendanceCtrl.resolve}). - when('/Attendance/:date', {templateUrl:'/partial/attendance.html', controller:AttendanceCtrl, resolve:AttendanceCtrl.resolve}). + when('/Attendance', {templateUrl: '/partial/attendance.html', controller: AttendanceCtrl, resolve: AttendanceCtrl.resolve}). + when('/Attendance/:date', {templateUrl: '/partial/attendance.html', controller: AttendanceCtrl, resolve: AttendanceCtrl.resolve}). - when('/EmployeeAttendance', {templateUrl:'/partial/employee-attendance.html', controller:EmployeeAttendanceCtrl, resolve:EmployeeAttendanceCtrl.resolve}). - when('/EmployeeAttendance/:id', {templateUrl:'/partial/employee-attendance.html', controller:EmployeeAttendanceCtrl, resolve:EmployeeAttendanceCtrl.resolve}). + when('/EmployeeAttendance', {templateUrl: '/partial/employee-attendance.html', controller: EmployeeAttendanceCtrl, resolve: EmployeeAttendanceCtrl.resolve}). + when('/EmployeeAttendance/:id', {templateUrl: '/partial/employee-attendance.html', controller: EmployeeAttendanceCtrl, resolve: EmployeeAttendanceCtrl.resolve}). - when('/Daybook', {templateUrl:'/partial/daybook.html', controller:DaybookCtrl, resolve:DaybookCtrl.resolve}). - when('/Unposted', {templateUrl:'/partial/unposted.html', controller:UnpostedCtrl, resolve:UnpostedCtrl.resolve}). - when('/ProfitLoss', {templateUrl:'/partial/profit-loss.html', controller:ProfitLossCtrl, resolve:ProfitLossCtrl.resolve}). - when('/PurchaseEntries', {templateUrl:'/partial/purchase-entries.html', controller:PurchaseEntriesCtrl, resolve:PurchaseEntriesCtrl.resolve}). - when('/EmployeeFunctions', {templateUrl:'/partial/employee-functions.html', controller:EmployeeFunctionsCtrl}). + when('/Daybook', {templateUrl: '/partial/daybook.html', controller: DaybookCtrl, resolve: DaybookCtrl.resolve}). + when('/Unposted', {templateUrl: '/partial/unposted.html', controller: UnpostedCtrl, resolve: UnpostedCtrl.resolve}). + when('/ProfitLoss', {templateUrl: '/partial/profit-loss.html', controller: ProfitLossCtrl, resolve: ProfitLossCtrl.resolve}). + when('/PurchaseEntries', {templateUrl: '/partial/purchase-entries.html', controller: PurchaseEntriesCtrl, resolve: PurchaseEntriesCtrl.resolve}). + when('/EmployeeFunctions', {templateUrl: '/partial/employee-functions.html', controller: EmployeeFunctionsCtrl}). - when('/TrialBalance', {templateUrl:'/partial/trial-balance.html', controller:TrialBalanceCtrl, resolve:TrialBalanceCtrl.resolve}). - when('/TrialBalance/:date', {templateUrl:'/partial/trial-balance.html', controller:TrialBalanceCtrl, resolve:TrialBalanceCtrl.resolve}). + when('/TrialBalance', {templateUrl: '/partial/trial-balance.html', controller: TrialBalanceCtrl, resolve: TrialBalanceCtrl.resolve}). + when('/TrialBalance/:date', {templateUrl: '/partial/trial-balance.html', controller: TrialBalanceCtrl, resolve: TrialBalanceCtrl.resolve}). - when('/ClosingStock', {templateUrl:'/partial/closing-stock.html', controller:ClosingStockCtrl, resolve:ClosingStockCtrl.resolve}). - when('/ClosingStock/:date', {templateUrl:'/partial/closing-stock.html', controller:ClosingStockCtrl, resolve:ClosingStockCtrl.resolve}). + when('/ClosingStock', {templateUrl: '/partial/closing-stock.html', controller: ClosingStockCtrl, resolve: ClosingStockCtrl.resolve}). + when('/ClosingStock/:date', {templateUrl: '/partial/closing-stock.html', controller: ClosingStockCtrl, resolve: ClosingStockCtrl.resolve}). - when('/Accounts', {templateUrl:'/partial/account-list.html', controller:AccountListCtrl, resolve:AccountListCtrl.resolve}). - when('/Account', {templateUrl:'/partial/account-detail.html', controller:AccountCtrl, resolve:AccountCtrl.resolve}). - when('/Account/:id', {templateUrl:'/partial/account-detail.html', controller:AccountCtrl, resolve:AccountCtrl.resolve}). + when('/Accounts', {templateUrl: '/partial/account-list.html', controller: AccountListCtrl, resolve: AccountListCtrl.resolve}). + when('/Account', {templateUrl: '/partial/account-detail.html', controller: AccountCtrl, resolve: AccountCtrl.resolve}). + when('/Account/:id', {templateUrl: '/partial/account-detail.html', controller: AccountCtrl, resolve: AccountCtrl.resolve}). - when('/Employees', {templateUrl:'/partial/employee-list.html', controller:EmployeeListCtrl, resolve:EmployeeListCtrl.resolve}). - when('/Employee', {templateUrl:'/partial/employee-detail.html', controller:EmployeeCtrl, resolve:EmployeeCtrl.resolve}). - when('/Employee/:id', {templateUrl:'/partial/employee-detail.html', controller:EmployeeCtrl, resolve:EmployeeCtrl.resolve}). + when('/Employees', {templateUrl: '/partial/employee-list.html', controller: EmployeeListCtrl, resolve: EmployeeListCtrl.resolve}). + when('/Employee', {templateUrl: '/partial/employee-detail.html', controller: EmployeeCtrl, resolve: EmployeeCtrl.resolve}). + when('/Employee/:id', {templateUrl: '/partial/employee-detail.html', controller: EmployeeCtrl, resolve: EmployeeCtrl.resolve}). - when('/CostCenters', {templateUrl:'/partial/cost-center-list.html', controller:CostCenterListCtrl, resolve:CostCenterListCtrl.resolve}). - when('/CostCenter', {templateUrl:'/partial/cost-center-detail.html', controller:CostCenterCtrl, resolve:CostCenterCtrl.resolve}). - when('/CostCenter/:id', {templateUrl:'/partial/cost-center-detail.html', controller:CostCenterCtrl, resolve:CostCenterCtrl.resolve}). + when('/CostCenters', {templateUrl: '/partial/cost-center-list.html', controller: CostCenterListCtrl, resolve: CostCenterListCtrl.resolve}). + when('/CostCenter', {templateUrl: '/partial/cost-center-detail.html', controller: CostCenterCtrl, resolve: CostCenterCtrl.resolve}). + when('/CostCenter/:id', {templateUrl: '/partial/cost-center-detail.html', controller: CostCenterCtrl, resolve: CostCenterCtrl.resolve}). - when('/Products', {templateUrl:'/partial/product-list.html', controller:ProductListCtrl, resolve:ProductListCtrl.resolve}). - when('/Product', {templateUrl:'/partial/product-detail.html', controller:ProductCtrl, resolve:ProductCtrl.resolve}). - when('/Product/:id', {templateUrl:'/partial/product-detail.html', controller:ProductCtrl, resolve:ProductCtrl.resolve}). + when('/Products', {templateUrl: '/partial/product-list.html', controller: ProductListCtrl, resolve: ProductListCtrl.resolve}). + when('/Product', {templateUrl: '/partial/product-detail.html', controller: ProductCtrl, resolve: ProductCtrl.resolve}). + when('/Product/:id', {templateUrl: '/partial/product-detail.html', controller: ProductCtrl, resolve: ProductCtrl.resolve}). - when('/ProductGroups', {templateUrl:'/partial/product-group-list.html', controller:ProductGroupListCtrl, resolve:ProductGroupListCtrl.resolve}). - when('/ProductGroup', {templateUrl:'/partial/product-group-detail.html', controller:ProductGroupCtrl, resolve:ProductGroupCtrl.resolve}). - when('/ProductGroup/:id', {templateUrl:'/partial/product-group-detail.html', controller:ProductGroupCtrl, resolve:ProductGroupCtrl.resolve}). + when('/ProductGroups', {templateUrl: '/partial/product-group-list.html', controller: ProductGroupListCtrl, resolve: ProductGroupListCtrl.resolve}). + when('/ProductGroup', {templateUrl: '/partial/product-group-detail.html', controller: ProductGroupCtrl, resolve: ProductGroupCtrl.resolve}). + when('/ProductGroup/:id', {templateUrl: '/partial/product-group-detail.html', controller: ProductGroupCtrl, resolve: ProductGroupCtrl.resolve}). - when('/Users', {templateUrl:'/partial/user-list.html', controller:UserListCtrl, resolve:UserListCtrl.resolve}). - when('/User', {templateUrl:'/partial/user-detail.html', controller:UserCtrl, resolve:UserCtrl.resolve}). - when('/User/:id', {templateUrl:'/partial/user-detail.html', controller:UserCtrl, resolve:UserCtrl.resolve}). + when('/Users', {templateUrl: '/partial/user-list.html', controller: UserListCtrl, resolve: UserListCtrl.resolve}). + when('/User', {templateUrl: '/partial/user-detail.html', controller: UserCtrl, resolve: UserCtrl.resolve}). + when('/User/:id', {templateUrl: '/partial/user-detail.html', controller: UserCtrl, resolve: UserCtrl.resolve}). - when('/Groups', {templateUrl:'/partial/group-list.html', controller:GroupListCtrl, resolve:GroupListCtrl.resolve}). - when('/Group', {templateUrl:'/partial/group-detail.html', controller:GroupCtrl, resolve:GroupCtrl.resolve}). - when('/Group/:id', {templateUrl:'/partial/group-detail.html', controller:GroupCtrl, resolve:GroupCtrl.resolve}). + when('/Groups', {templateUrl: '/partial/group-list.html', controller: GroupListCtrl, resolve: GroupListCtrl.resolve}). + when('/Group', {templateUrl: '/partial/group-detail.html', controller: GroupCtrl, resolve: GroupCtrl.resolve}). + when('/Group/:id', {templateUrl: '/partial/group-detail.html', controller: GroupCtrl, resolve: GroupCtrl.resolve}). - when('/Clients', {templateUrl:'/partial/client-list.html', controller:ClientCtrl, resolve:ClientCtrl.resolve}). + when('/Clients', {templateUrl: '/partial/client-list.html', controller: ClientCtrl, resolve: ClientCtrl.resolve}). - otherwise({templateUrl:'/partial/404.html'}); - $locationProvider.html5Mode(true).hashPrefix('!'); -}]) + otherwise({templateUrl: '/partial/404.html'}); + $locationProvider.html5Mode(true).hashPrefix('!'); + }]) .config(['$httpProvider', function ($httpProvider) { - $httpProvider.responseInterceptors.push('spinnerInterceptor'); - var spinnerFunction = function (data, headersGetter) { - var scope = angular.injector(['ng']).get('$rootScope'), - headers = headersGetter(), - isResourceRequest = headers['Content-Type'] === "application/json"; + $httpProvider.responseInterceptors.push('spinnerInterceptor'); + var spinnerFunction = function (data, headersGetter) { + var scope = angular.injector(['ng']).get('$rootScope'), + headers = headersGetter(), + isResourceRequest = headers['Content-Type'] === "application/json"; - if (isResourceRequest && scope) { - scope.$broadcast('spinnerStart', 'http'); - } - return data; - }; - $httpProvider.defaults.transformRequest.push(spinnerFunction); -}]) + if (isResourceRequest && scope) { + scope.$broadcast('spinnerStart', 'http'); + } + return data; + }; + $httpProvider.defaults.transformRequest.push(spinnerFunction); + }]) .factory('spinnerInterceptor', ['$q', '$rootScope', function ($q, $rootScope) { - return function (promise) { - return promise.then(function (response) { - var headers = response.headers(), - isResourceResponse = headers['content-type'] === "application/json; charset=utf-8"; - if (isResourceResponse) { - $rootScope.$broadcast('spinnerStop', 'http'); - } - return response; + return function (promise) { + return promise.then(function (response) { + var headers = response.headers(), + isResourceResponse = headers['content-type'] === "application/json; charset=utf-8"; + if (isResourceResponse) { + $rootScope.$broadcast('spinnerStop', 'http'); + } + return response; - }, function (response) { - var headers = response.headers(), - isResourceResponse = headers['content-type'] === "application/json; charset=utf-8"; - if (isResourceResponse) { - $rootScope.$broadcast('spinnerStop', 'http'); - } - var status = response.status; - if (status == 401 && !isResourceResponse) { - $rootScope.$broadcast('event:loginRequired'); - } - // otherwise - return $q.reject(response); - }); - }; -}]); + }, function (response) { + var headers = response.headers(), + isResourceResponse = headers['content-type'] === "application/json; charset=utf-8"; + if (isResourceResponse) { + $rootScope.$broadcast('spinnerStop', 'http'); + } + var status = response.status; + if (status == 401 && !isResourceResponse) { + $rootScope.$broadcast('event:loginRequired'); + } + // otherwise + return $q.reject(response); + }); + }; + }]); overlord.controller('BaseCtrl', ['$rootScope', '$scope', 'Auth', '$location', '$routeParams', function ($rootScope, $scope, Auth, $location, $routeParams) { - $rootScope.spinner = {http:0, route:false}; + $rootScope.spinner = {http: 0, route: false}; $rootScope.$on('event:loginRequired', function () { if ($rootScope.auth.isAuthenticated) { $location.path('/'); @@ -141,7 +141,7 @@ overlord.controller('BaseCtrl', ['$rootScope', '$scope', 'Auth', '$location', '$ if (typeof came_from === 'undefined' && $location.path() !== '/login') { came_from = $location.path(); } - $location.path('/login').search({came_from:came_from}); + $location.path('/login').search({came_from: came_from}); } }); @@ -168,10 +168,7 @@ overlord.controller('BaseCtrl', ['$rootScope', '$scope', 'Auth', '$location', '$ $scope.clearToast = function (item) { var idx = $scope.toasts.indexOf(item); if (idx !== -1) { - //injected into repeater scope by fadey directive - this.destroy(function () { - $scope.toasts.splice(idx, 1); - }); + $scope.toasts.splice(idx, 1); } }; diff --git a/brewman/brewman/templates/angular_base.mako b/brewman/brewman/templates/angular_base.mako index bcd4058f..2c791af2 100644 --- a/brewman/brewman/templates/angular_base.mako +++ b/brewman/brewman/templates/angular_base.mako @@ -19,51 +19,52 @@ - - - + + + - - - + + + - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - + + + + + + + + @@ -90,7 +91,8 @@
  • Home