use of teammates.ui.pagedata.AdminActivityLogPageData in project teammates by TEAMMATES.
the class AdminActivityLogPageActionTest method verifyActionResult.
private void verifyActionResult(int[][] expectedLogs, String... params) {
AdminActivityLogPageAction action = getAction(params);
ShowPageResult result = getShowPageResult(action);
AdminActivityLogPageData pageData = (AdminActivityLogPageData) result.data;
List<ActivityLogEntry> actualLogs = getLogsFromLogTemplateRows(pageData.getLogs());
verifyLogs(expectedLogs, actualLogs);
}
use of teammates.ui.pagedata.AdminActivityLogPageData in project teammates by TEAMMATES.
the class AdminActivityLogPageActionTest method verifyContinueSearch.
private void verifyContinueSearch(String[] params, int[][] expected, int totalLogs, int filteredLogs, Instant earliestDateInUtc) {
AdminActivityLogPageAction action = getAction(params);
ShowPageResult result = getShowPageResult(action);
AdminActivityLogPageData pageData = (AdminActivityLogPageData) result.data;
verifyStatusMessage(result.getStatusMessage(), totalLogs, filteredLogs, earliestDateInUtc);
verifyLogs(expected, getLogsFromLogTemplateRows(pageData.getLogs()));
}
use of teammates.ui.pagedata.AdminActivityLogPageData in project teammates by TEAMMATES.
the class AdminActivityLogPageActionTest method verifyLoadingLocalTimeAjaxResult.
private void verifyLoadingLocalTimeAjaxResult(String expected, String role, String googleId, long timeInMillis) {
String[] params = new String[] { "logRole", role, "logGoogleId", googleId, "logUnixTimeMillis", String.valueOf(timeInMillis) };
AdminActivityLogPageAction action = getAction(params);
AjaxResult result = getAjaxResult(action);
AdminActivityLogPageData pageData = (AdminActivityLogPageData) result.data;
assertEquals(expected, pageData.getLogLocalTime());
}
use of teammates.ui.pagedata.AdminActivityLogPageData in project teammates by TEAMMATES.
the class AdminActivityLogPageAction method execute.
@Override
protected ActionResult execute() {
gateKeeper.verifyAdminPrivileges(account);
AdminActivityLogPageData data = new AdminActivityLogPageData(account, sessionToken);
String searchTimeOffset = getRequestParamValue("searchTimeOffset");
if (searchTimeOffset == null) {
searchTimeOffset = "";
}
String logRoleFromAjax = getRequestParamValue("logRole");
String logGoogleIdFromAjax = getRequestParamValue("logGoogleId");
// logUnixTimeMillis is the number of milliseconds from the Unix epoch, i.e. independent of time zone
String logUnixTimeMillis = getRequestParamValue("logUnixTimeMillis");
boolean isLoadingLocalTimeAjax = logRoleFromAjax != null && logGoogleIdFromAjax != null && logUnixTimeMillis != null;
if (isLoadingLocalTimeAjax) {
data.setLogLocalTime(getLocalTimeInfo(logGoogleIdFromAjax, logRoleFromAjax, logUnixTimeMillis));
return createAjaxResult(data);
}
// This parameter determines whether the logs with requests contained in "excludedLogRequestURIs"
// in AdminActivityLogPageData should be shown. Use "?all=true" in URL to show all logs.
// This will keep showing all logs despite any action or change in the page unless
// the page is reloaded with "?all=false" or simply reloaded with this parameter omitted.
boolean shouldShowAllLogs = getRequestParamAsBoolean("all");
data.setShowAllLogs(shouldShowAllLogs);
// This determines whether the logs related to testing data should be shown. Use "testdata=true" in URL
// to show all testing logs. This will keep showing all logs from testing data despite any action
// or change in the page unless the page is reloaded with "?testdata=false"
// or simply reloaded with this parameter omitted.
boolean shouldShowTestData = getRequestParamAsBoolean("testdata");
data.setShowTestData(shouldShowTestData);
String filterQuery = getRequestParamValue("filterQuery");
if (filterQuery == null) {
filterQuery = "";
}
// This is used to parse the filterQuery. If the query is not parsed, the filter function would ignore the query
data.generateQueryParameters(filterQuery);
boolean isContinueFromPreviousSearch = !data.isFromDateSpecifiedInQuery() && !searchTimeOffset.isEmpty();
if (isContinueFromPreviousSearch) {
data.setToDate(Long.parseLong(searchTimeOffset));
}
List<String> versionToQuery = getVersionsForQuery(data.getVersions());
AdminLogQuery query = new AdminLogQuery(versionToQuery, data.getFromDate(), data.getToDate());
List<ActivityLogEntry> logs = null;
if (data.isFromDateSpecifiedInQuery()) {
logs = searchLogsWithExactTimePeriod(query, data);
} else {
logs = searchLogsWithTimeIncrement(query, data);
}
String courseIdFromSearchPage = getRequestParamValue("courseId");
generateStatusMessage(versionToQuery, data, logs, courseIdFromSearchPage);
data.init(logs);
if (searchTimeOffset.isEmpty()) {
return createShowPageResult(Const.ViewURIs.ADMIN_ACTIVITY_LOG, data);
}
return createShowPageResult(Const.ViewURIs.ADMIN_ACTIVITY_LOG_AJAX, data);
}
Aggregations