files widget

This commit is contained in:
Jan Prochazka
2021-03-11 09:42:14 +01:00
parent a93aff1bb7
commit d5ebea3764
20 changed files with 296 additions and 33 deletions

View File

@@ -1,16 +1,16 @@
import _ from 'lodash';
import { openedConnections, currentDatabase } from '../stores';
import axios from './axios';
import axiosInstance from './axiosInstance';
const doServerPing = value => {
axios.post('server-connections/ping', { connections: value });
axiosInstance.post('server-connections/ping', { connections: value });
};
const doDatabasePing = value => {
const database = _.get(value, 'name');
const conid = _.get(value, 'connection._id');
if (conid && database) {
axios.post('database-connections/ping', { conid, database });
axiosInstance.post('database-connections/ping', { conid, database });
}
};

View File

@@ -0,0 +1,15 @@
import { compilePermissions, testPermission } from 'dbgate-tools';
import { useConfig } from './metadataLoaders';
let compiled = null;
const config = useConfig();
config.subscribe(value => {
if (!value) return;
const { permissions } = value;
compiled = compilePermissions(permissions);
});
export default function hasPermission(tested) {
return testPermission(tested, compiled);
}

View File

@@ -1,4 +1,4 @@
import axios from './axios';
import axiosInstance from './axiosInstance';
import _ from 'lodash';
import { cacheGet, cacheSet, getCachedPromise } from './cache';
import stableStringify from 'json-stable-stringify';
@@ -130,7 +130,7 @@ async function getCore(loader, args) {
const key = stableStringify({ url, ...params });
async function doLoad() {
const resp = await axios.request({
const resp = await axiosInstance.request({
method: 'get',
url,
params,
@@ -154,7 +154,7 @@ function useCore(loader, args) {
subscribe: onChange => {
async function handleReload() {
async function doLoad() {
const resp = await axios.request({
const resp = await axiosInstance.request({
method: 'get',
params,
url,
@@ -331,7 +331,7 @@ export function getConfig() {
return getCore(configLoader, {}) || {};
}
export function useConfig() {
return useCore(configLoader, {}) || {};
return useCore(configLoader, {});
}
export function getPlatformInfo() {

View File

@@ -1,11 +1,11 @@
import _ from 'lodash';
import axios from './axios';
import axiosInstance from './axiosInstance';
import { writable } from 'svelte/store';
export default function useFetch({ url, data = undefined, params = undefined, defaultValue = undefined, ...config }) {
const result = writable(defaultValue);
axios
axiosInstance
.request({
method: 'get',
params,