Skip to content

Commit 56cdcf8

Browse files
committed
feat(admin): adding admin module to manage notifications
admin module showcase role based security and push notifications managment
1 parent fa7c98c commit 56cdcf8

File tree

53 files changed

+1337
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1337
-85
lines changed

.deploy/api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ oc delete all,configmap,secret -l app=ngx-starter-kit-api -n ngx-starter-kit
6868
6969
# redeploy
7070
# From OpenShift Console UI
71-
Applications > Deployments > ngx-starter-kit > Deploy
71+
Applications > Deployments > ngx-starter-kit > Deploy
7272
```
7373
7474
#### Kubernetes Deployment

PLAYBOOK.md

Lines changed: 63 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ Do-it-yourself step-by-step instructions to create this project structure from s
1010
| -------------------- | ------- | -------- |
1111
| Node | v11.1.0 | |
1212
| NPM | v6.4.1 | |
13-
| Angular CLI | v7.1.0 | |
14-
| @nrwl/schematics | v7.1.0 | |
13+
| Angular CLI | v7.1.2 | |
14+
| @nrwl/schematics | v7.1.1 | |
1515
| @nestjs/cli | v5.6.3 | |
16-
| semantic-release-cli | v4.0.11 | |
16+
| semantic-release-cli | v4.0.12 | |
17+
| commitizen | v3.0.5 | |
1718

1819
### Install Prerequisites
1920

@@ -61,7 +62,7 @@ npm remove -g @nestjs/cli
6162
npm remove -g semantic-release-cli
6263
npm remove -g commitizen
6364

64-
npm install -g @angular/cli@next
65+
npm install -g @angular/cli
6566
npm install -g @nrwl/schematics
6667
npm install -g @nestjs/cli
6768
npm install -g semantic-release-cli
@@ -76,6 +77,8 @@ ng config -g schematics.@nrwl/schematics:component.styleext scss
7677
ng config -g cli.packageManager npm
7778
# set jest as default TestRunner
7879
ng config -g schematics.@nrwl/schematics:library.unitTestRunner jest
80+
# set scss as default styleext for ngx-formly
81+
ng config -g schematics@ngx-formly/schematics:component.styleext scss
7982
# check your global defaults
8083
more cat ~/.angular-config.json
8184
# show dependency tree for specified package.
@@ -235,6 +238,7 @@ ng update @nrwl/schematics --force
235238
# generate `Lazy-loaded Feature Modules`
236239
ng g lib home --routing --lazy --prefix=ngx --parent-module=apps/webapp/src/app/app.module.ts --unit-test-runner=jest --tags=layout,entry-module
237240
ng g lib dashboard --routing --lazy --prefix=ngx --parent-module=apps/webapp/src/app/app.module.ts --unit-test-runner=jest --tags=layout,entry-module
241+
ng g lib admin --routing --lazy --prefix=ngx --parent-module=apps/webapp/src/app/app.module.ts --unit-test-runner=jest --tags=layout,entry-module
238242
ng g lib NotFound --routing --lazy --prefix=ngx --parent-module=apps/webapp/src/app/app.module.ts --unit-test-runner=jest --tags=entry-module
239243
ng g lib experiments --routing --lazy --prefix=ngx --parent-module=libs/dashboard/src/lib/dashboard.module.ts --unit-test-runner=jest --tags=child-module
240244
ng g lib widgets --routing --lazy --prefix=ngx --parent-module=libs/dashboard/src/lib/dashboard.module.ts --unit-test-runner=jest --tags=child-module
@@ -386,75 +390,91 @@ ng g service directives/in-viewport/Viewport --project=ngx-utils --module=in-vie
386390

387391
# generate components for `toolbar` Module
388392
ng g lib toolbar --prefix=ngx --tags=private-module --unit-test-runner=jest -d
389-
ng g component toolbar --project=toolbar --flat -d
390-
ng g component components/search --project=toolbar -d
391-
ng g component components/searchBar --project=toolbar
392-
ng g component components/UserMenu --project=toolbar
393-
ng g component components/FullscreenToggle --project=toolbar -d
393+
ng g component toolbar --project=toolbar --flat -d
394+
ng g component components/search --project=toolbar -d
395+
ng g component components/searchBar --project=toolbar -d
396+
ng g component components/UserMenu --project=toolbar -d
397+
ng g component components/FullscreenToggle --project=toolbar -d
394398
ng g component components/SidenavMobileToggle --project=toolbar -d
395-
ng g component components/QuickpanelToggle --project=toolbar -d
399+
ng g component components/QuickpanelToggle --project=toolbar -d
396400

397401
# generate components for `sidenav` Module
398402
ng g lib sidenav --prefix=ngx --tags=private-module --unit-test-runner=jest -d
399-
ng g component sidenav --project=sidenav --flat -d
400-
ng g component components/sidenavItem --project=sidenav -d
401-
ng g directive IconSidenav --project=sidenav -d
403+
ng g component sidenav --project=sidenav --flat -d
404+
ng g component components/sidenavItem --project=sidenav -d
405+
ng g directive IconSidenav --project=sidenav -d
402406

403407
# generate components for `auth` Module
404408
ng g lib auth --prefix=ngx --tags=private-module,core-module --prefix=ngx --style=scss --unit-test-runner=jest -d
405409
ng g component components/login --project=auth -d
410+
ng g guard admin --project=auth -d
406411
ng g @ngxs/schematics:store --name=auth --spec --project=auth -d
407412

408413
# generate components for `navigator` Module
409414
ng g lib navigator --prefix=ngx --tags=private-module,core-module --unit-test-runner=jest -d
410-
ng g service services/menu --project=navigator -d
411-
ng g class models/menuItem --project=navigator --type=model -d
412-
ng g class state/menu --project=navigator --type=state -d
415+
ng g service services/menu --project=navigator -d
416+
ng g class models/menuItem --project=navigator --type=model -d
417+
ng g class state/menu --project=navigator --type=state -d
413418

414419
# generate containers, components for `home` Module
415-
ng g component components/header --project=home
416-
ng g component containers/homeLayout --project=home
417-
ng g component containers/landing --project=home
418-
ng g component containers/blog --project=home
419-
ng g component containers/about --project=home
420+
ng g component components/header --project=home
421+
ng g component containers/homeLayout --project=home
422+
ng g component containers/landing --project=home
423+
ng g component containers/blog --project=home
424+
ng g component containers/about --project=home
420425

421426
# generate containers, components for `dashboard` Module
422-
ng g component components/rainbow --project=dashboard -d
427+
ng g component components/rainbow --project=dashboard -d
423428
ng g component containers/dashboardLayout --project=dashboard -d
424-
ng g component containers/overview --project=dashboard -d
425-
ng g component containers/profile --project=dashboard -d
426-
ng g component containers/settings --project=dashboard -d
429+
ng g component containers/overview --project=dashboard -d
430+
ng g component containers/profile --project=dashboard -d
431+
ng g component containers/settings --project=dashboard -d
427432

428433
# generate containers, components for `widgets` Module
429434
ng g component containers/wizdash --project=widgets -d
430435

431436
# generate containers, components for `grid` Module
432-
ng g component containers/AccountsTable --project=grid -d
433-
ng g component components/AccountDetail --project=grid -d
434-
ng g component components/AccountEdit --project=grid -d
435-
ng g class models/account --type=model --project=grid -d
436-
ng g service services/account --project=grid -d
437+
ng g component containers/AccountsTable --project=grid -d
438+
ng g component components/AccountDetail --project=grid -d
439+
ng g component components/AccountEdit --project=grid -d
440+
ng g class models/account --project=grid --type=model -d
441+
ng g service services/account --project=grid -d
437442
ng g component containers/AccountsGridList --project=grid -d
438443

439444
# generate containers, components for `experiments` Module
440-
ng g component containers/animations --project=experiments -d
441-
ng g component components/hammerCard --project=experiments -d
445+
ng g component containers/animations --project=experiments -d
446+
ng g component components/hammerCard --project=experiments -d
442447
ng g directive components/Hammertime/Hammertime --project=experiments -d
443-
ng g component containers/ContextMenu --project=experiments -d
444-
ng g component containers/FileUpload --project=experiments -d
445-
ng g component containers/virtualScroll --project=experiments -d
446-
ng g component containers/StickyTable --project=experiments -d
447-
ng g component containers/clapButton --project=experiments -s -t --spec=false -d
448-
ng g component containers/knobDemo --project=experiments -d
449-
ng g component containers/ledDemo --project=experiments -d
450-
ng g component containers/ImageComp --project=experiments -d
451-
ng g component containers/layout --project=experiments -d
452-
ng g component components/card --project=experiments -d
453-
ng g component containers/viewport --project=experiments --spec=false -d
448+
ng g component containers/ContextMenu --project=experiments -d
449+
ng g component containers/FileUpload --project=experiments -d
450+
ng g component containers/virtualScroll --project=experiments -d
451+
ng g component containers/StickyTable --project=experiments -d
452+
ng g component containers/clapButton --project=experiments -s -t --spec=false -d
453+
ng g component containers/knobDemo --project=experiments -d
454+
ng g component containers/ledDemo --project=experiments -d
455+
ng g component containers/ImageComp --project=experiments -d
456+
ng g component containers/layout --project=experiments -d
457+
ng g component components/card --project=experiments -d
458+
ng g component containers/viewport --project=experiments --spec=false -d
454459

455460
# generate components for `ImageComparison` Module
456461
ng g lib ImageComparison --prefix=ngx --tags=public-module --spec=false --publishable=true -d
457462
ng g component ImageComparison --project=image-comparison --export --flat -d
463+
464+
465+
# generate containers, components for `admin` Module
466+
ng g component containers/overview --project=admin -d
467+
ng g component containers/adminLayout --project=admin -d
468+
469+
ng g component containers/notifications --project=admin -d
470+
ng g component components/notificationDetail --project=admin -d
471+
ng g component components/notificationEdit --project=admin -d
472+
ng g service services/notification --project=admin -d
473+
474+
ng g component containers/subscriptions --project=admin -d
475+
ng g component components/subscriptionDetail --project=admin -d
476+
ng g class models/subscription --project=admin --type=model -d
477+
ng g service services/subscription --project=admin -d
458478
```
459479

