Include code snippets in full-text search (#7)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Garrett Mills 2020-10-13 09:25:03 -05:00
parent 28d6986eea
commit 527697b2fc
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
4 changed files with 21 additions and 8 deletions

View File

@ -105,7 +105,7 @@ export class CodeComponent implements OnInit {
this.loader.create({message: 'Loading code...'}).then(loader => { this.loader.create({message: 'Loading code...'}).then(loader => {
loader.present().then(() => { loader.present().then(() => {
this.getInitObservable().subscribe(() => { this.getInitObservable().subscribe(() => {
this.editorOptions.language = this.dbRecord.language; this.editorOptions.language = this.dbRecord.Language;
this.editorOptions.readOnly = this.readonly; this.editorOptions.readOnly = this.readonly;
this.onSelectChange(false); this.onSelectChange(false);
loader.dismiss(); loader.dismiss();
@ -136,7 +136,7 @@ export class CodeComponent implements OnInit {
this.api.get(`/code/${this.hostRecord.PageId}/${this.hostRecord.UUID}/get/${this.hostRecord.Value.Value}`).subscribe(res => { this.api.get(`/code/${this.hostRecord.PageId}/${this.hostRecord.UUID}/get/${this.hostRecord.Value.Value}`).subscribe(res => {
this.dbRecord = res.data; this.dbRecord = res.data;
this.editorValue = this.dbRecord.code; this.editorValue = this.dbRecord.code;
this.editorOptions.language = this.dbRecord.language; this.editorOptions.language = this.dbRecord.Language;
this.pendingSetup = false; this.pendingSetup = false;
sub.next(true); sub.next(true);
sub.complete(); sub.complete();
@ -154,11 +154,11 @@ export class CodeComponent implements OnInit {
} }
this.dbRecord.code = this.editorValue; this.dbRecord.code = this.editorValue;
this.dbRecord.language = this.editorOptions.language; this.dbRecord.Language = this.editorOptions.language;
this.api.post(`/code/${this.hostRecord.PageId}/${this.hostRecord.UUID}/set/${this.hostRecord.Value.Value}`, this.dbRecord) this.api.post(`/code/${this.hostRecord.PageId}/${this.hostRecord.UUID}/set/${this.hostRecord.Value.Value}`, this.dbRecord)
.subscribe(res => { .subscribe(res => {
this.dbRecord = res.data; this.dbRecord = res.data;
this.editorOptions.language = this.dbRecord.language; this.editorOptions.language = this.dbRecord.Language;
this.editorValue = this.dbRecord.code; this.editorValue = this.dbRecord.code;
this.dirty = false; this.dirty = false;
}); });
@ -200,7 +200,7 @@ export class CodeComponent implements OnInit {
onSelectChange(updateDbRecord = true) { onSelectChange(updateDbRecord = true) {
if ( updateDbRecord ) { if ( updateDbRecord ) {
this.dbRecord.language = this.editorOptions.language; this.dbRecord.Language = this.editorOptions.language;
} }
this.editorOptions = {...this.editorOptions}; this.editorOptions = {...this.editorOptions};

View File

@ -22,7 +22,6 @@
&.node { &.node {
.search-icon { .search-icon {
color: var(--noded-background-node); color: var(--noded-background-node);
content: '\f10d';
} }
} }
@ -31,6 +30,12 @@
color: var(--noded-background-db); color: var(--noded-background-db);
} }
} }
&.code {
.search-icon {
color: var(--noded-background-code);
}
}
} }
.search-assoc { .search-assoc {

View File

@ -7,11 +7,11 @@ import {Router} from '@angular/router';
export interface SearchResult { export interface SearchResult {
title: string; title: string;
short_title: string; short_title: string;
type: 'page' | 'node'; type: 'page' | 'node' | 'code';
id: string; id: string;
associated?: { associated?: {
title: string, title: string,
type: 'page' | 'node', type: 'page',
id: string id: string
}; };
} }
@ -30,6 +30,7 @@ export class SearchComponent implements OnInit {
node: 'fa fa-quote-left', node: 'fa fa-quote-left',
page: 'fa fa-sticky-note', page: 'fa fa-sticky-note',
db: 'fa fa-database', db: 'fa fa-database',
code: 'fa fa-code',
}; };
constructor( constructor(
@ -68,6 +69,9 @@ export class SearchComponent implements OnInit {
} else if ( result.type === 'node' ) { } else if ( result.type === 'node' ) {
await this.router.navigate(['/editor', { id: result.associated.id, node_id: result.id }]); await this.router.navigate(['/editor', { id: result.associated.id, node_id: result.id }]);
await this.dismiss(); await this.dismiss();
} else if ( result.type === 'code' ) {
await this.router.navigate(['/editor', { id: result.associated.id, node_id: result.id }]);
await this.dismiss();
} }
} }

View File

@ -42,6 +42,10 @@
--noded-background-node: #FB5607; --noded-background-node: #FB5607;
--noded-color-node: white; --noded-color-node: white;
--noded-background-node-hover: #fc864f; --noded-background-node-hover: #fc864f;
--noded-background-code: #FF006E;
--noded-color-code: white;
--noded-background-code-hover: #FF5CA3;
} }
div.picker-wrapper { div.picker-wrapper {