MCPcopy Create free account
hub / github.com/monitoror/monitoror / fetchConfiguration

Function fetchConfiguration

ui/src/store.ts:287–330  ·  view source on GitHub ↗
({commit, state, getters, dispatch})

Source from the content-addressed store, hash-verified

285 })
286 },
287 async fetchConfiguration({commit, state, getters, dispatch}) {
288 const hydrateTile = (tile: TileConfig, groupTile?: TileConfig) => {
289 // Create a identifier based on tile configuration
290 tile.stateKey = tile.type + '_' + md5.hashStr(JSON.stringify(tile))
291
292 if (tile.url) {
293 // Prefix URL with api base URL
294 tile.url = getters.apiBaseUrl + tile.url
295
296 // Create a task for this tile
297 dispatch('createRefreshTileTask', {tile, groupTile})
298 }
299
300 // Set stateKey on group subTiles
301 if (tile.tiles) {
302 tile.tiles = tile.tiles.map((subTile) => hydrateTile(subTile, tile))
303 }
304
305 return tile
306 }
307
308 commit('setLastRefreshDate', new Date())
309
310 return axios.get(getters.proxyfiedConfigUrl)
311 .then((response) => {
312 const configBag: ConfigBag = response.data
313
314 // Kill old refreshTile tasks
315 state.tasks
316 .filter((task) => task.type === TaskType.RefreshTile && !getters.tileStateKeys.includes(task.id))
317 .map((task) => task.kill())
318
319 if (configBag.errors !== undefined) {
320 commit('setErrors', configBag.errors)
321 } else {
322 commit('setErrors', [])
323
324 if (configBag.config !== undefined) {
325 configBag.config.tiles = configBag.config.tiles.map((tile) => hydrateTile(tile))
326 commit('setConfig', configBag.config)
327 }
328 }
329 })
330 },
331 createRefreshTileTask({dispatch}, {tile, groupTile}: { tile: TileConfig, groupTile?: TileConfig }) {
332 dispatch('addTask', {
333 id: tile.stateKey,

Callers

nothing calls this directly

Calls 3

hydrateTileFunction · 0.85
getMethod · 0.80
killMethod · 0.80

Tested by

no test coverage detected