Skip to content

Commit badc928

Browse files
Merge pull request #68 from RBTech-dev/develop
Added sidebar lib Improved winbox onClose
2 parents 7203451 + 1a711c5 commit badc928

47 files changed

Lines changed: 5742 additions & 4529 deletions

Some content is hidden

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

.github/workflows/pr_on_master.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request:
77
branches:
88
- master
9-
types: [ opened, reopened, synchronize ]
9+
types: [opened, reopened, synchronize]
1010

1111
jobs:
1212
build:
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
# Latest nodes only
18-
node-version: [ 16.x ]
18+
node-version: [16.x]
1919
# Define Steps
2020
steps:
2121
# Checkout code
@@ -37,13 +37,16 @@ jobs:
3737
- uses: c-hive/gha-npm-cache@v1
3838
if: ${{ !env.ACT }}
3939

40-
- uses: nrwl/nx-set-shas@v2
40+
- uses: nrwl/nx-set-shas@v3
41+
with:
42+
main-branch-name: 'master'
4143

4244
- name: Install environment
4345
run: npm ci --include=dev
4446

4547
- run: npx nx workspace-lint
46-
- run: npx nx format:check --base="origin/master" --code-coverage
48+
- run: npx nx format:write --base="origin/master" --code-coverage --verbose
49+
- run: npx nx format:check --base="origin/master" --code-coverage --verbose
4750
- run: npx nx affected --target=lint --parallel=3
48-
- run: npx nx affected --target=test --parallel=3 --ci --code-coverage
51+
- run: npx nx affected --target=test --parallel=3 --ci --code-coverage --verbose
4952
- run: npx nx affected --target=build --parallel=3

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# RBTech
2+
23
A Nx Workspace which contains our angular libraries.
34

45
## Requirements
56

