Skip to content

Commit

Permalink
add create and start.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed Oct 5, 2023
1 parent ff006fb commit 1f6eb49
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
28 changes: 23 additions & 5 deletions client/src/components/RoomsCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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 }[] = []
Expand Down Expand Up @@ -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
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/RoomsQuick.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions client/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f6eb49

Please sign in to comment.