Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
Merge ebd1f23 into 7f82fcd
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopgrassi committed May 6, 2018
2 parents 7f82fcd + ebd1f23 commit 9bd0117
Show file tree
Hide file tree
Showing 21 changed files with 6,027 additions and 3,239 deletions.
1 change: 0 additions & 1 deletion .angular-cli.json
Expand Up @@ -16,7 +16,6 @@
],
"index": "index.html",
"baseHref": "index.html",
"baseHref": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -31,6 +31,7 @@
/libpeerconnection.log
npm-debug.log
testem.log
debug.log
/typings
yarn-error.log

Expand Down
8,298 changes: 5,412 additions & 2,886 deletions package-lock.json

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions package.json
Expand Up @@ -13,51 +13,51 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^5.1.1",
"@angular/cdk": "^5.0.1",
"@angular/common": "^5.1.1",
"@angular/compiler": "^5.1.1",
"@angular/core": "^5.1.1",
"@angular/flex-layout": "^2.0.0-beta.12",
"@angular/forms": "^5.1.1",
"@angular/http": "^5.1.1",
"@angular/material": "^5.0.1",
"@angular/platform-browser": "^5.1.1",
"@angular/platform-browser-dynamic": "^5.1.1",
"@angular/router": "^5.1.1",
"@angular/animations": "^5.2.10",
"@angular/cdk": "^5.2.5",
"@angular/common": "^5.2.10",
"@angular/compiler": "^5.2.10",
"@angular/core": "^5.2.10",
"@angular/flex-layout": "^5.0.0-beta.13",
"@angular/forms": "^5.2.10",
"@angular/http": "^5.2.10",
"@angular/material": "^5.2.5",
"@angular/platform-browser": "^5.2.10",
"@angular/platform-browser-dynamic": "^5.2.10",
"@angular/router": "^5.2.10",
"@ngrx/effects": "^4.1.1",
"@ngrx/store": "^4.1.1",
"bootstrap": "4.0.0-beta.2",
"core-js": "^2.5.3",
"rxjs": "^5.5.5",
"uglify-es": "3.2.2",
"uuid": "^3.1.0",
"zone.js": "^0.8.18"
"bootstrap": "4.0.0",
"core-js": "^2.5.5",
"rxjs": "^5.5.10",
"uglify-es": "3.3.9",
"uuid": "^3.2.1",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/cli": "^1.6.3",
"@angular/compiler-cli": "^5.1.2",
"@angular/language-service": "^5.1.1",
"@types/chrome": "~0.0.56",
"@types/jasmine": "~2.8.2",
"@angular/cli": "^1.7.4",
"@angular/compiler-cli": "^5.2.10",
"@angular/language-service": "^5.2.10",
"@types/chrome": "0.0.63",
"@types/jasmine": "^2.8.7",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.5.1",
"codelyzer": "~4.0.2",
"coveralls": "^3.0.0",
"@types/node": "^9.6.12",
"codelyzer": "~4.2.1",
"coveralls": "^3.0.1",
"istanbul": "^0.4.5",
"jasmine-core": "~2.8.0",
"jasmine-core": "~3.1.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.0",
"karma": "~2.0.2",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.3.1",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-scss-preprocessor": "^3.0.0",
"mocha": "^4.0.1",
"protractor": "~5.2.2",
"ts-node": "~4.0.2",
"tslint": "~5.8.0",
"typescript": "~2.6.2"
"karma-coverage-istanbul-reporter": "~1.4.2",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "~1.0.0",
"karma-scss-preprocessor": "~3.0.0",
"mocha": "~5.0.5",
"protractor": "~5.3.1",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~2.7.2"
}
}
2 changes: 0 additions & 2 deletions src/app/app.component.spec.ts
Expand Up @@ -12,7 +12,6 @@ import { MockedRuleBrowserStorageService, MockedNotificationService, MockedRoute

import { HeaderComponent } from './_layout/header.component';
import { AppComponent } from './app.component';
import { RuleActions } from './rule/common/rule.actions';
import { RuleBrowserStorageService, RuleService } from './rule/common/';
import { Icon, IIcon, IRule, Rule } from './rule/common/rule-model';

Expand Down Expand Up @@ -41,7 +40,6 @@ describe('AppComponent', () => {
schemas: [ NO_ERRORS_SCHEMA ],
providers: [
{ provide: Router, useClass: MockedRouter },
{ provide: RuleActions, useValue: new RuleActions() },
{ provide: NotificationService, useClass: MockedNotificationService },
{ provide: RuleBrowserStorageService, useClass: MockedRuleBrowserStorageService },
{ provide: RuleService, useClass: MockedRuleService }
Expand Down
30 changes: 20 additions & 10 deletions src/app/app.component.ts
@@ -1,7 +1,7 @@
import { Component } from '@angular/core';
import { Store } from '@ngrx/store';

import { RuleActions } from './rule/common/rule.actions';
import * as RuleActions from './rule/common/rule.actions';
import { IAppStore } from './store';
import { MatIconRegistry } from '@angular/material';
import { DomSanitizer } from '@angular/platform-browser';
Expand All @@ -11,20 +11,30 @@ import { DomSanitizer } from '@angular/platform-browser';
templateUrl: './app.component.html'
})
export class AppComponent {

constructor(private ruleActions: RuleActions,
private iconRegistry: MatIconRegistry,
private sanitizer: DomSanitizer,
private store: Store<IAppStore>) {
this.store.dispatch(this.ruleActions.loadRules());
constructor(
private iconRegistry: MatIconRegistry,
private sanitizer: DomSanitizer,
private store: Store<IAppStore>
) {
this.store.dispatch(new RuleActions.LoadRules());
this.registerIcons();
}

/**
* Regiters custom items globaly to be used with mat-icon.
* Registers custom items globally to be used with mat-icon.
*/
private registerIcons() {
this.iconRegistry.addSvgIcon('github', this.sanitizer.bypassSecurityTrustResourceUrl('../assets/icons/mark-github.svg'));
this.iconRegistry.addSvgIcon('chrome', this.sanitizer.bypassSecurityTrustResourceUrl('../assets/icons/chrome.svg'));
this.iconRegistry.addSvgIcon(
'github',
this.sanitizer.bypassSecurityTrustResourceUrl(
'../assets/icons/mark-github.svg'
)
);
this.iconRegistry.addSvgIcon(
'chrome',
this.sanitizer.bypassSecurityTrustResourceUrl(
'../assets/icons/chrome.svg'
)
);
}
}
16 changes: 10 additions & 6 deletions src/app/app.module.ts
Expand Up @@ -12,14 +12,19 @@ import { HeaderComponent } from './_layout/';
import { NotificationService, BrowserStorageProvider } from './common';
import { AppStore } from './store/';

import { RuleDashboardComponent, RuleDetailsComponent, RuleService, RuleBrowserStorageService, RuleActions } from './rule';
import {
RuleDashboardComponent,
RuleDetailsComponent,
RuleService,
RuleBrowserStorageService
} from './rule';

@NgModule({
declarations: [
AppComponent,
HeaderComponent,
RuleDashboardComponent,
RuleDetailsComponent,
RuleDetailsComponent
],
imports: [
BrowserModule,
Expand All @@ -30,16 +35,15 @@ import { RuleDashboardComponent, RuleDetailsComponent, RuleService, RuleBrowserS
AppMaterialModule,
FlexLayoutModule,
BrowserAnimationsModule,
AppStore,
AppStore
],
providers: [
{ provide: 'Chrome', useValue: chrome },
{ provide: 'Chrome', useValue: chrome },
RuleService,
NotificationService,
RuleBrowserStorageService,
RuleActions,
BrowserStorageProvider
],
bootstrap: [AppComponent]
})
export class AppModule { }
export class AppModule {}
13 changes: 10 additions & 3 deletions src/app/rule/common/rule-model.ts
Expand Up @@ -49,7 +49,7 @@ export class RuleBanner implements IRuleBanner {

constructor(text: string, icon: Icon, textColor: string = '#FFF') {
this.text = text;
this.bgColor = (icon ? icon.iconBaseColor : '#EB1342'); // default is empty is red.
this.bgColor = icon ? icon.iconBaseColor : '#EB1342'; // default is empty is red.
this.textColor = textColor;
}
}
Expand Down Expand Up @@ -83,7 +83,13 @@ export class Rule implements IRule {
* @param {Icon} icon
* @param {IRuleBanner} banner
*/
constructor(id: string, name: string, url: string, operator: string, title: string, icon: Icon, banner?: IRuleBanner) {
constructor(id: string,
name: string,
url: string,
operator: string,
title: string,
icon: Icon,
banner?: IRuleBanner) {
this.id = id || uuid();
this.name = name;
this.url = url;
Expand All @@ -100,7 +106,8 @@ export class Rule implements IRule {

export class StorageRules {
envGuard: IRule[];
constructor (rules: IRule[]) {

constructor(rules: IRule[]) {
this.envGuard = rules;
}
}
94 changes: 94 additions & 0 deletions src/app/rule/common/rule.actions.spec.ts
@@ -0,0 +1,94 @@
import {
AddRule,
ADD_RULE,
SaveRule,
SAVE_RULE,
DeleteRule,
DELETE_RULE,
LoadRules,
LOAD_RULES,
LoadRuleSuccess,
LOAD_RULES_SUCCESS,
SyncLocalStorage,
SYNC_LOCAL_STORAGE,
SyncLocalStorageSuccess,
SYNC_LOCAL_STORAGE_SUCCESS
} from './rule.actions';
import { IRule } from './index';

let rule: IRule;

beforeEach(() => {
rule = {
id: '1',
name: 'name',
url: 'url',
operator: 'operator',
banner: null,
icon: null,
title: 'title'
};
});

describe('AddRule', () => {
it('should create an action', () => {
const action = new AddRule(rule);

expect({ ...action }).toEqual({ type: ADD_RULE, payload: rule });
});
});

describe('SaveRule', () => {
it('should create an action', () => {
const action = new SaveRule(rule);

expect({ ...action }).toEqual({ type: SAVE_RULE, payload: rule });
});
});

describe('DeleteRule', () => {
it('should create an action', () => {
const action = new DeleteRule(rule);

expect({ ...action }).toEqual({ type: DELETE_RULE, payload: rule });
});
});

describe('LoadRules', () => {
it('should create an action', () => {
const action = new LoadRules();

expect({ ...action }).toEqual({ type: LOAD_RULES });
});
});

describe('LoadRulesSuccess', () => {
it('should create an action', () => {
const action = new LoadRuleSuccess([rule]);

expect({ ...action }).toEqual({
type: LOAD_RULES_SUCCESS,
payload: [rule]
});
});
});

describe('SyncLocalStorage', () => {
it('should create an action', () => {
const action = new SyncLocalStorage();

expect({ ...action }).toEqual({
type: SYNC_LOCAL_STORAGE
});
});
});

describe('SyncLocalStorageSuccess', () => {
it('should create an action', () => {
const action = new SyncLocalStorageSuccess();

expect({ ...action }).toEqual({
type: SYNC_LOCAL_STORAGE_SUCCESS
});
});
});

0 comments on commit 9bd0117

Please sign in to comment.