Skip to content

Commit

Permalink
Merge pull request #3956 from rstudio/bugfix/superfluous-progress-bar
Browse files Browse the repository at this point in the history
Show status rather than progress bar for non-ranged jobs
  • Loading branch information
jmcphers committed Nov 27, 2018
2 parents bdaf906 + 4434aad commit 4c0c738
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 15 deletions.
Expand Up @@ -16,6 +16,7 @@

import org.rstudio.studio.client.application.events.EventBus;
import org.rstudio.studio.client.workbench.views.jobs.events.JobElapsedTickEvent;
import org.rstudio.studio.client.workbench.views.jobs.model.Job;
import org.rstudio.studio.client.workbench.views.jobs.model.LocalJobProgress;

import com.google.gwt.user.client.ui.IsWidget;
Expand All @@ -29,6 +30,7 @@ public interface Display extends IsWidget
{
void updateElapsed(int timestamp);
void showProgress(LocalJobProgress progress);
void showJob(Job job);
void setComplete();
}

Expand Down Expand Up @@ -57,6 +59,11 @@ public void showProgress(LocalJobProgress progress)
display_.showProgress(progress);
}

public void showJob(Job job)
{
display_.showJob(job);
}

public void setComplete()
{
display_.setComplete();
Expand Down
Expand Up @@ -37,4 +37,23 @@ public class JobConstants
public final static int JOB_TYPE_UNKNOWN = 0;
public final static int JOB_TYPE_SESSION = 1;
public final static int JOB_TYPE_LAUNCHER = 2;


public final static String stateDescription(int state)
{
switch(state)
{
case JobConstants.STATE_RUNNING:
return "Running";
case JobConstants.STATE_IDLE:
return "Idle";
case JobConstants.STATE_CANCELLED:
return "Cancelled";
case JobConstants.STATE_FAILED:
return "Failed";
case JobConstants.STATE_SUCCEEDED:
return "Succeeded";
}
return "Unknown " + state;
}
}
Expand Up @@ -144,29 +144,24 @@ public void update(Job job)
job_ = job;

String clazz = "";
String state = "";
String state = JobConstants.stateDescription(job_.state);

switch(job_.state)
{
case JobConstants.STATE_RUNNING:
clazz = styles_.running();
state = "Running";
break;
case JobConstants.STATE_IDLE:
clazz = styles_.idle();
state = "Idle";
break;
case JobConstants.STATE_CANCELLED:
clazz = styles_.cancelled();
state = "Cancelled";
break;
case JobConstants.STATE_FAILED:
clazz = styles_.failed();
state = "Failed";
break;
case JobConstants.STATE_SUCCEEDED:
clazz = styles_.succeeded();
state = "Succeeded";
break;
}

Expand Down Expand Up @@ -229,6 +224,12 @@ else if (hasStop)
stop_.setVisible(true);
stopOrKill_.setVisible(false);
}
else
{
// can't stop OR kill
stop_.setVisible(false);
stopOrKill_.setVisible(false);
}
}
else
{
Expand Down
Expand Up @@ -14,9 +14,13 @@
*/
package org.rstudio.studio.client.workbench.views.jobs.view;

import java.util.Date;

import org.rstudio.core.client.StringUtil;
import org.rstudio.core.client.widget.ProgressBar;
import org.rstudio.studio.client.workbench.views.jobs.JobProgressPresenter;
import org.rstudio.studio.client.workbench.views.jobs.model.Job;
import org.rstudio.studio.client.workbench.views.jobs.model.JobConstants;
import org.rstudio.studio.client.workbench.views.jobs.model.LocalJobProgress;

import com.google.gwt.core.client.GWT;
Expand Down Expand Up @@ -51,6 +55,36 @@ public void showProgress(LocalJobProgress progress)
progress_.setProgress(progress.units(), progress.max());
jobProgress_ = progress;
}

@Override
public void showJob(Job job)
{
name_.setText(job.name);
if (job.max > 0)
{
progress_.setVisible(true);
progress_.setProgress(job.progress, job.max);
}
else
{
progress_.setVisible(false);
status_.setVisible(true);
String status = JobConstants.stateDescription(job.state);
if (job.completed > 0)
{
// Job is not running; show its completion status and time
status += " " + StringUtil.friendlyDateTime(new Date(job.completed * 1000));
elapsed_.setText(StringUtil.conciseElaspedTime(job.completed - job.started));
}
else if (!StringUtil.isNullOrEmpty(job.status))
{
// Still running; show its status
status = job.status;
}
status_.setText(status);
}
jobProgress_ = new LocalJobProgress(job);
}

@Override
public void updateElapsed(int timestamp)
Expand All @@ -66,13 +100,13 @@ public void updateElapsed(int timestamp)
public void setComplete()
{
progress_.setVisible(false);
elapsed_.setVisible(false);
complete_ = true;
}

@UiField Label name_;
@UiField ProgressBar progress_;
@UiField Label elapsed_;
@UiField Label status_;

private LocalJobProgress jobProgress_;
private boolean complete_;
Expand Down
Expand Up @@ -4,13 +4,18 @@
xmlns:rw="urn:import:org.rstudio.core.client.widget">
<ui:style>

.name, .elapsed
.name, .elapsed, .status
{
text-overflow: ellipsis;
overflow: hidden;
word-wrap: nowrap;
}

.status
{
color: #808080;
}

.host
{
width: 100%;
Expand All @@ -30,10 +35,13 @@
width="20%">
<g:Label styleName="{style.name}" ui:field="name_"></g:Label>
</g:cell>
<g:cell horizontalAlignment="ALIGN_CENTER"
<g:cell horizontalAlignment="ALIGN_RIGHT"
verticalAlignment="ALIGN_MIDDLE"
width="70%">
<rw:ProgressBar ui:field="progress_"></rw:ProgressBar>
<g:HTMLPanel styleName="{style.host}">
<g:Label styleName="{style.status}" ui:field="status_"></g:Label>
<rw:ProgressBar ui:field="progress_"></rw:ProgressBar>
</g:HTMLPanel>
</g:cell>
<g:cell horizontalAlignment="ALIGN_RIGHT"
verticalAlignment="ALIGN_MIDDLE"
Expand Down
Expand Up @@ -130,7 +130,7 @@ public void updateJob(int type, Job job)
progress_ = new JobProgress();
toolbar_.addLeftWidget(progress_);
}
progress_.showProgress(new LocalJobProgress(job));
progress_.showJob(job);
}
}
break;
Expand Down Expand Up @@ -190,12 +190,12 @@ public void showJobOutput(String id, JsArray<JobOutput> output, boolean animate)
progress_ = null;
}

// save job id as current job
current_ = id;

// show the output pane
panel_.slideWidgets(SlidingLayoutPanel.Direction.SlideRight,
animate, this::installJobToolbar);

// save job id as current job
current_ = id;
}

@Override
Expand Down Expand Up @@ -281,7 +281,7 @@ private void installJobToolbar()
// show progress
progress_ = new JobProgress();
toolbar_.addLeftWidget(progress_);
progress_.showProgress(new LocalJobProgress(job));
progress_.showJob(job);

// if job is complete, mark that
if (job.completed > 0)
Expand Down

0 comments on commit 4c0c738

Please sign in to comment.