Skip to content

Commit

Permalink
Add filtering on Job Definition Id in the Search view (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Kestemont authored and akshayrai committed Jul 28, 2017
1 parent cc8e5dd commit f777264
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 13 deletions.
29 changes: 17 additions & 12 deletions app/controllers/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,10 @@
import views.html.page.homePage;
import views.html.page.jobHistoryPage;
import views.html.page.searchPage;
import views.html.results.compareResults;
import views.html.results.flowDetails;
import views.html.results.oldFlowHistoryResults;
import views.html.results.jobDetails;
import views.html.results.oldJobHistoryResults;
import views.html.results.oldFlowMetricsHistoryResults;
import views.html.results.oldJobMetricsHistoryResults;
import views.html.results.searchResults;
import views.html.results.*;

import views.html.page.oldFlowHistoryPage;
import views.html.page.oldJobHistoryPage;
import views.html.results.jobHistoryResults;
import views.html.results.flowHistoryResults;
import views.html.results.flowMetricsHistoryResults;
import views.html.results.jobMetricsHistoryResults;
import views.html.page.oldHelpPage;

import com.google.gson.*;
Expand Down Expand Up @@ -241,6 +230,9 @@ public static Result search() {
String partialFlowExecId = form.get(FLOW_EXEC_ID);
partialFlowExecId = (partialFlowExecId != null) ? partialFlowExecId.trim() : null;

String jobDefId = form.get(JOB_DEF_ID);
jobDefId = jobDefId != null ? jobDefId.trim() : "";

// Search and display job details when job id or flow execution url is provided.
if (!appId.isEmpty()) {
AppResult result = AppResult.find.select("*")
Expand All @@ -260,6 +252,19 @@ public static Result search() {
.findList();
Map<IdUrlPair, List<AppResult>> map = ControllerUtil.groupJobs(results, ControllerUtil.GroupBy.JOB_EXECUTION_ID);
return ok(searchPage.render(null, flowDetails.render(flowExecPair, map)));
} else if (!jobDefId.isEmpty()) {
List<AppResult> results = AppResult.find
.select(AppResult.getSearchFields() + "," + AppResult.TABLE.JOB_DEF_ID)
.fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS, AppHeuristicResult.getSearchFields())
.where()
.eq(AppResult.TABLE.JOB_DEF_ID, jobDefId)
.findList();
Map<IdUrlPair, List<AppResult>> map = ControllerUtil.groupJobs(results, ControllerUtil.GroupBy.FLOW_EXECUTION_ID);

String flowDefId = (results.isEmpty()) ? "" : results.get(0).flowDefId; // all results should have the same flow id
IdUrlPair flowDefIdPair = new IdUrlPair(flowDefId, AppResult.TABLE.FLOW_DEF_URL);

return ok(searchPage.render(null, flowDefinitionIdDetails.render(flowDefIdPair, map)));
}

// Prepare pagination of results
Expand Down
4 changes: 4 additions & 0 deletions app/views/page/searchPage.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
<label for="form-flow-exec-id">Flow Execution URL/ID</label>
<input type="text" class="form-control" id="form-flow-exec-id" name="flow-exec-id" placeholder="Flow Exec URL/ID">
</div>
<div class="form-group">
<label for="form-job-def-id">Job Definition ID</label>
<input type="text" class="form-control" id="form-job-def-id" name="job-def-id" placeholder="Job Definition ID">
</div>
<div class="form-group">
<label for="form-username">User</label>
<input type="text" class="form-control" id="form-username" name="username" placeholder="User">
Expand Down
61 changes: 61 additions & 0 deletions app/views/results/flowDefinitionIdDetails.scala.html
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.
*@

@(flowDefIdPair: IdUrlPair, results: java.util.Map[IdUrlPair, java.util.List[models.AppResult]])

@*
* Displays all the mr jobs triggered by a job definition id grouped by flow exec id
*
* @param flowDefIdPair The flow definition id pair
* @param results A map from flow exec id to all the MR jobs triggered by the job definition id in flowDefIdPair.
*@

<div class="panel panel-default">

<div class="panel-heading">
<h3 class="panel-title">
@if(flowDefIdPair.getUrl.isEmpty){
Flow Id: @flowDefIdPair.getId
} else {
Flow Id: <a href=@flowDefIdPair.getUrl>@flowDefIdPair.getId</a>
}
</h3>
</div>

<ul class="list-group">
@for( (flowExecPair, jobs) <- results) {
<div class="list-group-item">
@if(flowExecPair.getUrl.isEmpty){
Flow Execution ID: @flowExecPair.getId
} else {
Flow Execution ID: <a href=@flowExecPair.getUrl>@flowExecPair.getId</a>
}
<div class="list-group well-lg">
@for(result <- jobs) {
<a class="list-group-item [email protected]"
href="@routes.Application.search()[email protected]">
@tags.jobSummary(result)
</a>
}
</div>
</div>
}
</ul>

</div>



2 changes: 1 addition & 1 deletion app/views/results/flowDetails.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h3 class="panel-title">
<ul class="list-group">
@for( (jobExecPair, jobs) <- results) {
<div class="list-group-item">
Job Execution URL: <a href=@jobExecPair.getUrl>@jobExecPair.getUrl</a>
Job Execution URL: <a href=@jobExecPair.getUrl>@jobExecPair.getId</a>
<div class="list-group well-lg">
@for(result <- jobs) {
<a class="list-group-item [email protected]"
Expand Down
18 changes: 18 additions & 0 deletions public/js/searchform.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $(document).ready(function(){

var jobId = $("#form-job-id");
var flowExecId = $("#form-flow-exec-id");
var jobDefId = $("#form-job-def-id");
var user = $("#form-username");
var queueName = $("#form-queue-name");
var jobtypeEnable = $("#form-job-type-enable");
Expand All @@ -45,6 +46,7 @@ $(document).ready(function(){

var updateForm = function(){
if(jobId.val()) {
jobDefId.prop('disabled', true);
flowExecId.prop('disabled', true);
user.prop('disabled', true);
queueName.prop('disabled', true);
Expand All @@ -58,6 +60,20 @@ $(document).ready(function(){
finishTimeEndDate.prop('disabled', true);
} else if(flowExecId.val()) {
jobId.prop('disabled', true);
jobDefId.prop('disabled', true);
user.prop('disabled', true);
queueName.prop('disabled', true);
severity.prop('disabled', true);
analysis.prop('disabled', true);
jobtype.prop('disabled', true);
jobtypeEnable.prop('disabled', true);
severityEnable.prop('disabled', true);
datetimeEnable.prop('disabled', true);
finishTimeBeginDate.prop('disabled', true);
finishTimeEndDate.prop('disabled', true);
} else if (jobDefId.val()) {
jobId.prop('disabled', true);
flowExecId.prop('disabled', true);
user.prop('disabled', true);
queueName.prop('disabled', true);
severity.prop('disabled', true);
Expand All @@ -71,6 +87,7 @@ $(document).ready(function(){
}
else{
jobId.prop('disabled', false);
jobDefId.prop('disabled', false);
flowExecId.prop('disabled', false);
jobtypeEnable.prop('disabled', false);
severityEnable.prop('disabled', false);
Expand Down Expand Up @@ -103,6 +120,7 @@ $(document).ready(function(){
}
jobId.on("propertychange keyup input paste", updateForm);
flowExecId.on("propertychange keyup input paste", updateForm);
jobDefId.on("propertychange keyup input paste", updateForm);
jobtypeEnable.change(updateForm);
severityEnable.change(updateForm);
datetimeEnable.change(updateForm);
Expand Down

0 comments on commit f777264

Please sign in to comment.