Search in sources :

Example 1 with DashboardFor

use of com.thoughtworks.go.apiv4.dashboard.representers.DashboardFor in project gocd by gocd.

the class DashboardControllerV4 method index.

public Object index(Request request, Response response) throws IOException {
    if (!goDashboardService.hasEverLoadedCurrentState()) {
        response.status(ACCEPTED);
        return BEING_PROCESSED;
    }
    final String personalizationCookie = request.cookie(COOKIE_NAME);
    final Long userId = currentUserId(request);
    final Username userName = currentUsername();
    final PipelineSelections personalization = pipelineSelectionsService.load(personalizationCookie, userId);
    final DashboardFilter filter = personalization.namedFilter(getViewName(request));
    final boolean allowEmpty = Toggles.isToggleOn(Toggles.ALLOW_EMPTY_PIPELINE_GROUPS_DASHBOARD) && "true".equalsIgnoreCase(request.queryParams("allowEmpty"));
    List<GoDashboardPipelineGroup> pipelineGroups = goDashboardService.allPipelineGroupsForDashboard(filter, userName, allowEmpty);
    List<GoDashboardEnvironment> environments = goDashboardService.allEnvironmentsForDashboard(filter, userName);
    String etag = calcEtag(userName, pipelineGroups, environments);
    if (fresh(request, etag)) {
        return notModified(response);
    }
    setEtagHeader(response, etag);
    return writerForTopLevelObject(request, response, outputWriter -> DashboardRepresenter.toJSON(outputWriter, new DashboardFor(pipelineGroups, environments, userName, personalization.etag())));
}
Also used : DashboardFor(com.thoughtworks.go.apiv4.dashboard.representers.DashboardFor) DashboardFilter(com.thoughtworks.go.server.domain.user.DashboardFilter) PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Username(com.thoughtworks.go.server.domain.Username) GoDashboardPipelineGroup(com.thoughtworks.go.server.dashboard.GoDashboardPipelineGroup) GoDashboardEnvironment(com.thoughtworks.go.server.dashboard.GoDashboardEnvironment)

Example 2 with DashboardFor

use of com.thoughtworks.go.apiv4.dashboard.representers.DashboardFor in project gocd by gocd.

the class DashboardControllerV3 method index.

public Object index(Request request, Response response) throws IOException {
    if (!goDashboardService.hasEverLoadedCurrentState()) {
        response.status(ACCEPTED);
        return BEING_PROCESSED;
    }
    final String personalizationCookie = request.cookie(COOKIE_NAME);
    final Long userId = currentUserId(request);
    final Username userName = currentUsername();
    final PipelineSelections personalization = pipelineSelectionsService.load(personalizationCookie, userId);
    final DashboardFilter filter = personalization.namedFilter(getViewName(request));
    List<GoDashboardPipelineGroup> pipelineGroups = goDashboardService.allPipelineGroupsForDashboard(filter, userName);
    List<GoDashboardEnvironment> environments = goDashboardService.allEnvironmentsForDashboard(filter, userName);
    String etag = calcEtag(userName, pipelineGroups, environments);
    if (fresh(request, etag)) {
        return notModified(response);
    }
    setEtagHeader(response, etag);
    return writerForTopLevelObject(request, response, outputWriter -> DashboardRepresenter.toJSON(outputWriter, new DashboardFor(pipelineGroups, environments, userName, personalization.etag())));
}
Also used : DashboardFor(com.thoughtworks.go.apiv3.dashboard.representers.DashboardFor) DashboardFilter(com.thoughtworks.go.server.domain.user.DashboardFilter) PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Username(com.thoughtworks.go.server.domain.Username) GoDashboardPipelineGroup(com.thoughtworks.go.server.dashboard.GoDashboardPipelineGroup) GoDashboardEnvironment(com.thoughtworks.go.server.dashboard.GoDashboardEnvironment)

Example 3 with DashboardFor

use of com.thoughtworks.go.apiv4.dashboard.representers.DashboardFor in project gocd by gocd.

the class DashboardControllerDelegate method index.

public Object index(Request request, Response response) throws IOException {
    if (goDashboardService.isFeatureToggleDisabled()) {
        response.status(424);
        return FEATURE_NOT_ENABLED;
    }
    if (!goDashboardService.hasEverLoadedCurrentState()) {
        response.status(202);
        return BEING_PROCESSED;
    }
    String selectedPipelinesCookie = request.cookie("selected_pipelines");
    Long userId = currentUserId(request);
    Username userName = currentUsername();
    PipelineSelections selectedPipelines = pipelineSelectionsService.getPersistedSelectedPipelines(selectedPipelinesCookie, userId);
    List<GoDashboardPipelineGroup> pipelineGroups = goDashboardService.allPipelineGroupsForDashboard(selectedPipelines, userName);
    String etag = DigestUtils.md5Hex(pipelineGroups.stream().map(GoDashboardPipelineGroup::etag).collect(Collectors.joining("/")));
    if (fresh(request, etag)) {
        return notModified(response);
    }
    setEtagHeader(response, etag);
    return writerForTopLevelObject(request, response, outputWriter -> PipelineGroupsRepresenter.toJSON(outputWriter, new DashboardFor(pipelineGroups, userName)));
}
Also used : DashboardFor(com.thoughtworks.go.apiv2.dashboard.representers.DashboardFor) PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Username(com.thoughtworks.go.server.domain.Username) GoDashboardPipelineGroup(com.thoughtworks.go.server.dashboard.GoDashboardPipelineGroup)

Aggregations

GoDashboardPipelineGroup (com.thoughtworks.go.server.dashboard.GoDashboardPipelineGroup)3 Username (com.thoughtworks.go.server.domain.Username)3 PipelineSelections (com.thoughtworks.go.server.domain.user.PipelineSelections)3 GoDashboardEnvironment (com.thoughtworks.go.server.dashboard.GoDashboardEnvironment)2 DashboardFilter (com.thoughtworks.go.server.domain.user.DashboardFilter)2 DashboardFor (com.thoughtworks.go.apiv2.dashboard.representers.DashboardFor)1 DashboardFor (com.thoughtworks.go.apiv3.dashboard.representers.DashboardFor)1 DashboardFor (com.thoughtworks.go.apiv4.dashboard.representers.DashboardFor)1