mirror of https://github.com/Fabio286/antares.git
initial implementation of new feature
This commit is contained in:
parent
6573fe69ac
commit
f632a0f189
|
@ -3,6 +3,27 @@
|
||||||
:context-event="contextEvent"
|
:context-event="contextEvent"
|
||||||
@close-context="$emit('close-context')"
|
@close-context="$emit('close-context')"
|
||||||
>
|
>
|
||||||
|
<div
|
||||||
|
v-if="isPinned"
|
||||||
|
class="context-element"
|
||||||
|
@click="unpin"
|
||||||
|
>
|
||||||
|
<span class="d-flex"><i class="mdi mdi-18px mdi-pin-off text-light pr-1" /> {{ $t('word.unpin') }}</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="context-element"
|
||||||
|
@click="pin"
|
||||||
|
>
|
||||||
|
<span class="d-flex"><i class="mdi mdi-18px mdi-pin mdi-rotate-45 text-light pr-1" /> {{ $t('word.pin') }}</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="isConnected"
|
||||||
|
class="context-element"
|
||||||
|
@click="disconnect"
|
||||||
|
>
|
||||||
|
<span class="d-flex"><i class="mdi mdi-18px mdi-power text-light pr-1" /> {{ $t('word.disconnect') }}</span>
|
||||||
|
</div>
|
||||||
<div class="context-element" @click="duplicateConnection">
|
<div class="context-element" @click="duplicateConnection">
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-content-duplicate text-light pr-1" /> {{ $t('word.duplicate') }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-content-duplicate text-light pr-1" /> {{ $t('word.duplicate') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,15 +60,26 @@ import BaseContextMenu from '@/components/BaseContextMenu.vue';
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal.vue';
|
import ConfirmModal from '@/components/BaseConfirmModal.vue';
|
||||||
import { ConnectionParams } from 'common/interfaces/antares';
|
import { ConnectionParams } from 'common/interfaces/antares';
|
||||||
|
|
||||||
|
const connectionsStore = useConnectionsStore();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
getConnectionName,
|
getConnectionName,
|
||||||
addConnection,
|
addConnection,
|
||||||
deleteConnection
|
deleteConnection,
|
||||||
} = useConnectionsStore();
|
pinConnection,
|
||||||
|
unpinConnection
|
||||||
|
} = connectionsStore;
|
||||||
|
|
||||||
|
const { pinnedConnections } = storeToRefs(connectionsStore);
|
||||||
|
|
||||||
const workspacesStore = useWorkspacesStore();
|
const workspacesStore = useWorkspacesStore();
|
||||||
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
||||||
|
|
||||||
const { selectWorkspace } = workspacesStore;
|
const {
|
||||||
|
selectWorkspace,
|
||||||
|
removeConnected: disconnectWorkspace,
|
||||||
|
getWorkspace
|
||||||
|
} = workspacesStore;
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
contextEvent: MouseEvent,
|
contextEvent: MouseEvent,
|
||||||
|
@ -59,6 +91,8 @@ const emit = defineEmits(['close-context']);
|
||||||
const isConfirmModal = ref(false);
|
const isConfirmModal = ref(false);
|
||||||
|
|
||||||
const connectionName = computed(() => getConnectionName(props.contextConnection.uid));
|
const connectionName = computed(() => getConnectionName(props.contextConnection.uid));
|
||||||
|
const isConnected = computed(() => getWorkspace(props.contextConnection.uid).connectionStatus === 'connected');
|
||||||
|
const isPinned = computed(() => pinnedConnections.value.has(props.contextConnection.uid));
|
||||||
|
|
||||||
const confirmDeleteConnection = () => {
|
const confirmDeleteConnection = () => {
|
||||||
if (selectedWorkspace.value === props.contextConnection.uid)
|
if (selectedWorkspace.value === props.contextConnection.uid)
|
||||||
|
@ -88,6 +122,21 @@ const hideConfirmModal = () => {
|
||||||
closeContext();
|
closeContext();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const pin = () => {
|
||||||
|
pinConnection(props.contextConnection.uid);
|
||||||
|
closeContext();
|
||||||
|
};
|
||||||
|
|
||||||
|
const unpin = () => {
|
||||||
|
unpinConnection(props.contextConnection.uid);
|
||||||
|
closeContext();
|
||||||
|
};
|
||||||
|
|
||||||
|
const disconnect = () => {
|
||||||
|
disconnectWorkspace(props.contextConnection.uid);
|
||||||
|
closeContext();
|
||||||
|
};
|
||||||
|
|
||||||
const closeContext = () => {
|
const closeContext = () => {
|
||||||
emit('close-context');
|
emit('close-context');
|
||||||
};
|
};
|
||||||
|
|
|
@ -70,7 +70,7 @@ const connectionsStore = useConnectionsStore();
|
||||||
const workspacesStore = useWorkspacesStore();
|
const workspacesStore = useWorkspacesStore();
|
||||||
|
|
||||||
const { updateStatus } = storeToRefs(applicationStore);
|
const { updateStatus } = storeToRefs(applicationStore);
|
||||||
const { connections: getConnections } = storeToRefs(connectionsStore);
|
const { connections: storedConnections, pinnedConnections, lastConnections } = storeToRefs(connectionsStore);
|
||||||
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
||||||
|
|
||||||
const { showSettingModal, showScratchpad } = applicationStore;
|
const { showSettingModal, showScratchpad } = applicationStore;
|
||||||
|
@ -85,13 +85,16 @@ const contextConnection: Ref<ConnectionParams> = ref(null);
|
||||||
|
|
||||||
const connections = computed({
|
const connections = computed({
|
||||||
get () {
|
get () {
|
||||||
return getConnections.value;
|
return storedConnections.value;
|
||||||
},
|
},
|
||||||
set (value: ConnectionParams[]) {
|
set (value: ConnectionParams[]) {
|
||||||
updateConnections(value);
|
updateConnections(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const pinnedConnectionsArr = computed(() => storedConnections.value.filter(c => pinnedConnections.value.has(c.uid)));
|
||||||
|
const unpinnedConnectionsArr = computed(() => storedConnections.value.filter(c => !pinnedConnections.value.has(c.uid)));
|
||||||
|
|
||||||
const hasUpdates = computed(() => ['available', 'downloading', 'downloaded', 'link'].includes(updateStatus.value));
|
const hasUpdates = computed(() => ['available', 'downloading', 'downloaded', 'link'].includes(updateStatus.value));
|
||||||
|
|
||||||
const contextMenu = (event: MouseEvent, connection: ConnectionParams) => {
|
const contextMenu = (event: MouseEvent, connection: ConnectionParams) => {
|
||||||
|
|
|
@ -139,7 +139,9 @@ module.exports = {
|
||||||
commit: 'Commit',
|
commit: 'Commit',
|
||||||
rollback: 'Rollback',
|
rollback: 'Rollback',
|
||||||
connectionString: 'Connection string',
|
connectionString: 'Connection string',
|
||||||
contributors: 'Contributors'
|
contributors: 'Contributors',
|
||||||
|
pin: 'Pin',
|
||||||
|
unpin: 'Unpin'
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
appWelcome: 'Welcome to Antares SQL Client!',
|
appWelcome: 'Welcome to Antares SQL Client!',
|
||||||
|
|
|
@ -17,7 +17,9 @@ const persistentStore = new Store({
|
||||||
|
|
||||||
export const useConnectionsStore = defineStore('connections', {
|
export const useConnectionsStore = defineStore('connections', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
connections: persistentStore.get('connections', []) as ConnectionParams[]
|
connections: persistentStore.get('connections', []) as ConnectionParams[],
|
||||||
|
pinnedConnections: new Set([...persistentStore.get('pinnedConnections', []) as string[]]) as Set<string>,
|
||||||
|
lastConnections: persistentStore.get('lastConnections', {}) as {[k: string]: number}
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getConnectionName: state => (uid: string) => {
|
getConnectionName: state => (uid: string) => {
|
||||||
|
@ -63,6 +65,18 @@ export const useConnectionsStore = defineStore('connections', {
|
||||||
updateConnections (connections: ConnectionParams[]) {
|
updateConnections (connections: ConnectionParams[]) {
|
||||||
this.connections = connections;
|
this.connections = connections;
|
||||||
persistentStore.set('connections', this.connections);
|
persistentStore.set('connections', this.connections);
|
||||||
|
},
|
||||||
|
pinConnection (uid: string) {
|
||||||
|
(this.pinnedConnections as Set<string>).add(uid);
|
||||||
|
persistentStore.set('pinnedConnections', [...this.pinnedConnections]);
|
||||||
|
},
|
||||||
|
unpinConnection (uid: string) {
|
||||||
|
(this.pinnedConnections as Set<string>).delete(uid);
|
||||||
|
persistentStore.set('pinnedConnections', [...this.pinnedConnections]);
|
||||||
|
},
|
||||||
|
updateLastConnection (uid: string) {
|
||||||
|
this.lastConnections[uid] = new Date().getTime();
|
||||||
|
persistentStore.set('lastConnections', this.lastConnections);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -170,6 +170,9 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||||
let dataTypes: TypesGroup[] = [];
|
let dataTypes: TypesGroup[] = [];
|
||||||
let indexTypes: string[] = [];
|
let indexTypes: string[] = [];
|
||||||
let clientCustomizations: Customizations;
|
let clientCustomizations: Customizations;
|
||||||
|
const { updateLastConnection } = connectionsStore;
|
||||||
|
|
||||||
|
updateLastConnection(connection.uid);
|
||||||
|
|
||||||
switch (connection.client) {
|
switch (connection.client) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
|
|
Loading…
Reference in New Issue