Welcome to mirror list, hosted at ThFree Co, Russian Federation.

log_advanced_filters.vue « components « logs « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dfbd858bf180a006f1192d24d67709960c80a6f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<script>
import { s__ } from '~/locale';
import DateTimePicker from '~/vue_shared/components/date_time_picker/date_time_picker.vue';
import { mapActions, mapState } from 'vuex';
import {
  GlIcon,
  GlDropdown,
  GlDropdownHeader,
  GlDropdownDivider,
  GlDropdownItem,
  GlSearchBoxByClick,
} from '@gitlab/ui';
import { timeRanges } from '~/vue_shared/constants';

export default {
  components: {
    GlIcon,
    GlDropdown,
    GlDropdownHeader,
    GlDropdownDivider,
    GlDropdownItem,
    GlSearchBoxByClick,
    DateTimePicker,
  },
  props: {
    disabled: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  data() {
    return {
      timeRanges,
      searchQuery: '',
    };
  },
  computed: {
    ...mapState('environmentLogs', ['timeRange', 'pods']),

    timeRangeModel: {
      get() {
        return this.timeRange.selected;
      },
      set(val) {
        this.setTimeRange(val);
      },
    },

    podDropdownText() {
      return this.pods.current || s__('Environments|All pods');
    },
  },
  methods: {
    ...mapActions('environmentLogs', ['setSearch', 'showPodLogs', 'setTimeRange']),
    isCurrentPod(podName) {
      return podName === this.pods.current;
    },
  },
};
</script>
<template>
  <div>
    <gl-dropdown
      ref="podsDropdown"
      :text="podDropdownText"
      :disabled="disabled"
      class="mb-2 gl-h-32 pr-2 d-flex d-md-block flex-grow-0 qa-pods-dropdown"
    >
      <gl-dropdown-header class="text-center">
        {{ s__('Environments|Filter by pod') }}
      </gl-dropdown-header>

      <gl-dropdown-item v-if="!pods.options.length" disabled>
        <span ref="noPodsMsg" class="text-muted">
          {{ s__('Environments|No pods to display') }}
        </span>
      </gl-dropdown-item>

      <template v-else>
        <gl-dropdown-item ref="allPodsOption" key="all-pods" @click="showPodLogs(null)">
          <div class="d-flex">
            <gl-icon
              :class="{ invisible: pods.current !== null }"
              name="status_success_borderless"
            />
            <div class="flex-grow-1">{{ s__('Environments|All pods') }}</div>
          </div>
        </gl-dropdown-item>
        <gl-dropdown-divider />
        <gl-dropdown-item
          v-for="podName in pods.options"
          :key="podName"
          class="text-nowrap"
          @click="showPodLogs(podName)"
        >
          <div class="d-flex">
            <gl-icon
              :class="{ invisible: !isCurrentPod(podName) }"
              name="status_success_borderless"
            />
            <div class="flex-grow-1">{{ podName }}</div>
          </div>
        </gl-dropdown-item>
      </template>
    </gl-dropdown>

    <gl-search-box-by-click
      ref="searchBox"
      v-model.trim="searchQuery"
      :disabled="disabled"
      :placeholder="s__('Environments|Search')"
      class="mb-2 pr-2 flex-grow-1"
      type="search"
      autofocus
      @submit="setSearch(searchQuery)"
    />

    <date-time-picker
      ref="dateTimePicker"
      v-model="timeRangeModel"
      :disabled="disabled"
      :options="timeRanges"
      class="mb-2 gl-h-32 pr-2 d-block date-time-picker-wrapper"
      right
    />
  </div>
</template>