460480
#### Workspace Schematics

angular.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,34 @@
14711471
}
14721472
}
14731473
}
1474+
},
1475+
"admin": {
1476+
"root": "libs/admin",
1477+
"sourceRoot": "libs/admin/src",
1478+
"projectType": "library",
1479+
"prefix": "ngx",
1480+
"architect": {
1481+
"lint": {
1482+
"builder": "@angular-devkit/build-angular:tslint",
1483+
"options": {
1484+
"tsConfig": [
1485+
"libs/admin/tsconfig.lib.json",
1486+
"libs/admin/tsconfig.spec.json"
1487+
],
1488+
"exclude": [
1489+
"**/node_modules/**"
1490+
]
1491+
}
1492+
},
1493+
"test": {
1494+
"builder": "@nrwl/builders:jest",
1495+
"options": {
1496+
"jestConfig": "libs/admin/jest.config.js",
1497+
"tsConfig": "libs/admin/tsconfig.spec.json",
1498+
"setupFile": "libs/admin/src/test-setup.ts"
1499+
}
1500+
}
1501+
}
14741502
}
14751503
},
14761504
"schematics": {
@@ -1483,6 +1511,9 @@
14831511
},
14841512
"@nrwl/schematics:library": {
14851513
"unitTestRunner": "jest"
1514+
},
1515+
"@ngx-formly/schematics:component": {
1516+
"styleext": "scss"
14861517
}
14871518
},
14881519
"cli": {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { ApiModelProperty, ApiModelPropertyOptional } from '@nestjs/swagger';
2+
import { IsAscii, IsBoolean, IsEnum, IsNotEmpty, IsOptional, IsString, MaxLength, MinLength } from 'class-validator';
3+
import { NotificationColor, NotificationIcon, TargetType } from '../notification.entity';
4+
import { Column, Index } from 'typeorm';
5+
6+
export class UpdateNotificationDto {
7+
@ApiModelProperty({ type: String, minLength: 10, maxLength: 100 })
8+
@IsNotEmpty()
9+
@IsString()
10+
readonly title: string;
11+
12+
@ApiModelProperty({ type: String, minLength: 10, maxLength: 100 })
13+
@IsNotEmpty()
14+
@IsString()
15+
readonly body: string;
16+
17+
@ApiModelProperty({ type: String, minLength: 3, maxLength: 50 })
18+
@IsNotEmpty()
19+
@IsAscii()
20+
@MinLength(3)
21+
@MaxLength(50)
22+
readonly target: string;
23+
24+
@ApiModelProperty({ type: String, enum: TargetType })
25+
@IsNotEmpty()
26+
@IsEnum(TargetType)
27+
readonly targetType: TargetType;
28+
29+
@ApiModelPropertyOptional({ type: String, enum: NotificationIcon, default: NotificationIcon.NOTIFICATIONS })
30+
@IsOptional()
31+
@IsEnum(NotificationIcon)
32+
readonly icon?: NotificationIcon;
33+
34+
@ApiModelPropertyOptional({ type: String, enum: NotificationColor, default: NotificationColor.PRIMARY })
35+
@IsOptional()
36+
@IsEnum(NotificationColor)
37+
readonly color?: NotificationColor;
38+
39+
@ApiModelPropertyOptional({ type: Boolean, default: false })
40+
@IsOptional()
41+
@IsBoolean()
42+
readonly native?: boolean;
43+
44+
@ApiModelPropertyOptional({ type: Boolean, default: false })
45+
@IsOptional()
46+
@Index()
47+
readonly read?: boolean;
48+
}

libs/admin/jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
name: 'admin',
3+
preset: '../../jest.config.js',
4+
coverageDirectory: '../../coverage/libs/admin',
5+
};

