|
@@ -43,7 +43,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div v-else-if="!loading && !executor">
|
|
<div v-else-if="!loading && !executor">
|
|
|
- Failed loading the SQL Scratchpad!
|
|
|
|
|
|
|
+ {{ errorMessage || 'Failed loading the SQL Scratchpad!' }}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
@@ -66,6 +66,8 @@
|
|
|
import ResultTable from '../result/ResultTable.vue';
|
|
import ResultTable from '../result/ResultTable.vue';
|
|
|
import Executor from '../../execution/executor';
|
|
import Executor from '../../execution/executor';
|
|
|
import SqlExecutable from '../../execution/sqlExecutable';
|
|
import SqlExecutable from '../../execution/sqlExecutable';
|
|
|
|
|
+ import { AuthType, login } from 'api/auth';
|
|
|
|
|
+ import { setBaseUrl } from 'api/utils';
|
|
|
import contextCatalog from 'catalog/contextCatalog';
|
|
import contextCatalog from 'catalog/contextCatalog';
|
|
|
import HueIcons from 'components/icons/HueIcons.vue';
|
|
import HueIcons from 'components/icons/HueIcons.vue';
|
|
|
import Spinner from 'components/Spinner.vue';
|
|
import Spinner from 'components/Spinner.vue';
|
|
@@ -88,13 +90,30 @@
|
|
|
dialect: {
|
|
dialect: {
|
|
|
type: String as PropType<string | null>,
|
|
type: String as PropType<string | null>,
|
|
|
default: null
|
|
default: null
|
|
|
|
|
+ },
|
|
|
|
|
+ auth: {
|
|
|
|
|
+ type: String as PropType<AuthType | null>,
|
|
|
|
|
+ default: AuthType.jwt
|
|
|
|
|
+ },
|
|
|
|
|
+ user: {
|
|
|
|
|
+ type: String as PropType<string | null>,
|
|
|
|
|
+ default: null
|
|
|
|
|
+ },
|
|
|
|
|
+ password: {
|
|
|
|
|
+ type: String as PropType<string | null>,
|
|
|
|
|
+ default: null
|
|
|
|
|
+ },
|
|
|
|
|
+ apiUrl: {
|
|
|
|
|
+ type: String as PropType<string | null>,
|
|
|
|
|
+ default: null
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
setup(props) {
|
|
setup(props) {
|
|
|
- const { dialect } = toRefs(props);
|
|
|
|
|
- const activeExecutable = ref<SqlExecutable | null>(null);
|
|
|
|
|
- const executor = ref<Executor | null>(null);
|
|
|
|
|
|
|
+ const { apiUrl, auth, dialect, pass, user } = toRefs(props);
|
|
|
|
|
+ const activeExecutable = ref<SqlExecutable>(null);
|
|
|
|
|
+ const executor = ref<Executor>(null);
|
|
|
const loading = ref<boolean>(true);
|
|
const loading = ref<boolean>(true);
|
|
|
|
|
+ const errorMessage = ref<string>(null);
|
|
|
const id = UUID();
|
|
const id = UUID();
|
|
|
|
|
|
|
|
const sqlParserProvider: SqlParserProvider = {
|
|
const sqlParserProvider: SqlParserProvider = {
|
|
@@ -116,11 +135,26 @@
|
|
|
minLines: null
|
|
minLines: null
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const initializeExecutor = async (): Promise<void> => {
|
|
|
|
|
|
|
+ const initialize = async (): Promise<void> => {
|
|
|
|
|
+ if (apiUrl.value) {
|
|
|
|
|
+ setBaseUrl(apiUrl.value);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (user.value !== null && pass.value !== null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ await login(user.value, pass.value, auth.value);
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ errorMessage.value = 'Login failed!';
|
|
|
|
|
+ console.error(err);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
await getConfig();
|
|
await getConfig();
|
|
|
- } catch {
|
|
|
|
|
- console.warn('Failed loading Hue config!');
|
|
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ errorMessage.value = 'Failed loading the Hue config!';
|
|
|
|
|
+ console.error(err);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -128,7 +162,7 @@
|
|
|
connector => !dialect.value || connector.dialect === dialect.value
|
|
connector => !dialect.value || connector.dialect === dialect.value
|
|
|
);
|
|
);
|
|
|
if (!connector) {
|
|
if (!connector) {
|
|
|
- console.warn('No connector found!');
|
|
|
|
|
|
|
+ errorMessage.value = 'No connector found!';
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -136,7 +170,7 @@
|
|
|
const { namespaces } = await contextCatalog.getNamespaces({ connector });
|
|
const { namespaces } = await contextCatalog.getNamespaces({ connector });
|
|
|
|
|
|
|
|
if (!namespaces.length || !namespaces[0].computes.length) {
|
|
if (!namespaces.length || !namespaces[0].computes.length) {
|
|
|
- console.warn('No namespaces or computes found!');
|
|
|
|
|
|
|
+ errorMessage.value = 'No namespaces or computes found!';
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -162,14 +196,17 @@
|
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
|
loading.value = true;
|
|
loading.value = true;
|
|
|
try {
|
|
try {
|
|
|
- await initializeExecutor();
|
|
|
|
|
- } catch {}
|
|
|
|
|
|
|
+ await initialize();
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ console.error(err);
|
|
|
|
|
+ }
|
|
|
loading.value = false;
|
|
loading.value = false;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
aceOptions,
|
|
aceOptions,
|
|
|
activeExecutable,
|
|
activeExecutable,
|
|
|
|
|
+ errorMessage,
|
|
|
executor,
|
|
executor,
|
|
|
id,
|
|
id,
|
|
|
onActiveStatementChanged,
|
|
onActiveStatementChanged,
|