Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

app.js 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. 'use strict';
  2. /* App Module */
  3. angular.module('app', [
  4. 'ui.bootstrap',
  5. 'ui.router',
  6. 'LocalStorageModule',
  7. 'ngMaterial',
  8. 'md.data.table',
  9. 'sasrio.angular-material-sidenav',
  10. 'pascalprecht.translate',
  11. 'angular-busy',
  12. 'luticate2Utils',
  13. 'SignalR',
  14. // 'luticateAuth',
  15. 'appSdk'
  16. ])
  17. .config(['$stateProvider', '$urlRouterProvider', 'ssSideNavSectionsProvider', '$mdThemingProvider', '$mdIconProvider', '$translateProvider',
  18. function($stateProvider, $urlRouterProvider, ssSideNavSectionsProvider, $mdThemingProvider, $mdIconProvider, $translateProvider) {
  19. // $mdThemingProvider
  20. // .theme('default')
  21. // .primaryPalette('blue', {
  22. // 'default': '700'
  23. // });
  24. // $mdThemingProvider.theme('default')
  25. // .primaryPalette('blue')
  26. // .accentPalette('pink');
  27. $translateProvider.useSanitizeValueStrategy('escape');
  28. $translateProvider.useMessageFormatInterpolation();
  29. $translateProvider.useStaticFilesLoader({
  30. prefix: 'translations/',
  31. suffix: '.json'
  32. });
  33. $translateProvider.preferredLanguage('en');
  34. $mdIconProvider
  35. .icon('md-toggle-arrow', 'img/arrow.svg');
  36. ssSideNavSectionsProvider.initWithTheme($mdThemingProvider);
  37. ssSideNavSectionsProvider.initWithSections([{
  38. id: 'toogle_1',
  39. name: 'home.name',
  40. type: 'heading',
  41. children: [{
  42. name: 'home.name',
  43. type: 'toggle',
  44. pages: [{
  45. id: 'toogle_1_link_1',
  46. name: 'home.name',
  47. state: 'home'
  48. }, {
  49. id: 'toogle_1_link_2',
  50. name: 'Home 1 2',
  51. state: 'home.1.2',
  52. hidden: true
  53. }, {
  54. id: 'toogle_1_link_3',
  55. name: 'home.name',
  56. state: 'home.1.3'
  57. }]
  58. }]
  59. }, {
  60. id: 'link_1',
  61. name: 'home.name',
  62. state: 'home.2',
  63. type: 'link',
  64. icon: 'fa fa-check'
  65. }, {
  66. id: 'link_2',
  67. name: 'home.name',
  68. state: 'home.3',
  69. type: 'link'
  70. }, {
  71. id: 'link_3',
  72. name: 'home.name',
  73. state: 'common.link3',
  74. type: 'link',
  75. hidden: true
  76. }, {
  77. id: 'toogle_2',
  78. name: 'pkguid.name',
  79. type: 'heading',
  80. children: [{
  81. name: 'pkguid.name',
  82. type: 'toggle',
  83. pages: [{
  84. id: 'toogle_2_link_1',
  85. name: 'common.all',
  86. state: 'pkguid'
  87. },{
  88. id: 'toogle_2_link_1',
  89. name: 'common.new',
  90. state: 'pkguid_add'
  91. }]
  92. }]
  93. }]);
  94. $stateProvider.state('root', {
  95. abstract: true,
  96. template: '<div ui-view=""></div>',
  97. // resolve: ['luticateAuthUsers', function(luticateAuthUsers)
  98. // {
  99. // return luticateAuthUsers.loadUserData(null);
  100. // }]
  101. });
  102. $stateProvider.state('home', {
  103. url:'/',
  104. parent: 'root',
  105. title: "home.name",
  106. reloadOnSearch: false,
  107. templateUrl:'views/home.html',
  108. controller:'HomeController'
  109. });
  110. $stateProvider.state('pkguid', {
  111. url:'/pkguids',
  112. parent: 'root',
  113. title: "pkguid.name",
  114. reloadOnSearch: false,
  115. templateUrl:'views/pkguid.html',
  116. controller:'PkGuidController'
  117. });
  118. $stateProvider.state('pkguid_add', {
  119. url:'/pkguids/add',
  120. parent: 'root',
  121. title: "pkguid.add.defaultTitle",
  122. toolbarTitle: "pkguid.add.defaultToolbarTitle",
  123. reloadOnSearch: false,
  124. templateUrl:'views/pkguidedit.html',
  125. controller:'PkGuidEditController',
  126. params: {
  127. pkguid: null
  128. }
  129. });
  130. $stateProvider.state('pkguid_edit', {
  131. url:'/pkguids/edit/:id',
  132. parent: 'root',
  133. title: "pkguid.edit.defaultTitle",
  134. toolbarTitle: "pkguid.edit.defaultToolbarTitle",
  135. reloadOnSearch: false,
  136. templateUrl:'views/pkguidedit.html',
  137. controller:'PkGuidEditController',
  138. params: {
  139. pkguid: null
  140. }
  141. });
  142. $urlRouterProvider.otherwise('/');
  143. }])
  144. .run(['$rootScope', '$transitions', 'AppUtilsBusiness', 'ssSideNav', '$translate', 'luRequest', '$mdDialog', 'luNotificationsBusiness', '$mdToast', '$state',
  145. function ($rootScope, $transitions, AppUtilsBusiness, ssSideNav, $translate, luRequest, $mdDialog, luNotificationsBusiness, $mdToast, $state) {
  146. AppUtilsBusiness.addApiVersionChangedCallback(function(oldVersion, newVersion) {
  147. $mdDialog.show(
  148. $mdDialog.alert()
  149. .title(AppUtilsBusiness.tr('common.updateDetected.title'))
  150. .textContent(AppUtilsBusiness.tr('common.updateDetected.text',
  151. {oldVersion: oldVersion, newVersion: newVersion}))
  152. .ok(AppUtilsBusiness.tr('common.ok')));
  153. });
  154. luNotificationsBusiness.init();
  155. luNotificationsBusiness.addEventCrudCallback('pkguid', function(eventName, entityType, oldEntity, newEntity)
  156. {
  157. var text = null;
  158. if (eventName == luNotificationsBusiness.EVENT_CREATE) {
  159. text = AppUtilsBusiness.tr('pkguid.notifications.create', {text: newEntity.someText});
  160. }
  161. else if (eventName == luNotificationsBusiness.EVENT_UPDATE) {
  162. text = AppUtilsBusiness.tr('pkguid.notifications.update', {text: newEntity.someText});
  163. }
  164. else if (eventName == luNotificationsBusiness.EVENT_DELETE) {
  165. text = AppUtilsBusiness.tr('pkguid.notifications.delete', {text: oldEntity.someText});
  166. }
  167. var toast = $mdToast.simple()
  168. .textContent(text)
  169. .action(eventName == luNotificationsBusiness.EVENT_DELETE ? AppUtilsBusiness.tr('common.undo') : AppUtilsBusiness.tr('common.view'))
  170. .highlightAction(true)
  171. .highlightClass('md-accent')
  172. .position('bottom right');
  173. $mdToast.show(toast).then(function(response) {
  174. if (response == 'ok') {
  175. if (eventName == luNotificationsBusiness.EVENT_DELETE) {
  176. oldEntity.id = null;
  177. $state.go('pkguid_add', {pkguid: oldEntity});
  178. }
  179. else {
  180. $state.go('pkguid_edit', {id: newEntity.id, pkguid: newEntity});
  181. }
  182. }
  183. });
  184. });
  185. // luNotificationsBusiness.addEventDeleteCallback('pkguid', function(eventName, entityType, oldEntity)
  186. // {
  187. // var toast = $mdToast.simple()
  188. // .textContent("PkGuid \'" + oldEntity.someText + "\' was deleted")
  189. // .action("Undo")
  190. // .highlightAction(true)
  191. // .highlightClass('md-accent')
  192. // .position('bottom right');
  193. //
  194. // $mdToast.show(toast).then(function(response) {
  195. // if (response == 'ok') {
  196. // oldEntity.id = null;
  197. // $state.go('pkguid_add', {pkguid: oldEntity});
  198. // }
  199. // });
  200. // });
  201. //
  202. // luNotificationsBusiness.addEventCreateCallback('pkguid', function(eventName, entityType, oldEntity, newEntity)
  203. // {
  204. // var toast = $mdToast.simple()
  205. // .textContent("PkGuid \'" + newEntity.someText + "\' was added")
  206. // .action("View")
  207. // .highlightAction(true)
  208. // .highlightClass('md-accent')
  209. // .position('bottom right');
  210. //
  211. // $mdToast.show(toast).then(function(response) {
  212. // if (response == 'ok') {
  213. // $state.go('pkguid_edit', {id: newEntity.id, pkguid: newEntity});
  214. // }
  215. // });
  216. // });
  217. $translate('common.appName').then(function() {
  218. for (var i = 0; i < ssSideNav.sections.length; ++i) {
  219. var a = ssSideNav.sections[i];
  220. a.name = AppUtilsBusiness.tr(a.name);
  221. if (a.children != null) {
  222. for (var j = 0; j < a.children.length; ++j) {
  223. var b = a.children[j];
  224. b.name = AppUtilsBusiness.tr(b.name);
  225. if (b.pages != null) {
  226. for (var k = 0; k < b.pages.length; ++k) {
  227. var c = b.pages[k];
  228. c.name = AppUtilsBusiness.tr(c.name);
  229. }
  230. }
  231. }
  232. }
  233. }
  234. }, function (error) {
  235. console.error(error);
  236. });
  237. $transitions.onEnter({}, function($transitions)
  238. {
  239. var toState = $transitions.$to();
  240. var title = toState.title != null ? toState.title : toState.toolbarTitle != null ? toState.toolbarTitle : null;
  241. var toolbarTitle = toState.toolbarTitle != null ? toState.toolbarTitle : toState.title != null ? toState.title : null;
  242. if (title != null) {
  243. AppUtilsBusiness.setTitle(AppUtilsBusiness.tr(title));
  244. }
  245. if (toolbarTitle != null) {
  246. AppUtilsBusiness.setToolbarTitle(AppUtilsBusiness.tr(toolbarTitle));
  247. }
  248. });
  249. }]);