mno-enterprise-frontend 2.0.9 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/mno_enterprise/angular/app.js.coffee.erb +0 -120
  3. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/maestrano-components.js.coffee +0 -11
  4. data/app/assets/javascripts/mno_enterprise/application.js +0 -2
  5. data/app/assets/javascripts/mno_enterprise/lib/xeditable.js +0 -0
  6. data/app/assets/stylesheets/mno_enterprise/main.less +0 -28
  7. data/app/views/layouts/mno_enterprise/_application_js.html.haml +0 -4
  8. data/app/views/layouts/mno_enterprise/_common_cdn_lib_js.html.haml +0 -5
  9. data/app/views/layouts/mno_enterprise/_header_files.html.haml +0 -3
  10. data/app/views/layouts/mno_enterprise/application.html.haml +1 -1
  11. data/app/views/mno_enterprise/provision/_provision_apps.html.haml +7 -8
  12. data/config/routes.rb +1 -10
  13. data/lib/mno_enterprise/frontend/engine.rb +12 -0
  14. data/lib/mno_enterprise/frontend/locales_generator.rb +57 -0
  15. data/lib/tasks/mnoe_admin_tasks.rake +67 -0
  16. data/lib/tasks/mnoe_frontend_tasks.rake +138 -0
  17. data/lib/tasks/mnoe_locales.rake +14 -0
  18. data/lib/tasks/templates/bower.json +10 -0
  19. data/spec/controllers/mno_enterprise/auth/confirmations_controller_spec.rb +2 -2
  20. data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +1 -1
  21. data/spec/lib/mno_enterprise/locales_generator_spec.rb +14 -0
  22. data/spec/lib/tasks/mnoe_locales_rake_spec.rb +25 -0
  23. metadata +35 -145
  24. data/app/assets/images/mno_enterprise/impac/close-widget-pink.png +0 -0
  25. data/app/assets/images/mno_enterprise/impac/close-widget.png +0 -0
  26. data/app/assets/javascripts/mno_enterprise/angular/controllers/maestrano-controllers.js.coffee +0 -4
  27. data/app/assets/javascripts/mno_enterprise/angular/controllers/modals/modals-ctrl.js.coffee +0 -62
  28. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/dashboard-account.js.coffee +0 -157
  29. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/dashboard-app-deletion-request.js.coffee +0 -62
  30. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/dashboard-apps-list.js.coffee +0 -127
  31. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/dashboard-components.js.coffee +0 -25
  32. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/dashboard-marketplace-app.js.coffee +0 -77
  33. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/dashboard-marketplace.js.coffee +0 -51
  34. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/dashboard-menu.js.coffee +0 -174
  35. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/organization/arrears.js.coffee +0 -70
  36. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/organization/billing.js.coffee +0 -48
  37. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/organization/credit-card.js.coffee +0 -142
  38. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/organization/index.js.coffee +0 -61
  39. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/organization/invoices.js.coffee +0 -42
  40. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/organization/members.js.coffee +0 -280
  41. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/organization/settings.js.coffee +0 -91
  42. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/organization/team-list.js.coffee +0 -179
  43. data/app/assets/javascripts/mno_enterprise/angular/directives/dashboard/organization/teams.js.coffee +0 -268
  44. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/file-model.js.coffee +0 -33
  45. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-autostop-app.js.coffee +0 -123
  46. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-currency-widget.js.coffee +0 -43
  47. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-current-currency.js.coffee +0 -22
  48. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-editable.js.coffee +0 -68
  49. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-helptext.js.coffee +0 -38
  50. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-match.js.coffee +0 -14
  51. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-message-modal.js.coffee +0 -56
  52. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-partner-code-popup.js.coffee +0 -74
  53. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-partner-contact.js.coffee +0 -59
  54. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-price-converter.js.coffee +0 -49
  55. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-scroll-to.js.coffee +0 -14
  56. data/app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-typeahead.js.coffee +0 -89
  57. data/app/assets/javascripts/mno_enterprise/angular/directives/user-setup/components.js.coffee +0 -7
  58. data/app/assets/javascripts/mno_enterprise/angular/directives/user-setup/index.js.coffee +0 -256
  59. data/app/assets/javascripts/mno_enterprise/angular/filters/maestrano-app-by-category.js.coffee +0 -5
  60. data/app/assets/javascripts/mno_enterprise/angular/filters/maestrano-currency.js.coffee +0 -30
  61. data/app/assets/javascripts/mno_enterprise/angular/filters/maestrano-filters.js.coffee +0 -7
  62. data/app/assets/javascripts/mno_enterprise/angular/filters/maestrano-replace-underscore-with-space.js.coffee +0 -4
  63. data/app/assets/javascripts/mno_enterprise/angular/filters/maestrano-titleize.js.coffee +0 -7
  64. data/app/assets/javascripts/mno_enterprise/angular/filters/maestrano-truncate.js.coffee +0 -24
  65. data/app/assets/javascripts/mno_enterprise/angular/services/dashboard/maestrano-app-instance.js.coffee +0 -15
  66. data/app/assets/javascripts/mno_enterprise/angular/services/dashboard/maestrano-apps-document.js.coffee +0 -83
  67. data/app/assets/javascripts/mno_enterprise/angular/services/dashboard/maestrano-user.js.coffee +0 -27
  68. data/app/assets/javascripts/mno_enterprise/angular/services/dashboard/organization-svc.js.coffee +0 -318
  69. data/app/assets/javascripts/mno_enterprise/angular/services/dashboard/team-svc.js.coffee +0 -180
  70. data/app/assets/javascripts/mno_enterprise/angular/services/dashboard/tickets-svc.js.coffee +0 -109
  71. data/app/assets/javascripts/mno_enterprise/angular/services/impac-config.svc.js.coffee +0 -35
  72. data/app/assets/javascripts/mno_enterprise/angular/services/maestrano-apps-list-helper.js.coffee +0 -337
  73. data/app/assets/javascripts/mno_enterprise/angular/services/maestrano-current-currency.js.coffee +0 -7
  74. data/app/assets/javascripts/mno_enterprise/angular/services/maestrano-current-user-svc.js.coffee +0 -99
  75. data/app/assets/javascripts/mno_enterprise/angular/services/maestrano-exchange-rates.js.coffee +0 -102
  76. data/app/assets/javascripts/mno_enterprise/angular/services/maestrano-miscellaneous.js.coffee.erb +0 -46
  77. data/app/assets/javascripts/mno_enterprise/angular/services/maestrano-modal.js.coffee +0 -67
  78. data/app/assets/javascripts/mno_enterprise/angular/services/maestrano-services.js.coffee +0 -21
  79. data/app/assets/javascripts/mno_enterprise/angular/services/maestrano-shopping-cart.js.coffee +0 -361
  80. data/app/assets/javascripts/mno_enterprise/angular/services/marketplace-svc.js.coffee +0 -59
  81. data/app/assets/javascripts/mno_enterprise/lib/angular-really-click.js +0 -17
  82. data/app/assets/javascripts/ng-performance/ngPerformance.html +0 -109
  83. data/app/assets/javascripts/ng-performance/ngPerformance.js +0 -211
  84. data/app/assets/stylesheets/mno_enterprise/custom/impac-variables-override.less +0 -65
  85. data/app/assets/stylesheets/mno_enterprise/custom/utility/app-presentation.less +0 -77
  86. data/app/assets/stylesheets/mno_enterprise/custom/utility/banners.less +0 -145
  87. data/app/assets/stylesheets/mno_enterprise/custom/utility/carousel.less +0 -68
  88. data/app/assets/stylesheets/mno_enterprise/custom/utility/helptext.less +0 -40
  89. data/app/assets/stylesheets/mno_enterprise/custom/utility/miscellaneous.less +0 -134
  90. data/app/assets/stylesheets/mno_enterprise/custom/utility/testimonial.less +0 -118
  91. data/app/assets/stylesheets/mno_enterprise/custom/views/apps.less +0 -243
  92. data/app/assets/stylesheets/mno_enterprise/custom/views/myspace.less +0 -477
  93. data/app/assets/stylesheets/mno_enterprise/custom/views/pages/home.less +0 -57
  94. data/app/assets/stylesheets/mno_enterprise/custom/views/star.less +0 -18
  95. data/app/assets/stylesheets/mno_enterprise/custom/views/templates/dashboard/bootstrap-wizard.less +0 -63
  96. data/app/assets/stylesheets/mno_enterprise/custom/views/templates/dashboard/dashboard-marketplace.less +0 -187
  97. data/app/assets/stylesheets/mno_enterprise/custom/views/templates/dashboard/dashboard-organization.less +0 -149
  98. data/app/assets/stylesheets/mno_enterprise/custom/views/templates/dashboard/dashboard-teams.less +0 -119
  99. data/app/assets/stylesheets/mno_enterprise/custom/views/templates/dashboard/support.less +0 -42
  100. data/app/assets/stylesheets/mno_enterprise/custom/views/templates/dashboard/tickets.less +0 -80
  101. data/app/assets/stylesheets/mno_enterprise/custom/views/templates/mno-editable.less +0 -60
  102. data/app/assets/stylesheets/mno_enterprise/custom/views/templates/shopping-cart.less +0 -333
  103. data/app/assets/stylesheets/mno_enterprise/custom/views/templates/star-wizard.less +0 -49
  104. data/app/assets/stylesheets/mno_enterprise/custom/views/user-setup.less +0 -10
  105. data/app/assets/templates/mno_enterprise/dashboard/account.html +0 -131
  106. data/app/assets/templates/mno_enterprise/dashboard/app_deletion.html +0 -36
  107. data/app/assets/templates/mno_enterprise/dashboard/apps_list.html +0 -103
  108. data/app/assets/templates/mno_enterprise/dashboard/horizontal_menu.html +0 -85
  109. data/app/assets/templates/mno_enterprise/dashboard/marketplace/index.html +0 -60
  110. data/app/assets/templates/mno_enterprise/dashboard/marketplace/show.html +0 -133
  111. data/app/assets/templates/mno_enterprise/dashboard/menu.html +0 -161
  112. data/app/assets/templates/mno_enterprise/dashboard/organization/arrears.html +0 -37
  113. data/app/assets/templates/mno_enterprise/dashboard/organization/billing.html +0 -37
  114. data/app/assets/templates/mno_enterprise/dashboard/organization/credit-card.html +0 -156
  115. data/app/assets/templates/mno_enterprise/dashboard/organization/index.full.html +0 -181
  116. data/app/assets/templates/mno_enterprise/dashboard/organization/index.html +0 -173
  117. data/app/assets/templates/mno_enterprise/dashboard/organization/invoices.html +0 -27
  118. data/app/assets/templates/mno_enterprise/dashboard/organization/members.html +0 -288
  119. data/app/assets/templates/mno_enterprise/dashboard/organization/settings.html +0 -55
  120. data/app/assets/templates/mno_enterprise/dashboard/teams/index.html +0 -175
  121. data/app/assets/templates/mno_enterprise/dashboard/teams/member-add-modal.html +0 -60
  122. data/app/assets/templates/mno_enterprise/dashboard/teams/member-removal-modal.html +0 -35
  123. data/app/assets/templates/mno_enterprise/dashboard/teams/team-add-modal.html +0 -35
  124. data/app/assets/templates/mno_enterprise/dashboard/teams/team-delete-modal.html +0 -35
  125. data/app/assets/templates/mno_enterprise/dashboard/teams/team-list.html +0 -107
  126. data/app/assets/templates/mno_enterprise/default_template.html +0 -20
  127. data/app/assets/templates/mno_enterprise/maestrano-components/autostop_app.html +0 -42
  128. data/app/assets/templates/mno_enterprise/maestrano-components/currency_widget.html +0 -1
  129. data/app/assets/templates/mno_enterprise/maestrano-components/editable.html +0 -28
  130. data/app/assets/templates/mno_enterprise/maestrano-components/modal-messages/congratulations.html +0 -8
  131. data/app/assets/templates/mno_enterprise/maestrano-components/modal-messages/default.html +0 -1
  132. data/app/assets/templates/mno_enterprise/maestrano-components/modal-messages/information.html +0 -8
  133. data/app/assets/templates/mno_enterprise/maestrano-components/star_wizard.html +0 -254
  134. data/app/assets/templates/mno_enterprise/maestrano-components/upload_spreadsheet.html +0 -191
  135. data/app/assets/templates/mno_enterprise/modals/new-organization-reseller-req.html +0 -35
  136. data/app/assets/templates/mno_enterprise/modals/new-organization.html +0 -35
  137. data/app/assets/templates/mno_enterprise/user-setup/index.html +0 -312
  138. data/app/controllers/mno_enterprise/pages_controller.rb +0 -9
  139. data/app/controllers/mno_enterprise/user_setup_controller.rb +0 -11
  140. data/app/views/layouts/mno_enterprise/_impersonate_header.html.haml +0 -7
  141. data/app/views/layouts/mno_enterprise/application_dashboard.html.haml +0 -22
  142. data/app/views/mno_enterprise/pages/myspace.html.haml +0 -6
  143. data/app/views/mno_enterprise/user_setup/index.html.haml +0 -2
  144. data/config/initializers/ng-performance.rb +0 -3
  145. data/lib/assets/javascripts/impac-angular.js +0 -8719
  146. data/lib/assets/stylesheets/impac-angular.less +0 -2352
  147. data/lib/mno_enterprise/frontend/concerns/README.md +0 -6
  148. data/lib/mno_enterprise/frontend/concerns/controllers/pages_controller.rb +0 -25
  149. data/spec/controllers/mno_enterprise/pages_controller_spec.rb +0 -42
  150. data/spec/controllers/mno_enterprise/user_setup_controller_spec.rb +0 -33
  151. data/spec/routing/mno_enterprise/pages_controller_routing_spec.rb +0 -18
  152. data/spec/routing/mno_enterprise/user_setup_controller_routing_spec.rb +0 -11