6-
- node.js `v14`, [here](https://nodejs.org/it/)
7+
- node.js `v16`, [here](https://nodejs.org/it/)
78
- run `npm install`
89
- `nx` cli, `npm install -g nx`
910

1011
# Libraries
1112

1213
- [angular-winbox](packages/angular-winbox)
14+
- [angular-sidebar](packages/angular-sidebar)
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
/* eslint-disable */
2-
export default {
2+
const esModules = [
3+
'winbox',
4+
'@angular',
5+
'@ngrx',
6+
'@ng-bootstrap/ng-bootstrap',
7+
'@fortawesome/angular-fontawesome',
8+
].join('|');
9+
module.exports = {
310
displayName: 'winbox-example-app',
411
preset: '../../jest.preset.js',
512
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
@@ -10,10 +17,10 @@ export default {
1017
},
1118
},
1219
coverageDirectory: '../../coverage/apps/winbox-example-app',
20+
transformIgnorePatterns: [`/node_modules/(?!${esModules}/)`],
1321
transform: {
14-
'^.+\\.(ts|mjs|js|html)$': 'jest-preset-angular',
22+
'^.+\\.(ts|js|mjs|html|svg)$': 'jest-preset-angular',
1523
},
16-
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
1724
snapshotSerializers: [
1825
'jest-preset-angular/build/serializers/no-ng-attributes',
1926
'jest-preset-angular/build/serializers/ng-snapshot',

apps/winbox-example-app/project.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
"budgets": [
2828
{
2929
"type": "initial",
30-
"maximumWarning": "500kb",
31-
"maximumError": "1mb"
30+
"maximumWarning": "4mb",
31+
"maximumError": "5mb"
3232
},
3333
{
3434
"type": "anyComponentStyle",
35-
"maximumWarning": "2kb",
36-
"maximumError": "4kb"
35+
"maximumWarning": "150kb",
36+
"maximumError": "150kb"
3737
}
3838
],
3939
"fileReplacements": [
@@ -86,7 +86,7 @@
8686
"executor": "@nrwl/jest:jest",
8787
"outputs": ["{workspaceRoot}/coverage/apps/winbox-example-app"],
8888
"options": {
89-
"jestConfig": "apps/winbox-example-app/jest.config.ts",
89+
"jestConfig": "apps/winbox-example-app/jest.config.js",
9090
"passWithNoTests": true
9191
}
9292
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
<rbtech-sidebar [menu]="menu"></rbtech-sidebar>
12
<router-outlet></router-outlet>
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { TestBed } from '@angular/core/testing';
22
import { AppComponent } from './app.component';
3-
import { NxWelcomeComponent } from './nx-welcome.component';
43
import { RouterTestingModule } from '@angular/router/testing';
4+
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
5+
import { SidebarComponent } from '@rbtechdev/angular-sidebar';
6+
import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
57

68
describe('AppComponent', () => {
79
beforeEach(async () => {
810
await TestBed.configureTestingModule({
9-
imports: [RouterTestingModule],
10-
declarations: [AppComponent, NxWelcomeComponent],
11+
imports: [RouterTestingModule, PerfectScrollbarModule, NgbModalModule],
12+
declarations: [AppComponent, SidebarComponent],
1113
}).compileComponents();
1214
});
1315

@@ -22,13 +24,4 @@ describe('AppComponent', () => {
2224
const app = fixture.componentInstance;
2325
expect(app.title).toEqual('winbox-example-app');
2426
});
25-
26-
it('should render title', () => {
27-
const fixture = TestBed.createComponent(AppComponent);
28-
fixture.detectChanges();
29-
const compiled = fixture.nativeElement as HTMLElement;
30-
expect(compiled.querySelector('h1')?.textContent).toContain(
31-
'Welcome winbox-example-app'
32-
);
33-
});
3427
});
Lines changed: 110 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { Component, OnInit } from '@angular/core';
22
import { WinboxService } from '@rbtech/angular-winbox';
33
import { SimpleComponentComponent } from './simple-component/simple-component.component';
4+
import { SidebarMenuModel } from '@rbtechdev/angular-sidebar';
5+
import { ModalYesNoComponent } from './modal-yes-no/modal-yes-no.component';
6+
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
7+
import { faQuestion } from '@fortawesome/free-solid-svg-icons/faQuestion';
48

59
@Component({
610
selector: 'rbtech-root',
@@ -9,24 +13,116 @@ import { SimpleComponentComponent } from './simple-component/simple-component.co
913
})
1014
export class AppComponent implements OnInit {
1115
title = 'winbox-example-app';
16+
faIcon = faQuestion;
17+
menu: SidebarMenuModel = {
18+
sidebarTitle: 'SIDEBAR',
19+
status: '',
20+
username: 'USER',
21+
subtitle: 'Admin',
22+
sidebarTitleHref: '/home',
23+
sidebarUsrPicSrc: 'assets/user.png',
24+
placeholderSearch: 'Cerca...',
25+
isSearchVisible: true,
26+
contentMenus: [
27+
{
28+
title: 'HEADER',
29+
type: 'header',
30+
visible: true,
31+
badge: {
32+
visible: true,
33+
class: 'badge bg-secondary',
34+
text: '4',
35+
},
36+
},
37+
{
38+
title: 'MENU 1',
39+
type: 'simple',
40+
visible: true,
41+
icon: this.faIcon,
42+
href: '/s',
43+
},
44+
{
45+
title: 'HEADER',
46+
type: 'header',
47+
visible: true,
48+
},
49+
{
50+
title: 'MENU 1',
51+
type: 'dropdown',
52+
visible: true,
53+
icon: this.faIcon,
54+
href: '#',
55+
badge: {
56+
visible: true,
57+
class: 'badge bg-secondary',
58+
text: '4',
59+
},
60+
subMenus: [
61+
{
62+
title: 'SUBMENU 1',
63+
visible: true,
64+
href: '/g',
65+
badge: {
66+
visible: true,
67+
class: 'badge bg-secondary',
68+
text: 'New',
69+
},
70+
},
71+
],
72+
},
73+
],
74+
footerMenus: [
75+
{
76+
type: 'simple',
77+
icon: this.faIcon,
78+
},
79+
{
80+
type: 'dropdown',
81+
icon: this.faIcon,
82+
dropdownHeaderTitle: 'Hello',
83+
href: '#',
84+
dropdownItems: [
85+
{
86+
text: 'HELLO',
87+
icon: this.faIcon,
88+
subtitle: 'HELLO S',
89+
},
90+
],
91+
},
92+
],
93+
};
1294

13-
constructor(private winboxService: WinboxService) {}
95+
constructor(
96+
private winboxService: WinboxService,
97+
private modalService: NgbModal
98+
) {}
1499

15100
ngOnInit(): void {
16-
this.winboxService.openWinBox<SimpleComponentComponent>(
17-
{
18-
title: 'Test',
19-
height: '90%',
20-
width: '40%',
21-
x: 'center',
22-
y: 'center',
23-
index: 1057,
24-
onclose: (): boolean => {
25-
return true;
101+
const winboxInstance =
102+
this.winboxService.openWinBox<SimpleComponentComponent>(
103+
{
104+
title: 'Test',
105+
height: '90%',
106+
width: '40%',
107+
x: 'center',
108+
y: 'center',
109+
index: 1057,
110+
onclose: (): boolean => {
111+
const modal = this.modalService.open(ModalYesNoComponent);
112+
modal.componentInstance.title = 'Titolo';
113+
modal.componentInstance.message = 'Vuoi chiudere winbox?';
114+
winboxInstance.winBox.minimize(true);
115+
116+
modal.result
117+
.then(() => {
118+
winboxInstance.winBox.close(true);
119+
})
120+
.catch(() => winboxInstance.winBox.maximize(false));
121+
return false;
122+
},
26123
},
27-
},
28-
SimpleComponentComponent
29-
);
124+
SimpleComponentComponent
125+
);
30126
this.winboxService.showLastWinbox();
31127
}
32128
}

apps/winbox-example-app/src/app/app.module.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ import { BrowserModule } from '@angular/platform-browser';
44
import { AppComponent } from './app.component';
55
import { RouterModule } from '@angular/router';
66
import { SimpleComponentComponent } from './simple-component/simple-component.component';
7+
import { AngularSidebarModule } from '@rbtechdev/angular-sidebar';
8+
import { ModalYesNoComponent } from './modal-yes-no/modal-yes-no.component';
9+
import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
710

811
@NgModule({
9-
declarations: [AppComponent, SimpleComponentComponent],
12+
declarations: [AppComponent, SimpleComponentComponent, ModalYesNoComponent],
1013
imports: [
1114
BrowserModule,
1215
RouterModule.forRoot([], { initialNavigation: 'enabledBlocking' }),
16+
AngularSidebarModule,
17+
NgbModalModule,
1318
],
1419
providers: [],
1520
bootstrap: [AppComponent],
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<div class="modal-header">
2+
<h4 [innerHTML]="title" class="modal-title" id="modal-title"></h4>
3+
<button
4+
(click)="cancel()"
5+
aria-describedby="modal-title"
6+
aria-label="Close button"
7+
class="btn-close"
8+
type="button"
9+
>
10+
<span aria-hidden="true">&times;</span>
11+
</button>
12+
</div>
13+
14+
<div class="modal-body">
15+
<p [innerHTML]="message"></p>
16+
</div>
17+
18+
<div class="modal-footer">
19+
<button
20+
(click)="cancel()"
21+
[class]="ccsCancelClass"
22+
class="btn cursor-pointer text-uppercase"
23+
type="button"
24+
>
25+
{{ noLabel }}
26+
</button>
27+
<button
28+
(click)="confirm()"
29+
[class]="ccsConfirmClass"
30+
class="btn cursor-pointer text-uppercase"
31+
type="button"
32+
>
33+
{{ yesLabel }}
34+
</button>
35+
</div>

apps/winbox-example-app/src/app/modal-yes-no/modal-yes-no.component.scss

Whitespace-only changes.

0 commit comments

Comments
 (0)