MCPcopy Create free account
hub / github.com/OpenTSDB/opentsdb / refreshGraph

Method refreshGraph

src/tsd/client/QueryUi.java:882–1071  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

880 }
881
882 private void refreshGraph() {
883 final Date start = start_datebox.getValue();
884 if (start == null) {
885 graphstatus.setText("Please specify a start time.");
886 return;
887 }
888 final Date end = end_datebox.getValue();
889 if (end != null && !autoreload.getValue()) {
890 if (end.getTime() <= start.getTime()) {
891 end_datebox.addStyleName("dateBoxFormatError");
892 graphstatus.setText("End time must be after start time!");
893 return;
894 }
895 }
896 final StringBuilder url = new StringBuilder();
897 url.append("q?start=");
898 final String start_text = start_datebox.getTextBox().getText();
899 if (start_text.endsWith(" ago") || start_text.endsWith("-ago")) {
900 url.append(start_text);
901 } else {
902 url.append(FULLDATE.format(start));
903 }
904 if (end != null && !autoreload.getValue()) {
905 url.append("&end=");
906 final String end_text = end_datebox.getTextBox().getText();
907 if (end_text.endsWith(" ago") || end_text.endsWith("-ago")) {
908 url.append(end_text);
909 } else {
910 url.append(FULLDATE.format(end));
911 }
912 } else {
913 // If there's no end-time, the graph may change while the URL remains
914 // the same. No browser seems to re-fetch an image once it's been
915 // fetched, even if we destroy the DOM object and re-created it with the
916 // same src attribute. This has nothing to do with caching headers sent
917 // by the server. The browsers simply won't retrieve the same URL again
918 // through JavaScript manipulations, period. So as a workaround, we add
919 // a special parameter that the server will delete from the query.
920 url.append("&ignore=" + nrequests++);
921 }
922 if (global_annotations.getValue()) {
923 url.append("&global_annotations");
924 }
925
926 if(timezone.length() > 1)
927 url.append("&tz=").append(timezone);
928
929 if (!addAllMetrics(url)) {
930 return;
931 }
932 addLabels(url);
933 addFormats(url);
934 addYRanges(url);
935 addLogscales(url);
936 if (nokey.getValue()) {
937 url.append("&nokey");
938 } else if (!keypos.isEmpty() || horizontalkey.getValue()) {
939 url.append("&key=");

Callers 7

onEventMethod · 0.95
gotMethod · 0.95
onValueChangeMethod · 0.95
onClickMethod · 0.95
onHistoryChangedMethod · 0.95
runMethod · 0.95
endSelectionMethod · 0.80

Calls 13

addAllMetricsMethod · 0.95
addLabelsMethod · 0.95
addFormatsMethod · 0.95
addYRangesMethod · 0.95
addLogscalesMethod · 0.95
asyncGetJsonMethod · 0.95
isEmptyMethod · 0.80
getValueMethod · 0.45
getTimeMethod · 0.45
appendMethod · 0.45
toStringMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected