2021-09-16 07:26:57 -07:00
|
|
|
<script>
|
|
|
|
|
import {Meteor} from "meteor/meteor";
|
|
|
|
|
import {onMount} from 'svelte';
|
|
|
|
|
import {useTracker} from 'meteor/rdb:svelte-meteor-data';
|
|
|
|
|
import {BlazeTemplate} from 'meteor/svelte:blaze-integration';
|
2022-03-09 07:55:26 -08:00
|
|
|
import {Records} from '../api/records.js'
|
|
|
|
|
import ServiceConfiguration from "meteor/service-configuration";
|
2021-09-16 07:26:57 -07:00
|
|
|
|
|
|
|
|
let currentUser;
|
|
|
|
|
|
|
|
|
|
onMount(async () => {
|
2022-03-09 07:55:26 -08:00
|
|
|
// Meteor.subscribe('records');
|
2021-09-16 07:26:57 -07:00
|
|
|
});
|
|
|
|
|
|
2022-03-09 07:55:26 -08:00
|
|
|
// $: incompleteCount = useTracker(() => Tasks.find({checked: {$ne: true}}).count());
|
2021-09-16 07:26:57 -07:00
|
|
|
|
|
|
|
|
$: currentUser = useTracker(() => Meteor.user());
|
|
|
|
|
|
2022-03-09 07:55:26 -08:00
|
|
|
// const taskStore = Tasks.find({}, {sort: {createdAt: -1}});
|
|
|
|
|
// $: {
|
|
|
|
|
// tasks = $taskStore;
|
|
|
|
|
// if (hideCompleted) {
|
|
|
|
|
// tasks = tasks.filter(task => !task.checked);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2021-09-16 07:26:57 -07:00
|
|
|
|
2022-03-09 07:55:26 -08:00
|
|
|
// function handleSubmit(event) {
|
|
|
|
|
// Meteor.call("tasks.insert", newTask);
|
|
|
|
|
// // Clear form
|
|
|
|
|
// newTask = "";
|
|
|
|
|
// }
|
2021-09-16 07:26:57 -07:00
|
|
|
|
|
|
|
|
function performLogin() {
|
2022-03-09 07:55:26 -08:00
|
|
|
//Login style can be "popup" or "redirect". I am not sure we need to request and offline token.
|
|
|
|
|
Meteor.loginWithGoogle({loginStyle: "popup", requestOfflineToken: true}, (err) => {
|
2021-09-16 07:26:57 -07:00
|
|
|
if(err) {
|
|
|
|
|
console.log(err);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2022-03-09 07:55:26 -08:00
|
|
|
//console.log("Logged in");
|
2021-09-16 07:26:57 -07:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function performLogout() {
|
|
|
|
|
Meteor.logout();
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="container">
|
|
|
|
|
<header>
|
2022-03-09 07:55:26 -08:00
|
|
|
<!-- <h1>Todo List ({ $incompleteCount })</h1>-->
|
|
|
|
|
<!-- <label className="hide-completed">-->
|
|
|
|
|
<!-- <input-->
|
|
|
|
|
<!-- type="checkbox"-->
|
|
|
|
|
<!-- bind:checked={hideCompleted}-->
|
|
|
|
|
<!-- />-->
|
|
|
|
|
<!-- Hide Completed Tasks-->
|
|
|
|
|
<!-- </label>-->
|
2021-09-16 07:26:57 -07:00
|
|
|
|
2022-03-09 07:55:26 -08:00
|
|
|
<!-- <BlazeTemplate template="loginButtons"/>-->
|
2021-09-16 07:26:57 -07:00
|
|
|
{#if !$currentUser}
|
|
|
|
|
<button type="button" on:click={performLogin}>Login</button>
|
|
|
|
|
{:else}
|
|
|
|
|
<button type="button" on:click={performLogout}>Logout</button>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2022-03-09 07:55:26 -08:00
|
|
|
<!--{#if $currentUser}-->
|
|
|
|
|
<!-- <form class="new-task" on:submit|preventDefault={handleSubmit}>-->
|
|
|
|
|
<!-- <input-->
|
|
|
|
|
<!-- type="text"-->
|
|
|
|
|
<!-- placeholder="Type to add new tasks"-->
|
|
|
|
|
<!-- bind:value={newTask}-->
|
|
|
|
|
<!-- />-->
|
|
|
|
|
<!-- </form>-->
|
|
|
|
|
<!--{/if}-->
|
2021-09-16 07:26:57 -07:00
|
|
|
</header>
|
|
|
|
|
<ul>
|
2022-03-09 07:55:26 -08:00
|
|
|
<!--{#each tasks as task}-->
|
|
|
|
|
<!-- <Task-->
|
|
|
|
|
<!-- key={task._id}-->
|
|
|
|
|
<!-- task={task}-->
|
|
|
|
|
<!-- />-->
|
|
|
|
|
<!--{/each}-->
|
2021-09-16 07:26:57 -07:00
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
|