add create and start.

This commit is contained in:
Miroslav Šedivý
2023-10-05 19:55:37 +02:00
parent ff006fb466
commit 1f6eb49072
3 changed files with 29 additions and 6 deletions
+23 -5
View File
@@ -524,13 +524,21 @@
Close
</v-btn>
<v-btn
color="green"
color="blue"
dark
@click="Create"
:loading="loading"
@click="Create(false)"
:loading="loading && !loadingWithStart"
>
Create
</v-btn>
<v-btn
color="green"
dark
@click="CreateAndStart()"
:loading="loadingWithStart"
>
Create and start
</v-btn>
</v-card-actions>
</v-card>
</template>
@@ -574,6 +582,7 @@ export default class RoomsCreate extends Vue {
public browserPolicyEnabled = false
public loading = false
public loadingWithStart = false
public data: RoomSettings = { ...this.$store.state.defaultRoomSettings }
public browserPolicyContent: BrowserPolicyContent = { ...this.$store.state.defaultBrowserPolicyContent }
public envList: { key: string; val: string }[] = []
@@ -704,7 +713,16 @@ export default class RoomsCreate extends Vue {
Vue.delete(this.envList, index)
}
async Create() {
async CreateAndStart() {
this.loadingWithStart = true
try {
await this.Create(true)
} finally {
this.loadingWithStart = false
}
}
async Create(start = false) {
const valid = this._form.validate()
if (!valid) return
@@ -713,7 +731,7 @@ export default class RoomsCreate extends Vue {
try {
const envs = this.envList.reduce((obj, { key, val }) => ({ ...obj, [key]: val, }), {})
await this.$store.dispatch('ROOMS_CREATE', {
await this.$store.dispatch(start ? 'ROOMS_CREATE_AND_START' : 'ROOMS_CREATE', {
...this.data,
// eslint-disable-next-line
user_pass: this.data.user_pass || randomPassword(),
+1 -1
View File
@@ -70,7 +70,7 @@ export default class RoomActionBtn extends Vue {
this.loading = true
try {
const entry = await this.$store.dispatch('ROOMS_CREATE', {
const entry = await this.$store.dispatch('ROOMS_CREATE_AND_START', {
...this.$store.state.defaultRoomSettings,
// eslint-disable-next-line
neko_image,
+5
View File
@@ -85,6 +85,11 @@ export default new Vuex.Store({
commit('ROOMS_SET', res.data);
},
async ROOMS_CREATE({ commit }: ActionContext<State, State>, roomSettings: RoomSettings): Promise<RoomEntry> {
const res = await roomsApi.roomCreate(false, roomSettings)
commit('ROOMS_ADD', res.data);
return res.data
},
async ROOMS_CREATE_AND_START({ commit }: ActionContext<State, State>, roomSettings: RoomSettings): Promise<RoomEntry> {
const res = await roomsApi.roomCreate(true, roomSettings)
commit('ROOMS_ADD', res.data);
return res.data