Skip to content

Commit

Permalink
App: use dynamic inputs (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyBom authored May 20, 2024
1 parent 603fae8 commit 403838d
Show file tree
Hide file tree
Showing 44 changed files with 3,209 additions and 797 deletions.
41 changes: 41 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"root": true,
"ignorePatterns": ["projects/**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": [
"plugin:@angular-eslint/template/recommended",
"plugin:@angular-eslint/template/accessibility"
],
"rules": {}
}
]
}
5 changes: 4 additions & 1 deletion .example.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
ENABLE_CORS=true

AHB_CONTAINER_NAME='uploaded-files'
AZURE_BLOB_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol='http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;'
AZURE_BLOB_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol='http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;'
FORMAT_VERSION_CONTAINER_NAME=format-versions
46 changes: 46 additions & 0 deletions .github/workflows/action_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Pull Request"
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

- uses: actions/setup-node@v2
with:
node-version: "20.13"
cache: "npm"

- name: Install modules
run: npm ci

- name: Prettier
run: npm run format:check

- name: Lint frontend
run: npm run ng:lint

- name: Lint server
run: exit 0 # todo: add stuff

- name: Test frontend
run: exit 0 # todo: add stuff

- name: Test server
run: exit 0 # todo: add stuff

- name: Build frontend
run: npm run ng:build

- name: Build server
run: npm run server:build
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ testem.log
# System files
.DS_Store
Thumbs.db

.nx/cache
.nx/workspace-data
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/app/core/api
9 changes: 8 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,18 @@
"styles": ["src/styles.scss"],
"scripts": []
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
}
}
}
}
},
"cli": {
"analytics": false
"analytics": false,
"schematicCollections": ["@angular-eslint/schematics"]
}
}
85 changes: 46 additions & 39 deletions azure-mock/upload-documents.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,60 @@
import { BlobServiceClient, ContainerClient } from "@azure/storage-blob";
import * as fs from "fs";
import * as path from "path";
import { BlobServiceClient, ContainerClient } from '@azure/storage-blob';
import * as fs from 'fs';
import * as path from 'path';

// Function to create a BlobServiceClient
const createBlobServiceClient = () => {
const azureHost = process.env["AZURE_STORAGE_HOST"] || "http://127.0.0.1";
const connectionString = `DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=${azureHost}:10000/devstoreaccount1;`;
return BlobServiceClient.fromConnectionString(connectionString);
const azureHost = process.env['AZURE_STORAGE_HOST'] || 'http://127.0.0.1';
const connectionString = `DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=${azureHost}:10000/devstoreaccount1;`;
return BlobServiceClient.fromConnectionString(connectionString);
};

// Recursive function to upload files
const uploadFiles = async (folderPath: string, containerClient: ContainerClient) => {
const files = fs.readdirSync(folderPath);

for (const file of files) {
const filePath = path.join(folderPath, file);
const stat = fs.statSync(filePath);

if (stat.isDirectory()) {
await uploadFiles(filePath, containerClient);
} else {
const blobName = path.relative(process.argv[2], filePath).replace(/\\/g, "/");
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
console.log(`Uploading ${filePath} as ${blobName}`);
await blockBlobClient.uploadFile(filePath);
}
const uploadFiles = async (
folderPath: string,
containerClient: ContainerClient,
) => {
const files = fs.readdirSync(folderPath);

for (const file of files) {
const filePath = path.join(folderPath, file);
const stat = fs.statSync(filePath);

if (stat.isDirectory()) {
await uploadFiles(filePath, containerClient);
} else {
const blobName = path
.relative(process.argv[2], filePath)
.replace(/\\/g, '/');
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
console.log(`Uploading ${filePath} as ${blobName}`);
await blockBlobClient.uploadFile(filePath);
}
}
};

// Main function to handle the upload process
const main = async () => {
if (process.argv.length < 3) {
console.log("Usage: node dist/uploadFilesToAzurite.js <folderPath>");
return;
}

const folderPath = process.argv[2];
const containerName = "uploaded-files";
const blobServiceClient = createBlobServiceClient();
const containerClient = blobServiceClient.getContainerClient(containerName);

try {
await containerClient.createIfNotExists();
console.log(`Starting upload of files from ${folderPath} to container '${containerName}'`);
await uploadFiles(folderPath, containerClient);
console.log("All files uploaded successfully.");
} catch (error) {
console.error("Error uploading files:", error);
}
if (process.argv.length < 3) {
console.log('Usage: node dist/uploadFilesToAzurite.js <folderPath>');
return;
}

const folderPath = process.argv[2];
const containerName = 'uploaded-files';
const blobServiceClient = createBlobServiceClient();
const containerClient = blobServiceClient.getContainerClient(containerName);

try {
await containerClient.createIfNotExists();
console.log(
`Starting upload of files from ${folderPath} to container '${containerName}'`,
);
await uploadFiles(folderPath, containerClient);
console.log('All files uploaded successfully.');
} catch (error) {
console.error('Error uploading files:', error);
}
};

main();
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ services:
build:
dockerfile: ./Dockerfile
ports:
- 3000:3000
- 4000:4000
environment:
- PORT=4000
- AZURE_BLOB_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://host.docker.internal:10000/devstoreaccount1;
- AHB_CONTAINER_NAME=uploaded-files
- FORMAT_VERSION_CONTAINER_NAME=format-versions
Expand Down
1 change: 0 additions & 1 deletion openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ components:
- meta
FormatVersion:
type: string
enum: [FV2310, FV2404, FV2410]
Version:
type: object
properties:
Expand Down
Loading

0 comments on commit 403838d

Please sign in to comment.