Skip to content

Instantly share code, notes, and snippets.

View datphan126's full-sized avatar

Phan Thanh Dat datphan126

View GitHub Profile
@datphan126
datphan126 / book-form.component.ts
Created February 23, 2020 22:44
Book Form for CUD
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { MatSnackBar } from '@angular/material/snack-bar';
import { BookOfflineService } from '../services/book-offline.service';
import { filter, takeUntil } from 'rxjs/operators';
import { ReplaySubject } from 'rxjs';
import { OnlineOfflineService } from '../services/online-offline.service';
import { BackendService } from '../services/backend.service';
import { Book } from '../books/books.component';
@datphan126
datphan126 / book-offline.service.ts
Created February 23, 2020 22:40
Book Offline Service for CRUD
import { Injectable } from '@angular/core';
import Dexie from 'dexie';
import { Book } from '../books/books.component';
import { OnlineOfflineService } from './online-offline.service';
import { v1 as uuidv1 } from 'uuid'; // For generating time-based uuid
import { BackendService } from './backend.service';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Subject } from 'rxjs';
import { take } from 'rxjs/operators';
@datphan126
datphan126 / books.component.ts
Last active March 3, 2020 01:36
Books Component for displaying only
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { BookDetailDialogComponent } from '../book-detail-dialog/book-detail-dialog.component';
import { BackendService } from '../services/backend.service';
import { BookOfflineService } from '../services/book-offline.service';
import { OnlineOfflineService } from '../services/online-offline.service';
import { ReplaySubject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
export interface Book {
@datphan126
datphan126 / book-offline.service.ts
Created February 23, 2020 22:27
Book Offline Service for displaying data only
import { Injectable } from '@angular/core';
import Dexie from 'dexie';
import { Book } from '../books/books.component';
import { OnlineOfflineService } from './online-offline.service';
import { BackendService } from '../services/backend.service';
import { MatSnackBar } from '@angular/material/snack-bar';
@Injectable({
providedIn: 'root'
@datphan126
datphan126 / package.json
Created February 21, 2020 08:41
PWA Express package.json
{
"name": "module8",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc && cp ./src/.env ./public",
"copyViews": "cp -R src/views public"
},
"keywords": [],
@datphan126
datphan126 / package.json
Last active February 22, 2020 01:14
PWA Angular package.json
{
"name": "book-store",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
{% extends "base.html" %}
{% block header %}
<h2 class="page-section-heading text-center text-uppercase text-secondary mb-0">{{ title }}</h2>
{% endblock header %}
{% block main%}
<!-- Main Content -->
<h4 class="text-center text-uppercase text-secondary mb-0" style="padding-bottom: 1rem;">{{ context.card_type }} : {{ context.card_number }}</h4>
from django.shortcuts import render
from . import forms, models
from django.core.exceptions import ValidationError
from django.http import HttpResponseRedirect
import sys
# Create your views here.
def pay(request):
pmt_method_dict = models.fetch_all_pmt_methods_process()
{% extends "base.html" %}
{% block header %}
<h2 class="page-section-heading text-center text-uppercase text-secondary mb-0">{{ title }}</h2>
{% endblock header %}
{% block main%}
<!-- Main Content -->
{% if action == 'EDIT_SUCCESSFULL' %}
from django.shortcuts import render
from . import forms, models
from django.core.exceptions import ValidationError
from django.http import HttpResponseRedirect
import sys
# Create your views here.
def add_song(request):