Skip to content

pppiroto/visappproto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ctrl + Shift + v でプレビュー表示

visappproto

web application prototype

準備

git clone

git clone https://github.com/pppiroto/visappproto.git

  • 本プロジェクト
$ cd ClientApp
$ npm install

.NET Core 6.0

https://dotnet.microsoft.com/en-us/download/dotnet/3.1

NPM

Mac

  • Homebrew インストール
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • nodebrew インストール
brew install nodebrew
  • nodebrew にパスを通す
echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile
  • 最新バージョンをインストール
nodebrew install-binary latest

Windows

Angular

  • https://angular.jp/
  • dotnet new angular でプロジェクトにAngular CLI(ng)がインストールされるので、それを使用する場合
npm run ng --version
  • Angular CLI をグローバルにインストール
$ npm install -g @angular/cli@12.2.2

Build / Run

  • ClinentApp/dist が生成される
$ ng build
$ ng serve

E2Eテスト

  • ng e2e Protractorを使用したエンドツーエンドテスト

Service

$ ng g service services/Employee

.NET Core テンプレート

ASP.Net with Angular

https://docs.microsoft.com/ja-jp/dotnet/core/tools/dotnet-new-sdk-templates#spa

  • カレントディレクトリにプロジェクトを生成
$ dotnet new angular -o visappproto
  • テストプロジェクトの作成
$ dotnet new xunit -o visappproto_test
  • ソリューションの作成とプロジェクトの追加、テストプロジェクトに参照の追加
$ dotnet new sln -o .
$ dotnet sln add visappproto
$ dotnet sln add visappproto_test
$ dotnet add ./visappproto_test/visappproto_test.csproj reference ./visappproto/visappproto.csproj 

実行(Hello world と サンプル)

$ dotnet watch run

  • Angular : ClinentApp/src/app/counter Sample

  • Angular : ClientApp/src/app/fetch-data Sample
  • ASP.NET Core : Controllers/WeatherForcastController.cs

開発

$ cd ClientApp/src/app

ng generate サブコマンド

要素 コマンド
モジュール ng g moduole {{name}}
コンポーネント ng g component {{name}}
ディレクティブ ng g directive {{name}}
パイプ ng g pipe {{name}}
サービス ng g service {{name}}
ガード ng g guard {{name}}
クラス ng g class {{name}}
インターフェース ng g interface {{name}}
列挙 ng g enum {{name}}

component 追加

  • main-frame コンポーネントを追加
$ cd ClientApp
$ ng g component components/main-frame --module=app.module
CREATE src/app/components/main-frame/main-frame.component.css (0 bytes)
CREATE src/app/components/main-frame/main-frame.component.html (25 bytes)
CREATE src/app/components/main-frame/main-frame.component.spec.ts (650 bytes)
CREATE src/app/components/main-frame/main-frame.component.ts (284 bytes)
UPDATE src/app/app.module.ts (1267 bytes)
  • app.module.ts に参照が追記される
  • RouteModule.forRoot に追記
  imports: [
        :
    RouterModule.forRoot([
        :
      { path: 'main', component: MainFrameComponent },
    ])
  ],
  • nav-menu.component.html にリンクを追加
          <li class="nav-item" [routerLinkActive]="['link-active']">
          <a class="nav-link text-dark" [routerLink]="['/main']"
            > Main</a
          >
        </li>
  • Home画面のメニューにMainを追加

  • Mainクリックで作成したコンポーネント画面に遷移

Wijmo

NPM によるインストール(Angularコンポーネント)

$ cd ClientApp
$ npm install @grapecity/wijmo.angular2.all

VS Code 用 デザイナ (Wijmo Designer)

Demo

ASP.NET Core

コントローラー

ルーティング

Action

  • Progmra.cs 参照

ユニットテスト

$ cd visappproto_test
$ dotnet test
  • フィルタをかける
$ dotnet test --filter AutoCompleteControllerTest

Mock ライブラリの導入

$ dotnet add package Moq --version 4.16.1

Logger

Logger

dotnet add package Serilog.AspNetCore --version 5.0.0-dev-00259

Data Access

Oracle 19c

  • SQL Developer 接続
  • Connection文字列は、/Models/VisAppProtSettings.cs に記述したものをDI

DataAccess Package

$ dotnet add package Oracle.ManagedDataAccess.Core --version 3.21.50

Oracle Data Providor直接利用

  • /Controllers/SimpleDataAccessController.cs

MySQL

$ dotnet add package MySql.Data --version 8.0.28

OR Mapper(Dapper)

$ dotnet add package Dapper --version 2.0.123

Sample

  • ClientApp/src/app/orm-data-access
  • Controllers/OrmDataAccessController.cs

UI

Bootstrap

ngx-bootstrap

  • ngx-bootstrap
  • ngx-bootstrap npm
  • Bootstrapのラッパー
  • Bootstrapの機能をコンポーネント、ディレクティブとして呼び出すことができる
$ ng add ngx-bootstrap

Angular Material

$ ng add @angular/material

? Choose a prebuilt theme name, or "custom" for a custom theme: Custom
? Set up global Angular Material typography styles? Yes
? Set up browser animations for Angular Material? Yes

Components

Theme

Modal

Grid

  • FrexGrid
  • visappproto/ClientApp/src/app/components/employees

Angular Sample App

Windows

NVM

Deploy

IIS

発行

$ dotnet publish
visappproto -> ~/Workspaces/visappproto/visappproto/bin/Debug/net6.0/publish/

トラブルシュート

error : initial exceeded maximum budget

  • EXEC : error : initial exceeded maximum budget. Budget 1.00 MB was not met by 171.82 kB with a total of 1.17 MB.
  • angular.json
"budgets": [
  {
    "type": "initial",
    "maximumWarning": "5mb",
    "maximumError": "10mb"
  },

SPAサーバーループで起動しない原因が掴めない

  • dotnet watch run ではなく、以下いずれかで直接起動する
npm start
ng serve

Error: error:0308010C:digital envelope routines::unsupported

  • Node バージョン下げる

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published