Search in sources :

Example 1 with DashboardFilter

use of com.thoughtworks.go.server.domain.user.DashboardFilter 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 DashboardFilter

use of com.thoughtworks.go.server.domain.user.DashboardFilter 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 DashboardFilter

use of com.thoughtworks.go.server.domain.user.DashboardFilter in project gocd by gocd.

the class GoDashboardServiceTest method allEnvironmentsForDashboard_shouldRetrievePipelineGroupsBasedOnDashboardFilters.

@Test
public void allEnvironmentsForDashboard_shouldRetrievePipelineGroupsBasedOnDashboardFilters() {
    DashboardFilter filter = new ExcludesFilter("foo", CaseInsensitiveString.list("pipeline2", "pipeline4"), Collections.emptySet());
    configMother.addPipelineWithGroup(config, "group2", "pipeline4", "stage1A", "job1A1");
    GoDashboardPipeline pipeline4 = pipeline("pipeline4", "group2");
    configMother.addPipelineWithGroup(config, "group2", "pipeline3", "stage1A", "job1A1");
    GoDashboardPipeline pipeline3 = pipeline("pipeline3", "group2");
    configMother.addPipelineWithGroup(config, "group1", "pipeline2", "stage1A", "job1A1");
    GoDashboardPipeline pipeline2 = pipeline("pipeline2", "group1");
    configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1");
    GoDashboardPipeline pipeline1 = pipeline("pipeline1", "group1");
    addPipelinesToCache(pipeline1, pipeline2, pipeline3, pipeline4);
    configMother.addEnvironmentConfig(config, "env1", "pipeline1", "pipeline2");
    configMother.addEnvironmentConfig(config, "env2", "pipeline3", "pipeline4");
    List<GoDashboardEnvironment> envs = allEnvironmentsForDashboard(filter, new Username("user1"));
    assertThat(envs.size(), is(2));
    assertThat(envs.get(0).pipelines(), contains("pipeline1"));
    assertThat(envs.get(1).pipelines(), contains("pipeline3"));
}
Also used : DashboardFilter(com.thoughtworks.go.server.domain.user.DashboardFilter) Username(com.thoughtworks.go.server.domain.Username) ExcludesFilter(com.thoughtworks.go.server.domain.user.ExcludesFilter) Test(org.junit.jupiter.api.Test)

Example 4 with DashboardFilter

use of com.thoughtworks.go.server.domain.user.DashboardFilter in project gocd by gocd.

the class GoDashboardServiceTest method allPipelineGroupsForDashboard_shouldRetrievePipelineGroupsBasedOnDashboardFilters.

@Test
public void allPipelineGroupsForDashboard_shouldRetrievePipelineGroupsBasedOnDashboardFilters() {
    DashboardFilter filter = new ExcludesFilter("foo", CaseInsensitiveString.list("pipeline2", "pipeline4"), Collections.emptySet());
    configMother.addPipelineWithGroup(config, "group2", "pipeline4", "stage1A", "job1A1");
    GoDashboardPipeline pipeline4 = pipeline("pipeline4", "group2");
    configMother.addPipelineWithGroup(config, "group2", "pipeline3", "stage1A", "job1A1");
    GoDashboardPipeline pipeline3 = pipeline("pipeline3", "group2");
    configMother.addPipelineWithGroup(config, "group1", "pipeline2", "stage1A", "job1A1");
    GoDashboardPipeline pipeline2 = pipeline("pipeline2", "group1");
    configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1");
    GoDashboardPipeline pipeline1 = pipeline("pipeline1", "group1");
    addPipelinesToCache(pipeline1, pipeline2, pipeline3, pipeline4);
    List<GoDashboardPipelineGroup> pipelineGroups = allPipelineGroupsForDashboard(filter, new Username("user1"));
    assertThat(pipelineGroups.size(), is(2));
    assertThat(pipelineGroups.get(0).pipelines(), contains("pipeline1"));
    assertThat(pipelineGroups.get(1).pipelines(), contains("pipeline3"));
}
Also used : DashboardFilter(com.thoughtworks.go.server.domain.user.DashboardFilter) Username(com.thoughtworks.go.server.domain.Username) ExcludesFilter(com.thoughtworks.go.server.domain.user.ExcludesFilter) Test(org.junit.jupiter.api.Test)

Aggregations

Username (com.thoughtworks.go.server.domain.Username)4 DashboardFilter (com.thoughtworks.go.server.domain.user.DashboardFilter)4 GoDashboardEnvironment (com.thoughtworks.go.server.dashboard.GoDashboardEnvironment)2 GoDashboardPipelineGroup (com.thoughtworks.go.server.dashboard.GoDashboardPipelineGroup)2 ExcludesFilter (com.thoughtworks.go.server.domain.user.ExcludesFilter)2 PipelineSelections (com.thoughtworks.go.server.domain.user.PipelineSelections)2 Test (org.junit.jupiter.api.Test)2 DashboardFor (com.thoughtworks.go.apiv3.dashboard.representers.DashboardFor)1 DashboardFor (com.thoughtworks.go.apiv4.dashboard.representers.DashboardFor)1