@@ -1,179 +0,0 @@
1
- module = angular.module('maestrano.dashboard.dashboard-organization-team-list',['maestrano.assets'])
2
-
3
- #============================================
4
- #
5
- #============================================
6
- module.controller('DashboardOrganizationTeamListCtrl',[
7
- '$scope','$window','DhbOrganizationSvc', 'DhbTeamSvc', 'Utilities','AssetPath','$modal','TemplatePath','$q',
8
- ($scope, $window, DhbOrganizationSvc, DhbTeamSvc, Utilities, AssetPath,$modal,TemplatePath,$q) ->
9
- #====================================
10
- # Pre-Initialization
11
- #====================================
12
- $scope.assetPath = AssetPath
13
- $scope.isLoading = true
14
- $scope.teams = []
15
-
16
- #====================================
17
- # Scope Management
18
- #====================================
19
- # Initialize the data used by the directive
20
- # If the current user is not a manager then
21
- # the directive restricts the list to the current
22
- # user's teams only
23
- $scope.initialize = (teams) ->
24
- realTeams = []
25
- if $scope.canManageTeam()
26
- realTeams = teams
27
- else
28
- _.each teams, (t) ->
29
- realTeams.push(t) if $scope.teamHasUser(t,DhbOrganizationSvc.data.current_user)
30
-
31
- angular.copy(realTeams,$scope.teams)
32
- $scope.isLoading = false
33
-
34
- $scope.isTeamEmpty = (team) ->
35
- team.users.length == 0
36
-
37
- $scope.hasTeams = ->
38
- $scope.teams.length > 0
39
-
40
- $scope.canManageTeam = ->
41
- DhbOrganizationSvc.can.create.member()
42
-
43
- $scope.teamHasUser = (team,user) ->
44
- _.find(team.users,(u)-> u.id == user.id)?
45
-
46
- #====================================
47
- # Team: Member Add Modal
48
- #====================================
49
- $scope.memberAddModal = memberAddModal = {}
50
- memberAddModal.config = {
51
- instance: {
52
- backdrop: 'static'
53
- templateUrl: TemplatePath['mno_enterprise/dashboard/teams/member-add-modal.html']
54
- size: 'lg'
55
- windowClass: 'inverse team-member-add-modal'
56
- scope: $scope
57
- }
58
- }
59
-
60
- memberAddModal.open = (team) ->
61
- self = memberAddModal
62
- self.team = team
63
- self.users = []
64
- self.userList = self.getAvailableUsers(team)
65
- self.$instance = $modal.open(self.config.instance)
66
- self.isLoading = false
67
-
68
- memberAddModal.close = ->
69
- self = memberAddModal
70
- self.$instance.close()
71
-
72
- memberAddModal.getAvailableUsers = (team) ->
73
- self = memberAddModal
74
- list = []
75
- _.each DhbOrganizationSvc.data.organization.members, (m) ->
76
- unless _.find(team.users,(u)-> u.id == m.id)?
77
- list.push(m) if m.entity == 'User'
78
- return list
79
-
80
- memberAddModal.canAddUsers = ->
81
- self = memberAddModal
82
- self.userList.length > 0
83
-
84
- memberAddModal.hasUser = (user) ->
85
- self = memberAddModal
86
- _.contains(self.users,user)
87
-
88
- memberAddModal.toggleUser = (user) ->
89
- self = memberAddModal
90
- if self.hasUser(user)
91
- self.removeUser(user)
92
- else
93
- self.addUser(user)
94
-
95
- memberAddModal.addUser = (user) ->
96
- self = memberAddModal
97
- unless self.hasUser(user)
98
- self.users.push(user)
99
-
100
- memberAddModal.removeUser = (user) ->
101
- self = memberAddModal
102
- if (idx = self.users.indexOf(user)) >= 0
103
- self.users.splice(idx,1)
104
-
105
- memberAddModal.proceed = ->
106
- self = memberAddModal
107
- self.isLoading = true
108
- DhbTeamSvc.members.add(self.team.id,self.users).then(
109
- (users) ->
110
- self.errors = ''
111
- angular.copy(users,self.team.users)
112
- self.close()
113
- , (errors) ->
114
- self.errors = Utilities.processRailsError(errors)
115
- ).finally(-> self.isLoading = false)
116
-
117
- #====================================
118
- # Team: Member Removal Modal
119
- #====================================
120
- $scope.memberRemovalModal = memberRemovalModal = {}
121
- memberRemovalModal.config = {
122
- instance: {
123
- backdrop: 'static'
124
- templateUrl: TemplatePath['mno_enterprise/dashboard/teams/member-removal-modal.html']
125
- size: 'lg'
126
- windowClass: 'inverse team-member-removal-modal'
127
- scope: $scope
128
- }
129
- }
130
-
131
- memberRemovalModal.open = (team,user) ->
132
- self = memberRemovalModal
133
- self.team = team
134
- self.user = user
135
- self.$instance = $modal.open(self.config.instance)
136
- self.isLoading = false
137
-
138
- memberRemovalModal.close = ->
139
- self = memberRemovalModal
140
- self.$instance.close()
141
-
142
- memberRemovalModal.proceed = ->
143
- self = memberRemovalModal
144
- self.isLoading = true
145
- DhbTeamSvc.members.remove(self.team.id,[self.user]).then(
146
- (users) ->
147
- self.errors = ''
148
- angular.copy(users,self.team.users)
149
- self.close()
150
- , (errors) ->
151
- self.errors = Utilities.processRailsError(errors)
152
- ).finally(-> self.isLoading = false)
153
-
154
- #====================================
155
- # Post-Initialization
156
- #====================================
157
- refresh = ->
158
- $q.all([DhbOrganizationSvc.load(),DhbTeamSvc.load()]).then (values)->
159
- $scope.initialize(values[1])
160
-
161
- contextObj = ->
162
- { orgId: DhbOrganizationSvc.getId(), teams: DhbTeamSvc.data}
163
-
164
- # Combined Watch
165
- # reload on org id change and team change
166
- $scope.$watch contextObj, refresh, true
167
-
168
- ])
169
-
170
- module.directive('dashboardOrganizationTeamList', ['TemplatePath', (TemplatePath) ->
171
- return {
172
- restrict: 'A',
173
- scope: {
174
- title: '@'
175
- },
176
- templateUrl: TemplatePath['mno_enterprise/dashboard/teams/team-list.html'],
177
- controller: 'DashboardOrganizationTeamListCtrl'
178
- }
179
- ])
@@ -1,268 +0,0 @@
1
- module = angular.module('maestrano.dashboard.dashboard-organization-teams',['maestrano.assets'])
2
-
3
- #============================================
4
- #
5
- #============================================
6
- module.controller('DashboardOrganizationTeamsCtrl',[
7
- '$scope','$window','DhbOrganizationSvc', 'DhbTeamSvc', 'DashboardAppsDocument', 'Utilities','AssetPath','$modal', '$q','TemplatePath',
8
- ($scope, $window, DhbOrganizationSvc, DhbTeamSvc, DashboardAppsDocument, Utilities, AssetPath,$modal,$q,TemplatePath) ->
9
- #====================================
10
- # Pre-Initialization
11
- #====================================
12
- $scope.assetPath = AssetPath
13
- $scope.isLoading = true
14
- $scope.teams = []
15
- $scope.originalTeams = []
16
- $scope.appInstances = []
17
-
18
- #====================================
19
- # Scope Management
20
- #====================================
21
- # Initialize the data used by the directive
22
- $scope.initialize = (teams,appInstances) ->
23
- angular.copy(teams,$scope.teams)
24
- angular.copy(teams,$scope.originalTeams)
25
- realAppInstances = _.filter(appInstances, (i) -> i.status != 'terminated')
26
- angular.copy(realAppInstances,$scope.appInstances)
27
- $scope.isLoading = false
28
-
29
- $scope.isTeamEmpty = (team) ->
30
- team.users.length == 0
31
-
32
- $scope.hasTeams = ->
33
- $scope.teams.length > 0
34
-
35
- $scope.hasApps = ->
36
- $scope.appInstances.length > 0
37
-
38
- #====================================
39
- # Permissions matrix
40
- #====================================
41
- $scope.matrix = matrix = {}
42
- matrix.isLoading = false
43
-
44
- # Check if a team has access to the specified
45
- # app_instance
46
- # If appInstance is equal to the string 'all'
47
- # then it checks if the team has access to all
48
- # appInstances
49
- matrix.hasAccess = (team,appInstance) ->
50
- if angular.isString(appInstance) && appInstance == 'all'
51
- _.reduce($scope.appInstances,
52
- (memo,elem) ->
53
- memo && _.find(team.app_instances,(i)-> i.id == elem.id)?
54
- ,true
55
- )
56
- else
57
- _.find(team.app_instances,(i)-> i.id == appInstance.id)?
58
-
59
- # Add access to the app if the team does not have
60
- # access and remove access if the team already
61
- # have access
62
- matrix.toggleAccess = (team,appInstance) ->
63
- self = matrix
64
- if (self.hasAccess(team,appInstance))
65
- self.removeAccess(team,appInstance)
66
- else
67
- self.addAccess(team,appInstance)
68
-
69
- # Add access to a specified appInstance
70
- # If appInstance is equal to the string 'all'
71
- # then it adds permissions to all appInstances
72
- matrix.addAccess = (team,appInstance) ->
73
- if angular.isString(appInstance) && appInstance == 'all'
74
- team.app_instances.length = 0
75
- angular.copy($scope.appInstances,team.app_instances)
76
- else
77
- unless _.find(team.app_instances, (e)-> e.id == appInstance.id)?
78
- team.app_instances.push(appInstance)
79
-
80
- # Remove access to a specified appInstance
81
- # If appInstance is equal to the string 'all'
82
- # then it removes permissions to all appInstances
83
- matrix.removeAccess = (team,appInstance) ->
84
- if angular.isString(appInstance) && appInstance == 'all'
85
- team.app_instances.length = 0
86
- else
87
- if (elem = _.find(team.app_instances, (e)-> e.id == appInstance.id))?
88
- idx = team.app_instances.indexOf(elem)
89
- team.app_instances.splice(idx,1)
90
-
91
- # Open the 'add team' modal
92
- matrix.addTeam = ->
93
- addTeamModal.open()
94
-
95
- # Open the 'remove team' modal
96
- matrix.removeTeam = (team)->
97
- teamDeletionModal.open(team)
98
-
99
- matrix.compileHash = (teams) ->
100
- _.reduce teams,
101
- (hash,t) ->
102
- hash += "#{t.id}:"
103
- hash += _.sortBy(_.pluck(t.app_instances,'id'),(n)->n).join()
104
- hash += "::"
105
- ,""
106
-
107
- matrix.isChanged = ->
108
- self = matrix
109
- self.compileHash($scope.teams) != self.compileHash($scope.originalTeams)
110
-
111
- matrix.cancel = ->
112
- _.each $scope.teams, (t) ->
113
- ot = _.find($scope.originalTeams,(e) -> e.id == t.id)
114
- angular.copy(ot.app_instances,t.app_instances)
115
-
116
- matrix.save = ->
117
- self = matrix
118
- self.isLoading = true
119
-
120
- qs = []
121
- _.each $scope.teams, (team) ->
122
- # Force empty array if no app_instances permissions
123
- realAppInstances = if team.app_instances.length >0 then team.app_instances else [{}]
124
- qs.push DhbTeamSvc.team.update(team.id,{app_instances: realAppInstances})
125
-
126
- $q.all(qs).then(
127
- (->)
128
- self.errors = ''
129
- self.updateOriginalTeams()
130
- ,(errorsArray) ->
131
- self.errors = Utilities.processRailsError(errorsArray[0])
132
- ).finally(-> self.isLoading = false)
133
-
134
- matrix.updateOriginalTeams = ->
135
- _.each $scope.teams, (t) ->
136
- ot = _.find($scope.originalTeams,(e) -> e.id == t.id)
137
- angular.copy(t.app_instances,ot.app_instances)
138
-
139
- matrix.updateTeamName = (team) ->
140
- origTeam = _.find($scope.teams, (t) -> t.id == team.id)
141
- if team.name.length == 0
142
- team.name = origTeam.name
143
- else
144
- DhbTeamSvc.team.update(team.id,{name: team.name}).then(
145
- (->)
146
- origTeam.name = team.name
147
- , ->
148
- team.name = origTeam.name
149
- )
150
-
151
- #====================================
152
- # Add Team modal
153
- #====================================
154
- $scope.addTeamModal = addTeamModal = {}
155
- addTeamModal.config = {
156
- instance: {
157
- backdrop: 'static'
158
- templateUrl: TemplatePath['mno_enterprise/dashboard/teams/team-add-modal.html']
159
- size: 'lg'
160
- windowClass: 'inverse team-add-modal'
161
- scope: $scope
162
- }
163
- }
164
-
165
- # Open the modal
166
- addTeamModal.open = ->
167
- self = addTeamModal
168
- self.model = {}
169
- self.$instance = $modal.open(self.config.instance)
170
- self.isLoading = false
171
-
172
- # Close the modal
173
- addTeamModal.close = ->
174
- self = addTeamModal
175
- self.$instance.close()
176
-
177
- # Check if proceed btn should be
178
- # disabled
179
- addTeamModal.isProceedDisabled = ->
180
- self = addTeamModal
181
- !self.model.name? || self.model.name.length == 0
182
-
183
- # Create the team then close the
184
- # modal
185
- addTeamModal.proceed = ->
186
- self = addTeamModal
187
- self.isLoading = true
188
- DhbTeamSvc.team.create(self.model).then(
189
- (team) ->
190
- self.errors = ''
191
- self.addToScope(team)
192
- self.close()
193
- , (errors) ->
194
- self.errors = Utilities.processRailsError(errors)
195
- ).finally(-> self.isLoading = false)
196
-
197
- addTeamModal.addToScope = (team) ->
198
- $scope.teams.push(angular.copy(team))
199
- $scope.originalTeams.push(angular.copy(team))
200
-
201
- #====================================
202
- # Team Deletion Modal
203
- #====================================
204
- $scope.teamDeletionModal = teamDeletionModal = {}
205
- teamDeletionModal.config = {
206
- instance: {
207
- backdrop: 'static'
208
- templateUrl: TemplatePath['mno_enterprise/dashboard/teams/team-delete-modal.html']
209
- size: 'lg'
210
- windowClass: 'inverse team-delete-modal'
211
- scope: $scope
212
- }
213
- }
214
-
215
- teamDeletionModal.open = (team) ->
216
- self = teamDeletionModal
217
- self.team = team
218
- self.$instance = $modal.open(self.config.instance)
219
- self.isLoading = false
220
- self.errors = ''
221
-
222
- teamDeletionModal.close = ->
223
- self = teamDeletionModal
224
- self.$instance.close()
225
-
226
- teamDeletionModal.proceed = ->
227
- self = teamDeletionModal
228
- self.isLoading = true
229
- DhbTeamSvc.team.destroy(self.team.id).then(
230
- (data) ->
231
- self.errors = ''
232
- self.removeFromScope(self.team)
233
- self.close()
234
- , (errors) ->
235
- self.errors = Utilities.processRailsError(errors)
236
- ).finally(-> self.isLoading = false)
237
-
238
-
239
- teamDeletionModal.removeFromScope = (team) ->
240
- team = _.find($scope.teams, (t) -> t.id == team.id)
241
- idx = $scope.teams.indexOf(team)
242
- $scope.teams.splice(idx,1) if idx >= 0
243
-
244
- team = _.find($scope.originalTeams, (t) -> t.id == team.id)
245
- idx = $scope.originalTeams.indexOf(team)
246
- $scope.originalTeams.splice(idx,1) if idx >= 0
247
-
248
-
249
- #====================================
250
- # Post-Initialization
251
- #====================================
252
-
253
- # Watch organization id and reload on change
254
- $scope.$watch DhbOrganizationSvc.getId, (orgId) ->
255
- $q.all([DhbTeamSvc.load(),DashboardAppsDocument.load()]).then (values)->
256
- $scope.initialize(DhbTeamSvc.data,_.values(DashboardAppsDocument.data))
257
-
258
- ])
259
-
260
- module.directive('dashboardOrganizationTeams', ['TemplatePath', (TemplatePath) ->
261
- return {
262
- restrict: 'A',
263
- scope: {
264
- },
265
- templateUrl: TemplatePath['mno_enterprise/dashboard/teams/index.html'],
266
- controller: 'DashboardOrganizationTeamsCtrl'
267
- }
268
- ])
@@ -1,33 +0,0 @@
1
- module = angular.module('maestrano.components.file-model',[])
2
-
3
- # Allows angular binding on <input type="file">
4
- # Usage: <input type="file" file-model="someScopeObject.file">
5
- module.directive("fileModel", [
6
- '$parse', '$compile',
7
- ($parse, $compile) ->
8
- return {
9
- restrict: 'A',
10
- link: (scope, element, attrs) ->
11
- model = $parse(attrs.fileModel)
12
- modelSetter = model.assign
13
-
14
- element.bind('change', ->
15
- scope.$apply( ->
16
- modelSetter(scope, element[0].files[0])
17
- )
18
- )
19
-
20
- # The filelist on an <input type="file"> is read only
21
- # which means we cannot clear the list of files attached to it
22
- # --
23
- # The watcher below detects when the file-model is set to null,
24
- # undefined or '' and automatically replaces the input element
25
- # by a new one (no filelist attached)
26
- scope.$watch(model
27
- , (value, oldValue)->
28
- if !angular.equals(value,oldValue) && (!value? || value = '')
29
- clone = $compile(element.clone())(scope)
30
- element.replaceWith(clone)
31
- )
32
- }
33
- ])