forked from linkedin/dr-elephant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LIHADOOP-23924 Create dashboard of Dr Elephant using ember
- Loading branch information
Showing
98 changed files
with
2,343 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import DS from 'ember-data'; | ||
import Ember from 'ember'; | ||
|
||
export default DS.JSONAPIAdapter.extend({ | ||
namespace: 'rest' | ||
}); | ||
|
||
export default DS.RESTAdapter.extend({ | ||
namespace: 'rest', | ||
pathForType: function (type) { | ||
return Ember.String.pluralize(type); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Ember from 'ember'; | ||
import Resolver from './resolver'; | ||
import loadInitializers from 'ember-load-initializers'; | ||
import config from './config/environment'; | ||
|
||
let App; | ||
|
||
Ember.MODEL_FACTORY_INJECTIONS = true; | ||
|
||
App = Ember.Application.extend({ | ||
modulePrefix: config.modulePrefix, | ||
podModulePrefix: config.podModulePrefix, | ||
Resolver | ||
}); | ||
|
||
loadInitializers(App, config.modulePrefix); | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
newUser: null, // this is binded to the text box for adding user | ||
showInputBox: false, | ||
actions: { | ||
|
||
/** | ||
* sets showInputBox to true to show the input box | ||
*/ | ||
showInput() { | ||
this.set("showInputBox", true); | ||
}, | ||
|
||
/** | ||
* sets showInputBox to false to hide the input box | ||
*/ | ||
resetInput() { | ||
this.set("showInputBox", false); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Controller.extend({ | ||
queryParams: ['applicationid'], | ||
applicationid: null, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Controller.extend({ | ||
showInputBox: false, | ||
actions: { | ||
|
||
/** | ||
* This action adds a new tab and clicks on it once the tab is added and rendered | ||
* @params user The user to be added as a tab | ||
*/ | ||
addTab(user) { | ||
this.users.addToUsername(user); | ||
this.users.setActiveUser(user); | ||
this.set('model.usernames',this.users.getUsernames()); | ||
Ember.run.scheduleOnce('afterRender', this, function() { | ||
Ember.$("#"+user).trigger("click"); | ||
}); | ||
}, | ||
|
||
/** | ||
* This action deletes the tab from the list and clicks on the `all` tab | ||
* @params tabname the tab to delete | ||
*/ | ||
deleteTab(tabname) { | ||
this.users.deleteUsername(tabname); | ||
this.set('model.usernames',this.users.getUsernames()); | ||
if(this.users.getActiveUser()===tabname) { | ||
Ember.run.scheduleOnce('afterRender', this, function () { | ||
Ember.$("#all a").trigger("click"); | ||
}); | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import users from 'dr-elephant/models/users'; | ||
import Dashboard from 'dr-elephant/controllers/dashboard'; | ||
|
||
export default Dashboard.extend({ | ||
users: new users(), | ||
loading: false, | ||
|
||
/** | ||
* This function returns the list of usernames currently stored | ||
* @returns The list of usernames currently stored | ||
*/ | ||
usernames() { | ||
return this.users.getUsernames(); | ||
}, | ||
|
||
actions: { | ||
|
||
/** | ||
* changes the tab to the clicked user | ||
* @params The name of the user tab | ||
*/ | ||
changeTab(tabname) { | ||
this.set("loading", true); | ||
this.users.setActiveUser(tabname); | ||
var _this = this; | ||
_this.store.unloadAll(); | ||
var newApplications = this.store.query('application-summary', {username: tabname}); | ||
newApplications.then(function () { | ||
_this.set("model.applications", newApplications); | ||
_this.set("loading", false); | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import users from 'dr-elephant/models/users'; | ||
import Dashboard from 'dr-elephant/controllers/dashboard'; | ||
|
||
export default Dashboard.extend({ | ||
users: new users(), | ||
loading: false, | ||
|
||
/** | ||
* This function returns the list of usernames currently stored | ||
* @returns The list of usernames currently stored | ||
*/ | ||
usernames: function () { | ||
return this.users.getUsernames(); | ||
}, | ||
actions: { | ||
|
||
/** | ||
* changes the tab to the clicked user | ||
* @params The name of the user tab | ||
*/ | ||
changeTab(tabname) { | ||
this.set("loading", true); | ||
this.users.setActiveUser(tabname); | ||
var _this = this; | ||
_this.store.unloadAll(); | ||
var newJobs = this.store.query('job-summary', {username: tabname}); | ||
newJobs.then(function () { | ||
_this.set("model.jobs", newJobs); | ||
_this.set("loading", false); | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Ember from 'ember'; | ||
import users from 'dr-elephant/models/users'; | ||
import Dashboard from 'dr-elephant/controllers/dashboard'; | ||
|
||
export default Dashboard.extend({ | ||
users: new users(), | ||
loading: false, | ||
|
||
/** | ||
* This function returns the list of usernames currently stored | ||
* @returns The list of usernames currently stored | ||
*/ | ||
usernames: function () { | ||
return this.users.getUsernames(); | ||
}, | ||
actions: { | ||
|
||
/** | ||
* changes the tab to the clicked user | ||
* @params The name of the user tab | ||
*/ | ||
changeTab(tabname) { | ||
this.set("loading", true); | ||
this.users.setActiveUser(tabname); | ||
var _this = this; | ||
_this.store.unloadAll(); | ||
var newworkflows = this.store.query('workflow-summary', {username: tabname}); | ||
newworkflows.then(function () { | ||
_this.set("model.workflows", newworkflows); | ||
_this.set("loading", false); | ||
}); | ||
} | ||
|
||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Ember from 'ember'; | ||
|
||
/** | ||
* helper takes two parameters and returns true if both are equal else returns false | ||
* @param params The parameters for the helper | ||
* @returns {boolean} | ||
*/ | ||
export function eq(params) { | ||
if (params[0] === params[1]) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
export default Ember.Helper.helper(eq); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Ember from 'ember'; | ||
|
||
/** Map to convert serverity to bootstrap class **/ | ||
const SEVERITY_TO_BOOTSTRAP_MAP = { | ||
critical: "danger", | ||
severe: "severe", | ||
moderate: "warning", | ||
low: "success", | ||
none:"success" | ||
}; | ||
|
||
/** | ||
* This helper takes the serverity as the parameter value and returns the corresponding bootstrap code | ||
* @param params The parameters | ||
* @returns one of {"danger","severe","warning","success"} | ||
*/ | ||
export function getBootstrapSeverityCode(params) { | ||
let [severity] = params; | ||
if (severity == null) { | ||
return SEVERITY_TO_BOOTSTRAP_MAP.none; | ||
} | ||
return SEVERITY_TO_BOOTSTRAP_MAP[severity.toLowerCase()]; | ||
} | ||
|
||
export default Ember.Helper.helper(getBootstrapSeverityCode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Ember from 'ember'; | ||
|
||
|
||
/** Map to convert severity to color **/ | ||
const SEVERITY_TO_COLOR_CODE_MAP = { | ||
critical: "#D9534F", | ||
severe: "#E4804E", | ||
moderate: "#F0AD4E", | ||
low: "#5CB85C", | ||
none:"#5CB85C" | ||
}; | ||
|
||
/** | ||
* Returns the color based on the severity | ||
* @param params The severity value | ||
* @returns The color based on the serverity | ||
*/ | ||
export function getColorForSeverity(params) { | ||
let [severity] = params; | ||
if(severity==null) { | ||
return SEVERITY_TO_COLOR_CODE_MAP.none; | ||
} | ||
return SEVERITY_TO_COLOR_CODE_MAP[severity.toLowerCase()]; | ||
} | ||
|
||
export default Ember.Helper.helper(getColorForSeverity); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Ember from 'ember'; | ||
|
||
/** | ||
* Returns the date from milliseconds | ||
* @param params The date to convert | ||
* @returns The converted date | ||
*/ | ||
export function getDate(params) { | ||
let [date] = params; | ||
return new Date(date); | ||
} | ||
|
||
export default Ember.Helper.helper(getDate); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Ember from 'ember'; | ||
|
||
const TIME = { | ||
milliseconds_in_seconds: 1000, | ||
seconds_in_minutes: 60, | ||
minutes_in_hours: 60, | ||
hours_in_days: 24 | ||
}; | ||
|
||
/** | ||
* Breaks down milliseconds to HH:MM:SS | ||
* @param params time in milliseconds | ||
* @returns {*} | ||
*/ | ||
export function getDurationBreakdown(params) { | ||
let [duration] = params; | ||
var seconds = parseInt((duration / TIME.milliseconds_in_seconds) % TIME.seconds_in_minutes), minutes = parseInt((duration / (TIME.milliseconds_in_seconds * TIME.seconds_in_minutes)) % TIME.minutes_in_hours), hours = parseInt((duration / (TIME.milliseconds_in_seconds * TIME.seconds_in_minutes * TIME.minutes_in_hours)) % TIME.hours_in_days); | ||
|
||
if(duration<TIME.milliseconds_in_seconds) { | ||
return "00:00:00"; | ||
} | ||
hours = (hours < 10) ? "0" + hours : hours; | ||
minutes = (minutes < 10) ? "0" + minutes : minutes; | ||
seconds = (seconds < 10) ? "0" + seconds : seconds; | ||
|
||
return hours + ":" + minutes + ":" + seconds; | ||
} | ||
|
||
export default Ember.Helper.helper(getDurationBreakdown); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Ember from 'ember'; | ||
|
||
/** | ||
* Calculates the percentage given two params | ||
* @param params The arguments for percentage | ||
* @returns The percentage in the form PP.PP% | ||
*/ | ||
export function getPercentage(params) { | ||
let [arg1, arg2] = params; | ||
if(arg2===0) { | ||
return "0%"; | ||
} | ||
|
||
var percentage = ( arg1 / arg2 ) * 100; | ||
var percentString = percentage.toFixed(2).toString()+ "%"; | ||
return percentString; | ||
} | ||
|
||
export default Ember.Helper.helper(getPercentage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Ember from 'ember'; | ||
|
||
const mbs_in_one_gb = 1024; | ||
const seconds_in_one_hour = 3600; | ||
|
||
/** | ||
* Returns the resource after converting to GB Hours | ||
* @param params The resource in MB Seconds | ||
* @returns Resource in GB Hours | ||
*/ | ||
export function getResourceInGBHours(params) { | ||
let [MBSeconds] = params; | ||
if (MBSeconds == 0) { | ||
return "0 GB Hours"; | ||
} | ||
|
||
var GBseconds = MBSeconds/mbs_in_one_gb; | ||
var GBHours = GBseconds / seconds_in_one_hour; | ||
|
||
if ((GBHours * 1000).toFixed(0) == 0) { | ||
return "0 GB Hours"; | ||
} | ||
|
||
var GBHoursString = GBHours.toFixed(3).toString(); | ||
GBHoursString = GBHoursString + " GB Hours"; | ||
return GBHoursString; | ||
} | ||
|
||
export default Ember.Helper.helper(getResourceInGBHours); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Ember from 'ember'; | ||
|
||
/** | ||
* Checks if a given string is empty | ||
* @param params | ||
* @returns {boolean} | ||
*/ | ||
export function notEmpty(params) { | ||
let [id] = params; | ||
if(id==="") { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
export default Ember.Helper.helper(notEmpty); |
Oops, something went wrong.