fix:补充导入信息

This commit is contained in:
wangwenrui
2021-03-22 10:25:41 +08:00
parent 74633869d6
commit 870be5a22b
2 changed files with 80 additions and 80 deletions

View File

@@ -370,8 +370,8 @@ import draggable from 'vuedraggable'
// 引入Leaflet对象 挂载到Vue上便于全局使用也可以单独页面中单独引用 // 引入Leaflet对象 挂载到Vue上便于全局使用也可以单独页面中单独引用
import 'leaflet/dist/leaflet.css' import 'leaflet/dist/leaflet.css'
import * as L from 'leaflet' import * as L from 'leaflet'
import icon from 'leaflet/dist/images/marker-icon.png'; import icon from 'leaflet/dist/images/marker-icon.png'
import iconShadow from 'leaflet/dist/images/marker-shadow.png'; import iconShadow from 'leaflet/dist/images/marker-shadow.png'
export default { export default {
name: 'system', name: 'system',
components: { draggable }, components: { draggable },
@@ -390,7 +390,7 @@ export default {
default_cabinet_usize: '', default_cabinet_usize: '',
query_max_series: '', query_max_series: '',
unsaved_change: 'on', unsaved_change: 'on',
map_center_config:{"longitude":116.39,"latitude":39.9,"zoom":4,"minZoom":1,"maxZoom":10} map_center_config: { longitude: 116.39, latitude: 39.9, zoom: 4, minZoom: 1, maxZoom: 10 }
}, },
mapConfigVisible: false, mapConfigVisible: false,
map: null, map: null,
@@ -556,56 +556,56 @@ export default {
methods: { methods: {
initMap: function () { initMap: function () {
if (this.map) { if (this.map) {
this.map.remove(); this.map.remove()
this.map=null; this.map = null
} }
let DefaultIcon = L.icon({ const DefaultIcon = L.icon({
iconUrl: icon, iconUrl: icon,
iconSize: [26, 40], iconSize: [26, 40],
iconAnchor: [13, 40], iconAnchor: [13, 40],
shadowUrl: iconShadow shadowUrl: iconShadow
}); })
L.Marker.prototype.options.icon = DefaultIcon; L.Marker.prototype.options.icon = DefaultIcon
let map = L.map("map",{ const map = L.map('map', {
minZoom: this.basic.map_center_config.minZoom, minZoom: this.basic.map_center_config.minZoom,
maxZoom: this.basic.map_center_config.maxZoom, maxZoom: this.basic.map_center_config.maxZoom,
attributionControl: false, attributionControl: false,
zoomControl: false, zoomControl: false,
maxBounds: L.latLngBounds(L.latLng(-90, -180), L.latLng(90, 180)) maxBounds: L.latLngBounds(L.latLng(-90, -180), L.latLng(90, 180))
}).setView([this.basic.map_center_config.latitude,this.basic.map_center_config.longitude],this.basic.map_center_config.zoom); }).setView([this.basic.map_center_config.latitude, this.basic.map_center_config.longitude], this.basic.map_center_config.zoom)
L.tileLayer( L.tileLayer(
"/static/Tiles/{z}/{x}/{y}.png", '/static/Tiles/{z}/{x}/{y}.png',
{ noWrap: true } { noWrap: true }
).addTo(map); ).addTo(map)
let attribution=L.control.attribution({position:'bottomright',prefix:''}) const attribution = L.control.attribution({ position: 'bottomright', prefix: '' })
attribution.addAttribution(' © OpenStreetMap contributors') attribution.addAttribution(' © OpenStreetMap contributors')
attribution.addTo(map) attribution.addTo(map)
L.control.zoom({ L.control.zoom({
position: 'bottomright', position: 'bottomright',
zoomInText:`<i class="nz-icon nz-icon-enlarge"></i>`, zoomInText: '<i class="nz-icon nz-icon-enlarge"></i>',
zoomOutText:`<i class="nz-icon nz-icon-narrow"></i>`, zoomOutText: '<i class="nz-icon nz-icon-narrow"></i>',
zoomInTitle: '', zoomInTitle: '',
zoomOutTitle:'', zoomOutTitle: ''
}).addTo(map) }).addTo(map)
let marker = L.marker([this.basic.map_center_config.latitude,this.basic.map_center_config.longitude]).addTo(map); const marker = L.marker([this.basic.map_center_config.latitude, this.basic.map_center_config.longitude]).addTo(map)
map.on("click", function(e) { map.on('click', function (e) {
var lat = e.latlng.lat; const lat = e.latlng.lat
var lng = e.latlng.lng; const lng = e.latlng.lng
marker.setLatLng([lat,lng]); marker.setLatLng([lat, lng])
}); })
this.map = map; this.map = map
this.marker = marker; this.marker = marker
}, },
mapClose: function () { mapClose: function () {
this.mapConfigVisible = false this.mapConfigVisible = false
let latlng = this.marker.getLatLng(); const latlng = this.marker.getLatLng()
this.basic.map_center_config.latitude = latlng.lat; this.basic.map_center_config.latitude = latlng.lat
this.basic.map_center_config.longitude = latlng.lng; this.basic.map_center_config.longitude = latlng.lng
this.basic.map_center_config.zoom = this.map.getZoom(); this.basic.map_center_config.zoom = this.map.getZoom()
}, },
selectTab: function (tab) { selectTab: function (tab) {
this.querySetInfo(tab.name) this.querySetInfo(tab.name)
@@ -654,14 +654,14 @@ export default {
this.prevent_opt.save = true this.prevent_opt.save = true
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
let param={}; const param = {}
if (type == 'basic') { if (type == 'basic') {
this.basic.map_center_config = JSON.stringify(this.basic.map_center_config) this.basic.map_center_config = JSON.stringify(this.basic.map_center_config)
} }
param[type] = Object.assign({}, this[type]) param[type] = Object.assign({}, this[type])
this.$set(param[type], 'test', 'false') this.$set(param[type], 'test', 'false')
let postParam = Object.assign({}, param) const postParam = Object.assign({}, param)
for (let key in postParam[type]) { for (const key in postParam[type]) {
postParam[type][key] = postParam[type][key] + '' postParam[type][key] = postParam[type][key] + ''
} }
this.$put('/sysConfig', postParam).then(response => { this.$put('/sysConfig', postParam).then(response => {
@@ -687,11 +687,11 @@ export default {
this.prevent_opt.save = true this.prevent_opt.save = true
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
let param = {} const param = {}
param[type] = Object.assign({}, this[type]) param[type] = Object.assign({}, this[type])
this.$set(param[type], 'test', 'true') this.$set(param[type], 'test', 'true')
let postParam = Object.assign({}, param) const postParam = Object.assign({}, param)
for (let key in postParam[type]) { for (const key in postParam[type]) {
postParam[type][key] = postParam[type][key] + '' postParam[type][key] = postParam[type][key] + ''
} }
this.$put('/sysConfig', postParam).then(response => { this.$put('/sysConfig', postParam).then(response => {
@@ -709,7 +709,6 @@ export default {
}) })
}, },
resetForm (formName, type) { resetForm (formName, type) {
this.$refs[formName].resetFields() this.$refs[formName].resetFields()
this[type] = Object.assign({}, this[type + 'Copy']) this[type] = Object.assign({}, this[type + 'Copy'])
@@ -927,7 +926,7 @@ export default {
}, },
// link edit // link edit
notificationEdit (item) { notificationEdit (item) {
let index = this.notification.findIndex((item1) => item.id == item1.id) const index = this.notification.findIndex((item1) => item.id == item1.id)
this.$set(this.notification, index, { ...this.notification[index], isEdit: true }) this.$set(this.notification, index, { ...this.notification[index], isEdit: true })
}, },
// link update // link update
@@ -936,7 +935,7 @@ export default {
this.prevent_opt.save = true this.prevent_opt.save = true
this.$refs['notificationForm' + item.id][0].validate((valid) => { this.$refs['notificationForm' + item.id][0].validate((valid) => {
if (valid) { if (valid) {
let params = { const params = {
id: item.id, id: item.id,
name: item.name, name: item.name,
filePath: item.filePath filePath: item.filePath
@@ -944,7 +943,7 @@ export default {
this.$put('/alert/script', params).then(response => { this.$put('/alert/script', params).then(response => {
this.prevent_opt.save = false this.prevent_opt.save = false
if (response.code == 200) { if (response.code == 200) {
let index = this.notification.findIndex((item1) => item.id == item1.id) const index = this.notification.findIndex((item1) => item.id == item1.id)
this.$set(this.notification, index, { ...this.notification[index], isEdit: false }) this.$set(this.notification, index, { ...this.notification[index], isEdit: false })
this.notificationReserved = [...this.notification] this.notificationReserved = [...this.notification]
// this.$store.commit('setLinkData',this.notification); // this.$store.commit('setLinkData',this.notification);
@@ -961,8 +960,8 @@ export default {
}, },
// link cancel // link cancel
notificationCancel (item) { notificationCancel (item) {
let index = this.notification.findIndex((item1) => item.id == item1.id) const index = this.notification.findIndex((item1) => item.id == item1.id)
let indexReserved = this.notificationReserved.findIndex((item1) => item.id == item1.id) const indexReserved = this.notificationReserved.findIndex((item1) => item.id == item1.id)
this.$set(this.notification, index, { ...this.notificationReserved[indexReserved], isEdit: false }) this.$set(this.notification, index, { ...this.notificationReserved[indexReserved], isEdit: false })
}, },
// link del // link del

View File

@@ -151,10 +151,11 @@
<script> <script>
import selectAlertSilence from '../../../common/alert/selectAlertSilence' import selectAlertSilence from '../../../common/alert/selectAlertSilence'
import editor from './editor'
export default { export default {
name: 'promqlInput', name: 'promqlInput',
components: { components: {
'editor':editor, editor: editor,
selectAlertSilence selectAlertSilence
}, },
props: { props: {
@@ -203,7 +204,7 @@ export default {
datacenterOption: [], datacenterOption: [],
projectOption: [], projectOption: [],
filterSilence: '', filterSilence: '',
tempBoxId:{}, tempBoxId: {}
} }
}, },
created () { created () {
@@ -232,8 +233,8 @@ export default {
queryMetrics: function () { queryMetrics: function () {
this.$get('prom/api/v1/label/__name__/values').then(response => { this.$get('prom/api/v1/label/__name__/values').then(response => {
if (response.status == 'success') { if (response.status == 'success') {
let metrics = response.data.sort() const metrics = response.data.sort()
let metricMap = new Map() const metricMap = new Map()
metrics.forEach((item) => { metrics.forEach((item) => {
let key = '' let key = ''
if (/^[a-zA-Z]+?_[a-zA-Z]*/.test(item)) { if (/^[a-zA-Z]+?_[a-zA-Z]*/.test(item)) {
@@ -244,16 +245,16 @@ export default {
key = item key = item
} }
if (metricMap.get(key)) { if (metricMap.get(key)) {
let values = metricMap.get(key) const values = metricMap.get(key)
values.push({ label: item, value: item }) values.push({ label: item, value: item })
} else { } else {
let values = [{ label: item, value: item }] const values = [{ label: item, value: item }]
metricMap.set(key, values) metricMap.set(key, values)
} }
// this.metricStore.push({label:item,value:item,insertText:item}) // this.metricStore.push({label:item,value:item,insertText:item})
}) })
for (let key of metricMap.keys()) { for (const key of metricMap.keys()) {
let option = { const option = {
label: key, label: key,
value: key value: key
} }
@@ -269,8 +270,8 @@ export default {
}) })
}, },
filterInput: function (queryString, cb) { filterInput: function (queryString, cb) {
let metrics = Object.assign([], this.metricStore) const metrics = Object.assign([], this.metricStore)
let result = queryString const result = queryString
? metrics.filter((item) => { ? metrics.filter((item) => {
return item.value.toLowerCase().indexOf(queryString.toLowerCase()) != -1 return item.value.toLowerCase().indexOf(queryString.toLowerCase()) != -1
}) })
@@ -354,7 +355,7 @@ export default {
this.tempBoxShow = flag this.tempBoxShow = flag
if (flag) { if (flag) {
this.cascaderValue = '' this.cascaderValue = ''
let params = {} const params = {}
params.expression = this.tempBox.expression params.expression = this.tempBox.expression
params.varsVal = {} params.varsVal = {}
let returnFlag = false let returnFlag = false
@@ -395,8 +396,8 @@ export default {
}, },
format (str) { format (str) {
let arr = str.split('.') const arr = str.split('.')
let keyword = arr[0].toLowerCase() const keyword = arr[0].toLowerCase()
switch (keyword) { switch (keyword) {
case 'asset': case 'asset':
case 'module': case 'module':
@@ -419,14 +420,14 @@ export default {
case 'asset': case 'asset':
this.$get('asset', { pageNo: 1, pageSize: -1 }).then(response => { this.$get('asset', { pageNo: 1, pageSize: -1 }).then(response => {
if (response.code == 200) { if (response.code == 200) {
let arr = [] const arr = []
response.data.list.forEach(asset => { response.data.list.forEach(asset => {
asset.name = asset.sn asset.name = asset.sn
let idcF = arr.find(idc => idc.id === asset.idc.id) const idcF = arr.find(idc => idc.id === asset.idc.id)
if (idcF) { if (idcF) {
idcF.children.push(asset) idcF.children.push(asset)
} else { } else {
let idc = { ...asset.idc } const idc = { ...asset.idc }
idc.children = [asset] idc.children = [asset]
arr.push(idc) arr.push(idc)
} }
@@ -438,13 +439,13 @@ export default {
case 'module': case 'module':
this.$get('module', { pageNo: 1, pageSize: -1 }).then(response => { this.$get('module', { pageNo: 1, pageSize: -1 }).then(response => {
if (response.code == 200) { if (response.code == 200) {
let arr = [] const arr = []
response.data.list.forEach(module => { response.data.list.forEach(module => {
let projectF = arr.find(project => project.id === module.project.id) const projectF = arr.find(project => project.id === module.project.id)
if (projectF) { if (projectF) {
projectF.children.push(module) projectF.children.push(module)
} else { } else {
let project = { ...module.project } const project = { ...module.project }
project.children = [module] project.children = [module]
arr.push(project) arr.push(project)
} }
@@ -456,19 +457,19 @@ export default {
case 'endpoint': case 'endpoint':
this.$get('endpoint', { pageNo: 1, pageSize: -1 }).then(response => { this.$get('endpoint', { pageNo: 1, pageSize: -1 }).then(response => {
if (response.code == 200) { if (response.code == 200) {
let arr = [] const arr = []
response.data.list.forEach(item => { response.data.list.forEach(item => {
item.name = item.host item.name = item.host
let projectF = arr.find(project => item.project.id === project.id) const projectF = arr.find(project => item.project.id === project.id)
if (projectF) { if (projectF) {
let moduleF = projectF.children.find(module => module.id === item.module.id) const moduleF = projectF.children.find(module => module.id === item.module.id)
if (moduleF) { if (moduleF) {
moduleF.children.push(item) moduleF.children.push(item)
} else { } else {
projectF.children.push({ ...item.module, children: [item] }) projectF.children.push({ ...item.module, children: [item] })
} }
} else { } else {
let project = { ...item.project } const project = { ...item.project }
project.children = [{ ...item.module, children: [item] }] project.children = [{ ...item.module, children: [item] }]
arr.push(project) arr.push(project)
} }
@@ -497,7 +498,7 @@ export default {
}, },
silenceChange (val, key) { silenceChange (val, key) {
this.tempBox[key] = val.name this.tempBox[key] = val.name
this.tempBoxId[key]=val.id; this.tempBoxId[key] = val.id
}, },
clearValue (key) { clearValue (key) {
this.tempBox[key] = '' this.tempBox[key] = ''