Commit 62df98c9 authored by John Doe's avatar John Doe
Browse files

Upload Frontend.

parent 8b6a1aef
No related merge requests found
Pipeline #5 failed with stages
in 0 seconds
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support
# You can see what browsers were selected by your queries by running:
# npx browserslist
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
# 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 = off
trim_trailing_whitespace = false
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.json"
],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "*",
"next": "return"
},
{
"blankLine": "always",
"prev": [
"const",
"let",
"var"
],
"next": "*"
},
{
"blankLine": "any",
"prev": [
"const",
"let",
"var"
],
"next": [
"const",
"let",
"var"
]
},
{
"blankLine": "always",
"prev": "*",
"next": "block"
},
{
"blankLine": "always",
"prev": "block",
"next": "*"
},
{
"blankLine": "always",
"prev": "*",
"next": "block-like"
},
{
"blankLine": "always",
"prev": "block-like",
"next": "*"
}
],
"function-paren-newline": [
"off"
],
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"semi": [
"error",
"always"
],
"max-len": [
"error",
{
"code": 120
}
],
"quotes": [
"error",
"single"
],
"comma-dangle": [
"error",
"only-multiline"
],
"object-curly-spacing": [
"error",
"always"
],
"arrow-parens": [
"error",
"always"
],
"linebreak-style": [
"off"
],
"no-multiple-empty-lines": [
"error"
],
"space-before-blocks": [
"error"
],
"no-var": [
"error"
],
"no-duplicate-imports": [
"error"
],
"no-prototype-builtins": [
"off"
],
"@typescript-eslint/no-unsafe-assignment": [
"off"
],
"@typescript-eslint/no-inferrable-types": [
"off"
],
"@angular-eslint/no-output-rename": [
"off"
],
"@angular-eslint/no-output-on-prefix": [
"off"
],
"@typescript-eslint/no-floating-promises": [
"off"
],
"@typescript-eslint/unbound-method": [
"off"
],
"@typescript-eslint/no-empty-function": [
"off"
],
"@typescript-eslint/no-unsafe-member-access": [
"off"
],
"@typescript-eslint/no-unsafe-call": [
"off"
],
"@typescript-eslint/no-explicit-any": [
"off"
],
"@typescript-eslint/no-unsafe-return": [
"off"
],
"@typescript-eslint/explicit-module-boundary-types": [
"off"
],
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "explicit",
"overrides": {
"accessors": "explicit",
"constructors": "no-public",
"methods": "explicit",
"properties": "explicit",
"parameterProperties": "explicit"
}
}
],
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "os",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "os",
"style": "kebab-case"
}
]
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {}
},
{
"files": [
"*.ts"
],
"extends": [
"plugin:ngrx/recommended"
]
}
]
}
# See http://help.github.com/ignore-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
FROM node:16.14.2-alpine as builder
WORKDIR /offshift
COPY . /offshift/
RUN npm install
RUN npm run build:prod
FROM nginx:1.21.6-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /offshift/dist /usr/share/nginx/html
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
# Pilot Frontend
# OffshiftFe
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.6.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
## Docker
###Frontend
`docker build -t offshift-frontend .`
`docker run -p 8080:80 offshift-frontend`
###Client
`docker build -t offshift-client .`
`docker run -p 10000:10000 offshift-client`
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"offshift-fe": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"changeDetection": "OnPush"
},
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "os",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/offshift-fe",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/primeicons/primeicons.css",
"./node_modules/primeng/resources/primeng.min.css",
"src/styles.scss"
],
"scripts": [
"./node_modules/chart.js/dist/chart.min.js"
],
"allowedCommonJsDependencies": [
"core-js/modules/es.array.filter",
"core-js/modules/es.array.for-each",
"core-js/modules/es.array.iterator",
"core-js/modules/es.array.reduce",
"core-js/modules/es.function.name",
"core-js/modules/es.object.assign",
"core-js/modules/es.object.to-string",
"core-js/modules/es.parse-int",
"core-js/modules/es.regexp.exec",
"core-js/modules/es.string.iterator",
"core-js/modules/es.string.match",
"core-js/modules/es.string.replace",
"core-js/modules/es.weak-map",
"core-js/modules/web.dom-collections.iterator",
"web3",
"hash.js"
]
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "4mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "10kb",
"maximumError": "12kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "offshift-fe:build:production"
},
"development": {
"browserTarget": "offshift-fe:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "offshift-fe:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
]
}
}
}
}
},
"defaultProject": "offshift-fe",
"cli": {
"defaultCollection": "@angular-eslint/schematics"
}
}
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage/offshift-fe'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
server {
listen 80;
sendfile on;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 1000;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html =404;
}
}
This diff is collapsed.
{
"name": "offshift-fe",
"version": "0.0.0",
"scripts": {
"ng": "node --max_old_space_size=10240 ./node_modules/@angular/cli/bin/ng",
"start": "npm run ng -- serve --port 4315",
"build": "npm run ng -- build",
"build:prod": "npm run ng -- build --output-path=dist",
"watch": "npm run ng -- build --watch --configuration development",
"test": "ng test",
"lint": "ng lint",
"lint:fix": "ng lint --fix"
},
"private": true,
"dependencies": {
"@angular/animations": "~13.2.0",
"@angular/cdk": "^13.3.0",
"@angular/common": "~13.2.0",
"@angular/compiler": "~13.2.0",
"@angular/core": "~13.2.0",
"@angular/forms": "~13.2.0",
"@angular/platform-browser": "~13.2.0",
"@angular/platform-browser-dynamic": "~13.2.0",
"@angular/router": "~13.2.0",
"@ethersproject/address": "^5.6.0",
"@fontsource/material-icons": "^4.5.2",
"@fontsource/metropolis": "^4.5.1",
"@metamask/jazzicon": "^2.0.0",
"@ngrx/component": "^13.0.2",
"@ngrx/effects": "^13.0.2",
"@ngrx/entity": "^13.0.2",
"@ngrx/router-store": "^13.0.2",
"@ngrx/store": "^13.0.2",
"@ngrx/store-devtools": "^13.0.2",
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
"@uiowa/digit-only": "^3.2.1",
"@walletconnect/web3-provider": "^1.7.5",
"bignumber.js": "^9.0.2",
"chart.js": "^3.7.1",
"primeicons": "^5.0.0",
"primeng": "^13.2.1",
"rxjs": "~7.5.0",
"simplebar-angular": "^2.3.6",
"tslib": "^2.3.0",
"web3": "^1.7.1",
"web3-eth-contract": "^1.7.1",
"web3-utils": "^1.7.1",
"web3modal": "^1.9.5",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.2.6",
"@angular-eslint/builder": "13.1.0",
"@angular-eslint/eslint-plugin": "13.1.0",
"@angular-eslint/eslint-plugin-template": "13.1.0",
"@angular-eslint/schematics": "13.1.0",
"@angular-eslint/template-parser": "13.1.0",
"@angular/cli": "~13.2.6",
"@angular/compiler-cli": "~13.2.0",
"@types/jasmine": "~3.10.0",
"@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "5.11.0",
"@typescript-eslint/parser": "5.11.0",
"assert": "^2.0.0",
"browser": "^0.2.6",
"crypto-browserify": "^3.12.0",
"eslint": "^8.2.0",
"eslint-plugin-ngrx": "^2.0.0",
"https-browserify": "^1.0.0",
"jasmine-core": "~4.0.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.1.0",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"os-browserify": "^0.3.0",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"typescript": "~4.5.2",
"url": "^0.11.0"
}
}
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const ROUTES: Routes = [
{
path: '',
redirectTo: 'swap',
pathMatch: 'full',
},
{
path: 'swap',
loadChildren: () => import('./views/swap/swap.module')
.then((m) => m.SwapModule),
},
{
path: 'transfer',
loadChildren: () => import('./views/transfer/transfer.module')
.then((m) => m.TransferModule),
},
{
path: 'wallet',
loadChildren: () => import('./views/wallet/wallet.module')
.then((m) => m.WalletModule),
},
{
path: 'error',
loadChildren: () => import('./views/error/error.module')
.then((m) => m.ErrorModule),
},
{
path: '**',
redirectTo: '/error',
},
];
@NgModule({
imports: [RouterModule.forRoot(ROUTES)],
exports: [RouterModule],
})
export class AppRoutingModule {
}
<div class="wrapper">
<div class="wrapper__header header">
<div class="header__left">
<img src="assets/images/logo.svg" alt="offshift">
</div>
<div class="header__center">
<a routerLink="/swap" routerLinkActive="active">Shift</a>
<a routerLink="/transfer" routerLinkActive="active">Transfer</a>
<a routerLink="/wallet" routerLinkActive="active">Wallet</a>
</div>
<div class="header__right">
<os-connect-wallet class="header__connect"></os-connect-wallet>
<!--<div class="header__switch">
<span [class.is-active]="!isDarkTheme" class="material-icons light-mode">light_mode</span>
<span [class.is-active]="isDarkTheme" class="material-icons dark-mode">dark_mode</span>
<p-inputSwitch [(ngModel)]="isDarkTheme"></p-inputSwitch>
</div>-->
</div>
</div>
<div class="wrapper__content">
<router-outlet></router-outlet>
</div>
</div>
@use "sass:math";
@import "~src/styles/variables";
:host {
display: block;
position: relative;
}
.wrapper {
display: flex;
flex-direction: column;
& &__header {
height: 72px;
background: #FFFFFF;
}
& &__content {
padding: $offshift-gap 80px;
}
}
.header {
display: flex;
align-items: center;
padding: 0 80px;
gap: $offshift-gap;
& &__left,
& &__right {
width: 260px;
}
& &__left {
height: 30px;
> img {
width: auto;
height: 100%;
display: block;
}
}
& &__center {
margin: 0 auto;
display: flex;
align-items: center;
align-self: flex-end;
gap: $offshift-gap * 2;
> a {
position: relative;
text-decoration: unset;
color: #1B0D3D;
text-transform: uppercase;
font-weight: 600;
font-size: 14px;
padding-bottom: 20px;
&.active:after {
width: 100%;
}
&:after {
width: 0;
left: 0;
bottom: 0;
position: absolute;
background: #5800B0;
height: 3px;
content: "";
transition: .5s ease-in-out;
}
}
}
& &__right {
display: flex;
align-items: center;
justify-content: flex-end;
gap: math.div($offshift-gap * 3, 2);;
}
& &__connect {
}
& &__switch {
position: relative;
cursor: pointer;
.light-mode,
.dark-mode {
position: absolute;
top: calc(50% - 9px);
font-size: 16px;
z-index: 1;
color: #FFFFFF;
opacity: 0.3;
&.is-active {
opacity: unset;
color: #5800B0;
}
}
.light-mode {
left: 6px;
}
.dark-mode {
right: 6px;
}
> p-inputSwitch {
display: inline-flex;
}
}
}
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterTestingModule,
],
declarations: [
AppComponent,
],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
});
import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { WalletService } from './core/services/wallet.service';
import { selectAccountAddress } from './core/selectors';
import { BaseComponent } from './base.component';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
@Component({
selector: 'os-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent extends BaseComponent {
public accountAddress$: Observable<string>;
constructor(
store: Store,
private readonly _cdr: ChangeDetectorRef,
private readonly _walletService: WalletService,
) {
super(store);
this.accountAddress$ = this.store.select(selectAccountAddress);
}
}
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { ButtonModule } from 'primeng/button';
import { DialogService, DynamicDialogModule } from 'primeng/dynamicdialog';
import { InputSwitchModule } from 'primeng/inputswitch';
import { firstValueFrom } from 'rxjs';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { ConnectWalletModule } from './components/connect-wallet/connect-wallet.module';
import { metaReducers, reducers } from './core';
import { CoreEffects } from './core/effects';
import { RouterParamsSerializer } from './core/router-params.serializer';
import { WalletService } from './core/services/wallet.service';
import { StoreModule } from '@ngrx/store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { environment } from '../environments/environment';
import { EffectsModule } from '@ngrx/effects';
import { StoreRouterConnectingModule } from '@ngrx/router-store';
export function translateHttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
}
export function initializeFactory(
walletService: WalletService,
translateService: TranslateService,
): () => Promise<void> {
return () => {
return walletService.initialize()
.then(() => firstValueFrom(translateService.use('en')))
.then(() => {
const loader = document.querySelector('div.loader');
loader && document.body.removeChild(loader);
});
};
}
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserAnimationsModule,
BrowserModule,
HttpClientModule,
AppRoutingModule,
TranslateModule.forRoot({
defaultLanguage: 'en',
loader: {
provide: TranslateLoader,
useFactory: translateHttpLoaderFactory,
deps: [HttpClient],
},
isolate: true,
}),
DynamicDialogModule,
ButtonModule,
InputSwitchModule,
FormsModule,
StoreModule.forRoot(reducers, {
metaReducers,
runtimeChecks: {
strictStateImmutability: true,
strictActionImmutability: true,
},
}),
StoreDevtoolsModule.instrument({
maxAge: 25,
logOnly: environment.production,
}),
EffectsModule.forRoot([
CoreEffects,
]),
StoreRouterConnectingModule.forRoot({
stateKey: 'router',
}),
ConnectWalletModule,
],
bootstrap: [
AppComponent,
],
providers: [
{
provide: APP_INITIALIZER,
useFactory: initializeFactory,
deps: [WalletService, TranslateService],
multi: true,
},
DialogService,
RouterParamsSerializer,
],
})
export class AppModule {
}
import { Store } from '@ngrx/store';
export abstract class BaseComponent {
protected constructor(
protected readonly store: Store,
) {
}
}
<div class="connect-wallet">
<div *ngIf="(accountAddress$ | ngrxPush) as accountAddress else connectWallet"
(click)="onDisconnectWalletClick()"
class="p-button connect-wallet__connected">
{{ accountAddress | shortAddress }}
</div>
<ng-template #connectWallet>
<button (click)="onConnectWalletClick()"
class="connect-wallet__connect"
pButton
type="button"
label="Connect wallet">
</button>
</ng-template>
</div>
@use "sass:math";
@import "~src/styles/variables";
:host {
display: inline-flex;
}
.connect-wallet {
display: inline-flex;
width: 100%;
& &__connect {
width: 100%;
}
& &__connected {
color: #1B0D3D;
border: 1px solid rgba(107, 57, 250, 0.1);
background: rgba(107, 57, 250, 0.1);
padding: 0.5rem 2rem;
height: 42px;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment