main.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. module.exports = Em.Route.extend({
  19. route: '/main',
  20. enter: function (router) {
  21. console.log('in /main:enter');
  22. if (router.getAuthenticated()) {
  23. // TODO: redirect to last known state
  24. /*
  25. Ember.run.next(function () {
  26. router.transitionTo('step' + router.getInstallerCurrentStep());
  27. });
  28. */
  29. } else {
  30. Ember.run.next(function () {
  31. router.transitionTo('login');
  32. });
  33. }
  34. },
  35. connectOutlets: function (router, context) {
  36. router.get('applicationController').connectOutlet('main');
  37. },
  38. charts:Em.Route.extend({
  39. route:'/charts',
  40. connectOutlets:function (router, context) {
  41. router.get('mainController').connectOutlet('mainCharts');
  42. }
  43. }),
  44. hosts:Em.Route.extend({
  45. route:'/hosts',
  46. connectOutlets:function (router, context) {
  47. router.get('mainController').connectOutlet('mainHosts');
  48. }
  49. }),
  50. admin:Em.Route.extend({
  51. route:'/admin',
  52. connectOutlets:function (router, context) {
  53. router.get('mainController').connectOutlet('mainAdmin');
  54. }
  55. }),
  56. dashboard:Em.Route.extend({
  57. route:'/dashboard',
  58. connectOutlets:function (router, context) {
  59. router.get('mainController').connectOutlet('mainDashboard');
  60. }
  61. }),
  62. service:Em.Route.extend({
  63. route:'/services',
  64. enter:function (router) {
  65. Ember.run.next(function () {
  66. var service = router.get('mainServiceItemController.content');
  67. if (!service) {
  68. service = App.Service.find(1); // getting the first service to display
  69. }
  70. router.transitionTo('advanced', service);
  71. });
  72. },
  73. connectOutlets:function (router, context) {
  74. router.get('mainController').connectOutlet('mainService');
  75. },
  76. advanced:Em.Route.extend({
  77. route:'/:name',
  78. connectOutlets:function (router, service) {
  79. router.get('mainServiceController').connectOutlet('mainServiceItem', service);
  80. }
  81. }),
  82. showService: Em.Router.transitionTo('advanced')
  83. }),
  84. navigate:function (router, event) {
  85. var parent = event.view._parentView;
  86. parent.deactivateChildViews();
  87. event.view.set('active', "active");
  88. router.transitionTo(event.context);
  89. }
  90. // TODO: create new routes here
  91. // dashboard
  92. // charts
  93. // hosts
  94. // hosts/:hostname
  95. // admin
  96. // etc...
  97. });