Skip to content

Commit

Permalink
npm install create package-lock.json
Browse files Browse the repository at this point in the history
  • Loading branch information
vnobo committed Nov 5, 2023
1 parent 61bb3d6 commit f665b43
Show file tree
Hide file tree
Showing 17 changed files with 173 additions and 46 deletions.
2 changes: 1 addition & 1 deletion boot/platform/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spring:
max-acquire-time: 5s
validation-query: "select version()"
sql.init:
mode: never
mode: always
platform: postgres
encoding: utf-8
data.redis:
Expand Down
9 changes: 9 additions & 0 deletions boot/platform/src/main/resources/data-postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ values ('1000', 'FOLDER', 'ROLE_FOLDER_SYSTEM', 'System manager', '', 'U1000', '
insert into se_menus(code, pcode, type, authority, name, path, creator, updater, extend)
values ('1001', '1000', 'MENU', 'ROLE_MENU_SYSTEM_MENUS', 'MENUS', '/system/menus', 'U1000', 'U1000', '{
"icons": "menu-2"
}');
insert into se_menus(code, type, authority, name, path, creator, updater, extend)
values ('1002', 'FOLDER', 'ROLE_FOLDER_SYSTEM1', 'System manager1', '', 'U1000', 'U1000', '{
"icons": "settings"
}');

insert into se_menus(code, pcode, type, authority, name, path, creator, updater, extend)
values ('1003', '1002', 'MENU', 'ROLE_MENU_SYSTEM_MENUS!', 'MENUS1', '/system/menus', 'U1000', 'U1000', '{
"icons": "menu-2"
}');
2 changes: 1 addition & 1 deletion ui/web/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="layui-layout">
<nz-spin [nzSpinning]="loadingShow">
<nz-spin [nzSpinning]="loadingShow$|async">
<router-outlet></router-outlet>
</nz-spin>
</div>
Expand Down
29 changes: 17 additions & 12 deletions ui/web/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import {Component, OnInit} from '@angular/core';
import {AfterContentInit, Component, OnInit} from '@angular/core';
import {LoadingService} from "./core/loading.service";
import {Observable, of} from "rxjs";

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
export class AppComponent implements OnInit, AfterContentInit {

loadingShow: boolean;
loadingShow$: Observable<boolean> = of(false);

constructor(private loading: LoadingService) {
this.loadingShow = false;
}
constructor(private loading: LoadingService) {
this.loadingShow$ = of(false);
}

ngOnInit(): void {
this.loading.progress$.subscribe(res => this.loadingShow = res);
}
ngOnInit(): void {
//this.loadingShow$ = this.loading.progress$;
}

ngAfterContentInit(): void {
this.loadingShow$ = this.loading.progress$;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class HandleErrorInterceptor implements HttpInterceptor {
}

intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).pipe(timeout({each: 10000}),
return next.handle(request).pipe(timeout({first: 30_000, each: 10_000}),
catchError(err => this.handleError(err)));
}

Expand Down
45 changes: 45 additions & 0 deletions ui/web/src/app/core/interfaces/menu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
export interface Menu {
id?: number;
code?: string;
pcode?: string;
tenantCode?: string;
type?: MenuType;
authority?: string;
name?: string;
path?: string;
sort?: number;
extend?: any;
creator?: UserAuditor;
updater?: UserAuditor;
createdTime?: Date;
updatedTime?: Date;
getPermissions?: Permission[];
getIcons?: string;
children?: Menu[]
}

export interface UserAuditor {
code: string;
username: string;
name?: string;
}

export enum MenuType {
FOLDER = "FOLDER",
MENU = "MENU",
}

export enum HttpMethod {
GET = "GET",
POST = "POST",
PUT = "PUT",
DELETE = "DELETE",
ALL = "ALL",
}

export interface Permission {
method: HttpMethod;
name: string;
path: string;
authority: string;
}
16 changes: 16 additions & 0 deletions ui/web/src/app/core/menus.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {TestBed} from '@angular/core/testing';

import {MenusService} from './menus.service';

describe('MenusService', () => {
let service: MenusService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(MenusService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
32 changes: 32 additions & 0 deletions ui/web/src/app/core/menus.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {Injectable} from '@angular/core';
import {HttpClient, HttpParams} from "@angular/common/http";
import {delay, from, map, mergeMap, Observable, retry, switchMap, toArray} from "rxjs";
import {Menu} from "./interfaces/menu";

@Injectable({
providedIn: 'root'
})
export class MenusService {

constructor(private http: HttpClient) {
}

getMenus(request: Menu): Observable<Menu[]> {
let params = new HttpParams({fromObject: request as any});
return this.http.get<Menu[]>('/menus/me', {params: params})
.pipe(switchMap(items => {
return from(items).pipe(delay(20),
mergeMap(item => {
return this.getChildren({pcode: item.code}).pipe(map(children => {
item.children = children;
return item;
}));
}));
}), toArray(), retry(3));
}

getChildren(request: Menu): Observable<Menu[]> {
let params = new HttpParams({fromObject: request as any});
return this.http.get<Menu[]>('/menus/me', {params: params});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<nz-layout class="layout">
<nz-header>
<nz-header class="nz-header">
<div class="logo"></div>
<ul class="header-menu" nz-menu nzMode="horizontal" nzTheme="dark">
<li nz-menu-item nzSelected>nav 1</li>
Expand All @@ -9,10 +9,13 @@
</nz-header>
<nz-layout>
<nz-sider [nzCollapsedWidth]="0" nzBreakpoint="lg" nzCollapsible nzTheme="light" nzWidth="14.5rem">
<ul class="sider-menu" nz-menu nzMode="inline">
<li nz-submenu nzIcon="user" nzOpen nzTitle="subnav 1">
<ul class="sider-menu" nz-menu nzMode="inline" nzTheme="dark">
<li *ngFor="let menu of menus$|async; index as i" nz-submenu nzIcon="user" nzOpen
nzTitle="{{menu.name}}">
<ul>
<li nz-menu-item nzSelected>option1</li>
<li *ngFor="let child of menu.children; index as i" nz-menu-item nzSelected>
{{child.name}}
</li>
<li nz-menu-item>option2</li>
<li nz-menu-item>option3</li>
<li nz-menu-item>option4</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
min-height: 100vh;
}

.nz-header {
padding-left: 1rem !important;
}

.logo {
width: 9.8rem;
width: 12.8rem;
height: 2.5rem;
background: rgba(255, 255, 255, 0.2);
margin: 0.8rem 2.2rem 1rem 0;
margin: 0.8rem 0.8rem 0.1rem 0;
float: left;
}

Expand Down
29 changes: 29 additions & 0 deletions ui/web/src/app/pages/index/index.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {Component, OnInit} from '@angular/core';
import {MenusService} from "../../core/menus.service";
import {Menu} from "../../core/interfaces/menu";
import {Observable, of} from "rxjs";

@Component({
selector: 'app-welcome',
templateUrl: './index.component.html',
styleUrls: ['./index.component.scss']
})
export class IndexComponent implements OnInit {

menus$: Observable<Menu[]> = of([]);

constructor(private menusService: MenusService) {
}

ngOnInit() {
this.initMenu();
}

initMenu() {
let menuRequest: Menu = {
pcode: "0",
tenantCode: "0"
};
this.menus$ = this.menusService.getMenus(menuRequest);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<nz-result nzStatus="403" nzSubTitle="Sorry, you are not authorized to access this page." nzTitle="403">
<div nz-result-extra>
<button nz-button nzType="primary">Back Home</button>
<a href="/index" nz-button nzType="primary">Back Home</a>
</div>
</nz-result>
4 changes: 2 additions & 2 deletions ui/web/src/app/pages/pages-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {WelcomeComponent} from "./welcome/welcome.component";
import {IndexComponent} from "./index/index.component";
import {PageNotFoundComponent} from "./page-not-found/page-not-found.component";

const routes: Routes = [
{path: 'welcome', component: WelcomeComponent, title: '欢迎主页'},
{path: 'index', component: IndexComponent, title: '欢迎主页'},
{
path: 'auth', loadChildren: () => import('./security/security.module').then(m => m.SecurityModule),
title: '系统登录'
Expand Down
4 changes: 2 additions & 2 deletions ui/web/src/app/pages/pages.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {NgModule, Optional, SkipSelf} from '@angular/core';

import {PagesRoutingModule} from './pages-routing.module';

import {WelcomeComponent} from './welcome/welcome.component';
import {IndexComponent} from './index/index.component';
import {PageNotFoundComponent} from "./page-not-found/page-not-found.component";
import {SharedModule} from "../shared/shared.module";

Expand All @@ -11,7 +11,7 @@ import {SharedModule} from "../shared/shared.module";
PagesRoutingModule,
SharedModule
],
declarations: [WelcomeComponent, PageNotFoundComponent],
declarations: [IndexComponent, PageNotFoundComponent],
exports: [PageNotFoundComponent]
})
export class PagesModule {
Expand Down
2 changes: 1 addition & 1 deletion ui/web/src/app/pages/security/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class LoginComponent implements OnInit, OnDestroy {
this.loginService.clearRememberMe();
}
this.loginService.login(credentials).subscribe((res) => {
this.router.navigate(['/welcome'], {relativeTo: this.route}).then();
this.router.navigate(['/index'], {relativeTo: this.route}).then();
});
}

Expand Down
18 changes: 0 additions & 18 deletions ui/web/src/app/pages/welcome/welcome.component.ts

This file was deleted.

4 changes: 3 additions & 1 deletion ui/web/src/app/shared/shared-zorro.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {NzLayoutModule} from "ng-zorro-antd/layout";
import {NzMenuModule} from "ng-zorro-antd/menu";
import {NzSliderModule} from "ng-zorro-antd/slider";
import {NzBreadCrumbModule} from "ng-zorro-antd/breadcrumb";
import {NzButtonModule} from "ng-zorro-antd/button";


@NgModule({
Expand All @@ -26,7 +27,8 @@ import {NzBreadCrumbModule} from "ng-zorro-antd/breadcrumb";
NzMenuModule,
NzIconModule,
NzResultModule,
NzBreadCrumbModule
NzBreadCrumbModule,
NzButtonModule
]
})
export class SharedZorroModule {
Expand Down

0 comments on commit f665b43

Please sign in to comment.