Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

profile pages #407

Merged
merged 4 commits into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ export function objectsEqual(a: any, b: any): boolean {
return true;
}

export function assertObjectsEqual(a, b) {
if (!objectsEqual(a, b)) {
console.error("Objects not equal:\n", a, "\n", b);
throw Error("assertObjectsEqual failed.");
}
}

const propelHosts = new Set(["", "127.0.0.1", "localhost", "propelml.org"]);

export interface FetchEncodingMap {
Expand Down
23 changes: 23 additions & 0 deletions website/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface Database {
updateDoc(nbId: string, doc: NotebookDoc): Promise<void>;
clone(existingDoc: NotebookDoc): Promise<string>;
create(): Promise<string>;
queryProfile(uid: string, limit: number): Promise<NbInfo[]>;
queryLatest(): Promise<NbInfo[]>;
signIn(): void;
signOut(): void;
Expand Down Expand Up @@ -167,6 +168,19 @@ class DatabaseFB implements Database {
return out.reverse();
}

async queryProfile(uid: string, limit: number): Promise<NbInfo[]> {
lazyInit();
const query = nbCollection.where("owner.uid", "==", uid).limit(limit);
const snapshots = await query.get();
const out = [];
snapshots.forEach(snap => {
const nbId = snap.id;
const doc = snap.data();
out.push({ nbId, doc });
});
return out;
}

signIn() {
lazyInit();
const provider = new firebase.auth.GithubAuthProvider();
Expand Down Expand Up @@ -224,6 +238,15 @@ export class DatabaseMock implements Database {
return "createdNbId";
}

async queryProfile(uid: string, limit: number): Promise<NbInfo[]> {
this.inc("queryProfile");
if (uid === defaultOwner.uid) {
return [{ nbId: "default", doc: defaultDoc }];
} else {
return [];
}
}

async queryLatest(): Promise<NbInfo[]> {
this.inc("queryLatest");
return [];
Expand Down
33 changes: 6 additions & 27 deletions website/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ body {
}

/* Centers and gives max-width to index, references, notebook pages */
.centered,
.training-example-inner,
.use-it-inner,
.flex-row,
Expand Down Expand Up @@ -654,7 +655,6 @@ header {
font-size: 1.2rem;
letter-spacing: 0.5px;
display: flex;
margin-top: 8px;

img {
margin-right: $size0;
Expand All @@ -665,12 +665,6 @@ header {
max-width: 960px;
margin: 0 auto;
padding: 0 8px;

.blurb {
box-shadow: inset 0 -1px 0 $borderColor;
background-color: #fff;
margin-bottom: 16px;
}
}

.most-recent {
Expand Down Expand Up @@ -728,33 +722,18 @@ header {
background-color: $cellBackgroundFocus;
}

&:hover .displayName {
color: $linkColor;
text-decoration: underline;
}

p {
margin: 8px;
color: $base03;
}

.code-snippit {
margin: 8px;
max-height: 180px;
margin: 8px 8px 0 8px;
font-family: 'Roboto Mono', monospace;
}

.blurb {
background-color: #fff;
box-shadow: inset 0 1px 0 $borderColor;
font-size: 1.3rem;
line-height: 1.6rem;
letter-spacing: 0.5px;
display: flex;
margin-top: 8px;

img {
margin-right: $size0;
}
white-space: pre;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
Expand Down
Loading