libs/admin/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './lib/admin.module';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { async, TestBed } from '@angular/core/testing';
2+
import { AdminModule } from './admin.module';
3+
4+
describe('AdminModule', () => {
5+
beforeEach(async(() => {
6+
TestBed.configureTestingModule({
7+
imports: [AdminModule],
8+
}).compileComponents();
9+
}));
10+
11+
it('should create', () => {
12+
expect(AdminModule).toBeDefined();
13+
});
14+
});

libs/admin/src/lib/admin.module.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule } from '@angular/router';
3+
import { SharedModule } from '@ngx-starter-kit/shared';
4+
import { DragDropModule } from '@angular/cdk/drag-drop';
5+
import { AppConfirmModule } from '@ngx-starter-kit/app-confirm';
6+
import { HelperModule, TruncateModule } from '@ngx-starter-kit/ngx-utils';
7+
import { OverviewComponent } from './containers/overview/overview.component';
8+
import { SubscriptionsComponent } from './containers/subscriptions/subscriptions.component';
9+
import { SubscriptionDetailComponent } from './components/subscription-detail/subscription-detail.component';
10+
import { NotificationsComponent } from './containers/notifications/notifications.component';
11+
import { NotificationDetailComponent } from './components/notification-detail/notification-detail.component';
12+
import { NotificationEditComponent } from './components/notification-edit/notification-edit.component';
13+
import { AdminLayoutComponent } from './containers/admin-layout/admin-layout.component';
14+
import { ToolbarModule } from '@ngx-starter-kit/toolbar';
15+
import { QuickpanelModule } from '@ngx-starter-kit/quickpanel';
16+
import { AdminGuard } from '@ngx-starter-kit/auth';
17+
import { FormlyModule } from '@ngx-formly/core';
18+
import { FormlyMaterialModule } from '@ngx-formly/material';
19+
20+
@NgModule({
21+
imports: [
22+
SharedModule,
23+
DragDropModule,
24+
AppConfirmModule,
25+
TruncateModule,
26+
HelperModule,
27+
ToolbarModule,
28+
QuickpanelModule,
29+
FormlyModule.forRoot(),
30+
FormlyMaterialModule,
31+
RouterModule.forChild([
32+
/* {path: '', pathMatch: 'full', component: InsertYourComponentHere} */
33+
{
34+
path: '',
35+
component: AdminLayoutComponent,
36+
canActivate: [AdminGuard],
37+
data: { title: 'Admin', depth: 1 },
38+
children: [
39+
{ path: '', component: OverviewComponent, data: { title: 'Overview', depth: 2 } },
40+
{
41+
path: 'subscriptions',
42+
component: SubscriptionsComponent,
43+
data: { title: 'Subscriptions', depth: 3 },
44+
children: [
45+
{
46+
path: ':id',
47+
component: SubscriptionDetailComponent,
48+
data: { title: 'Subscription Detail' },
49+
},
50+
],
51+
},
52+
{
53+
path: 'notifications',
54+
component: NotificationsComponent,
55+
data: { title: 'Notifications', depth: 3 },
56+
children: [
57+
{
58+
path: ':id',
59+
component: NotificationDetailComponent,
60+
data: { title: 'Notification Detail' },
61+
},
62+
],
63+
},
64+
],
65+
},
66+
]),
67+
],
68+
declarations: [
69+
OverviewComponent,
70+
NotificationsComponent,
71+
SubscriptionsComponent,
72+
SubscriptionDetailComponent,
73+
NotificationDetailComponent,
74+
NotificationEditComponent,
75+
AdminLayoutComponent,
76+
],
77+
entryComponents: [NotificationEditComponent],
78+
})
79+
export class AdminModule {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<mat-card [@fadeAnimation]="animationTrigger$ | async">
2+
<mat-card-header>
3+
<mat-card-title><h3>Selected Notification</h3></mat-card-title>
4+
</mat-card-header>
5+
<mat-divider></mat-divider>
6+
<mat-card-content>
7+
<mat-list role="list">
8+
<mat-list-item *ngFor="let entry of (notification | keyvalue)" role="listitem">
9+
<div>
10+
<span>{{ entry.key }}:</span><span>{{ entry.value | json }}</span>
11+
</div>
12+
</mat-list-item>
13+
</mat-list>
14+
</mat-card-content>
15+
</mat-card>

libs/admin/src/lib/components/notification-detail/notification-detail.component.scss

Whitespace-only changes.

0 commit comments

Comments
 (0)