Spaces:
Runtime error
Runtime error
File size: 3,117 Bytes
32f0b26 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
<script lang="ts">
import { onMount } from "svelte";
import "../node_modules/svelte-material-ui/bare.css";
import HypothesisPanel from "./HypothesisPanel.svelte";
import MainPanel from "./MainPanel.svelte";
import SelectUserDialog from "./SelectUserDialog.svelte";
import Explore from "./Explore.svelte";
import Results from "./Results.svelte";
import StudyLinks from "./StudyLinks.svelte";
import { user } from './stores/cur_user_store.js';
import { users } from "./stores/all_users_store.js";
let personalized_model;
let personalized_models = [];
// let topic = "";
let error_type_options = ['Both', 'System is under-sensitive', 'System is over-sensitive', 'Show errors and non-errors'];
let error_type = error_type_options[0];
// Handle routing
let searchParams = new URLSearchParams(window.location.search);
let mode = searchParams.get("mode");
let cur_user = searchParams.get("user");
// Set cur_user if it's provided in URL params
if (cur_user !== null) {
user.update((value) => cur_user);
}
// Handle user dialog
let user_dialog_open = false;
user.subscribe(value => {
cur_user = value;
});
// Handle all users
let all_users = [];
async function getUsers() {
const response = await fetch("./get_users");
const text = await response.text();
const data = JSON.parse(text);
all_users = data["users"];
users.update((value) => all_users);
}
function getAuditSettings() {
let req_params = {
user: cur_user,
};
let params = new URLSearchParams(req_params).toString();
fetch("./audit_settings?" + params)
.then((r) => r.text())
.then(function (r_orig) {
let r = JSON.parse(r_orig);
personalized_models = r["personalized_models"];
personalized_model = personalized_models[0]; // TEMP
console.log("personalized_model", personalized_model);
// personalized_model = "model_1632886687_iterA";
// let clusters = r["clusters"];
// topic = clusters[0]; // TEMP
});
// fetch("./audit_settings")
// .then((r) => r.text())
// .then(function (r_orig) {
// let r = JSON.parse(r_orig);
// personalized_models = r["personalized_models"];
// personalized_model = personalized_models[0]; // TEMP
// // personalized_model = "model_1632886687_iterA";
// let clusters = r["clusters"];
// topic = clusters[0]; // TEMP
// });
}
onMount(async () => {
getAuditSettings();
getUsers();
});
</script>
<svelte:head>
<title>IndieLabel</title>
</svelte:head>
<main>
{#if mode == "explore"}
<div>
<Explore />
</div>
{:else if mode == "results"}
<div>
<Results />
</div>
{:else if mode == "study_links"}
<div>
<StudyLinks />
</div>
{:else }
<SelectUserDialog bind:open={user_dialog_open} cur_user={cur_user} />
<div>
{#key personalized_model }
<HypothesisPanel model={personalized_model} bind:user_dialog_open={user_dialog_open}/>
{/key}
<MainPanel bind:model={personalized_model} bind:error_type={error_type} on:change />
</div>
{/if}
</main>
<style>
</style>
|