- AbitaregliIblei.it
- Server aggiornamenti agli script. - Editor HTML corretto un po'. - Record Mysql per server (appena iniziato)
This commit is contained in:
@@ -21,6 +21,7 @@ export default defineComponent({
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
const circuitStore = useCircuitStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const messages = ref('')
|
||||
const input = ref('')
|
||||
@@ -57,6 +58,84 @@ export default defineComponent({
|
||||
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
const selectedApi = ref(<string>'');
|
||||
|
||||
const dnsPageActive = ref(false)
|
||||
|
||||
const optionsApi = ref(<any>[])
|
||||
const arrZones = ref(<any>[])
|
||||
const arrDNS = ref(<any>[])
|
||||
const optZones = ref(<any>[])
|
||||
|
||||
const selected = ref(<any>[])
|
||||
const selZoneId = ref('')
|
||||
|
||||
const columnsZones = [
|
||||
{ name: 'id', align: 'right', label: 'ID', field: 'id', visible: true },
|
||||
{ name: 'name', required: true, label: 'Nome', align: 'left', field: 'name', sortable: true, visible: true },
|
||||
{ name: 'status', align: 'center', label: 'Status', field: 'status', sortable: true, visible: true },
|
||||
{ name: 'proxied', align: 'center', label: 'Proxy', field: 'proxied', sortable: true, visible: true },
|
||||
{ name: 'type', required: true, label: 'Tipo', align: 'left', field: 'type', sortable: true, visible: true },
|
||||
];
|
||||
|
||||
const columnsDNS = [
|
||||
{ name: 'id', required: false, label: 'Id', align: 'left', field: 'id', sortable: false, visible: false },
|
||||
{ name: 'name', required: true, label: 'Nome', align: 'left', field: 'name', sortable: true, visible: true },
|
||||
{ name: 'type', required: true, label: 'Tipo', align: 'left', field: 'type', sortable: true, visible: true },
|
||||
{ name: 'proxied', required: true, align: 'center', label: 'Proxy', field: 'proxied', sortable: true, visible: true },
|
||||
{ name: 'content', required: true, label: 'Valore', align: 'left', field: 'content', sortable: true, visible: true },
|
||||
];
|
||||
|
||||
const viscolumnsDNS = [
|
||||
{ name: 'name', required: true, label: 'Nome', align: 'left', field: 'name', sortable: true, visible: true, editable: true },
|
||||
{ name: 'type', required: true, label: 'Tipo', align: 'left', field: 'type', sortable: true, visible: true, editable: true },
|
||||
{ name: 'proxied', required: true, align: 'center', label: 'Proxy', field: 'proxied', sortable: true, visible: true, editable: true },
|
||||
{ name: 'content', required: true, label: 'Valore', align: 'left', field: 'content', sortable: true, visible: true, editable: true },
|
||||
];
|
||||
|
||||
const pagination = {
|
||||
rowsPerPage: 10,
|
||||
}
|
||||
|
||||
watch(() => selectedApi.value, async (to: any, from: any) => {
|
||||
if (selectedApi.value) {
|
||||
incaricamento.value = true
|
||||
|
||||
tools.setCookie('CF_API_SEL', selectedApi.value)
|
||||
|
||||
arrZones.value = await globalStore.getCloudFlareTok("getzones", selectedApi.value, "")
|
||||
|
||||
incaricamento.value = false
|
||||
|
||||
selZoneId.value = tools.getCookie('CF_API_ZONE_ID_' + selectedApi.value, '')
|
||||
|
||||
optZones.value = []
|
||||
|
||||
for (let i = 0; i < arrZones.value.length; i++) {
|
||||
optZones.value.push({ label: arrZones.value[i].name, value: arrZones.value[i].id })
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => selZoneId.value, async (to: any, from: any) => {
|
||||
if (selZoneId.value) {
|
||||
incaricamento.value = true
|
||||
arrDNS.value = await globalStore.getCloudFlareTok("getDNS", selectedApi.value, selZoneId.value)
|
||||
|
||||
incaricamento.value = false
|
||||
|
||||
tools.setCookie('CF_API_ZONE_ID_' + selectedApi.value, selZoneId.value)
|
||||
|
||||
/*optDNS.value = []
|
||||
|
||||
for (let i = 0; i < arrZones.value.length; i++) {
|
||||
optDNS.value.push({ label: arrZones.value[i].name, value: arrZones.value[i].id })
|
||||
}*/
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => mydir.value, async (to: any, from: any) => {
|
||||
// ...
|
||||
|
||||
@@ -64,9 +143,21 @@ export default defineComponent({
|
||||
|
||||
myarrscript.value = []
|
||||
|
||||
if (mydir.value)
|
||||
myarrscript.value = await getArrayByScript('ls "admin_scripts/' + mydir.value + '/"', 'sh')
|
||||
dnsPageActive.value = (mydir.value === '2_DNS')
|
||||
|
||||
incaricamento.value = true
|
||||
|
||||
tools.setCookie('CF_API_DIR', mydir.value)
|
||||
|
||||
if (dnsPageActive.value) {
|
||||
// get the Tokens
|
||||
optionsApi.value = await globalStore.getCloudFlareTok("gettok", selectedApi.value, "")
|
||||
} else {
|
||||
if (mydir.value)
|
||||
myarrscript.value = await getArrayByScript('ls "admin_scripts/' + mydir.value + '/"', 'sh')
|
||||
}
|
||||
|
||||
incaricamento.value = false
|
||||
})
|
||||
|
||||
watch(() => messages.value, async (to: any, from: any) => {
|
||||
@@ -88,8 +179,12 @@ export default defineComponent({
|
||||
withinput
|
||||
}
|
||||
|
||||
incaricamento.value = true
|
||||
|
||||
const risfunz = await globalStore.execScript({ mydata })
|
||||
|
||||
incaricamento.value = false
|
||||
|
||||
if (ritornaout) {
|
||||
if (listafiles) {
|
||||
return risfunz.arrout
|
||||
@@ -134,6 +229,9 @@ export default defineComponent({
|
||||
|
||||
scrollToBottom()
|
||||
|
||||
mydir.value = tools.getCookie('CF_API_DIR')
|
||||
|
||||
selectedApi.value = tools.getCookie('CF_API_SEL', '')
|
||||
}
|
||||
|
||||
const scrollToBottom = () => {
|
||||
@@ -237,7 +335,7 @@ export default defineComponent({
|
||||
let timenowstr = '<br><span style="font-style: italic; color: gray;">✅ Eseguito alle ' + tools.getstrTimeAll(Date.now()) + ' -> ' + '</span><br>'
|
||||
messages.value += timenowstr
|
||||
|
||||
ws.send(JSON.stringify({ type: 'start_script', scriptName, dir: mydir.value }));
|
||||
ws.send(JSON.stringify({ user_id: userStore.my._id, type: 'start_script', scriptName, dir: mydir.value }));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -250,6 +348,75 @@ export default defineComponent({
|
||||
}
|
||||
};
|
||||
|
||||
// get the label of the selectedApi (value)
|
||||
const getLabelSelApi = () => {
|
||||
const myrec = optionsApi.value.find((opt: any) => opt.value === selectedApi.value)
|
||||
return myrec ? myrec.label : ''
|
||||
};
|
||||
const getNameBySelZoneinId = () => {
|
||||
const myrec = arrZones.value.find((zone: any) => zone.id === selZoneId.value)
|
||||
return myrec ? myrec.name : ''
|
||||
};
|
||||
|
||||
const getSelectedString = () => {
|
||||
return selected.value.length === 0 ? '' : `${selected.value[0].name} selezionata.`
|
||||
}
|
||||
|
||||
const toggleSelect = (row: any) => {
|
||||
if (selected.value.length > 0 && selected.value[0].id === row.id) {
|
||||
selected.value = [];
|
||||
} else {
|
||||
selected.value = [row];
|
||||
}
|
||||
}
|
||||
|
||||
const saveContentDNS = async (content: string, initialValue: string) => {
|
||||
console.log('record da salvare su CF:', content)
|
||||
|
||||
if (selected.value && selected.value.length > 0 && selected.value[0].id) {
|
||||
const indrec = arrDNS.value.findIndex((rec: any) => rec.id === selected.value[0].id)
|
||||
arrDNS.value[indrec].content = content
|
||||
|
||||
await saveRecordDNS(arrDNS.value[indrec])
|
||||
}
|
||||
}
|
||||
const saveNameDNS = async (name: string, initialValue: string) => {
|
||||
|
||||
if (selected.value && selected.value.length > 0 && selected.value[0].id) {
|
||||
const indrec = arrDNS.value.findIndex((rec: any) => rec.id === selected.value[0].id)
|
||||
arrDNS.value[indrec].name = name
|
||||
|
||||
await saveRecordDNS(arrDNS.value[indrec])
|
||||
}
|
||||
}
|
||||
const saveTypeDNS = async (type: string, initialValue: string) => {
|
||||
|
||||
if (selected.value && selected.value.length > 0 && selected.value[0].id) {
|
||||
const indrec = arrDNS.value.findIndex((rec: any) => rec.id === selected.value[0].id)
|
||||
arrDNS.value[indrec].type = type
|
||||
|
||||
await saveRecordDNS(arrDNS.value[indrec])
|
||||
}
|
||||
}
|
||||
|
||||
const saveRecordDNS = async (row: any) => {
|
||||
|
||||
console.log('record da salvare su CF:', row)
|
||||
|
||||
const recupdated = await globalStore.getCloudFlareTok("setRecordDNS", selectedApi.value, selZoneId.value, row.id, row)
|
||||
|
||||
if (recupdated) {
|
||||
const indrec = arrDNS.value.findIndex((rec: any) => rec.id === recupdated.id)
|
||||
// update record
|
||||
arrDNS.value[indrec] = recupdated
|
||||
|
||||
tools.showPositiveNotif($q, t('db.recupdated'))
|
||||
} else {
|
||||
tools.showNegativeNotif($q, t('db.recfailed'))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -281,6 +448,26 @@ export default defineComponent({
|
||||
inputPrompt,
|
||||
statusWs,
|
||||
scrollArea,
|
||||
selectedApi,
|
||||
dnsPageActive,
|
||||
optionsApi,
|
||||
arrZones,
|
||||
getLabelSelApi,
|
||||
columnsZones,
|
||||
pagination,
|
||||
selected,
|
||||
getSelectedString,
|
||||
toggleSelect,
|
||||
optZones,
|
||||
selZoneId,
|
||||
arrDNS,
|
||||
columnsDNS,
|
||||
getNameBySelZoneinId,
|
||||
viscolumnsDNS,
|
||||
saveRecordDNS,
|
||||
saveContentDNS,
|
||||
saveNameDNS,
|
||||
saveTypeDNS,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user