This is start angular17 project

This commit is contained in:
35 changed files with 836 additions and 0 deletions

16
.editorconfig Normal file
View File

@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = 100
trim_trailing_whitespace = false

42
.gitignore vendored Normal file
View File

@@ -0,0 +1,42 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out
# Node
/node_modules
npm-debug.log
yarn-error.log
# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings
# System files
.DS_Store
Thumbs.db

4
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,4 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
}

123
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,123 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Angular (Cursor)",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"preLaunchTask": "npm: start",
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/**"
],
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/src/*",
"webpack:///src/*": "${webRoot}/src/*",
"webpack:///*": "*",
"webpack:///./~/*": "${webRoot}/node_modules/*",
"meteor://💻app/*": "${webRoot}/*"
}
},
{
"name": "Attach to Chrome (Cursor)",
"type": "chrome",
"request": "attach",
"port": 9222,
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/**"
],
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/src/*",
"webpack:///src/*": "${webRoot}/src/*",
"webpack:///*": "*",
"webpack:///./~/*": "${webRoot}/node_modules/*",
"meteor://💻app/*": "${webRoot}/*"
}
},
{
"name": "Debug Angular Application",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*",
"/./*": "${webRoot}/*",
"/src/*": "${webRoot}/src/*",
"/*": "*",
"/./~/*": "${webRoot}/node_modules/*"
},
"preLaunchTask": "npm: start",
"userDataDir": "${workspaceFolder}/.vscode/chrome-debug-profile",
"runtimeArgs": [
"--disable-web-security",
"--disable-features=VizDisplayCompositor",
"--remote-debugging-port=9222"
],
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/**"
],
"trace": true
},
{
"name": "Debug Angular (Simple)",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"preLaunchTask": "npm: start",
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/**"
]
},
{
"name": "Attach to Chrome",
"type": "chrome",
"request": "attach",
"port": 9222,
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*",
"/./*": "${webRoot}/*",
"/src/*": "${webRoot}/src/*",
"/*": "*",
"/./~/*": "${webRoot}/node_modules/**"
},
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/**"
]
},
{
"name": "Debug with Edge",
"type": "msedge",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"preLaunchTask": "npm: start",
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/**"
]
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
]
}

32
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,32 @@
{
"djlint.showInstallError": false,
"typescript.preferences.includePackageJsonAutoImports": "on",
"typescript.suggest.autoImports": true,
"typescript.updateImportsOnFileMove.enabled": "always",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "explicit"
},
"debug.javascript.autoAttachFilter": "disabled",
"debug.javascript.terminalOptions": {
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/**"
]
},
"files.associations": {
"*.ts": "typescript",
"*.html": "html"
},
"emmet.includeLanguages": {
"typescript": "html"
},
"debug.allowBreakpointsEverywhere": true,
"debug.javascript.breakOnConditionalError": false,
"debug.javascript.codelens.npmScripts": "never",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
}

86
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,86 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "npm: start",
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "npm: build",
"type": "npm",
"script": "build",
"group": "build",
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared"
},
"problemMatcher": ["$tsc"]
},
{
"label": "npm: test",
"type": "npm",
"script": "test",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
},
{
"label": "Start Chrome for Debugging",
"type": "shell",
"command": "google-chrome",
"args": [
"--remote-debugging-port=9222",
"--user-data-dir=${workspaceFolder}/.vscode/chrome-debug-profile",
"--disable-web-security",
"--disable-features=VizDisplayCompositor"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"group": "build"
}
]
}

69
README.md Normal file
View File

@@ -0,0 +1,69 @@
# ProjectApp
Современное веб-приложение для обеспечения GUI в браузере,
построенное на Angular 17 с использованием PrimeNG.
## 🚀 Быстрый старт
### Установка зависимостей
```bash
npm install
```
### Запуск в режиме разработки
```bash
npm start
```
Приложение будет доступно по адресу `http://localhost:4200/`
### Сборка для продакшена
```bash
npm run build
```
Артефакты сборки будут сохранены в папке `dist/`
## 🏗️ Архитектура
- **Frontend**: Angular 17 с PrimeNG 17
- **Backend**: Go с Gin (отдельный проект)
- **API**: REST API для получения данных о погоде
- **Стили**: SCSS с Glassmorphism эффектами
## 🔧 Разработка
### Генерация компонентов
```bash
ng generate component component-name
```
### Тестирование
```bash
# Unit тесты
ng test
# E2E тесты
ng e2e
```
### Линтинг
```bash
# Проверка стиля кода
ng lint
## 📦 Сборка для встраивания
Для встраивания в Go приложение:
```bash
npm run build:embed [/path/to/front] # /home/user/projects/golang/go-project/project-front
```
Файлы будут собраны в папку `/path/to/front`

102
angular.json Normal file
View File

@@ -0,0 +1,102 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"restapi-adminka": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/restapi-adminka",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets",
"src/manifest.webmanifest"
],
"styles": ["src/styles.scss"],
"scripts": [],
"baseHref": "/api/v1/front/project/"
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "64kb",
"maximumError": "128kb"
}
],
"outputHashing": "all",
"serviceWorker": "ngsw-config.json",
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "restapi-adminka:build:production"
},
"development": {
"buildTarget": "restapi-adminka:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "restapi-adminka:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets",
"src/manifest.webmanifest"
],
"styles": ["src/styles.scss"],
"scripts": []
}
}
}
}
}
}

20
build-for-embeding.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Ошибка: Пожалуйста, укажите директорию назначения."
exit 1
fi
DESTINATION_DIR=$1
echo "Building Angular app for embedding..."
# ng build --configuration production --output-path ../../golang/gin-restapi/weather-front
rm -rf "$DESTINATION_DIR"
npx ng build --configuration production
mkdir -p "$DESTINATION_DIR"
cp -r /home/su/projects/angular/restapi-adminka/dist/restapi-adminka/browser/* \
"$DESTINATION_DIR"
echo "Build completed successfully!"
echo "Frontend files are ready for embedding in Go binary"

30
ngsw-config.json Normal file
View File

@@ -0,0 +1,30 @@
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/manifest.webmanifest",
"/*.css",
"/*.js"
]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/media/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"
]
}
}
]
}

44
package.json Normal file
View File

@@ -0,0 +1,44 @@
{
"name": "front-project",
"version": "0.0.1",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:embed": "ng build --configuration production --output-path ",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"server": "http-server -p 8880 -c-1 dist/front-project/browser"
},
"private": true,
"dependencies": {
"@angular/animations": "^17.3.0",
"@angular/common": "^17.3.0",
"@angular/compiler": "^17.3.0",
"@angular/core": "^17.3.0",
"@angular/forms": "^17.3.0",
"@angular/platform-browser": "^17.3.0",
"@angular/platform-browser-dynamic": "^17.3.0",
"@angular/router": "^17.3.0",
"@angular/service-worker": "^17.3.0",
"primeicons": "^7.0.0",
"primeng": "^17.18.15",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.3.8",
"@angular/cli": "^17.3.8",
"@angular/compiler-cli": "^17.3.0",
"@types/jasmine": "~5.1.0",
"http-server": "^14.1.1",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.4.2"
}
}

View File

@@ -0,0 +1 @@
<router-outlet></router-outlet>

View File

@@ -0,0 +1,26 @@
ul {
list-style-type: none; /* Remove default list styling */
padding: 0; /* Remove default padding */
}
li {
cursor: pointer; /* Change cursor to pointer on hover */
padding: 10px; /* Add some padding for better click area */
transition: background-color 0.3s; /* Smooth transition for background color */
}
li:hover {
color: #9a5d5d; /* Change background color on hover */
font-weight: bold;
font-size: larger;
}
.center-container {
margin-top: 30px;
display: flex; /* Use Flexbox */
flex-direction: column; /* Stack children vertically */
align-items: center; /* Center horizontally */
// justify-content: center; /* Center vertically */
// height: 100vh; /* Full viewport height */
text-align: center; /* Center text */
}

