feat: bulk edit transformation
This commit is contained in:
@@ -49,11 +49,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="bulkMode" class="flex">
|
<div v-if="bulkMode" class="flex">
|
||||||
<textarea
|
<textarea
|
||||||
name="bulk-parameters"
|
v-model="bulkHeaders"
|
||||||
|
v-focus
|
||||||
|
name="bulk-headers"
|
||||||
class="
|
class="
|
||||||
bg-transparent border-b
|
bg-transparent
|
||||||
border-dividerLight flex
|
border-b border-dividerLight
|
||||||
flex-1
|
flex flex-1
|
||||||
py-2
|
py-2
|
||||||
px-4
|
px-4
|
||||||
whitespace-pre
|
whitespace-pre
|
||||||
@@ -62,7 +64,6 @@
|
|||||||
"
|
"
|
||||||
rows="10"
|
rows="10"
|
||||||
:placeholder="$t('state.bulk_mode_placeholder')"
|
:placeholder="$t('state.bulk_mode_placeholder')"
|
||||||
v-focus
|
|
||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
@@ -191,13 +192,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref } from "@nuxtjs/composition-api"
|
import {
|
||||||
|
defineComponent,
|
||||||
|
ref,
|
||||||
|
useContext,
|
||||||
|
watch,
|
||||||
|
} from "@nuxtjs/composition-api"
|
||||||
import {
|
import {
|
||||||
restHeaders$,
|
restHeaders$,
|
||||||
addRESTHeader,
|
addRESTHeader,
|
||||||
updateRESTHeader,
|
updateRESTHeader,
|
||||||
deleteRESTHeader,
|
deleteRESTHeader,
|
||||||
deleteAllRESTHeaders,
|
deleteAllRESTHeaders,
|
||||||
|
setRESTHeaders,
|
||||||
} from "~/newstore/RESTSession"
|
} from "~/newstore/RESTSession"
|
||||||
import { commonHeaders } from "~/helpers/headers"
|
import { commonHeaders } from "~/helpers/headers"
|
||||||
import { useSetting } from "~/newstore/settings"
|
import { useSetting } from "~/newstore/settings"
|
||||||
@@ -206,11 +213,38 @@ import { HoppRESTHeader } from "~/helpers/types/HoppRESTRequest"
|
|||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
setup() {
|
setup() {
|
||||||
|
const {
|
||||||
|
$toast,
|
||||||
|
app: { i18n },
|
||||||
|
} = useContext()
|
||||||
|
const t = i18n.t.bind(i18n)
|
||||||
|
|
||||||
const bulkMode = ref(false)
|
const bulkMode = ref(false)
|
||||||
|
const bulkHeaders = ref("")
|
||||||
|
|
||||||
|
watch(bulkHeaders, () => {
|
||||||
|
try {
|
||||||
|
const transformation = bulkHeaders.value.split("\n").map((item) => {
|
||||||
|
return {
|
||||||
|
key: item.substr(0, item.indexOf(":")).trim(),
|
||||||
|
value: item.substr(item.indexOf(":") + 1).trim(),
|
||||||
|
active: true,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
setRESTHeaders(transformation)
|
||||||
|
} catch (e) {
|
||||||
|
$toast.error(t("error.something_went_wrong").toString(), {
|
||||||
|
icon: "error_outline",
|
||||||
|
})
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
headers$: useReadonlyStream(restHeaders$, []),
|
headers$: useReadonlyStream(restHeaders$, []),
|
||||||
EXPERIMENTAL_URL_BAR_ENABLED: useSetting("EXPERIMENTAL_URL_BAR_ENABLED"),
|
EXPERIMENTAL_URL_BAR_ENABLED: useSetting("EXPERIMENTAL_URL_BAR_ENABLED"),
|
||||||
bulkMode,
|
bulkMode,
|
||||||
|
bulkHeaders,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|||||||
@@ -49,6 +49,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="bulkMode" class="flex">
|
<div v-if="bulkMode" class="flex">
|
||||||
<textarea
|
<textarea
|
||||||
|
v-model="bulkParams"
|
||||||
|
v-focus
|
||||||
name="bulk-parameters"
|
name="bulk-parameters"
|
||||||
class="
|
class="
|
||||||
bg-transparent
|
bg-transparent
|
||||||
@@ -62,7 +64,6 @@
|
|||||||
"
|
"
|
||||||
rows="10"
|
rows="10"
|
||||||
:placeholder="$t('state.bulk_mode_placeholder')"
|
:placeholder="$t('state.bulk_mode_placeholder')"
|
||||||
v-focus
|
|
||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
@@ -200,7 +201,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref } from "@nuxtjs/composition-api"
|
import {
|
||||||
|
defineComponent,
|
||||||
|
ref,
|
||||||
|
useContext,
|
||||||
|
watch,
|
||||||
|
} from "@nuxtjs/composition-api"
|
||||||
import { HoppRESTParam } from "~/helpers/types/HoppRESTRequest"
|
import { HoppRESTParam } from "~/helpers/types/HoppRESTRequest"
|
||||||
import { useReadonlyStream } from "~/helpers/utils/composables"
|
import { useReadonlyStream } from "~/helpers/utils/composables"
|
||||||
import {
|
import {
|
||||||
@@ -209,16 +215,44 @@ import {
|
|||||||
updateRESTParam,
|
updateRESTParam,
|
||||||
deleteRESTParam,
|
deleteRESTParam,
|
||||||
deleteAllRESTParams,
|
deleteAllRESTParams,
|
||||||
|
setRESTParams,
|
||||||
} from "~/newstore/RESTSession"
|
} from "~/newstore/RESTSession"
|
||||||
import { useSetting } from "~/newstore/settings"
|
import { useSetting } from "~/newstore/settings"
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
setup() {
|
setup() {
|
||||||
|
const {
|
||||||
|
$toast,
|
||||||
|
app: { i18n },
|
||||||
|
} = useContext()
|
||||||
|
const t = i18n.t.bind(i18n)
|
||||||
|
|
||||||
const bulkMode = ref(false)
|
const bulkMode = ref(false)
|
||||||
|
const bulkParams = ref("")
|
||||||
|
|
||||||
|
watch(bulkParams, () => {
|
||||||
|
try {
|
||||||
|
const transformation = bulkParams.value.split("\n").map((item) => {
|
||||||
|
return {
|
||||||
|
key: item.substr(0, item.indexOf(":")).trim(),
|
||||||
|
value: item.substr(item.indexOf(":") + 1).trim(),
|
||||||
|
active: true,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
setRESTParams(transformation)
|
||||||
|
} catch (e) {
|
||||||
|
$toast.error(t("error.something_went_wrong").toString(), {
|
||||||
|
icon: "error_outline",
|
||||||
|
})
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
params$: useReadonlyStream(restParams$, []),
|
params$: useReadonlyStream(restParams$, []),
|
||||||
EXPERIMENTAL_URL_BAR_ENABLED: useSetting("EXPERIMENTAL_URL_BAR_ENABLED"),
|
EXPERIMENTAL_URL_BAR_ENABLED: useSetting("EXPERIMENTAL_URL_BAR_ENABLED"),
|
||||||
bulkMode,
|
bulkMode,
|
||||||
|
bulkParams,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|||||||
Reference in New Issue
Block a user