step4.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. var App = require('app');
  19. App.MainAdminSecurityAddStep4View = Em.View.extend({
  20. templateName: require('templates/main/admin/security/add/step4'),
  21. didInsertElement: function () {
  22. this.get('controller').loadStep();
  23. },
  24. msgColor: 'alert-info',
  25. message: Em.I18n.t('admin.security.step4.body.header'),
  26. onResult: function () {
  27. var stage1 = this.get('controller.stages').findProperty('stage', 'stage2');
  28. var stage2 = this.get('controller.stages').findProperty('stage', 'stage3');
  29. var stage3 = this.get('controller.stages').findProperty('stage', 'stage4');
  30. if (stage2 && stage2.get('isSuccess') === true ) {
  31. this.set('message', Em.I18n.t('admin.security.step4.body.success.header'));
  32. this.set('msgColor','alert-success');
  33. } else if ((stage1 && stage1.get('isError') === true) || (stage2 && stage2.get('isError') === true)) {
  34. this.set('message', Em.I18n.t('admin.security.step4.body.failure.header'));
  35. this.set('msgColor','alert-error');
  36. } else {
  37. this.set('message', Em.I18n.t('admin.security.step4.body.header'));
  38. this.set('msgColor','alert-info');
  39. }
  40. }.observes('controller.stages.@each.isCompleted')
  41. });
  42. App.StageStatusView = Em.View.extend({
  43. tagName: 'tr',
  44. hasStarted: null,
  45. classNameBindings: ['faintText']
  46. });
  47. App.StageSuccessView = Em.View.extend({
  48. template: Ember.Handlebars.compile('<i class="icon-ok icon-large"></i> {{t common.done}}')
  49. });
  50. App.StageFailureView = Em.View.extend({
  51. template: Ember.Handlebars.compile('<i class="icon-remove icon-large"></i> {{t comomn.failed}}')
  52. });
  53. App.StageInProgressView = Em.View.extend({
  54. stage: null,
  55. classNames: ['progress-striped', 'active', 'progress'],
  56. template: Ember.Handlebars.compile('<div class="bar" {{bindAttr style="stage.barWidth"}}></div>'),
  57. isStageCompleted: function () {
  58. return this.get('obj.progress') == 100 || this.get('controller.isStepCompleted');
  59. }.property('controller.isStepCompleted', 'obj.progress')
  60. });