12
src/app/app.component.ts Normal file
View File

@@ -0,0 +1,12 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterOutlet } from '@angular/router';
@Component({
selector: 'app-root',
standalone: true,
imports: [CommonModule, RouterOutlet],
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
})
export class AppComponent {}

18
src/app/app.config.ts Normal file
View File

@@ -0,0 +1,18 @@
import { ApplicationConfig, isDevMode } from '@angular/core';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { provideHttpClient, withInterceptors } from '@angular/common/http';
import { provideServiceWorker } from '@angular/service-worker';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [
provideAnimationsAsync(),
provideHttpClient(),
provideRouter(routes),
provideServiceWorker('ngsw-worker.js', {
enabled: !isDevMode(),
registrationStrategy: 'registerWhenStable:30000'
})
],
};

7
src/app/app.routes.ts Normal file
View File

@@ -0,0 +1,7 @@
import { Routes } from '@angular/router';
// import { WeatherComponent } from './weather/weather.component';
export const routes: Routes = [
// { path: '', component: WeatherComponent },
{ path: '**', redirectTo: '' }
];

0
src/assets/.gitkeep Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,16 @@
const logFunction = (...messages: any[]) => {};
const errorLogFunction = (...messages: any[]) => {};
export const environment = {
production: true,
apiBaseUrl: '/api/v1',
adminApiUrl: '/api/v1/project',
log: logFunction,
errLog: errorLogFunction,
debugAny: (
something: any,
transformer: (...args: any[]) => any = (...args: any[]): any => {
return args[0];
}
) => transformer(something),
};

