progress_bar_view.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.ProgressBarView = Em.View.extend({
  20. template: Ember.Handlebars.compile('<div class="bar" {{bindAttr style="view.progressWidth"}}></div>'),
  21. classNameBindings: ['generalClass', 'barClass'],
  22. /**
  23. * @type {number}
  24. * @default null
  25. */
  26. progress: null,
  27. /**
  28. * @type {string}
  29. * @default null
  30. */
  31. status: null,
  32. /**
  33. * @type {string}
  34. */
  35. generalClass: 'progress',
  36. /**
  37. * string format: width:<number>%;
  38. * @type {string}
  39. */
  40. progressWidth: Em.computed.format('width:{0}%;', 'progress'),
  41. /**
  42. * @type {string}
  43. */
  44. barClass: function () {
  45. switch (this.get('status')) {
  46. case 'FAILED':
  47. return 'progress-danger';
  48. case 'ABORTED':
  49. case 'TIMED_OUT':
  50. return 'progress-warning';
  51. case 'COMPLETED':
  52. return 'progress-success';
  53. case 'QUEUED':
  54. case 'PENDING':
  55. case 'IN_PROGRESS':
  56. return 'progress-info active progress-striped';
  57. default:
  58. return 'progress-info'
  59. }
  60. }.property('status')
  61. });