This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Injectable() | |
| export class IpfsDaemonEffects { | |
| constructor( | |
| private ipfsSrv: IpfsDaemonService, | |
| private readonly actions$: Actions | |
| ) {} | |
| onConnectEffect$ = createEffect( | |
| () => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Injectable({ | |
| providedIn: 'root' | |
| }) | |
| export class IpfsDaemonService { | |
| constructor(@Inject(ipfsToken) private ipfs) {} | |
| public getVersion(): Observable<string> { | |
| return from(this.ipfs.version()).pipe( | |
| tap((res: any) => console.log(`IPFS node version object: ${JSON.stringify(res)}`)), | |
| map(res => res.version), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| node: { | |
| crypto: true, | |
| path: true, | |
| os: true, | |
| stream: true, | |
| buffer: true | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "architect": { | |
| "build": { | |
| "builder": "@angular-builders/custom-webpack:browser", | |
| "options": { | |
| "customWebpackConfig": { | |
| "path": "./extra-webpack.config.js" | |
| } , | |
| "serve": { | |
| "builder": "@angular-builders/custom-webpack:dev-server", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injectable, Inject } from '@angular/core'; | |
| import { HttpClient } from '@angular/common/http'; | |
| import { Observable, from, empty } from 'rxjs'; | |
| import { switchMap, map, tap } from 'rxjs/operators'; | |
| import { ipfsToken } from './tokens'; | |
| import { Buffer } from 'buffer'; | |
| @Injectable({ | |
| providedIn: 'root' | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injectable, InjectionToken, Inject } from '@angular/core'; | |
| import { providers } from 'ethers'; | |
| import IpfsHttpClient from 'ipfs-http-client'; | |
| export const ipfsToken = new InjectionToken('The IPFS Token', { | |
| providedIn: 'root', | |
| factory: () => { | |
| try { | |
| return new IpfsHttpClient('ipfs.infura.io', '5001', { | |
| protocol: 'https' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { NgModule } from '@angular/core'; | |
| import { Routes, RouterModule } from '@angular/router'; | |
| import { DashboardComponent } from './core/components/dashboard/dashboard.component'; | |
| import { NotFoundPageComponent } from './core/containers/not-found-page.component'; | |
| import * as guards from './core/guards'; | |
| export const routes: Routes = [ | |
| { path: '', redirectTo: '/dashboard', pathMatch: 'full' }, | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {Component, ViewChild, ElementRef, OnInit, OnDestroy} from '@angular/core'; | |
| import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | |
| import {MatDialog, MatDialogRef, MatDialogConfig} from '@angular/material'; | |
| import { Observable } from 'rxjs'; | |
| import { Store, select } from '@ngrx/store'; | |
| import * as fromStore from '../../store/ipfs-upload.reducer'; | |
| import * as IpfsActions from '../../store/ipfs-upload.actions'; | |
| import { ShowIpfsImageComponent } from '../../components/show-ipfs-image/show-ipfs-image.component'; | |
| @Component({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uploadFile$ = createEffect( | |
| () => | |
| this.actions$.pipe( | |
| ofType(IpfsUploadActions.upload_image), | |
| map(action => action.file), | |
| exhaustMap((file) => { | |
| return this.ipfsSrv.addFile(file).pipe( | |
| tap(ipfsHash => console.log(`IPFS file hash: ${ipfsHash}`)), | |
| map(ipfsHash => IpfsUploadActions.upload_image_success({ipfsHash})), | |
| catchError((err: Error) => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ChangeDetectionStrategy, Component, Inject, OnInit, ViewChild , ElementRef } from '@angular/core'; | |
| import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; | |
| import { windowRefToken } from '../../../core/services/tokens'; | |
| import { Observable } from 'rxjs'; | |
| import { takeUntil, map, tap, filter, take } from 'rxjs/operators'; | |
| import { Store, select } from '@ngrx/store'; | |
| import * as fromStore from '../../store/ipfs-upload.reducer'; | |
| import * as IpfsActions from '../../store/ipfs-upload.actions'; |