Compare commits

..

No commits in common. "6848a5a4c98bc2e384e8f8cfc12be05a69e4ad62" and "ac70429e69b84bceab2c490fe4da5770002479be" have entirely different histories.

10 changed files with 38 additions and 39 deletions

View file

@ -1,9 +1,9 @@
FROM node:alpine
COPY dist/universal-statuspage /universal-statuspage
COPY dist/grafana-statuspage /grafana-statuspage
WORKDIR /app
EXPOSE 4000
ENTRYPOINT ["node", "/universal-statuspage/server/main.js"]
ENTRYPOINT ["node", "/grafana-statuspage/server/main.js"]

View file

@ -3,7 +3,7 @@
"version": 1,
"newProjectRoot": "projects",
"projects": {
"universal-statuspage": {
"grafana-statuspage": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
@ -17,7 +17,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/universal-statuspage/browser",
"outputPath": "dist/grafana-statuspage/browser",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
@ -69,18 +69,18 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "universal-statuspage:build"
"browserTarget": "grafana-statuspage:build"
},
"configurations": {
"production": {
"browserTarget": "universal-statuspage:build:production"
"browserTarget": "grafana-statuspage:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "universal-statuspage:build"
"browserTarget": "grafana-statuspage:build"
}
},
"test": {
@ -120,18 +120,18 @@
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "universal-statuspage:serve"
"devServerTarget": "grafana-statuspage:serve"
},
"configurations": {
"production": {
"devServerTarget": "universal-statuspage:serve:production"
"devServerTarget": "grafana-statuspage:serve:production"
}
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/universal-statuspage/server",
"outputPath": "dist/grafana-statuspage/server",
"main": "server.ts",
"tsConfig": "tsconfig.server.json"
},
@ -152,21 +152,21 @@
"serve-ssr": {
"builder": "@nguniversal/builders:ssr-dev-server",
"options": {
"browserTarget": "universal-statuspage:build",
"serverTarget": "universal-statuspage:server"
"browserTarget": "grafana-statuspage:build",
"serverTarget": "grafana-statuspage:server"
},
"configurations": {
"production": {
"browserTarget": "universal-statuspage:build:production",
"serverTarget": "universal-statuspage:server:production"
"browserTarget": "grafana-statuspage:build:production",
"serverTarget": "grafana-statuspage:server:production"
}
}
},
"prerender": {
"builder": "@nguniversal/builders:prerender",
"options": {
"browserTarget": "universal-statuspage:build:production",
"serverTarget": "universal-statuspage:server:production",
"browserTarget": "grafana-statuspage:build:production",
"serverTarget": "grafana-statuspage:server:production",
"routes": [
"/"
]
@ -177,5 +177,5 @@
}
}
}},
"defaultProject": "universal-statuspage"
"defaultProject": "grafana-statuspage"
}

View file

@ -10,7 +10,7 @@ describe('workspace-project App', () => {
it('should display welcome message', () => {
page.navigateTo();
expect(page.getTitleText()).toEqual('universal-statuspage app is running!');
expect(page.getTitleText()).toEqual('grafana-statuspage app is running!');
});
afterEach(async () => {

View file

@ -16,7 +16,7 @@ module.exports = function (config) {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/universal-statuspage'),
dir: require('path').join(__dirname, './coverage/grafana-statuspage'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},

View file

@ -1,5 +1,5 @@
{
"name": "universal-statuspage",
"name": "grafana-statuspage",
"version": "0.0.0",
"scripts": {
"ng": "ng",
@ -8,10 +8,10 @@
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"dev:ssr": "ng run universal-statuspage:serve-ssr",
"serve:ssr": "node dist/universal-statuspage/server/main.js",
"build:ssr": "ng build --prod && ng run universal-statuspage:server:production",
"prerender": "ng run universal-statuspage:prerender"
"dev:ssr": "ng run grafana-statuspage:serve-ssr",
"serve:ssr": "node dist/grafana-statuspage/server/main.js",
"build:ssr": "ng build --prod && ng run grafana-statuspage:server:production",
"prerender": "ng run grafana-statuspage:prerender"
},
"private": true,
"dependencies": {
@ -30,7 +30,7 @@
"@nguniversal/express-engine": "^10.0.1",
"bootstrap": "^4.5.0",
"express": "^4.15.2",
"jsonpath-plus": "^4.0.0",
"jsonpath": "^1.0.2",
"roboto-fontface": "^0.10.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",

View file

@ -8,12 +8,12 @@ import {AppServerModule} from './src/main.server';
import {APP_BASE_HREF} from '@angular/common';
import {existsSync} from 'fs';
import {api} from './src/main.status';
import {environment} from './src/environments/environment';
import {environment} from "./src/environments/environment";
// The Express app is exported so that it can be used by serverless Functions.
export function app() {
const server = express();
const distFolder = environment.production ? '/universal-statuspage/browser' : join(process.cwd(), 'dist/universal-statuspage/browser');
const distFolder = environment.production ? '/grafana-statuspage/browser' : join(process.cwd(), 'dist/grafana-statuspage/browser');
const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index';
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)

View file

@ -20,16 +20,16 @@ describe('AppComponent', () => {
expect(app).toBeTruthy();
});
it(`should have as title 'universal-statuspage'`, () => {
it(`should have as title 'grafana-statuspage'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('universal-statuspage');
expect(app.title).toEqual('grafana-statuspage');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain('universal-statuspage app is running!');
expect(compiled.querySelector('.content span').textContent).toContain('grafana-statuspage app is running!');
});
});

View file

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>universal-statuspage</title>
<title>grafana-statuspage</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link id="favicon" rel="icon" type="image/x-icon" href="">

View file

@ -1,8 +1,7 @@
import {json, Router} from 'express';
import {CurrentStatus, State} from './app/_data/data';
import {existsSync, readFileSync, writeFileSync} from 'fs';
import {join} from 'path';
import {JSONPath} from 'jsonpath-plus';
import * as jp from 'jsonpath';
interface Cache {
[id: string]: State;
@ -44,8 +43,7 @@ interface StateKey {
const api = Router();
api.use(json());
const serviceStates = existsSync(join(process.cwd(), 'cache.json')) ? JSON.parse(readFileSync(join(process.cwd(), 'cache.json'), {encoding: 'utf-8'})) : {} as Cache;
const config = JSON.parse(readFileSync(join(process.cwd(), 'config.json'), {encoding: 'utf-8'})) as Config;
const config = JSON.parse(readFileSync('config.json', {encoding: 'utf-8'})) as Config;
const stateKeys: { [service: string]: StateKey } = config.groups
.map(g => g.services).reduce((x, y) => x.concat(y), [])
.reduce((services, service) => {
@ -58,6 +56,7 @@ const stateKeys: { [service: string]: StateKey } = config.groups
};
return services;
}, {});
const serviceStates = existsSync('cache.json') ? JSON.parse(readFileSync('cache.json', {encoding: 'utf-8'})) : {} as Cache;
let cache: CurrentStatus;
updateCache();
@ -69,7 +68,7 @@ api.post('/update/health', (req, res) => {
}
const serviceId = req.query.service as string;
const keys = stateKeys[serviceId];
const state = JSONPath({path: keys.statePath, json: req.body, wrap: false});
const state = jp.value(req.body, keys.statePath);
if (keys.stateValues.operational.includes(state)) {
serviceStates[serviceId] = 'operational';

View file

@ -4,9 +4,9 @@
"outDir": "./out-tsc/app-server",
"types": [
"node"
],
"target": "es2016"
},
]
, "target": "es2016"
},
"files": [
"src/main.server.ts",
"server.ts"