Skip to content

Commit

Permalink
[feat] HertzBeat Official Template Marketplace [apache#1792]
Browse files Browse the repository at this point in the history
  • Loading branch information
All-The-Best-for committed Oct 24, 2024
1 parent 679e019 commit b8f69c1
Show file tree
Hide file tree
Showing 62 changed files with 10,499 additions and 748 deletions.
18 changes: 18 additions & 0 deletions template-marketplace/hertzbeat-template-hub-web-app/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
module.exports = {
singleQuote: true,
useTabs: false,
Expand Down
7 changes: 4 additions & 3 deletions template-marketplace/hertzbeat-template-hub-web-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ This project was generated with [Angular CLI](https://github.com/angular/angular
- 搜索页面:名称模糊查询+类别查询+排序功能
- 详情页面:模版信息展示、版本信息展示、下载功能、分享功能
- 上传页面:上传模版

## 待完成工作
- 登录注册页面
- 详情页面:收藏功能
- 用户中心页面:资产管理
- 用户中心页面:资产管理、收藏管理、版本更新

## 待完成工作

- 管理员页面

## Development server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@angular/compiler-cli": "^18.2.0",
"@types/file-saver": "^2.0.7",
"@types/jasmine": "~5.1.0",
"@types/node": "^22.7.7",
"jasmine-core": "~5.2.0",
"jasmine-spec-reporter": "^7.0.0",
"karma": "~6.4.0",
Expand All @@ -54,6 +55,7 @@
"ng-alain": "^18.1.0",
"node-fetch": "^3.3.2",
"prettier": "^3.3.3",
"purgecss": "^6.0.0",
"ts-node": "^10.9.2",
"typescript": "~5.5.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class DefaultInterceptor implements HttpInterceptor {

private tryRefreshToken(ev: HttpResponseBase, req: HttpRequest<any>, next: HttpHandler): Observable<any> {
// 1, redirect to login page if this request is used for refreshing token
if ([`/account/auth/refresh`].some(url => req.url.includes(url))) {
if ([`/api/auth/refresh`].some(url => req.url.includes(url))) {
this.toLogin();
return throwError(ev);
}
Expand Down Expand Up @@ -161,7 +161,7 @@ export class DefaultInterceptor implements HttpInterceptor {
private toLogin(): void {
if (!this.notified) {
this.notified = true;
this.goTo('/passport/login');
this.goTo('/login');
}
}

Expand Down Expand Up @@ -193,10 +193,12 @@ export class DefaultInterceptor implements HttpInterceptor {
return of(httpEvent);
}
}),
catchError((err: HttpErrorResponse) => {
catchError((err: any) => {
console.error("err:",err);
// handle failed response and token expired
switch (err.status) {
case 401:
console.log('检测到401了')
return this.tryRefreshToken(err, newReq, next);
case 404:
case 500:
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,39 @@ import {RouterOutlet} from "@angular/router";
import {NzImageDirective} from "ng-zorro-antd/image";
import {TemplateService} from "../../service/template.service";
import {NzMessageService} from "ng-zorro-antd/message";
import {NgIf} from "@angular/common";
import {LocalStorageService} from "../../service/local-storage.service";

@Component({
selector: 'app-market',
templateUrl: 'market.component.html',
standalone: true,
imports: [
RouterOutlet,
NzImageDirective
NzImageDirective,
NgIf
]
})
export class LayoutMarketComponent implements OnInit{
options: LayoutDefaultOptions = {
logoExpanded: `./assets/brand_white.svg`,
logoCollapsed: `./assets/logo.svg`
};

constructor(private templateService: TemplateService,private msg: NzMessageService,) {}
constructor(private templateService: TemplateService,
private msg: NzMessageService,
private localStorageService: LocalStorageService,
) {}

count=0;
isLogin:boolean = false;

ngOnInit(): void {
const userInfo = this.localStorageService.getData('userInfo');
if(userInfo!=null){

this.isLogin=true
}

this.templateService.getTemplateCount(0,0).subscribe(message=>{
if (message.code == 0) {
this.count=message.data;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

.image-container {
display: flex;
justify-content: center;
align-items: center;
position: relative;
width: 300px;
height: 300px;
margin: auto;
}

.img1, .img2 {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

.img2 {
opacity: 0.7;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<main>
<div class="tp-register__area pt-xxl-4 pb-xxl-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-xl-6">
<div class="tp-register__form-box">
<div class="tp-register__form-title text-center mb-5">
<h6>邮箱登录</h6>
<!-- <span>邮箱登录 <br>-->
<!-- & become our partner</span>-->
</div>
<form>
<div class="row">
<div class="col-xl-12">
<div class="tp-register__input-box">
<label for="email">Email 地址</label>
<input id="email" type="email" placeholder="邮箱地址">
</div>
</div>
<div class="col-xl-12">
<div class="tp-register__input-box">
<label for="password">密码</label>
<input id="password" type="password" placeholder="密码">
<a href="" class="tp-register__input-text">忘记密码?</a>
</div>
</div>
<div class="col-xl-12">
<div class="tp-contact-4__comment-agree label-2 pt-5 pb-5">
<div class="form-check-box">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<label class="form-check-label text-theme" for="flexCheckDefault">
我同意 xxx & <span class="red">xxx</span> 和 xxx
</label>
</div>
</div>
<div class="tp-contact-4__btn">
<!-- <button nz-button (click)="submitLogin()" nzType="primary">登录</button>-->
<button type="button" class="tp-btn-square w-100" (click)="submitLogin()">登录</button>
<!-- <button class="tp-btn-square w-100">登录</button>-->
<button type="button" class="tp-btn-square w-100">去注册</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</main>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import {Component, Injector, OnDestroy, OnInit} from '@angular/core';
import {FormBuilder} from '@angular/forms';
import {AuthService, LoginDTO} from "../../service/auth.service";
import {LocalStorageService} from "../../service/local-storage.service";
import {NzMessageService} from "ng-zorro-antd/message";
import {Router} from "@angular/router";
import {NzButtonComponent} from "ng-zorro-antd/button";

@Component({
selector: 'login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.less'],
standalone: true,
providers: [],
imports: [
NzButtonComponent
],
// changeDetection: ChangeDetectionStrategy.OnPush
})
export class LoginComponent implements OnInit,OnDestroy {
constructor(
fb: FormBuilder,
private authService: AuthService,
private localStorageService: LocalStorageService,
private msg: NzMessageService,
private injector: Injector,
) {}

loginForm: LoginDTO={
type:1,
identifier:'[email protected]',
credential:'123456',
};

submitLogin():void{
this.authService.tryLogin(this.loginForm).subscribe(response => {
if(response.code == 0) {
console.log(response);
this.localStorageService.storageAuthorizationToken(response.data.token);
this.localStorageService.storageRefreshToken(response.data.refreshToken);
this.msg.success('登录成功');
this.localStorageService.putData('userInfo',this.loginForm.identifier);
this.injector.get(Router).navigateByUrl('/');
}else{
this.msg.error('登录失败:'+response.msg)
}
})
}

ngOnInit(): void {
}

ngOnDestroy(): void {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {FormsModule} from "@angular/forms";
import {NzPaginationComponent} from "ng-zorro-antd/pagination";
import {NzCheckboxComponent, NzCheckboxGroupComponent} from "ng-zorro-antd/checkbox";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzTooltipDirective} from "ng-zorro-antd/tooltip";

const COMPONENTS: Array<Type<void>> = [TemplateListComponent, TemplateDetailComponent, TemplateListComponent];

Expand All @@ -59,7 +60,8 @@ const COMPONENTS: Array<Type<void>> = [TemplateListComponent, TemplateDetailComp
NzPaginationComponent,
NzCheckboxComponent,
NzCheckboxGroupComponent,
NzIconDirective
NzIconDirective,
NzTooltipDirective
],
declarations: COMPONENTS,
exports:[RouterModule]
Expand Down
Loading

0 comments on commit b8f69c1

Please sign in to comment.