├── .editorconfig
├── .gitignore
├── LICENSE
├── README.md
├── angular.json
├── e2e
├── app.e2e-spec.ts
├── app.po.ts
└── tsconfig.e2e.json
├── karma.conf.js
├── package-lock.json
├── package.json
├── protractor.conf.js
├── src
├── _variables.scss
├── app
│ ├── app-routing.module.ts
│ ├── app.component.html
│ ├── app.component.scss
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── chats
│ │ ├── chats-routing.module.ts
│ │ ├── chats.component.html
│ │ ├── chats.component.scss
│ │ ├── chats.component.ts
│ │ ├── chats.module.ts
│ │ └── details
│ │ │ ├── details.component.html
│ │ │ ├── details.component.scss
│ │ │ └── details.component.ts
│ ├── db.ts
│ ├── me
│ │ ├── me.component.html
│ │ ├── me.component.scss
│ │ └── me.component.ts
│ └── signup
│ │ ├── signup.component.html
│ │ ├── signup.component.scss
│ │ └── signup.component.ts
├── assets
│ └── Angular+Baqend.svg
├── baqend-model.d.ts
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── main.ts
├── polyfills.ts
├── styles.scss
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── typings.d.ts
├── tsconfig.json
└── tslint.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 |
8 | # dependencies
9 | /node_modules
10 |
11 | # IDEs and editors
12 | /.idea
13 | .project
14 | .classpath
15 | .c9/
16 | *.launch
17 | .settings/
18 | *.sublime-workspace
19 |
20 | # IDE - VSCode
21 | .vscode/*
22 | !.vscode/settings.json
23 | !.vscode/tasks.json
24 | !.vscode/launch.json
25 | !.vscode/extensions.json
26 |
27 | # misc
28 | /.sass-cache
29 | /connect.lock
30 | /coverage
31 | /libpeerconnection.log
32 | npm-debug.log
33 | testem.log
34 | /typings
35 |
36 | # e2e
37 | /e2e/*.js
38 | /e2e/*.map
39 |
40 | # System Files
41 | .DS_Store
42 | Thumbs.db
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015-2016 AngularClass LLC
4 | Copyright (c) 2016 Baqend GmbH
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |
4 | # Angular and Baqend Starter
5 | With this Angular and Baqend starter kit you can build **blazingly fast single page applications** in no time. Setup your project by following the simple steps below.
6 |
7 | The starter is based on the [official Angular CLI](https://github.com/angular/angular-cli) and uses:
8 |
9 | * [**SASS**](http://sass-lang.com) as a CSS precompiler with cool features and syntax
10 | * [**TypeScript**](https://www.typescriptlang.org) for typed JavaScript, ES6 features and because it is recommended for Angular
11 | * [**Bootstrap**](http://getbootstrap.com) for easy modern styling
12 | * [**Baqend**](https://www.baqend.com) as a fully managed backend service for backend-less development
13 |
14 | ## How to use the template
15 |
16 | 1. Make sure you have [Node.js](https://nodejs.org/en/) installed on your machine
17 | 2. Clone the repository with `git clone https://github.com/Baqend/angular-starter.git`
18 | 3. Install the project with `npm install`
19 | 4. Start the server with `npm start`
20 | 5. Open the url in your browser [http://localhost:4200](http://localhost:4200), you should see a small sample application with signup capability
21 | 6. You can build a [AOT](https://angular.io/docs/ts/latest/cookbook/aot-compiler.html) production version with `npm run build -- --prod`
22 |
23 | Your app is currently connected to a Baqend test instance called 'app-starter', which provides common backend features like data and file storage, user authentication (used in the example), queries and push notifications among others.
24 |
25 | To develop your own application
26 |
27 | 1. Launch a free Baqend instance at [baqend.com](http://dashboard.baqend.com/register)
28 | 2. Change the app name in your projects `src/app/db.ts` from `app-starter` to your app name
29 | 3. Your Angular app will automatically connect to your app instance
30 | 4. To start accessing data or backend features, simply import the `db`-object with `import {db} from 'baqend';`
31 | and see our [Guide](https://www.baqend.com/guide) and [API Docs](https://www.baqend.com/js-sdk/latest/baqend.html) for details
32 |
33 | For more information: on [Angular](https://angular.io/docs/ts/latest/), the
34 | [Angular CLI](https://github.com/angular/angular-cli) or [Baqend](http://www.baqend.com).
35 |
36 | ## How the Baqend integration into Angular works
37 |
38 | Before the Baqend SDK can be used, a connection to the Baqend instance must be established. There are two options
39 | to wait for the initialization.
40 |
41 | 1. You can use the `DBReady` resolver to delay the route component rendering, or `DBLoggedIn` to prevent navigation to
42 | protected routes that are only accessible by logged in users. For a live example look into the `src/app/app-routing.modules.ts`.
43 |
44 | 2. Or you can manually wait on `db.ready()` within your components and use the SDK afterwards.
45 | ```js
46 | import { Component, OnInit } from '@angular/core';
47 | import { db } from 'baqend';
48 |
49 | @Component({
50 | selector: 'myRoute'
51 | })
52 | export class MyRoute implement OnInit {
53 |
54 | ngOnInit(private router:Router) {
55 | db.ready().then(() => {
56 | db.MyClass.find()...
57 | });
58 | }
59 | ```
60 |
61 | ## How Baqend fits your Backend requirements
62 |
63 | Baqend is a fully managed Backend-as-a-Service platform with a strong focus on performance and scalability
64 | ([click here for details](https://medium.baqend.com/bringing-web-performance-to-the-next-level-an-overview-of-baqend-be3521bc2faf)).
65 | The [JavaScript API](https://www.baqend.com/js-sdk/latest/baqend.html) gives you access to common backend features
66 | while the [dashboard](https://www.baqend.com/guide/topics/dashboard/) lets you define data models and access rules as
67 | well as business logic to execute on the server side.
68 |
69 | Baqend's feature set includes:
70 |
71 | * Automated Browser and CDN Caching
72 | * Scalable Data Storage
73 | * Realtime Streaming Queries
74 | * Powerful Search and Query Language
75 | * Push Notifications
76 | * User Authentication and OAuth
77 | * File Storage and Hosting
78 | * Access Control on Object and Schema Level
79 |
80 | # License
81 |
82 | [MIT](https://github.com/Baqend/angular-starter/blob/master/LICENSE)
83 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "angular4-starter": {
7 | "root": "",
8 | "sourceRoot": "src",
9 | "projectType": "application",
10 | "architect": {
11 | "build": {
12 | "builder": "@angular-devkit/build-angular:browser",
13 | "options": {
14 | "outputPath": "dist",
15 | "index": "src/index.html",
16 | "main": "src/main.ts",
17 | "tsConfig": "src/tsconfig.app.json",
18 | "polyfills": "src/polyfills.ts",
19 | "assets": [
20 | "src/assets",
21 | "src/favicon.ico"
22 | ],
23 | "styles": [
24 | "src/styles.scss"
25 | ],
26 | "scripts": []
27 | },
28 | "configurations": {
29 | "production": {
30 | "optimization": true,
31 | "outputHashing": "all",
32 | "sourceMap": false,
33 | "extractCss": true,
34 | "namedChunks": false,
35 | "aot": true,
36 | "extractLicenses": true,
37 | "vendorChunk": false,
38 | "buildOptimizer": true,
39 | "fileReplacements": [
40 | {
41 | "replace": "src/environments/environment.ts",
42 | "with": "src/environments/environment.prod.ts"
43 | }
44 | ]
45 | }
46 | }
47 | },
48 | "serve": {
49 | "builder": "@angular-devkit/build-angular:dev-server",
50 | "options": {
51 | "browserTarget": "angular4-starter:build"
52 | },
53 | "configurations": {
54 | "production": {
55 | "browserTarget": "angular4-starter:build:production"
56 | }
57 | }
58 | },
59 | "extract-i18n": {
60 | "builder": "@angular-devkit/build-angular:extract-i18n",
61 | "options": {
62 | "browserTarget": "angular4-starter:build"
63 | }
64 | },
65 | "test": {
66 | "builder": "@angular-devkit/build-angular:karma",
67 | "options": {
68 | "main": "src/test.ts",
69 | "karmaConfig": "./karma.conf.js",
70 | "polyfills": "src/polyfills.ts",
71 | "tsConfig": "src/tsconfig.spec.json",
72 | "scripts": [],
73 | "styles": [
74 | "src/styles.scss"
75 | ],
76 | "assets": [
77 | "src/assets",
78 | "src/favicon.ico"
79 | ]
80 | }
81 | },
82 | "lint": {
83 | "builder": "@angular-devkit/build-angular:tslint",
84 | "options": {
85 | "tsConfig": [
86 | "src/tsconfig.app.json",
87 | "src/tsconfig.spec.json"
88 | ],
89 | "exclude": []
90 | }
91 | }
92 | }
93 | },
94 | "angular4-starter-e2e": {
95 | "root": "",
96 | "sourceRoot": "e2e",
97 | "projectType": "application",
98 | "architect": {
99 | "e2e": {
100 | "builder": "@angular-devkit/build-angular:protractor",
101 | "options": {
102 | "protractorConfig": "./protractor.conf.js",
103 | "devServerTarget": "angular4-starter:serve"
104 | }
105 | },
106 | "lint": {
107 | "builder": "@angular-devkit/build-angular:tslint",
108 | "options": {
109 | "tsConfig": [
110 | "e2e/tsconfig.e2e.json"
111 | ],
112 | "exclude": []
113 | }
114 | }
115 | }
116 | }
117 | },
118 | "defaultProject": "angular4-starter",
119 | "schematics": {
120 | "@schematics/angular:component": {
121 | "prefix": "app",
122 | "styleext": "scss"
123 | },
124 | "@schematics/angular:directive": {
125 | "prefix": "app"
126 | }
127 | }
128 | }
--------------------------------------------------------------------------------
/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { Angular4StarterPage } from './app.po';
2 |
3 | describe('angular4-starter App', () => {
4 | let page: Angular4StarterPage;
5 |
6 | beforeEach(() => {
7 | page = new Angular4StarterPage();
8 | });
9 |
10 | it('should display welcome message', done => {
11 | page.navigateTo();
12 | page.getFooterText()
13 | .then(msg => expect(msg).toContain('Angular + Baqend by'))
14 | .then(done, done.fail);
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class Angular4StarterPage {
4 | navigateTo() {
5 | return browser.get('/signup');
6 | }
7 |
8 | getFooterText() {
9 | return element(by.css('footer span')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "node"
10 | ]
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
20 | fixWebpackSourcePaths: true
21 | },
22 |
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
32 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-starter",
3 | "version": "4.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/animations": "^7.1.1",
16 | "@angular/common": "^7.1.1",
17 | "@angular/compiler": "^7.1.1",
18 | "@angular/core": "^7.1.1",
19 | "@angular/forms": "^7.1.1",
20 | "@angular/http": "^7.1.1",
21 | "@angular/platform-browser": "^7.1.1",
22 | "@angular/platform-browser-dynamic": "^7.1.1",
23 | "@angular/router": "^7.1.1",
24 | "baqend": "^2.13.0",
25 | "bootstrap-sass": "^3.3.7",
26 | "core-js": "^2.5.7",
27 | "rxjs": "^6.3.3",
28 | "tslib": "^1.9.3",
29 | "zone.js": "^0.8.26"
30 | },
31 | "devDependencies": {
32 | "@angular/compiler-cli": "^7.1.1",
33 | "@angular-devkit/build-angular": "~0.11.1",
34 | "typescript": "~3.1.6",
35 | "@angular/cli": "~7.1.1",
36 | "@angular/language-service": "^7.1.1",
37 | "@types/jasmine": "~3.3.1",
38 | "@types/jasminewd2": "~2.0.6",
39 | "@types/node": "~10.12.12",
40 | "codelyzer": "~4.5.0",
41 | "jasmine-core": "~3.3.0",
42 | "jasmine-spec-reporter": "~4.2.1",
43 | "karma": "~3.1.3",
44 | "karma-chrome-launcher": "~2.2.0",
45 | "karma-coverage-istanbul-reporter": "~2.0.4",
46 | "karma-jasmine": "~2.0.1",
47 | "karma-jasmine-html-reporter": "^1.4.0",
48 | "protractor": "~5.4.1",
49 | "ts-node": "~7.0.1",
50 | "tslint": "~5.11.0"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/src/_variables.scss:
--------------------------------------------------------------------------------
1 | /* Add your variables or configure bootstrap */
2 |
3 | $icon-font-path: '../node_modules/bootstrap-sass/assets/fonts/bootstrap/';
4 |
--------------------------------------------------------------------------------
/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { SignupComponent } from './signup/signup.component';
4 | import { DBLoggedIn, DBReady } from './db';
5 | import { MeComponent } from './me/me.component';
6 |
7 | const routes: Routes = [
8 | { path: '', redirectTo: '/signup', pathMatch: 'full', resolve: { db: DBReady }}, // redirect to signup page
9 | { path: 'signup', component: SignupComponent, resolve: { db: DBReady } }, // will activate the route after the db is ready
10 | { path: 'signup/me', component: MeComponent, canActivate: [DBLoggedIn] }, // will prevent none logged in users from accessing it
11 | { path: 'chats', loadChildren: './chats/chats.module#ChatsModule'} // Using loadChildren to async load the route
12 | ];
13 |
14 | @NgModule({
15 | imports: [RouterModule.forRoot(routes)],
16 | exports: [RouterModule]
17 | })
18 | export class AppRoutingModule { }
19 |
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
6 |
7 |
17 |
18 |
19 |
20 |
21 |
24 |
--------------------------------------------------------------------------------
/src/app/app.component.scss:
--------------------------------------------------------------------------------
1 | html, body{
2 | height: 100%;
3 | font-family: Arial, Helvetica, sans-serif
4 | }
5 |
6 | .nav {
7 | margin: 30px auto;
8 | width: 204px;
9 | > li {
10 | a {
11 | &.active {
12 | background-color: #337ab7;
13 | color: #ffffff;
14 | }
15 | background-color: #f5f5f5;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.scss']
7 | })
8 | export class AppComponent {
9 |
10 | public angularbaqendLogo = 'assets/Angular+Baqend.svg';
11 | public baqend = 'https://www.baqend.com';
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 |
5 | import { AppRoutingModule } from './app-routing.module';
6 | import { AppComponent } from './app.component';
7 | import { DB_PROVIDERS } from './db';
8 | import { MeComponent } from './me/me.component';
9 | import { SignupComponent } from './signup/signup.component';
10 |
11 | @NgModule({
12 | declarations: [
13 | AppComponent,
14 | MeComponent,
15 | SignupComponent
16 | ],
17 | imports: [
18 | BrowserModule,
19 | FormsModule,
20 | AppRoutingModule
21 | ],
22 | providers: [DB_PROVIDERS],
23 | bootstrap: [AppComponent]
24 | })
25 | export class AppModule { }
26 |
--------------------------------------------------------------------------------
/src/app/chats/chats-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { ChatsComponent } from './chats.component';
4 | import { DBReady } from '../db';
5 | import { DetailsComponent } from './details/details.component';
6 |
7 | const routes: Routes = [
8 | { path: '', component: ChatsComponent, resolve: { db: DBReady } },
9 | { path: ':id', component: DetailsComponent, resolve: { db: DBReady } },
10 | ];
11 |
12 | @NgModule({
13 | imports: [RouterModule.forChild(routes)],
14 | exports: [RouterModule]
15 | })
16 | export class ChatsRoutingModule { }
17 |
--------------------------------------------------------------------------------
/src/app/chats/chats.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
{{ message.name }}
6 |
7 |
8 |
9 |
10 |
![]()
11 |
12 |
13 | {{ message.text }}
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/app/chats/chats.component.scss:
--------------------------------------------------------------------------------
1 | .row {
2 | margin-top: 20px
3 | }
4 |
5 | img {
6 | width: 100%
7 | }
8 |
9 | .panel {
10 | cursor: pointer
11 | }
12 |
--------------------------------------------------------------------------------
/src/app/chats/chats.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { db, model } from 'baqend';
3 |
4 | @Component({
5 | selector: 'app-chats',
6 | templateUrl: './chats.component.html',
7 | styleUrls: ['./chats.component.scss']
8 | })
9 | export class ChatsComponent implements OnInit {
10 |
11 | public messages: Array;
12 |
13 | constructor() {}
14 |
15 | getImageUrl(message) {
16 | return new db.File(message.face).url;
17 | }
18 |
19 | ngOnInit() {
20 | db.Message
21 | .find()
22 | .resultList()
23 | .then(messages => this.messages = messages);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/app/chats/chats.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { ChatsRoutingModule } from './chats-routing.module';
5 | import { DetailsComponent } from './details/details.component';
6 | import { ChatsComponent } from './chats.component';
7 |
8 | @NgModule({
9 | imports: [
10 | CommonModule,
11 | ChatsRoutingModule
12 | ],
13 | declarations: [
14 | DetailsComponent,
15 | ChatsComponent
16 | ]
17 | })
18 | export class ChatsModule {
19 | }
20 |
--------------------------------------------------------------------------------
/src/app/chats/details/details.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
{{ message.name }}
6 |
7 |
8 |
9 |
10 |
![]()
11 |
12 |
13 | {{ message.text }}
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/app/chats/details/details.component.scss:
--------------------------------------------------------------------------------
1 | .row {
2 | margin-top: 20px
3 | }
4 |
5 | img {
6 | width: 100%
7 | }
8 |
--------------------------------------------------------------------------------
/src/app/chats/details/details.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { ActivatedRoute, Params } from '@angular/router';
3 | import { db, model } from 'baqend';
4 |
5 | @Component({
6 | selector: 'app-details',
7 | templateUrl: './details.component.html',
8 | styleUrls: ['./details.component.scss']
9 | })
10 | export class DetailsComponent implements OnInit {
11 |
12 | public message: model.Message;
13 |
14 | constructor(private route: ActivatedRoute) {}
15 |
16 | getImageUrl(message) {
17 | return new db.File(message.face).url;
18 | }
19 |
20 | ngOnInit() {
21 | this.route.params
22 | .subscribe((params: Params) => {
23 | db.Message.load(params['id']).then(message => this.message = message);
24 | });
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/app/db.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { Resolve, Router, ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router';
3 | import { db, baqend } from 'baqend';
4 |
5 | db.connect('app-starter', true);
6 |
7 | @Injectable()
8 | export class DBReady implements Resolve {
9 | resolve(route: ActivatedRouteSnapshot): Promise {
10 | return db.ready();
11 | }
12 | }
13 |
14 | @Injectable()
15 | export class DBLoggedIn implements CanActivate {
16 | constructor(private router: Router) {}
17 |
18 | canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise {
19 | return db.ready().then(() => {
20 | if (!db.User.me) {
21 | this.router.navigate(['/signup']);
22 | return false;
23 | }
24 | return true;
25 | });
26 | }
27 | }
28 |
29 | export const DB_PROVIDERS = [DBReady, DBLoggedIn];
30 |
--------------------------------------------------------------------------------
/src/app/me/me.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
You are logged in as {{me.username}}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/app/me/me.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Baqend/angular-starter/f91205fce04ea7c4a6736b15a14120c19f76a6ba/src/app/me/me.component.scss
--------------------------------------------------------------------------------
/src/app/me/me.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { Router } from '@angular/router';
3 | import { model, db } from 'baqend';
4 |
5 | @Component({
6 | selector: 'app-me',
7 | templateUrl: './me.component.html',
8 | styleUrls: ['./me.component.scss']
9 | })
10 | export class MeComponent implements OnInit {
11 |
12 | me: model.User;
13 |
14 | constructor(private router: Router) {}
15 |
16 | ngOnInit() {
17 | this.me = db.User.me;
18 | }
19 |
20 | logout() {
21 | db.User.logout().then(() => {
22 | this.router.navigate(['/']);
23 | })
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/app/signup/signup.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
User registration example
5 |
23 |
24 |
{{error}}
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/app/signup/signup.component.scss:
--------------------------------------------------------------------------------
1 | .panel {
2 | margin-top: 20px;
3 | }
4 |
--------------------------------------------------------------------------------
/src/app/signup/signup.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { Router } from '@angular/router';
3 | import { db } from 'baqend';
4 |
5 | @Component({
6 | selector: 'app-signup',
7 | templateUrl: './signup.component.html',
8 | styleUrls: ['./signup.component.scss']
9 | })
10 | export class SignupComponent {
11 |
12 | user = {
13 | name: '',
14 | password: ''
15 | };
16 | error;
17 |
18 | constructor(private router: Router) {
19 | if (db.User.me) {
20 | this.router.navigate(['/signup/me']);
21 | }
22 | }
23 |
24 | register() {
25 | db.User.register(this.user.name, this.user.password).then(() => {
26 | this.router.navigate(['/signup/me']);
27 | }, (error) => {
28 | this.error = error.message;
29 | });
30 | }
31 |
32 | logIn() {
33 | db.User.login(this.user.name, this.user.password).then(() => {
34 | this.router.navigate(['/signup/me']);
35 | }, (error) => {
36 | this.error = error.message;
37 | });
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/assets/Angular+Baqend.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
112 |
--------------------------------------------------------------------------------
/src/baqend-model.d.ts:
--------------------------------------------------------------------------------
1 | import {binding, GeoPoint} from 'baqend';
2 |
3 | declare module 'baqend' {
4 |
5 | interface baqend {
6 | Message: binding.EntityFactory;
7 | }
8 |
9 | namespace model {
10 | interface Device extends binding.Entity {
11 | deviceOs: string;
12 | }
13 |
14 | interface Role extends binding.Entity {
15 | name: string;
16 | users: Set;
17 | }
18 |
19 | interface User extends binding.Entity {
20 | username: string;
21 | inactive: boolean;
22 | }
23 |
24 | interface Message extends binding.Entity {
25 | name: string;
26 | text: string;
27 | face: string;
28 | }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false
8 | };
9 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Baqend/angular-starter/f91205fce04ea7c4a6736b15a14120c19f76a6ba/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Baqend Angular Starter
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule);
12 |
--------------------------------------------------------------------------------
/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/weak-map';
35 | // import 'core-js/es6/set';
36 |
37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
38 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
39 |
40 | /** IE10 and IE11 requires the following to support `@angular/animation`. */
41 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
42 |
43 |
44 | /** Evergreen browsers require these. **/
45 | import 'core-js/es6/reflect';
46 |
47 |
48 |
49 | /** ALL Firefox browsers require the following to support `@angular/animation`. **/
50 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
51 |
52 |
53 |
54 | /***************************************************************************************************
55 | * Zone JS is required by Angular itself.
56 | */
57 | import 'zone.js/dist/zone'; // Included with Angular CLI.
58 |
59 |
60 |
61 | /***************************************************************************************************
62 | * APPLICATION IMPORTS
63 | */
64 |
65 | /**
66 | * Date, currency, decimal and percent pipes.
67 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
68 | */
69 | // import 'intl'; // Run `npm install --save intl`.
70 | /**
71 | * Need to import at least one locale-data with intl.
72 | */
73 | // import 'intl/locale-data/jsonp/en';
74 |
--------------------------------------------------------------------------------
/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
3 | @import 'variables';
4 | @import '../node_modules/bootstrap-sass/assets/stylesheets/_bootstrap';
5 |
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare const __karma__: any;
17 | declare const require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "baseUrl": "",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "baseUrl": "",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts",
15 | "polyfills.ts"
16 | ],
17 | "include": [
18 | "**/*.spec.ts",
19 | "**/*.d.ts"
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "importHelpers": true,
5 | "outDir": "./dist/out-tsc",
6 | "baseUrl": "src",
7 | "sourceMap": true,
8 | "declaration": false,
9 | "moduleResolution": "node",
10 | "emitDecoratorMetadata": true,
11 | "experimentalDecorators": true,
12 | "target": "es5",
13 | "typeRoots": [
14 | "node_modules/@types"
15 | ],
16 | "lib": [
17 | "es2016",
18 | "dom"
19 | ]
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "eofline": true,
15 | "forin": true,
16 | "import-blacklist": [
17 | true
18 | ],
19 | "import-spacing": true,
20 | "indent": [
21 | true,
22 | "spaces"
23 | ],
24 | "interface-over-type-literal": true,
25 | "label-position": true,
26 | "max-line-length": [
27 | true,
28 | 140
29 | ],
30 | "member-access": false,
31 | "member-ordering": [
32 | true,
33 | "static-before-instance",
34 | "variables-before-functions"
35 | ],
36 | "no-arg": true,
37 | "no-bitwise": true,
38 | "no-console": [
39 | true,
40 | "debug",
41 | "info",
42 | "time",
43 | "timeEnd",
44 | "trace"
45 | ],
46 | "no-construct": true,
47 | "no-debugger": true,
48 | "no-duplicate-super": true,
49 | "no-empty": false,
50 | "no-empty-interface": true,
51 | "no-eval": true,
52 | "no-inferrable-types": [
53 | true,
54 | "ignore-params"
55 | ],
56 | "no-misused-new": true,
57 | "no-non-null-assertion": true,
58 | "no-shadowed-variable": true,
59 | "no-string-literal": false,
60 | "no-string-throw": true,
61 | "no-switch-case-fall-through": true,
62 | "no-unnecessary-initializer": true,
63 | "no-unused-expression": true,
64 | "no-use-before-declare": true,
65 | "no-var-keyword": true,
66 | "object-literal-sort-keys": false,
67 | "one-line": [
68 | true,
69 | "check-open-brace",
70 | "check-catch",
71 | "check-else",
72 | "check-whitespace"
73 | ],
74 | "prefer-const": true,
75 | "quotemark": [
76 | true,
77 | "single"
78 | ],
79 | "radix": true,
80 | "semicolon": [
81 | "always"
82 | ],
83 | "triple-equals": [
84 | true,
85 | "allow-null-check"
86 | ],
87 | "typedef-whitespace": [
88 | true,
89 | {
90 | "call-signature": "nospace",
91 | "index-signature": "nospace",
92 | "parameter": "nospace",
93 | "property-declaration": "nospace",
94 | "variable-declaration": "nospace"
95 | }
96 | ],
97 | "typeof-compare": true,
98 | "unified-signatures": true,
99 | "variable-name": false,
100 | "whitespace": [
101 | true,
102 | "check-branch",
103 | "check-decl",
104 | "check-operator",
105 | "check-separator",
106 | "check-type"
107 | ],
108 | "directive-selector": [
109 | true,
110 | "attribute",
111 | "app",
112 | "camelCase"
113 | ],
114 | "component-selector": [
115 | true,
116 | "element",
117 | "app",
118 | "kebab-case"
119 | ],
120 | "use-input-property-decorator": true,
121 | "use-output-property-decorator": true,
122 | "use-host-property-decorator": true,
123 | "no-input-rename": true,
124 | "no-output-rename": true,
125 | "use-life-cycle-interface": true,
126 | "use-pipe-transform-interface": true,
127 | "component-class-suffix": true,
128 | "directive-class-suffix": true,
129 | "no-access-missing-member": true,
130 | "templates-use-public": true,
131 | "invoke-injectable": true
132 | }
133 | }
134 |
--------------------------------------------------------------------------------