(forceLoad = false)
| 121 | } |
| 122 | |
| 123 | const loadValues = async (forceLoad = false) => { |
| 124 | if (v.type == VariableQueryType.TextInput) { |
| 125 | return |
| 126 | } |
| 127 | |
| 128 | let result = [] |
| 129 | if (v.enableAll) { |
| 130 | result.push(VarialbeAllOption) |
| 131 | } |
| 132 | |
| 133 | let needQuery = true |
| 134 | if (!forceLoad && v.refresh == VariableRefresh.Manually) { |
| 135 | // load from storage first |
| 136 | let vs = storage.get(VariableManuallyChangedKey + v.id) |
| 137 | if (vs) { |
| 138 | result = [...result, ...vs] |
| 139 | needQuery = false |
| 140 | } |
| 141 | |
| 142 | } |
| 143 | if (needQuery) { |
| 144 | setLoading(true) |
| 145 | const res = await queryVariableValues(v, datasourcs) |
| 146 | setLoading(false) |
| 147 | console.log("load variable values( query )", v.name, res) |
| 148 | if (res.error) { |
| 149 | result = [] |
| 150 | } else { |
| 151 | res.data?.sort() |
| 152 | result = [...result, ...res.data ?? []] |
| 153 | if (v.refresh == VariableRefresh.Manually) { |
| 154 | storage.set(VariableManuallyChangedKey + v.id, res.data) |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | const oldSelected = v.selected |
| 160 | if (!isEqual(result, v.values)) { |
| 161 | if (v.selected != VarialbeAllOption) { |
| 162 | if (!isEmpty(v.selected)) { |
| 163 | const selected = v.selected.split(VariableSplitChar)?.filter(s => result.includes(s)) |
| 164 | if (selected.length == 0) { |
| 165 | autoSetSelected(v, result) |
| 166 | } else { |
| 167 | v.selected = selected.join(VariableSplitChar) |
| 168 | } |
| 169 | } else { |
| 170 | autoSetSelected(v, result) |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | const vars = $variables.get() |
| 176 | if (v.selected != oldSelected || v.selected == VarialbeAllOption) { |
| 177 | const referVars = parseVariableFormat(v.value) |
| 178 | for (const variable of vars) { |
| 179 | // console.log("here33333:",v.name, variable) |
| 180 | // to avoid circle refer evets: |
no test coverage detected