mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 06:26:00 +00:00
files widget
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
15
packages/web/src/utility/hasPermission.ts
Normal file
15
packages/web/src/utility/hasPermission.ts
Normal 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);
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user