mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-21 15:55:40 +00:00
Remove 'auto refresh' feature (#4503)
* Remove 'auto refresh' feature * Remove obsolete CSS
This commit is contained in:
1 parent
5729fb717e
commit
3472e10e95
97 files changed
+72
-535
No files matched your search
@@ -28,7 +28,6 @@ package hudson;
|
||||
import hudson.model.Slave;
|
||||
import hudson.security.*;
|
||||
import java.util.function.Predicate;
|
||||
import jenkins.telemetry.impl.AutoRefresh;
|
||||
import jenkins.util.SystemProperties;
|
||||
import hudson.cli.CLICommand;
|
||||
import hudson.console.ConsoleAnnotationDescriptor;
|
||||
@@ -646,54 +645,17 @@ public class Functions {
|
||||
private static final SimpleFormatter formatter = new SimpleFormatter();
|
||||
|
||||
/**
|
||||
* Used by {@code layout.jelly} to control the auto refresh behavior.
|
||||
* No longer used.
|
||||
*
|
||||
* @param noAutoRefresh
|
||||
* On certain pages, like a page with forms, will have annoying interference
|
||||
* with auto refresh. On those pages, disable auto-refresh.
|
||||
* @deprecated auto refresh has been removed
|
||||
*/
|
||||
@Deprecated
|
||||
public static void configureAutoRefresh(HttpServletRequest request, HttpServletResponse response, boolean noAutoRefresh) {
|
||||
if(noAutoRefresh)
|
||||
return;
|
||||
|
||||
String param = request.getParameter("auto_refresh");
|
||||
boolean refresh = isAutoRefresh(request);
|
||||
if (param != null) {
|
||||
refresh = Boolean.parseBoolean(param);
|
||||
Cookie c = new Cookie("hudson_auto_refresh", Boolean.toString(refresh));
|
||||
// Need to set path or it will not stick from e.g. a project page to the dashboard.
|
||||
// Using request.getContextPath() might work but it seems simpler to just use the hudson_ prefix
|
||||
// to avoid conflicts with any other web apps that might be on the same machine.
|
||||
c.setPath("/");
|
||||
c.setMaxAge(60*60*24*30); // persist it roughly for a month
|
||||
c.setHttpOnly(true);
|
||||
response.addCookie(c);
|
||||
}
|
||||
if (refresh) {
|
||||
response.addHeader("Refresh", SystemProperties.getString("hudson.Functions.autoRefreshSeconds", "10"));
|
||||
}
|
||||
|
||||
try {
|
||||
ExtensionList.lookupSingleton(AutoRefresh.class).recordRequest(request, refresh);
|
||||
} catch (Exception e) {
|
||||
LOGGER.log(Level.WARNING, "Failed to record auto refresh status in telemetry", e);
|
||||
}
|
||||
/* feature has been removed */
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isAutoRefresh(HttpServletRequest request) {
|
||||
String param = request.getParameter("auto_refresh");
|
||||
if (param != null) {
|
||||
return Boolean.parseBoolean(param);
|
||||
}
|
||||
Cookie[] cookies = request.getCookies();
|
||||
if(cookies==null)
|
||||
return false; // when API design messes it up, we all suffer
|
||||
|
||||
for (Cookie c : cookies) {
|
||||
if (c.getName().equals("hudson_auto_refresh")) {
|
||||
return Boolean.parseBoolean(c.getValue());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -384,12 +384,15 @@ public abstract class View extends AbstractModelObject implements AccessControll
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables automatic refreshes of the view.
|
||||
* By default, automatic refreshes are enabled.
|
||||
* Used to enable or disable automatic refreshes of the view.
|
||||
*
|
||||
* @since 1.557
|
||||
*
|
||||
* @deprecated Auto-refresh has been removed
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isAutomaticRefreshEnabled() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2019, Daniel Beck
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package jenkins.telemetry.impl;
|
||||
|
||||
import hudson.Extension;
|
||||
import jenkins.telemetry.Telemetry;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Extension
|
||||
@Restricted(NoExternalUse.class)
|
||||
public class AutoRefresh extends Telemetry {
|
||||
|
||||
private static final Set<String> sessionsWithAutoRefresh = new HashSet<>();
|
||||
private static final Set<String> sessionsWithoutAutoRefresh = new HashSet<>();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return Messages.AutoRefresh_DisplayName();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LocalDate getStart() {
|
||||
return LocalDate.of(2019, 10, 20);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LocalDate getEnd() {
|
||||
return LocalDate.of(2019, 12, 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject createContent() {
|
||||
int sessionsWithAutoRefreshCount, sessionsWithoutAutoRefreshCount;
|
||||
synchronized (sessionsWithAutoRefresh) {
|
||||
sessionsWithAutoRefreshCount = sessionsWithAutoRefresh.size();
|
||||
sessionsWithAutoRefresh.clear();
|
||||
}
|
||||
synchronized (sessionsWithoutAutoRefresh) {
|
||||
sessionsWithoutAutoRefreshCount = sessionsWithoutAutoRefresh.size();
|
||||
sessionsWithoutAutoRefresh.clear();
|
||||
}
|
||||
|
||||
if (sessionsWithAutoRefreshCount == 0 && sessionsWithoutAutoRefreshCount == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("enabled", sessionsWithAutoRefreshCount);
|
||||
payload.put("disabled", sessionsWithoutAutoRefreshCount);
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void recordRequest(HttpServletRequest request, boolean enabled) {
|
||||
if (Telemetry.isDisabled()) {
|
||||
return;
|
||||
}
|
||||
if (!isActivePeriod()) {
|
||||
return;
|
||||
}
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session != null) {
|
||||
String sessionId = session.getId();
|
||||
if (enabled) {
|
||||
synchronized (sessionsWithAutoRefresh) {
|
||||
sessionsWithAutoRefresh.add(sessionId);
|
||||
}
|
||||
} else {
|
||||
synchronized (sessionsWithoutAutoRefresh) {
|
||||
sessionsWithoutAutoRefresh.add(sessionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user