Skip to content

Instantly share code, notes, and snippets.

View a9kitkumar's full-sized avatar

Ankit Kumar a9kitkumar

View GitHub Profile
@a9kitkumar
a9kitkumar / cosmic.config.ts
Created January 1, 2019 17:27
Configuration setting of Angular-Cosmic JS auth app
export const config = {
production: false,
read_key: COSMIC_READ_KEY,
write_key: COSMIC_WRITE_KEY,
bucket_id: COSMIC_BUCKET_ID,
bucket_slug: COSMIC_BUCKET,
URL: 'https://api.cosmicjs.com/v1/',
};
@a9kitkumar
a9kitkumar / apicall.service.ts
Created January 1, 2019 17:38
This file contains the code of all backend calls from Angular frontend
import { Injectable } from '@angular/core';
import { config } from './../../config/cosmic.config';
import { Http } from '@angular/http';
import { userModel } from './../models/user.model';
@Injectable({
providedIn: 'root'
})
export class ApicallService {
@a9kitkumar
a9kitkumar / user.model.ts
Created January 1, 2019 17:51
Model for the Angular side
export class userModel {
_id: string;
fullName: string;
email: string;
password: string;
confirmPassword: string;
gender: string;
mobile: string;
@a9kitkumar
a9kitkumar / register.component.ts
Created January 1, 2019 18:00
It registers the new user and save all data to Cosmic JS server
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms';
import { userModel } from './../../models/user.model';
import { Router } from '@angular/router';
import { ApicallService } from './../../services/apicall.service';
@Component({
selector: 'app-register',
templateUrl: './register.component.html',
styleUrls: ['./register.component.css']
@a9kitkumar
a9kitkumar / authentication.component.ts
Created January 1, 2019 18:18
Gives authentication to logged in usres
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms';
import { ApicallService } from './../../services/apicall.service';
import { Router } from '@angular/router';
import {
AuthService,
GoogleLoginProvider,
} from 'angular-6-social-login-v2';
@a9kitkumar
a9kitkumar / dashboard.component.ts
Created January 1, 2019 18:28
dashboard component which will be shown to logged in users only
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements OnInit {
currentUser: any;
const config = {
bucket_name: "react-pwa",
bucket_slug: "react-pwa",
bucket_id: "YOUR COSMIC BUCKET_ID",
read_key: "YOUR COSMIC READ_KEY",
write_key: "YOUR COSMIC WRITE_KEY",
url: "https://api.cosmicjs.com/v1/"
}
import React, { Component } from 'react';
import authentication from './../services/authentication';
import { Link } from 'react-router-dom';
import './../App.css';
import './../CSS/login.css';
class login extends Component {
returnedData;
constructor(props) {
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import './../CSS/dashboard.css';
class dashboard extends Component {
constructor(props) {
super(props);
this.state = {
};
this.logout = this.logout.bind(this);
import React, { Component } from 'react';
import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.snow.css';
import './../CSS/addnews.css';
import newsData from './../services/news';
import { Link } from 'react-router-dom';
class addnews extends Component {
constructor(props) {
super(props);