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-24211 Implement search page and panel
- Loading branch information
Showing
36 changed files
with
955 additions
and
22 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,51 @@ | ||
/* | ||
* Copyright 2016 LinkedIn Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
|
||
shouldShowPrevious: false, | ||
shouldShowNext: false, | ||
nextPageNumber: 1, | ||
previousPageNumber: 1, | ||
|
||
didReceiveAttrs() { | ||
this._super(...arguments); | ||
let currentPage = this.get('paging.currentPage'); | ||
|
||
/** | ||
* if currentPage is not first page, show previous button and assign a page number to previous button | ||
*/ | ||
if (currentPage > 1) { | ||
this.set('shouldShowPrevious', true); | ||
this.set('previousPageNumber', currentPage - 1); | ||
} else { | ||
this.set('shouldShowPrevious', false); | ||
this.set('previousPageNumber', 1); | ||
} | ||
|
||
/** | ||
* if currentPage is not the last page, show next button and assign a page number to next button | ||
*/ | ||
if (currentPage != this.get("paging.numberOfPages")) { | ||
this.set("shouldShowNext", true); | ||
this.set("nextPageNumber", currentPage + 1); | ||
} else { | ||
this.set("shouldShowNext", 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,61 @@ | ||
/* | ||
* Copyright 2016 LinkedIn Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
import Ember from 'ember'; | ||
|
||
const APPLICATION_TYPES = { | ||
workflow: "Workflow", job: "Job", application: "Application" | ||
}; | ||
|
||
export default Ember.Component.extend({ | ||
|
||
searchQuery: null, | ||
selectedType: APPLICATION_TYPES.workflow, | ||
applicationTypes: [APPLICATION_TYPES.workflow, APPLICATION_TYPES.job, APPLICATION_TYPES.application], | ||
|
||
notifications: Ember.inject.service('notification-messages'), | ||
|
||
actions: { | ||
selected(selectionName) { | ||
if (selectionName === "Advanced") { | ||
// go to advanced search when Advanced is clicked | ||
this.get('router').transitionTo("search"); | ||
} else { | ||
this.set("selectedType", selectionName); | ||
} | ||
}, | ||
|
||
search() { | ||
let searchText = this.get("searchQuery"); | ||
let type = this.get("selectedType"); | ||
|
||
if (searchText === "" || searchText == null) { | ||
this.get('notifications').error('Search field cannot be empty!', { | ||
autoClear: true | ||
}); | ||
return; | ||
} | ||
|
||
if (type === APPLICATION_TYPES.workflow) { | ||
this.get('router').transitionTo('workflow', {queryParams: {workflowid: searchText}}); | ||
} else if (type === APPLICATION_TYPES.job) { | ||
this.get('router').transitionTo('job', {queryParams: {jobid: searchText}}); | ||
} else if (type === APPLICATION_TYPES.application) { | ||
this.get('router').transitionTo('app', {queryParams: {applicationid: searchText}}); | ||
} | ||
} | ||
} | ||
}); |
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
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,194 @@ | ||
/* | ||
* Copyright 2016 LinkedIn Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
import Ember from 'ember'; | ||
import moment from 'moment'; | ||
|
||
export default Ember.Controller.extend({ | ||
notifications: Ember.inject.service('notification-messages'), | ||
|
||
queryParams: ['username', 'queueName', 'jobType', 'severity', 'analysis', 'finishTimeBegin', 'finishTimeEnd', | ||
'offset', 'limit'], | ||
|
||
/** query params **/ | ||
username: null, | ||
queueName: null, | ||
jobType: null, | ||
severity: null, | ||
analysis: null, | ||
finishTimeBegin: null, | ||
finishTimeEnd: null, | ||
offset: null, | ||
limit: null, | ||
|
||
/** values binded to form inputs **/ | ||
finishTimeBeginValue: null, | ||
finishTimeEndValue: null, | ||
isJobTypeChecked: false, | ||
isSeverityChecked: false, | ||
isFinishDateChecked: false, | ||
|
||
/** pagination variables **/ | ||
paging: null, | ||
shouldShowPaging: false, | ||
entriesPerPage: 20, | ||
maxPagesToShow: 10, | ||
currentPage: 1, | ||
|
||
/** | ||
* Watcher for model. We need this watcher for paging and notifications | ||
*/ | ||
watchModel: Ember.observer('model.summaries', function () { | ||
var totalEntries = this.get("model.summaries.total"); | ||
var startOfEntries = this.get("model.summaries.start"); | ||
|
||
var numberOfPages = Math.ceil(totalEntries / this.get("entriesPerPage")); | ||
var startPage = Math.ceil((startOfEntries + 1) / this.get("entriesPerPage")); | ||
|
||
var currentPage = Math.ceil((startOfEntries + 1) / this.get("entriesPerPage")); | ||
|
||
var pages = []; | ||
for (var i = startPage; i <= Math.min(numberOfPages, startPage + this.get("maxPagesToShow")); i++) { | ||
var singleObject = {}; | ||
singleObject['number'] = (i); | ||
pages.push(singleObject); | ||
} | ||
|
||
/** show paging when number of pages are more than one **/ | ||
if (numberOfPages > 1) { | ||
this.set("shouldShowPaging", true); | ||
} else { | ||
this.set("shouldShowPaging", false); | ||
} | ||
|
||
/** set variables for paging **/ | ||
this.set("currentPage", currentPage); | ||
this.set("paging", {pages: pages, currentPage: currentPage, numberOfPages: numberOfPages}); | ||
|
||
/** show notification if no results **/ | ||
if (this.get("model.summaries.total") == 0) { | ||
this.get('notifications').error('No applications found for given query!', { | ||
autoClear: true | ||
}); | ||
} | ||
}), | ||
|
||
/** | ||
* Watches the finishTimeBeginValue. We need to set finishTimeBegin this way to make datepicker work | ||
*/ | ||
watchFinishTimeBeginValue: Ember.observer('finishTimeBeginValue', function () { | ||
this.set("finishTimeBegin", this.get("finishTimeBeginValue")); | ||
}), | ||
|
||
/** | ||
* Watches the finishTimeEndValue. We need to set finishTimeEnd this way to make datepicker work | ||
*/ | ||
watchFinishTimeEndValue: Ember.observer('finishTimeEndValue', function () { | ||
this.set("finishTimeEnd", this.get("finishTimeEndValue")); | ||
}), | ||
|
||
/** | ||
* Watches the isJobTypeChecked boolean flag. This flag is true when the checkbox for jobtype is ticked. | ||
* We need to tie the jobType with the value of the jobtype selection input whenever the checkbox is checked. | ||
*/ | ||
watchJobCheck: Ember.observer('isJobTypeChecked', function () { | ||
if (!this.get("isJobTypeChecked")) { | ||
this.set("jobType", null); | ||
} else { | ||
this.set("jobType", | ||
this.get("model.searchOptions.jobcategory").get('firstObject').jobtypes.get('firstObject').name); | ||
} | ||
}), | ||
|
||
/** | ||
* Watches the isFinishDateChecked boolean flag. This flag is true when the checkbox for FinishDate is ticked. | ||
* We need to tie the finishTimeBegin and finishTimeEnd with the value of the jobtype selection input whenever the checkbox is checked. | ||
*/ | ||
watchFinishTimeCheck: Ember.observer('isFinishDateChecked', function () { | ||
this.set("finishTimeBegin", null); | ||
this.set("finishTimeEnd", null); | ||
this.set("finishTimeBeginValue", null); | ||
this.set("finishTimeEndValue", null); | ||
}), | ||
|
||
/** | ||
* Watches the isSeverityChecked boolean flag. This flag is true when the checkbox for Severity is ticked. | ||
* We need to tie the severity and analysis with the value of the severity and analysis selection input whenever the checkbox is checked. | ||
*/ | ||
watchSeverityCheck: Ember.observer('isSeverityCheched', function () { | ||
if (!this.get("isSeverityChecked")) { | ||
this.set("analysis", null); | ||
this.set("severity", null); | ||
} else { | ||
this.set("severity", this.get("model.searchOptions.severities").get('firstObject').value); | ||
} | ||
}), | ||
|
||
/** | ||
* Actions | ||
**/ | ||
actions: { | ||
|
||
/** | ||
* Actions for select inputs | ||
*/ | ||
|
||
selectHeuristic(heuristic) { | ||
this.set("analysis", heuristic); | ||
}, | ||
selectSeverity(severity) { | ||
this.set("severity", severity); | ||
}, | ||
selectJobType(jobType) { | ||
this.set("jobType", jobType); | ||
}, | ||
|
||
/** | ||
* loads the page | ||
*/ | ||
loadPage (page) { | ||
var _this = this; | ||
this.set("offset", this.get("entriesPerPage") * (page - 1)); | ||
this.set("limit", this.get("entriesPerPage")); | ||
var newsummaries = this.store.queryRecord('search-result', { | ||
'username': this.username, | ||
'queue-name': this.queueName, | ||
'job-type': this.jobType, | ||
'severity': this.severity, | ||
'analysis': this.analysis, | ||
'finished-time-begin': moment(this.get('finishTimeBegin')).valueOf(), | ||
'finished-time-end': moment(this.get('finishTimeEnd')).valueOf(), | ||
'type': this.type, | ||
'offset': this.offset, | ||
'limit': this.limit | ||
}); | ||
|
||
/** | ||
* update model after fetching the searched data | ||
*/ | ||
newsummaries.then(() => { | ||
_this.set("model.summaries", newsummaries) | ||
}); | ||
}, | ||
|
||
/** | ||
* loads the first page | ||
*/ | ||
search: function () { | ||
this.send('loadPage', 1); | ||
} | ||
} | ||
}); |
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,24 @@ | ||
/* | ||
* Copyright 2016 LinkedIn Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
import Ember from 'ember'; | ||
|
||
export function gt(params) { | ||
let[first,second] = params; | ||
return first>second; | ||
} | ||
|
||
export default Ember.Helper.helper(gt); |
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
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,8 @@ | ||
export function initialize(application) { | ||
application.inject('controller', 'notifications', 'service:notification-messages'); | ||
} | ||
|
||
export default { | ||
name: 'inject-notifications', | ||
initialize: initialize | ||
}; |
Oops, something went wrong.