Skip to content

Commit

Permalink
Merge branch 'frontend-dev' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
azurity committed Mar 8, 2020
2 parents 5ddc73f + 7825280 commit 067af63
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
26 changes: 25 additions & 1 deletion app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
<nav-list :isLogin="!!$store.state.global.userId"></nav-list>
</v-navigation-drawer>

<v-app-bar app clipped-left class="higher">
<v-app-bar app clipped-left class="higher pr-2">
<v-app-bar-nav-icon @click.stop="drawer = !drawer"></v-app-bar-nav-icon>
<v-toolbar-title>Tp0t OJ</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn
icon
@click="WarmUp"
v-if="$store.state.global.role==='admin'"
>
<v-icon color="primary">whatshot</v-icon>
</v-btn>
</v-app-bar>

<v-content>
Expand All @@ -25,6 +33,7 @@

<script lang="ts">
import { Component, Vue, Prop, Watch } from "vue-property-decorator";
import gql from 'graphql-tag';
import NavList from "@/components/NavList.vue";
@Component({
Expand All @@ -44,6 +53,21 @@ export default class App extends Vue {
}
this.$store.commit("global/setUserIdAndRole", { userId, role });
}
async WarmUp() {
try{
let res = await this.$apollo.mutate<Boolean>({
mutation: gql`
mutation{
warmUp
}`
});
if (res.errors) throw res.errors.map(v => v.message).join(",");
if (!res.data!) throw "error";
}catch(e) {
console.log(e);
}
}
}
</script>

Expand Down
21 changes: 18 additions & 3 deletions app/src/components/ChallengeEditor.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-form>
<v-row>
<v-col cols="6">
<v-col cols="4">
<v-row>
<v-spacer></v-spacer>
<v-switch
Expand All @@ -13,7 +13,19 @@
<v-spacer></v-spacer>
</v-row>
</v-col>
<v-col cols="6">
<v-col cols="4">
<v-row>
<v-spacer></v-spacer>
<v-switch
v-model="dynamicScore"
label="DynamicScore"
:disabled="loading || disabled"
@change="Changed"
></v-switch>
<v-spacer></v-spacer>
</v-row>
</v-col>
<v-col cols="4">
<v-file-input
v-model="configFile"
accept=".yaml, .yml"
Expand Down Expand Up @@ -152,6 +164,7 @@ export default class ChallengeEditor extends Vue {
private reader: FileReader = new FileReader();
private state: boolean = false;
private dynamicScore: boolean = false;
private name: string = "";
private type: string = "";
private score: number = 0;
Expand Down Expand Up @@ -181,6 +194,7 @@ export default class ChallengeEditor extends Vue {
this.hints = config.hint || this.hints;
this.setValue = false;
this.state = false;
this.dynamicScore = config.score.dynamic || this.dynamicScore;
} catch (e) {
this.EmitError(e.toString());
}
Expand All @@ -194,6 +208,7 @@ export default class ChallengeEditor extends Vue {
this.links = this.config.external_link;
this.hints = this.config.hint;
this.state = this.config.state == "enabled";
this.dynamicScore = this.config.score.dynamic;
}
@Emit("error")
Expand All @@ -210,7 +225,7 @@ export default class ChallengeEditor extends Vue {
challengeId: (this.config && this.config.challengeId) || "",
name: this.name,
type: this.type,
score: { dynamic: false, base_score: this.score.toString() },
score: { dynamic: this.dynamicScore, base_score: this.score.toString() },
flag: { dynamic: false, value: this.flag },
description: this.description,
external_link: this.links,
Expand Down

0 comments on commit 067af63

Please sign in to comment.