dataset.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.Dataset = DS.Model.extend({
  20. name: DS.attr('string'),
  21. status: DS.attr('string'),
  22. sourceClusterName: DS.attr('string'),
  23. targetClusterName: DS.attr('string'),
  24. sourceDir: DS.attr('string'),
  25. targetDir: DS.attr('string'),
  26. frequency: DS.attr('string'),
  27. frequencyUnit: DS.attr('string'),
  28. scheduleStartDate: DS.attr('string'),
  29. scheduleEndDate: DS.attr('string'),
  30. datasetJobs: DS.hasMany('App.DataSetJob'),
  31. // name with special prefix to distinguish feeds created with Ambari
  32. prefixedName: function () {
  33. return App.mirroringDatasetNamePrefix + this.get('name');
  34. }.property('name'),
  35. statusFormatted: function (){
  36. var status = this.get('status');
  37. if (status) {
  38. return status.toLowerCase().capitalize();
  39. }
  40. }.property('status'),
  41. isRunning: function () {
  42. return this.get('status') === 'RUNNING';
  43. }.property('status'),
  44. isSuspended: function () {
  45. return this.get('status') === 'SUSPENDED';
  46. }.property('status'),
  47. isSubmitted: function () {
  48. return this.get('status') === 'SUBMITTED';
  49. }.property('status'),
  50. //Last succeeded date. Will be calculated later.
  51. lastSucceededDate: function () {
  52. return '';
  53. }.property(),
  54. //Next instance to run. Will be calculated later.
  55. nextInstance: function () {
  56. return '';
  57. }.property(),
  58. //Class name for dataset health status indicator
  59. healthClass: function () {
  60. var jobs = this.get('datasetJobs').toArray();
  61. jobs = jobs.filterProperty('status', 'FAILED').concat(jobs.filterProperty('status', 'SUCCESSFUL'));
  62. jobs = jobs.sortProperty('endDate');
  63. return jobs.length && jobs[0].get('status') === 'FAILED' ? 'health-status-DEAD-RED' : 'health-status-LIVE';
  64. }.property('datasetJobs', 'datasetJobs.@each.status'),
  65. healthIconClass: function () {
  66. switch (this.get('healthClass')) {
  67. case 'health-status-LIVE':
  68. return App.healthIconClassGreen;
  69. break;
  70. case 'health-status-DEAD-RED':
  71. return App.healthIconClassRed;
  72. break;
  73. default:
  74. return "";
  75. break;
  76. }
  77. }.property('healthClass')
  78. });
  79. App.Dataset.FIXTURES = [];