dashboard-shell-shell 1.0.122 → 1.0.1000000082
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.DS_Store +0 -0
- package/assets/brand/harvester/favicon.png +0 -0
- package/assets/brand/suse/favicon.png +0 -0
- package/assets/icons/iconfont.css +19 -3
- package/assets/icons/iconfont.js +1 -1
- package/assets/icons/iconfont.json +28 -0
- package/assets/icons/iconfont.ttf +0 -0
- package/assets/icons/iconfont.woff +0 -0
- package/assets/icons/iconfont.woff2 +0 -0
- package/assets/images/pl/half-logo.svg +2 -23
- package/assets/styles/base/_functions.scss +0 -0
- package/assets/styles/base/_mixins.scss +0 -0
- package/assets/styles/base/_variables.scss +1 -1
- package/assets/styles/global/_labeled-input.scss +0 -1
- package/assets/styles/global/_layout.scss +1 -1
- package/assets/styles/global/_select.scss +4 -2
- package/assets/styles/global/_table.scss +5 -0
- package/assets/styles/vendor/vue-select.scss +2 -1
- package/assets/translations/en-us.yaml +1 -1
- package/assets/translations/zh-hans.yaml +25 -15
- package/chart/monitoring/index.vue +3 -1
- package/chart/monitoring/prometheus/index.vue +13 -10
- package/cloud-credential/aws.vue +2 -0
- package/components/ActionDropdown.vue +1 -1
- package/components/ActionDropdownShell.vue +71 -0
- package/components/ActionMenu.vue +2 -2
- package/components/ActionMenuShell.vue +3 -0
- package/components/AppModal.vue +84 -8
- package/components/AssignTo.vue +25 -11
- package/components/AsyncButton.vue +24 -7
- package/components/BannerGraphic.vue +1 -0
- package/components/ButtonDropdown.vue +26 -4
- package/components/ButtonGroup.vue +4 -0
- package/components/ButtonMultiAction.vue +1 -0
- package/components/CodeMirror.vue +19 -6
- package/components/CommunityLinks.vue +3 -3
- package/components/ConsumptionGauge.vue +24 -5
- package/components/CopyToClipboardText.vue +2 -1
- package/components/CruResource.vue +13 -7
- package/components/CruResourceFooter.vue +2 -2
- package/components/DashboardOptions.vue +29 -17
- package/components/DetailText.vue +5 -0
- package/components/DisableAuthProviderModal.vue +1 -0
- package/components/DotState.vue +84 -0
- package/components/ExplorerMembers.vue +1 -1
- package/components/ExplorerProjectsNamespaces.vue +88 -16
- package/components/FixedBanner.vue +19 -12
- package/components/GlobalRoleBindings.vue +5 -1
- package/components/GrafanaDashboard.vue +4 -4
- package/components/GrowlManager.vue +4 -1
- package/components/HardwareResourceGauge.vue +39 -3
- package/components/InfoBox.vue +3 -3
- package/components/InputOrDisplay.vue +28 -2
- package/components/LabelValue.vue +20 -1
- package/components/LandingPagePreference.vue +5 -3
- package/components/LocaleSelector.vue +39 -93
- package/components/ModalManager.vue +55 -0
- package/components/ModalWithCard.vue +13 -3
- package/components/MoveModal.vue +1 -0
- package/components/PodSecurityAdmission.vue +1 -1
- package/components/PromptChangePassword.vue +1 -1
- package/components/PromptModal.vue +16 -3
- package/components/PromptRemove.vue +29 -9
- package/components/PromptRestore.vue +1 -0
- package/components/ResourceCancelModal.vue +1 -0
- package/components/ResourceDetail/Masthead.vue +52 -17
- package/components/ResourceDetail/__tests__/Masthead.test.ts +5 -1
- package/components/ResourceDetail/index.vue +54 -16
- package/components/ResourceList/Masthead.vue +26 -4
- package/components/ResourceList/index.vue +4 -3
- package/components/ResourceTable.vue +1 -0
- package/components/SideNav.vue +20 -15
- package/components/SlideInPanelManager.vue +126 -0
- package/components/SortableTable/THead.vue +10 -4
- package/components/SortableTable/actions.js +1 -1
- package/components/SortableTable/index.vue +542 -553
- package/components/SortableTable/selection.js +2 -13
- package/components/StatusBadge.vue +77 -0
- package/components/Tabbed/Tab.vue +3 -3
- package/components/Tabbed/index.vue +47 -29
- package/components/Wizard.vue +2 -2
- package/components/YamlEditor.vue +1 -1
- package/components/__tests__/AsyncButton.test.ts +2 -2
- package/components/__tests__/FixedBanner.test.ts +3 -3
- package/components/__tests__/ModalManager.spec.ts +176 -0
- package/components/__tests__/SlideInPanelManager.spec.ts +166 -0
- package/components/auth/Principal.vue +10 -3
- package/components/auth/RoleDetailEdit.vue +1 -1
- package/components/auth/__tests__/RoleDetailEdit.test.ts +3 -2
- package/components/form/ArrayList.vue +123 -85
- package/components/form/ArrayListGrouped.vue +10 -2
- package/components/form/ArrayListSelect.vue +1 -1
- package/components/form/Command.vue +6 -15
- package/components/form/EnvVars.vue +16 -8
- package/components/form/Footer.vue +10 -7
- package/components/form/HealthCheck.vue +3 -3
- package/components/form/HookOption.vue +11 -16
- package/components/form/InputWithSelect.vue +6 -5
- package/components/form/KeyValue.vue +39 -10
- package/components/form/LabeledSelect.vue +73 -77
- package/components/form/Labels.vue +6 -3
- package/components/form/LifecycleHooks.vue +3 -3
- package/components/form/MatchExpressions.vue +42 -17
- package/components/form/NameNsDescription.vue +163 -116
- package/components/form/Networking.vue +20 -12
- package/components/form/NodeAffinity.vue +31 -23
- package/components/form/NodeScheduling.vue +13 -3
- package/components/form/Password.vue +11 -5
- package/components/form/PodAffinity.vue +47 -48
- package/components/form/Probe.vue +68 -66
- package/components/form/ResourceQuota/Namespace.vue +4 -4
- package/components/form/ResourceQuota/NamespaceRow.vue +5 -7
- package/components/form/ResourceQuota/Project.vue +9 -5
- package/components/form/ResourceQuota/ProjectRow.vue +4 -6
- package/components/form/ResourceSelector.vue +7 -9
- package/components/form/SSHKnownHosts/KnownHostsEditDialog.vue +6 -3
- package/components/form/SSHKnownHosts/__tests__/KnownHostsEditDialog.test.ts +12 -1
- package/components/form/SSHKnownHosts/index.vue +16 -2
- package/components/form/Security.vue +54 -56
- package/components/form/Select.vue +44 -7
- package/components/form/ShellInput.vue +5 -1
- package/components/form/SimpleSecretSelector.vue +29 -9
- package/components/form/Tolerations.vue +5 -1
- package/components/form/UnitInput.vue +10 -5
- package/components/form/ValueFromResource.vue +134 -121
- package/components/form/WorkloadPorts.vue +18 -18
- package/components/form/__tests__/ArrayList.test.ts +5 -2
- package/components/form/__tests__/MatchExpressions.test.ts +12 -12
- package/components/form/__tests__/NameNsDescription.test.ts +115 -14
- package/components/form/__tests__/Probe.test.ts +12 -8
- package/components/form/__tests__/SSHKnownHosts.test.ts +11 -0
- package/components/form/__tests__/Select.test.ts +37 -0
- package/components/form/__tests__/UnitInput.test.ts +4 -5
- package/components/formatter/BadgeStateFormatter.vue +8 -5
- package/components/formatter/InternalExternalIP.vue +2 -0
- package/components/formatter/LiveDate.vue +3 -3
- package/components/formatter/SecretData.vue +20 -7
- package/components/nav/Favorite.vue +5 -1
- package/components/nav/Group.vue +18 -4
- package/components/nav/Header.vue +39 -13
- package/components/nav/Jump.vue +7 -0
- package/components/nav/NamespaceFilter.vue +21 -11
- package/components/nav/Pinned.vue +1 -1
- package/components/nav/TopLevelMenu.vue +5 -17
- package/components/nav/Type.vue +30 -33
- package/components/nav/__tests__/TopLevelMenu.test.ts +0 -40
- package/components/rancherResourceDetail/Masthead.vue +769 -0
- package/components/rancherResourceDetail/__tests__/Masthead.test.ts +65 -0
- package/components/rancherResourceDetail/index.vue +591 -0
- package/components/rancherResourceList/Masthead-btn.vue +225 -0
- package/components/rancherResourceList/Masthead.vue +375 -0
- package/components/rancherResourceList/ResourceLoadingIndicator.vue +140 -0
- package/components/rancherResourceList/index.vue +307 -0
- package/components/rancherResourceList/resource-list.config.js +7 -0
- package/components/rancherResourceTable.vue +783 -0
- package/components/rancherSortableTable/THead.vue +561 -0
- package/components/rancherSortableTable/actions.js +153 -0
- package/components/rancherSortableTable/advanced-filtering.js +272 -0
- package/components/rancherSortableTable/debug.js +117 -0
- package/components/rancherSortableTable/filtering.js +290 -0
- package/components/rancherSortableTable/grouping.js +48 -0
- package/components/rancherSortableTable/index.vue +2712 -0
- package/components/rancherSortableTable/paging.js +155 -0
- package/components/rancherSortableTable/selection.js +629 -0
- package/components/rancherSortableTable/sortable-config.ts +4 -0
- package/components/rancherSortableTable/sorting.js +129 -0
- package/components/templates/blank.vue +4 -1
- package/components/templates/default.vue +8 -0
- package/components/templates/home.vue +10 -1
- package/components/templates/plain.vue +10 -1
- package/composables/focusTrap.ts +11 -3
- package/composables/useRuntimeFlag.ts +29 -0
- package/config/private-label.js +15 -10
- package/config/router/routes.js +21 -13
- package/config/store.js +4 -0
- package/config/table-headers.js +3 -2
- package/config/uiplugins.js +5 -1
- package/core/plugin-routes.ts +5 -115
- package/core/plugins.js +1 -1
- package/core/types.ts +23 -2
- package/detail/__tests__/autoscaling.horizontalpodautoscaler.test.ts +84 -23
- package/detail/autoscaling.horizontalpodautoscaler/index.vue +13 -3
- package/detail/provisioning.cattle.io.cluster.vue +72 -6
- package/dialog/AddCustomBadgeDialog.vue +1 -0
- package/dialog/DeactivateDriverDialog.vue +5 -4
- package/dialog/ForceMachineRemoveDialog.vue +6 -3
- package/dialog/GitRepoForceUpdateDialog.vue +1 -1
- package/dialog/ScalePoolDownDialog.vue +2 -2
- package/edit/__tests__/monitoring.coreos.com.prometheusrule.test.ts +16 -3
- package/edit/auth/__tests__/oidc.test.ts +162 -88
- package/edit/auth/azuread.vue +2 -1
- package/edit/auth/github.vue +1 -1
- package/edit/auth/googleoauth.vue +5 -1
- package/edit/auth/ldap/__tests__/config.test.ts +0 -14
- package/edit/auth/ldap/config.vue +0 -24
- package/edit/auth/ldap/index.vue +1 -1
- package/edit/auth/oidc.vue +39 -6
- package/edit/auth/saml.vue +1 -1
- package/edit/autoscaling.horizontalpodautoscaler/metric-identifier.vue +5 -2
- package/edit/cloudcredential.vue +24 -9
- package/edit/fleet.cattle.io.clustergroup.vue +5 -3
- package/edit/fleet.cattle.io.gitrepo.vue +2 -0
- package/edit/logging-flow/Match.vue +1 -1
- package/edit/logging.banzaicloud.io.output/__tests__/logging.banzaicloud.io.output.test.ts +40 -9
- package/edit/management.cattle.io.user.vue +28 -3
- package/edit/monitoring.coreos.com.alertmanagerconfig/auth.vue +19 -19
- package/edit/monitoring.coreos.com.alertmanagerconfig/receiverConfig.vue +31 -31
- package/edit/monitoring.coreos.com.alertmanagerconfig/routeConfig.vue +36 -12
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/email.vue +6 -6
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/opsgenie.vue +10 -10
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/pagerduty.vue +4 -4
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/slack.vue +4 -4
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/webhook.vue +1 -1
- package/edit/monitoring.coreos.com.receiver/auth.vue +29 -29
- package/edit/monitoring.coreos.com.receiver/types/email.vue +6 -6
- package/edit/monitoring.coreos.com.receiver/types/opsgenie.vue +10 -10
- package/edit/monitoring.coreos.com.receiver/types/pagerduty.vue +5 -5
- package/edit/monitoring.coreos.com.receiver/types/slack.vue +4 -4
- package/edit/namespace.vue +1 -2
- package/edit/networking.k8s.io.ingress/IngressClass.vue +7 -3
- package/edit/networking.k8s.io.ingress/RulePath.vue +1 -1
- package/edit/networking.k8s.io.ingress/__tests__/IngressClass.test.ts +58 -0
- package/edit/persistentvolume/__tests__/persistentvolume.test.ts +14 -2
- package/edit/provisioning.cattle.io.cluster/CustomCommand.vue +4 -1
- package/edit/provisioning.cattle.io.cluster/SelectCredential.vue +26 -9
- package/edit/provisioning.cattle.io.cluster/__tests__/Advanced.test.ts +8 -10
- package/edit/provisioning.cattle.io.cluster/rke2.vue +31 -40
- package/edit/provisioning.cattle.io.cluster/tabs/Advanced.vue +5 -2
- package/edit/provisioning.cattle.io.cluster/tabs/AgentConfiguration.vue +6 -1
- package/edit/provisioning.cattle.io.cluster/tabs/MachinePool.vue +33 -2
- package/edit/provisioning.cattle.io.cluster/tabs/etcd/index.vue +3 -3
- package/edit/service.vue +0 -3
- package/edit/token.vue +32 -11
- package/edit/workload/Job.vue +6 -6
- package/edit/workload/__tests__/Job.test.ts +0 -1
- package/edit/workload/index.vue +1 -0
- package/edit/workload/mixins/workload.js +3 -3
- package/initialize/install-plugins.js +2 -1
- package/list/harvesterhci.io.management.cluster.vue +4 -1
- package/list/management.cattle.io.feature.vue +1 -0
- package/list/namespace.vue +3 -1
- package/list/provisioning.cattle.io.cluster.vue +20 -12
- package/list/workload.vue +7 -6
- package/machine-config/__tests__/vmwarevsphere.test.ts +48 -3
- package/machine-config/azure.vue +16 -4
- package/machine-config/vmwarevsphere.vue +16 -0
- package/mixins/resource-fetch.js +2 -1
- package/models/__tests__/logging.banzaicloud.io.flow.test.ts +88 -0
- package/models/__tests__/namespace.test.ts +25 -1
- package/models/cloudcredential.js +5 -0
- package/models/kontainerdriver.js +6 -3
- package/models/logging.banzaicloud.io.flow.js +2 -1
- package/models/management.cattle.io.node.js +3 -3
- package/models/management.cattle.io.setting.js +2 -1
- package/models/namespace.js +4 -5
- package/models/nodedriver.js +6 -3
- package/models/storage.k8s.io.storageclass.js +2 -2
- package/models/workload.js +4 -1
- package/package.json +1 -1
- package/pages/about.vue +16 -8
- package/pages/account/index.vue +80 -24
- package/pages/account/pri.vue +229 -0
- package/pages/auth/login.vue +195 -44
- package/pages/auth/logout.vue +4 -1
- package/pages/auth/setup.vue +144 -19
- package/pages/auth/verify.vue +13 -8
- package/pages/auth copy/login.vue +595 -0
- package/pages/auth copy/logout.vue +47 -0
- package/pages/auth copy/setup.vue +523 -0
- package/pages/auth copy/verify.vue +203 -0
- package/pages/c/_cluster/_product/namespaces.vue +5 -5
- package/pages/c/_cluster/apps/charts/chart.vue +1 -1
- package/pages/c/_cluster/apps/charts/install.vue +26 -26
- package/pages/c/_cluster/auth/config/index.vue +10 -12
- package/pages/c/_cluster/explorer/EventsTable.vue +38 -33
- package/pages/c/_cluster/explorer/index.vue +17 -15
- package/pages/c/_cluster/istio/index.vue +2 -2
- package/pages/c/_cluster/longhorn/index.vue +1 -1
- package/pages/c/_cluster/monitoring/index.vue +1 -1
- package/pages/c/_cluster/monitoring/monitor/_namespace/_id.vue +4 -2
- package/pages/c/_cluster/monitoring/monitor/create.vue +4 -2
- package/pages/c/_cluster/monitoring/monitor/index.vue +2 -2
- package/pages/c/_cluster/monitoring/route-receiver/_id.vue +4 -2
- package/pages/c/_cluster/monitoring/route-receiver/create.vue +5 -2
- package/pages/c/_cluster/neuvector/index.vue +1 -1
- package/pages/c/_cluster/settings/brand.vue +3 -3
- package/pages/c/_cluster/uiplugins/CatalogList/index.vue +8 -10
- package/pages/diagnostic.vue +59 -11
- package/pages/fail-whale.vue +14 -8
- package/pages/home.vue +24 -18
- package/pages/prefs.vue +9 -7
- package/pages/support/index.vue +4 -1
- package/pkg/tsconfig.json +9 -9
- package/pkg/vue.config.js +1 -1
- package/plugins/dashboard-store/normalize.js +3 -1
- package/plugins/dashboard-store/resource-class.js +31 -29
- package/plugins/internal-api/index.ts +37 -0
- package/plugins/internal-api/shared/base-api.ts +13 -0
- package/plugins/internal-api/shell/shell.api.ts +108 -0
- package/promptRemove/management.cattle.io.fleetworkspace.vue +1 -1
- package/promptRemove/management.cattle.io.globalrole.vue +1 -1
- package/promptRemove/management.cattle.io.project.vue +2 -2
- package/promptRemove/management.cattle.io.roletemplate.vue +1 -1
- package/promptRemove/pod.vue +1 -1
- package/public/index.html +2 -1
- package/rancher-components/BadgeState/BadgeState.vue +5 -1
- package/rancher-components/Banner/Banner.vue +8 -2
- package/rancher-components/Card/Card.vue +3 -6
- package/rancher-components/Form/Checkbox/Checkbox.vue +4 -0
- package/rancher-components/Form/LabeledInput/LabeledInput.vue +5 -2
- package/rancher-components/Form/Radio/RadioButton.vue +3 -3
- package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +1 -5
- package/rancher-components/LabeledTooltip/LabeledTooltip.vue +9 -4
- package/rancher-components/RcDropdown/RcDropdownItem.vue +1 -2
- package/rancher-components/RcDropdown/RcDropdownMenu.vue +7 -3
- package/rancher-components/RcDropdown/types.ts +1 -0
- package/scripts/clean +0 -0
- package/scripts/extension/bundle +20 -0
- package/scripts/extension/helm/charts/ui-plugin-server/templates/_helpers.tpl +2 -2
- package/scripts/extension/helm/charts/ui-plugin-server/templates/cr.yaml +2 -1
- package/scripts/extension/helm/charts/ui-plugin-server/values.yaml +2 -0
- package/scripts/extension/helm/scripts/package +0 -0
- package/scripts/extension/helm/scripts/patch +0 -0
- package/scripts/extension/helm/scripts/version +0 -0
- package/scripts/extension/helmpatch +44 -31
- package/scripts/extension/parse-tag-name +0 -0
- package/scripts/extension/publish +12 -12
- package/scripts/publish-shell.sh +18 -23
- package/scripts/serve-pkgs +0 -0
- package/scripts/sync-shell-deps +0 -0
- package/scripts/test-plugins-build.sh +4 -6
- package/scripts/typegen.sh +28 -46
- package/server/har-file.js +25 -3
- package/static/favicon.ico +0 -0
- package/static/favicon.png +0 -0
- package/static/loading-indicator.html +2 -2
- package/store/aws.js +9 -2
- package/store/features.js +2 -1
- package/store/i18n.js +3 -3
- package/store/modal.ts +71 -0
- package/store/slideInPanel.ts +47 -0
- package/store/type-map.js +9 -1
- package/types/cloud-shell/index.d.ts +11020 -0
- package/types/global-vue.d.ts +5 -0
- package/types/internal-api/shell/growl.d.ts +25 -0
- package/types/internal-api/shell/modal.d.ts +77 -0
- package/types/internal-api/shell/slideIn.d.ts +15 -0
- package/types/shell/index.d.ts +118 -128
- package/types/vue-shim.d.ts +4 -1
- package/utils/__tests__/object.test.ts +38 -4
- package/utils/__tests__/string.test.ts +2 -2
- package/utils/auth.js +1 -0
- package/utils/banners.js +0 -45
- package/utils/cluster.js +35 -0
- package/utils/color.js +9 -8
- package/utils/error.js +61 -3
- package/utils/errorTranslate.json +450 -30
- package/utils/object.js +46 -6
- package/utils/router.js +22 -1
- package/utils/select.js +26 -3
- package/utils/string.js +9 -8
- package/utils/title.ts +1 -1
- package/utils/validators/machine-pool.ts +20 -0
- package/vue.config.js +7 -2
- package/components/formatter/ExtensionCache.vue +0 -74
- package/components/formatter/Port.vue +0 -24
- package/components/formatter/SecretType.vue +0 -41
- package/types/resources/fleet.d.ts +0 -57
- package/types/resources/pod-security-admission.ts +0 -36
- package/types/resources/settings.d.ts +0 -93
- package/types/resources/userPreferences.d.ts +0 -13
- package/types/vue-shim.d +0 -20
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { ADV_FILTER_ALL_COLS_VALUE, ADV_FILTER_ALL_COLS_LABEL } from './filtering';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_ADV_FILTER_COLS_VALUE = ADV_FILTER_ALL_COLS_VALUE;
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
props: {
|
|
7
|
+
/**
|
|
8
|
+
* Group value
|
|
9
|
+
* To be used on the THead component when adv filtering is present
|
|
10
|
+
*/
|
|
11
|
+
group: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: () => ''
|
|
14
|
+
},
|
|
15
|
+
/**
|
|
16
|
+
* Group options
|
|
17
|
+
* All of the grouping options available to be used on the THead component when adv filtering is present
|
|
18
|
+
*/
|
|
19
|
+
groupOptions: {
|
|
20
|
+
type: Array,
|
|
21
|
+
default: () => []
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Flag that controls visibility of advanced filtering feature
|
|
25
|
+
*/
|
|
26
|
+
hasAdvancedFiltering: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Flag that controls visibility of labels as possibe toggable cols to be displayed on the Sortable Table
|
|
32
|
+
*/
|
|
33
|
+
advFilterHideLabelsAsCols: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Flag that prevents filtering by labels
|
|
39
|
+
*/
|
|
40
|
+
advFilterPreventFilteringLabels: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
data() {
|
|
46
|
+
return {
|
|
47
|
+
columnOptions: [],
|
|
48
|
+
colOptionsWatcher: null,
|
|
49
|
+
advancedFilteringVisibility: false,
|
|
50
|
+
advancedFilteringValues: [],
|
|
51
|
+
advFilterSearchTerm: null,
|
|
52
|
+
advFilterSelectedProp: DEFAULT_ADV_FILTER_COLS_VALUE,
|
|
53
|
+
advFilterSelectedLabel: ADV_FILTER_ALL_COLS_LABEL,
|
|
54
|
+
column: null,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
mounted() {
|
|
59
|
+
if (this.hasAdvancedFiltering) {
|
|
60
|
+
// trigger to first populate the cols options for filters
|
|
61
|
+
this.updateColsOptions();
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
watch: {
|
|
66
|
+
advancedFilteringValues() {
|
|
67
|
+
// passing different dummy args to make sure update is triggered
|
|
68
|
+
this.watcherUpdateLiveAndDelayed(true, false);
|
|
69
|
+
},
|
|
70
|
+
advancedFilteringVisibility(neu) {
|
|
71
|
+
if (neu) {
|
|
72
|
+
// check if user clicked outside the advanced filter box
|
|
73
|
+
window.addEventListener('click', this.onClickOutside);
|
|
74
|
+
|
|
75
|
+
// update filtering options and toggable cols every time dropdown is open
|
|
76
|
+
this.updateColsOptions();
|
|
77
|
+
} else {
|
|
78
|
+
// unregister click event
|
|
79
|
+
window.removeEventListener('click', this.onClickOutside);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
computed: {
|
|
85
|
+
advFilterSelectOptions() {
|
|
86
|
+
return this.columnOptions.filter((c) => c.isFilter && !c.preventFiltering);
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
advGroupOptions() {
|
|
90
|
+
return this.groupOptions.map((item) => {
|
|
91
|
+
return {
|
|
92
|
+
label: this.t(item.tooltipKey),
|
|
93
|
+
value: item.value
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
methods: {
|
|
100
|
+
handleColsVisibilyAndFiltering(cols) {
|
|
101
|
+
const allCols = cols;
|
|
102
|
+
|
|
103
|
+
this.columnOptions.forEach((advCol) => {
|
|
104
|
+
if (advCol.isTableOption) {
|
|
105
|
+
const index = allCols.findIndex((col) => col.name === advCol.name);
|
|
106
|
+
|
|
107
|
+
if (index !== -1) {
|
|
108
|
+
allCols[index].isColVisible = advCol.isColVisible;
|
|
109
|
+
allCols[index].isFilter = advCol.isFilter;
|
|
110
|
+
} else {
|
|
111
|
+
allCols.push(advCol);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return allCols;
|
|
117
|
+
},
|
|
118
|
+
// advanced filtering methods
|
|
119
|
+
setColsOptions() {
|
|
120
|
+
let opts = [];
|
|
121
|
+
const rowLabels = [];
|
|
122
|
+
const headerProps = [];
|
|
123
|
+
|
|
124
|
+
// Filter out any columns that are too heavy to show for large page sizes
|
|
125
|
+
const filteredHeaders = this.headers.slice().filter((c) => (!c.maxPageSize || (c.maxPageSize && c.maxPageSize >= this.perPage)));
|
|
126
|
+
|
|
127
|
+
// add table cols from config (headers)
|
|
128
|
+
filteredHeaders.forEach((prop) => {
|
|
129
|
+
const name = prop.name;
|
|
130
|
+
const label = prop.labelKey ? this.t(`${ prop.labelKey }`) : prop.label;
|
|
131
|
+
const isFilter = !!((!Object.keys(prop).includes('search') || prop.search));
|
|
132
|
+
let sortVal = prop.sort;
|
|
133
|
+
const valueProp = prop.valueProp || prop.value;
|
|
134
|
+
let value = null;
|
|
135
|
+
let isColVisible = true;
|
|
136
|
+
|
|
137
|
+
if (prop.sort && valueProp) {
|
|
138
|
+
if (typeof prop.sort === 'string') {
|
|
139
|
+
sortVal = prop.sort.includes(':') ? [prop.sort.split(':')[0]] : [prop.sort];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (!sortVal.includes(valueProp)) {
|
|
143
|
+
value = JSON.stringify(sortVal.concat([valueProp]));
|
|
144
|
+
} else {
|
|
145
|
+
value = JSON.stringify([valueProp]);
|
|
146
|
+
}
|
|
147
|
+
} else if (valueProp) {
|
|
148
|
+
value = JSON.stringify([valueProp]);
|
|
149
|
+
} else {
|
|
150
|
+
value = null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// maintain current visibility of cols if they exist already
|
|
154
|
+
if (this.columnOptions?.length) {
|
|
155
|
+
const opt = this.columnOptions.find((colOpt) => colOpt.name === name && colOpt.label === label);
|
|
156
|
+
|
|
157
|
+
if (opt) {
|
|
158
|
+
isColVisible = opt.isColVisible;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
headerProps.push({
|
|
163
|
+
name,
|
|
164
|
+
label,
|
|
165
|
+
value,
|
|
166
|
+
isFilter,
|
|
167
|
+
isTableOption: true,
|
|
168
|
+
isColVisible
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// add labels as table cols
|
|
173
|
+
if (this.rows.length) {
|
|
174
|
+
this.rows.forEach((row) => {
|
|
175
|
+
if (row.metadata?.labels && Object.keys(row.metadata?.labels).length) {
|
|
176
|
+
Object.keys(row.metadata?.labels).forEach((label) => {
|
|
177
|
+
const res = {
|
|
178
|
+
name: label,
|
|
179
|
+
label,
|
|
180
|
+
value: `metadata.labels.${ label }`,
|
|
181
|
+
isFilter: true,
|
|
182
|
+
isTableOption: true,
|
|
183
|
+
isColVisible: false,
|
|
184
|
+
isLabel: true,
|
|
185
|
+
preventFiltering: this.advFilterPreventFilteringLabels,
|
|
186
|
+
preventColToggle: this.advFilterHideLabelsAsCols
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// maintain current visibility of cols if they exist already
|
|
190
|
+
if (this.columnOptions?.length) {
|
|
191
|
+
const opt = this.columnOptions.find((colOpt) => colOpt.name === label && colOpt.label === label);
|
|
192
|
+
|
|
193
|
+
if (opt) {
|
|
194
|
+
res.isColVisible = opt.isColVisible;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (!rowLabels.filter((row) => row.label === label).length) {
|
|
199
|
+
rowLabels.push(res);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
opts = headerProps.concat(rowLabels);
|
|
207
|
+
|
|
208
|
+
// add find on all cols option...
|
|
209
|
+
if (opts.length) {
|
|
210
|
+
opts.unshift({
|
|
211
|
+
name: ADV_FILTER_ALL_COLS_LABEL,
|
|
212
|
+
label: ADV_FILTER_ALL_COLS_LABEL,
|
|
213
|
+
value: ADV_FILTER_ALL_COLS_VALUE,
|
|
214
|
+
isFilter: true,
|
|
215
|
+
isTableOption: false
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return opts;
|
|
220
|
+
},
|
|
221
|
+
addAdvancedFilter() {
|
|
222
|
+
// set new advanced filter
|
|
223
|
+
if (this.advFilterSelectedProp && this.advFilterSearchTerm) {
|
|
224
|
+
this.advancedFilteringValues.push({
|
|
225
|
+
prop: this.advFilterSelectedProp,
|
|
226
|
+
value: this.advFilterSearchTerm,
|
|
227
|
+
label: this.advFilterSelectedLabel
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
this.eventualSearchQuery = this.advancedFilteringValues;
|
|
231
|
+
|
|
232
|
+
this.advancedFilteringVisibility = false;
|
|
233
|
+
this.advFilterSelectedProp = DEFAULT_ADV_FILTER_COLS_VALUE;
|
|
234
|
+
this.advFilterSelectedLabel = ADV_FILTER_ALL_COLS_LABEL;
|
|
235
|
+
this.advFilterSearchTerm = null;
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
clearAllAdvancedFilters() {
|
|
239
|
+
this.advancedFilteringValues = [];
|
|
240
|
+
this.eventualSearchQuery = this.advancedFilteringValues;
|
|
241
|
+
|
|
242
|
+
this.advancedFilteringVisibility = false;
|
|
243
|
+
this.advFilterSelectedProp = DEFAULT_ADV_FILTER_COLS_VALUE;
|
|
244
|
+
this.advFilterSelectedLabel = ADV_FILTER_ALL_COLS_LABEL;
|
|
245
|
+
this.advFilterSearchTerm = null;
|
|
246
|
+
},
|
|
247
|
+
clearAdvancedFilter(index) {
|
|
248
|
+
this.advancedFilteringValues.splice(index, 1);
|
|
249
|
+
this.eventualSearchQuery = this.advancedFilteringValues;
|
|
250
|
+
},
|
|
251
|
+
onClickOutside(event) {
|
|
252
|
+
const advFilterBox = this.$refs['advanced-filter-group'];
|
|
253
|
+
|
|
254
|
+
if (!advFilterBox || advFilterBox.contains(event.target)) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
this.advancedFilteringVisibility = false;
|
|
258
|
+
},
|
|
259
|
+
updateColsOptions() {
|
|
260
|
+
this.columnOptions = this.setColsOptions();
|
|
261
|
+
},
|
|
262
|
+
|
|
263
|
+
// cols visibility
|
|
264
|
+
changeColVisibility(colData) {
|
|
265
|
+
const index = this.columnOptions.findIndex((col) => col.label === colData.label);
|
|
266
|
+
|
|
267
|
+
if (index !== -1) {
|
|
268
|
+
this.columnOptions[index].isColVisible = colData.value;
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
|
|
3
|
+
// =========================================================================================
|
|
4
|
+
// Debug helper
|
|
5
|
+
// Adds a bunch of watches to help dignose computed properties bring re-evaluated
|
|
6
|
+
// =========================================================================================
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
watch: {
|
|
10
|
+
sortFields(neu, old) {
|
|
11
|
+
console.log('sortFields changed ------------------------------------------------');
|
|
12
|
+
console.log(neu);
|
|
13
|
+
console.log(old);
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
descending(neu, old) {
|
|
17
|
+
console.log('descending changed ------------------------------------------------');
|
|
18
|
+
console.log(neu);
|
|
19
|
+
console.log(old);
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
rows(neu, old) {
|
|
23
|
+
console.log('rows changed ------------------------------------------------');
|
|
24
|
+
console.log(neu.length);
|
|
25
|
+
console.log(old.length);
|
|
26
|
+
|
|
27
|
+
// console.log('Checking rows');
|
|
28
|
+
|
|
29
|
+
// let diff = 0;
|
|
30
|
+
|
|
31
|
+
// for (let i=0;i<neu.length;i++) {
|
|
32
|
+
// const a = JSON.stringify(neu[i]);
|
|
33
|
+
// const b = JSON.stringify(old[i]);
|
|
34
|
+
|
|
35
|
+
// if (a !== b) {
|
|
36
|
+
// console.log('rows differ ' + i);
|
|
37
|
+
// diff++;
|
|
38
|
+
// }
|
|
39
|
+
// }
|
|
40
|
+
|
|
41
|
+
// console.log(diff + ' rows changed');
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
pagingDisplay(neu, old) {
|
|
45
|
+
console.log('pagingDisplay changed ------------------------------------------------');
|
|
46
|
+
console.log(neu.length);
|
|
47
|
+
console.log(old.length);
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
totalPages(neu, old) {
|
|
51
|
+
console.log('totalPages changed ------------------------------------------------');
|
|
52
|
+
console.log(neu.length);
|
|
53
|
+
console.log(old.length);
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
pagedRows(neu, old) {
|
|
57
|
+
console.log('pagedRows changed ------------------------------------------------');
|
|
58
|
+
console.log(neu.length);
|
|
59
|
+
console.log(old.length);
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
arrangedRows(neu, old) {
|
|
63
|
+
console.log('arrangedRows changed ------------------------------------------------');
|
|
64
|
+
console.log(neu.length);
|
|
65
|
+
console.log(old.length);
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
searchFields(neu, old) {
|
|
69
|
+
console.log('searchFields changed ------------------------------------------------');
|
|
70
|
+
console.log(neu.length);
|
|
71
|
+
console.log(old.length);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
filteredRows(neu, old) {
|
|
75
|
+
console.log('filteredRows changed ------------------------------------------------');
|
|
76
|
+
console.log(neu.length);
|
|
77
|
+
console.log(old.length);
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
groupedRows(neu, old) {
|
|
81
|
+
console.log('groupedRows changed ------------------------------------------------');
|
|
82
|
+
console.log(neu.length);
|
|
83
|
+
console.log(old.length);
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
headers(neu, old) {
|
|
87
|
+
console.log('headers changed ------------------------------------------------');
|
|
88
|
+
console.log(neu);
|
|
89
|
+
console.log(old);
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
displayRows(neu, old) {
|
|
93
|
+
console.log('displayRows changed ------------------------------------------------');
|
|
94
|
+
console.log(neu);
|
|
95
|
+
console.log(old);
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
groupBy(neu, old) {
|
|
99
|
+
console.log('groupBy changed ------------------------------------------------');
|
|
100
|
+
console.log(neu);
|
|
101
|
+
console.log(old);
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
groupSort(neu, old) {
|
|
105
|
+
console.log('groupSort changed ------------------------------------------------');
|
|
106
|
+
console.log(neu);
|
|
107
|
+
console.log(old);
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
columns(neu, old) {
|
|
111
|
+
console.log('columns changed ------------------------------------------------');
|
|
112
|
+
console.log(neu);
|
|
113
|
+
console.log(old);
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
/* eslint-enable no-console */
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { get } from '@shell/utils/object';
|
|
2
|
+
import { addObject, addObjects, isArray, removeAt } from '@shell/utils/array';
|
|
3
|
+
|
|
4
|
+
export const ADV_FILTER_ALL_COLS_VALUE = 'allcols';
|
|
5
|
+
export const ADV_FILTER_ALL_COLS_LABEL = 'All Columns';
|
|
6
|
+
const LABEL_IDENTIFIER = ':::islabel';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
data() {
|
|
10
|
+
return {
|
|
11
|
+
searchQuery: null,
|
|
12
|
+
previousFilter: null,
|
|
13
|
+
previousResult: null,
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
computed: {
|
|
18
|
+
searchFields() {
|
|
19
|
+
const out = columnsToSearchField(this.columns);
|
|
20
|
+
|
|
21
|
+
if ( this.extraSearchFields ) {
|
|
22
|
+
addObjects(out, this.extraSearchFields);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return out;
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
subFields: computed('subHeaders.@each.{searchField,name}', 'extraSearchSubFields.[]', function() {
|
|
30
|
+
let out = headersToSearchField(get(this, 'subHeaders'));
|
|
31
|
+
|
|
32
|
+
return out.addObjects(get(this, 'extraSearchSubFields') || []);
|
|
33
|
+
}),
|
|
34
|
+
*/
|
|
35
|
+
filteredRows() {
|
|
36
|
+
if (this.externalPaginationEnabled) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// PROP hasAdvancedFiltering comes from Advanced Filtering mixin (careful changing data var there...)
|
|
41
|
+
if (!this.hasAdvancedFiltering) {
|
|
42
|
+
return this.handleFiltering();
|
|
43
|
+
} else {
|
|
44
|
+
return this.handleAdvancedFiltering();
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
methods: {
|
|
50
|
+
handleAdvancedFiltering() {
|
|
51
|
+
this.subMatches = null;
|
|
52
|
+
|
|
53
|
+
if (this.searchQuery.length) {
|
|
54
|
+
const out = (this.arrangedRows || []).slice();
|
|
55
|
+
|
|
56
|
+
const res = out.filter((row) => {
|
|
57
|
+
return this.searchQuery.every((f) => {
|
|
58
|
+
if (f.prop === ADV_FILTER_ALL_COLS_VALUE) {
|
|
59
|
+
// advFilterSelectOptions comes from Advanced Filtering mixin
|
|
60
|
+
// remove the All Columns option from the list so that we don't iterate over it
|
|
61
|
+
const allCols = this.advFilterSelectOptions.slice(1);
|
|
62
|
+
let searchFields = [];
|
|
63
|
+
|
|
64
|
+
allCols.forEach((col) => {
|
|
65
|
+
if (col.value.includes('[') && col.value.includes(']')) {
|
|
66
|
+
searchFields = searchFields.concat(JSON.parse(col.value));
|
|
67
|
+
} else {
|
|
68
|
+
// this means we are on the presence of a label, which should be dealt
|
|
69
|
+
// carefully because of object path such row.metadata.labels."app.kubernetes.io/managed-by
|
|
70
|
+
const value = col.isLabel ? `${ col.label }${ LABEL_IDENTIFIER }` : col.value;
|
|
71
|
+
|
|
72
|
+
searchFields.push(value);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return handleStringSearch(searchFields, [f.value], row);
|
|
77
|
+
} else {
|
|
78
|
+
if (f.prop.includes('[') && f.prop.includes(']')) {
|
|
79
|
+
return handleStringSearch(JSON.parse(f.prop), [f.value], row);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let prop = f.prop;
|
|
83
|
+
|
|
84
|
+
// this means we are on the presence of a label, which should be dealt
|
|
85
|
+
// carefully because of object path such row.metadata.labels."app.kubernetes.io/managed-by"
|
|
86
|
+
if (f.prop.includes('metadata.labels')) {
|
|
87
|
+
prop = `${ f.label }${ LABEL_IDENTIFIER }`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return handleStringSearch([prop], [f.value], row);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return res;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// return arrangedRows array if we don't have anything to search for...
|
|
99
|
+
return this.arrangedRows;
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
handleFiltering() {
|
|
103
|
+
const searchText = (this.searchQuery || '').trim().toLowerCase();
|
|
104
|
+
let out;
|
|
105
|
+
|
|
106
|
+
if ( searchText && this.previousResult && searchText.startsWith(this.previousFilter) ) {
|
|
107
|
+
// If the new search is an addition to the last one, we can start with the same set of results as last time
|
|
108
|
+
// and filter those down, since adding more searchText can only reduce the number of results.
|
|
109
|
+
out = this.previousResult.slice();
|
|
110
|
+
} else {
|
|
111
|
+
this.previousResult = null;
|
|
112
|
+
out = (this.arrangedRows || []).slice();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.previousFilter = searchText;
|
|
116
|
+
|
|
117
|
+
if ( !searchText.length ) {
|
|
118
|
+
this.subMatches = null;
|
|
119
|
+
this.previousResult = null;
|
|
120
|
+
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const searchFields = this.searchFields;
|
|
125
|
+
const searchTokens = searchText.split(/\s*[, ]\s*/);
|
|
126
|
+
const subSearch = this.subSearch;
|
|
127
|
+
const subFields = this.subFields;
|
|
128
|
+
const subMatches = {};
|
|
129
|
+
|
|
130
|
+
for ( let i = out.length - 1 ; i >= 0 ; i-- ) {
|
|
131
|
+
const row = out[i];
|
|
132
|
+
let hits = 0;
|
|
133
|
+
let mainFound = true;
|
|
134
|
+
|
|
135
|
+
mainFound = handleStringSearch(searchFields, searchTokens, row);
|
|
136
|
+
|
|
137
|
+
if ( subFields && subSearch) {
|
|
138
|
+
const subRows = row[subSearch] || [];
|
|
139
|
+
|
|
140
|
+
for ( let k = subRows.length - 1 ; k >= 0 ; k-- ) {
|
|
141
|
+
let subFound = true;
|
|
142
|
+
|
|
143
|
+
subFound = handleStringSearch(subFields, searchTokens, row);
|
|
144
|
+
|
|
145
|
+
if ( subFound ) {
|
|
146
|
+
hits++;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
subMatches[get(row, this.keyField)] = hits;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if ( !mainFound && hits === 0 ) {
|
|
154
|
+
removeAt(out, i);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
this.subMatches = subMatches;
|
|
159
|
+
this.previousResult = out;
|
|
160
|
+
|
|
161
|
+
return out;
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
watch: {
|
|
166
|
+
arrangedRows(q) {
|
|
167
|
+
// The rows changed so the old filter result is no longer useful
|
|
168
|
+
this.previousResult = null;
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
searchQuery() {
|
|
172
|
+
this.debouncedPaginationChanged();
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
function columnsToSearchField(columns) {
|
|
178
|
+
const out = [];
|
|
179
|
+
|
|
180
|
+
(columns || []).forEach((column) => {
|
|
181
|
+
const field = column.search;
|
|
182
|
+
|
|
183
|
+
if ( field ) {
|
|
184
|
+
if ( typeof field === 'string' ) {
|
|
185
|
+
addObject(out, field);
|
|
186
|
+
} else if ( isArray(field) ) {
|
|
187
|
+
addObjects(out, field);
|
|
188
|
+
}
|
|
189
|
+
} else if ( field === false ) {
|
|
190
|
+
// Don't add the name
|
|
191
|
+
} else {
|
|
192
|
+
// Use value/name as the default
|
|
193
|
+
addObject(out, column.value || column.name);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
return out.filter((x) => !!x);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const ipLike = /^[0-9a-f\.:]+$/i;
|
|
201
|
+
|
|
202
|
+
function handleStringSearch(searchFields, searchTokens, row) {
|
|
203
|
+
for ( let j = 0 ; j < searchTokens.length ; j++ ) {
|
|
204
|
+
let expect = true;
|
|
205
|
+
let token = searchTokens[j];
|
|
206
|
+
|
|
207
|
+
if ( token.substr(0, 1) === '!' ) {
|
|
208
|
+
expect = false;
|
|
209
|
+
token = token.substr(1);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if ( token && matches(searchFields, token, row) !== expect ) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function matches(fields, token, item) {
|
|
221
|
+
for ( let field of fields ) {
|
|
222
|
+
if ( !field ) {
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// some items might not even have metadata.labels or metadata.labels.something... ignore those items. Nothing to filter by
|
|
227
|
+
if (typeof field !== 'function' &&
|
|
228
|
+
field.includes(LABEL_IDENTIFIER) &&
|
|
229
|
+
(!item.metadata.labels || !item.metadata.labels[field.replace(LABEL_IDENTIFIER, '')])) {
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
let modifier;
|
|
234
|
+
let val;
|
|
235
|
+
|
|
236
|
+
if (typeof field === 'function') {
|
|
237
|
+
val = field(item);
|
|
238
|
+
} else if (field.includes(LABEL_IDENTIFIER)) {
|
|
239
|
+
val = item.metadata.labels[field.replace(LABEL_IDENTIFIER, '')];
|
|
240
|
+
} else {
|
|
241
|
+
const idx = field.indexOf(':');
|
|
242
|
+
|
|
243
|
+
if ( idx > 0 ) {
|
|
244
|
+
modifier = field.substr(idx + 1);
|
|
245
|
+
field = field.substr(0, idx);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if ( field.includes('.') ) {
|
|
249
|
+
val = get(item, field);
|
|
250
|
+
} else {
|
|
251
|
+
val = item[field];
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if ( val === undefined ) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
val = (`${ val }`).toLowerCase();
|
|
260
|
+
if ( !val ) {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if ( !modifier ) {
|
|
265
|
+
if ( val.includes((`${ token }`).toLowerCase()) ) {
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
} else if ( modifier === 'exact' ) {
|
|
269
|
+
if ( val === token ) {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
} else if ( modifier === 'ip' ) {
|
|
273
|
+
const tokenMayBeIp = ipLike.test(token);
|
|
274
|
+
|
|
275
|
+
if ( tokenMayBeIp ) {
|
|
276
|
+
const re = new RegExp(`(?:^|\\.)${ token }(?:\\.|$)`);
|
|
277
|
+
|
|
278
|
+
if ( re.test(val) ) {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} else if ( modifier === 'prefix' ) {
|
|
283
|
+
if ( val.indexOf(token) === 0) {
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return false;
|
|
290
|
+
}
|