View File

@@ -0,0 +1,26 @@
const logFunction = (...messages: any[]) => {
messages.forEach((msg) => console.log(msg));
};
const errorLogFunction = (...messages: any[]) => {
messages.forEach((msg) => console.error(msg));
};
const debugAny = (
something: any,
transformer: (...args: any[]) => any = (...args: any[]): any => {
return args[0];
}
) => transformer(something);
export const environment = {
production: false,
apiBaseUrl: 'http://localhost:8080/api/v1',
adminApiUrl: 'http://localhost:8080/api/v1/project',
log: logFunction,
errLog: errorLogFunction,
debugAny
};

BIN
src/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

18
src/index.html Normal file
View File

@@ -0,0 +1,18 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>RestAPI Adminka</title>
<base href="/api/v1/front/project/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700;900&display=swap" rel="stylesheet">
<link rel="manifest" href="manifest.webmanifest">
<meta name="theme-color" content="#1976d2">
</head>
<body class="mat-typography">
<app-root></app-root>
<noscript>Please enable JavaScript to continue using this application.</noscript>
</body>
</html>

6
src/main.ts Normal file
View File

@@ -0,0 +1,6 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, appConfig)
.catch((err) => console.error(err));

59
src/manifest.webmanifest Normal file
View File

@@ -0,0 +1,59 @@
{
"name": "weather-app",
"short_name": "weather-app",
"theme_color": "#1976d2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "./",
"start_url": "./",
"icons": [
{
"src": "assets/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "assets/icons/icon-96x96.png",
"sizes": "96x96",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "assets/icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "assets/icons/icon-144x144.png",
"sizes": "144x144",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "assets/icons/icon-152x152.png",
"sizes": "152x152",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "assets/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "assets/icons/icon-384x384.png",
"sizes": "384x384",
"type": "image/png",
"purpose": "maskable any"
},
{
"src": "assets/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable any"
}
]
}

19
src/styles.scss Normal file
View File

@@ -0,0 +1,19 @@
/* You can add global styles to this file, and also import other style files */
/* PrimeNG */
@import "primeng/resources/themes/lara-light-blue/theme.css";
// @import "primeng/resources/themes/saga-blue/theme.css";
// @import "primeng/resources/themes/nova/theme.css";
@import "primeng/resources/primeng.css";
/* PrimeIcons */
@import "primeicons/primeicons.css";
html,
body {
height: 100%;
}
body {
margin: 0;
font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

14
tsconfig.app.json Normal file
View File

@@ -0,0 +1,14 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts"
],
"include": [
"src/**/*.d.ts"
]
}

32
tsconfig.json Normal file
View File

@@ -0,0 +1,32 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"esModuleInterop": true,
"sourceMap": true,
"declaration": false,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2022",
"module": "ES2022",
"useDefineForClassFields": false,
"lib": [
"ES2022",
"dom"
]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}

14
tsconfig.spec.json Normal file
View File

@@ -0,0 +1,14 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}