Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52db63bca2 | ||
|
|
55dfd9e2a1 | ||
|
|
d193cbf2b7 | ||
|
|
bdec56a543 | ||
|
|
e0a6d9740c | ||
|
|
0ce9c057e1 | ||
|
|
12a2fdbc20 | ||
|
|
57c294bc89 | ||
|
|
9758757805 | ||
|
|
f9350fa35f | ||
|
|
e120da4ecd | ||
|
|
328a10b70c | ||
|
|
1ed97c8deb | ||
|
|
91b970e2aa | ||
|
|
99af1bb479 | ||
|
|
11ddcbdee3 | ||
|
|
6e8a1086d8 | ||
|
|
c78945436e | ||
|
|
6eff8fde74 | ||
|
|
726d5a177e | ||
|
|
33495b5cb3 | ||
|
|
fe159a13a9 | ||
|
|
22a1dc0566 | ||
|
|
02e6b732e9 | ||
|
|
cc6fa135ac | ||
|
|
5747732156 |
@@ -57,6 +57,7 @@ common:
|
|||||||
memo: "Notizen"
|
memo: "Notizen"
|
||||||
trends: "Trends"
|
trends: "Trends"
|
||||||
photo-stream: "Bilder"
|
photo-stream: "Bilder"
|
||||||
|
posts-monitor: "投稿チャート"
|
||||||
slideshow: "Diashow"
|
slideshow: "Diashow"
|
||||||
version: "Version"
|
version: "Version"
|
||||||
broadcast: "ブロードキャスト"
|
broadcast: "ブロードキャスト"
|
||||||
@@ -220,6 +221,9 @@ common/views/widgets/donation.vue:
|
|||||||
common/views/widgets/photo-stream.vue:
|
common/views/widgets/photo-stream.vue:
|
||||||
title: "Fotostream"
|
title: "Fotostream"
|
||||||
no-photos: "Keine Fotos"
|
no-photos: "Keine Fotos"
|
||||||
|
common/views/widgets/posts-monitor.vue:
|
||||||
|
title: "投稿チャート"
|
||||||
|
toggle: "表示を切り替え"
|
||||||
common/views/widgets/server.vue:
|
common/views/widgets/server.vue:
|
||||||
title: "Serverinformationen"
|
title: "Serverinformationen"
|
||||||
toggle: "Sicht umschalten"
|
toggle: "Sicht umschalten"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ common:
|
|||||||
memo: "Memo"
|
memo: "Memo"
|
||||||
trends: "Trends"
|
trends: "Trends"
|
||||||
photo-stream: "Photo stream"
|
photo-stream: "Photo stream"
|
||||||
|
posts-monitor: "投稿チャート"
|
||||||
slideshow: "Slideshow"
|
slideshow: "Slideshow"
|
||||||
version: "Version"
|
version: "Version"
|
||||||
broadcast: "Broadcast"
|
broadcast: "Broadcast"
|
||||||
@@ -220,6 +221,9 @@ common/views/widgets/donation.vue:
|
|||||||
common/views/widgets/photo-stream.vue:
|
common/views/widgets/photo-stream.vue:
|
||||||
title: "Photostream"
|
title: "Photostream"
|
||||||
no-photos: "No photos"
|
no-photos: "No photos"
|
||||||
|
common/views/widgets/posts-monitor.vue:
|
||||||
|
title: "投稿チャート"
|
||||||
|
toggle: "表示を切り替え"
|
||||||
common/views/widgets/server.vue:
|
common/views/widgets/server.vue:
|
||||||
title: "Server info"
|
title: "Server info"
|
||||||
toggle: "Toggle views"
|
toggle: "Toggle views"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ common:
|
|||||||
memo: "メモ"
|
memo: "メモ"
|
||||||
trends: "トレンド"
|
trends: "トレンド"
|
||||||
photo-stream: "フォトストリーム"
|
photo-stream: "フォトストリーム"
|
||||||
|
posts-monitor: "投稿チャート"
|
||||||
slideshow: "スライドショー"
|
slideshow: "スライドショー"
|
||||||
version: "バージョン"
|
version: "バージョン"
|
||||||
broadcast: "ブロードキャスト"
|
broadcast: "ブロードキャスト"
|
||||||
@@ -220,6 +221,9 @@ common/views/widgets/donation.vue:
|
|||||||
common/views/widgets/photo-stream.vue:
|
common/views/widgets/photo-stream.vue:
|
||||||
title: "フォトストリーム"
|
title: "フォトストリーム"
|
||||||
no-photos: "写真はありません"
|
no-photos: "写真はありません"
|
||||||
|
common/views/widgets/posts-monitor.vue:
|
||||||
|
title: "投稿チャート"
|
||||||
|
toggle: "表示を切り替え"
|
||||||
common/views/widgets/server.vue:
|
common/views/widgets/server.vue:
|
||||||
title: "サーバー情報"
|
title: "サーバー情報"
|
||||||
toggle: "表示を切り替え"
|
toggle: "表示を切り替え"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ common:
|
|||||||
memo: "Note"
|
memo: "Note"
|
||||||
trends: "Tendances"
|
trends: "Tendances"
|
||||||
photo-stream: "Flux de photos"
|
photo-stream: "Flux de photos"
|
||||||
|
posts-monitor: "投稿チャート"
|
||||||
slideshow: "Diaporama"
|
slideshow: "Diaporama"
|
||||||
version: "Version"
|
version: "Version"
|
||||||
broadcast: "Diffusion"
|
broadcast: "Diffusion"
|
||||||
@@ -220,6 +221,9 @@ common/views/widgets/donation.vue:
|
|||||||
common/views/widgets/photo-stream.vue:
|
common/views/widgets/photo-stream.vue:
|
||||||
title: "Flux de photo"
|
title: "Flux de photo"
|
||||||
no-photos: "Pas de photos"
|
no-photos: "Pas de photos"
|
||||||
|
common/views/widgets/posts-monitor.vue:
|
||||||
|
title: "投稿チャート"
|
||||||
|
toggle: "表示を切り替え"
|
||||||
common/views/widgets/server.vue:
|
common/views/widgets/server.vue:
|
||||||
title: "Info sur le serveur"
|
title: "Info sur le serveur"
|
||||||
toggle: "Afficher les vues"
|
toggle: "Afficher les vues"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ common:
|
|||||||
memo: "メモ"
|
memo: "メモ"
|
||||||
trends: "トレンド"
|
trends: "トレンド"
|
||||||
photo-stream: "フォトストリーム"
|
photo-stream: "フォトストリーム"
|
||||||
|
posts-monitor: "投稿チャート"
|
||||||
slideshow: "スライドショー"
|
slideshow: "スライドショー"
|
||||||
version: "バージョン"
|
version: "バージョン"
|
||||||
broadcast: "ブロードキャスト"
|
broadcast: "ブロードキャスト"
|
||||||
@@ -220,6 +221,9 @@ common/views/widgets/donation.vue:
|
|||||||
common/views/widgets/photo-stream.vue:
|
common/views/widgets/photo-stream.vue:
|
||||||
title: "フォトストリーム"
|
title: "フォトストリーム"
|
||||||
no-photos: "写真はありません"
|
no-photos: "写真はありません"
|
||||||
|
common/views/widgets/posts-monitor.vue:
|
||||||
|
title: "投稿チャート"
|
||||||
|
toggle: "表示を切り替え"
|
||||||
common/views/widgets/server.vue:
|
common/views/widgets/server.vue:
|
||||||
title: "サーバー情報"
|
title: "サーバー情報"
|
||||||
toggle: "表示を切り替え"
|
toggle: "表示を切り替え"
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ common:
|
|||||||
memo: "メモ"
|
memo: "メモ"
|
||||||
trends: "トレンド"
|
trends: "トレンド"
|
||||||
photo-stream: "フォトストリーム"
|
photo-stream: "フォトストリーム"
|
||||||
|
posts-monitor: "投稿チャート"
|
||||||
slideshow: "スライドショー"
|
slideshow: "スライドショー"
|
||||||
version: "バージョン"
|
version: "バージョン"
|
||||||
broadcast: "ブロードキャスト"
|
broadcast: "ブロードキャスト"
|
||||||
@@ -249,6 +250,10 @@ common/views/widgets/photo-stream.vue:
|
|||||||
title: "フォトストリーム"
|
title: "フォトストリーム"
|
||||||
no-photos: "写真はありません"
|
no-photos: "写真はありません"
|
||||||
|
|
||||||
|
common/views/widgets/posts-monitor.vue:
|
||||||
|
title: "投稿チャート"
|
||||||
|
toggle: "表示を切り替え"
|
||||||
|
|
||||||
common/views/widgets/server.vue:
|
common/views/widgets/server.vue:
|
||||||
title: "サーバー情報"
|
title: "サーバー情報"
|
||||||
toggle: "表示を切り替え"
|
toggle: "表示を切り替え"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ common:
|
|||||||
memo: "メモ"
|
memo: "メモ"
|
||||||
trends: "トレンド"
|
trends: "トレンド"
|
||||||
photo-stream: "フォトストリーム"
|
photo-stream: "フォトストリーム"
|
||||||
|
posts-monitor: "投稿チャート"
|
||||||
slideshow: "スライドショー"
|
slideshow: "スライドショー"
|
||||||
version: "バージョン"
|
version: "バージョン"
|
||||||
broadcast: "ブロードキャスト"
|
broadcast: "ブロードキャスト"
|
||||||
@@ -220,6 +221,9 @@ common/views/widgets/donation.vue:
|
|||||||
common/views/widgets/photo-stream.vue:
|
common/views/widgets/photo-stream.vue:
|
||||||
title: "フォトストリーム"
|
title: "フォトストリーム"
|
||||||
no-photos: "写真はありません"
|
no-photos: "写真はありません"
|
||||||
|
common/views/widgets/posts-monitor.vue:
|
||||||
|
title: "投稿チャート"
|
||||||
|
toggle: "表示を切り替え"
|
||||||
common/views/widgets/server.vue:
|
common/views/widgets/server.vue:
|
||||||
title: "サーバー情報"
|
title: "サーバー情報"
|
||||||
toggle: "表示を切り替え"
|
toggle: "表示を切り替え"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ common:
|
|||||||
memo: "Notatki"
|
memo: "Notatki"
|
||||||
trends: "Na czasie"
|
trends: "Na czasie"
|
||||||
photo-stream: "Photostream"
|
photo-stream: "Photostream"
|
||||||
|
posts-monitor: "投稿チャート"
|
||||||
slideshow: "Pokaz slajdów"
|
slideshow: "Pokaz slajdów"
|
||||||
version: "Wersja"
|
version: "Wersja"
|
||||||
broadcast: "Transmisja"
|
broadcast: "Transmisja"
|
||||||
@@ -220,6 +221,9 @@ common/views/widgets/donation.vue:
|
|||||||
common/views/widgets/photo-stream.vue:
|
common/views/widgets/photo-stream.vue:
|
||||||
title: "Photostream"
|
title: "Photostream"
|
||||||
no-photos: "Brak zdjęć"
|
no-photos: "Brak zdjęć"
|
||||||
|
common/views/widgets/posts-monitor.vue:
|
||||||
|
title: "投稿チャート"
|
||||||
|
toggle: "表示を切り替え"
|
||||||
common/views/widgets/server.vue:
|
common/views/widgets/server.vue:
|
||||||
title: "Informacje o serwerze"
|
title: "Informacje o serwerze"
|
||||||
toggle: "Przełącz widok"
|
toggle: "Przełącz widok"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ common:
|
|||||||
memo: "メモ"
|
memo: "メモ"
|
||||||
trends: "トレンド"
|
trends: "トレンド"
|
||||||
photo-stream: "フォトストリーム"
|
photo-stream: "フォトストリーム"
|
||||||
|
posts-monitor: "投稿チャート"
|
||||||
slideshow: "スライドショー"
|
slideshow: "スライドショー"
|
||||||
version: "バージョン"
|
version: "バージョン"
|
||||||
broadcast: "ブロードキャスト"
|
broadcast: "ブロードキャスト"
|
||||||
@@ -220,6 +221,9 @@ common/views/widgets/donation.vue:
|
|||||||
common/views/widgets/photo-stream.vue:
|
common/views/widgets/photo-stream.vue:
|
||||||
title: "フォトストリーム"
|
title: "フォトストリーム"
|
||||||
no-photos: "写真はありません"
|
no-photos: "写真はありません"
|
||||||
|
common/views/widgets/posts-monitor.vue:
|
||||||
|
title: "投稿チャート"
|
||||||
|
toggle: "表示を切り替え"
|
||||||
common/views/widgets/server.vue:
|
common/views/widgets/server.vue:
|
||||||
title: "サーバー情報"
|
title: "サーバー情報"
|
||||||
toggle: "表示を切り替え"
|
toggle: "表示を切り替え"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ common:
|
|||||||
memo: "メモ"
|
memo: "メモ"
|
||||||
trends: "トレンド"
|
trends: "トレンド"
|
||||||
photo-stream: "フォトストリーム"
|
photo-stream: "フォトストリーム"
|
||||||
|
posts-monitor: "投稿チャート"
|
||||||
slideshow: "スライドショー"
|
slideshow: "スライドショー"
|
||||||
version: "バージョン"
|
version: "バージョン"
|
||||||
broadcast: "ブロードキャスト"
|
broadcast: "ブロードキャスト"
|
||||||
@@ -220,6 +221,9 @@ common/views/widgets/donation.vue:
|
|||||||
common/views/widgets/photo-stream.vue:
|
common/views/widgets/photo-stream.vue:
|
||||||
title: "フォトストリーム"
|
title: "フォトストリーム"
|
||||||
no-photos: "写真はありません"
|
no-photos: "写真はありません"
|
||||||
|
common/views/widgets/posts-monitor.vue:
|
||||||
|
title: "投稿チャート"
|
||||||
|
toggle: "表示を切り替え"
|
||||||
common/views/widgets/server.vue:
|
common/views/widgets/server.vue:
|
||||||
title: "サーバー情報"
|
title: "サーバー情報"
|
||||||
toggle: "表示を切り替え"
|
toggle: "表示を切り替え"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ common:
|
|||||||
memo: "メモ"
|
memo: "メモ"
|
||||||
trends: "トレンド"
|
trends: "トレンド"
|
||||||
photo-stream: "フォトストリーム"
|
photo-stream: "フォトストリーム"
|
||||||
|
posts-monitor: "投稿チャート"
|
||||||
slideshow: "スライドショー"
|
slideshow: "スライドショー"
|
||||||
version: "バージョン"
|
version: "バージョン"
|
||||||
broadcast: "ブロードキャスト"
|
broadcast: "ブロードキャスト"
|
||||||
@@ -220,6 +221,9 @@ common/views/widgets/donation.vue:
|
|||||||
common/views/widgets/photo-stream.vue:
|
common/views/widgets/photo-stream.vue:
|
||||||
title: "フォトストリーム"
|
title: "フォトストリーム"
|
||||||
no-photos: "写真はありません"
|
no-photos: "写真はありません"
|
||||||
|
common/views/widgets/posts-monitor.vue:
|
||||||
|
title: "投稿チャート"
|
||||||
|
toggle: "表示を切り替え"
|
||||||
common/views/widgets/server.vue:
|
common/views/widgets/server.vue:
|
||||||
title: "サーバー情報"
|
title: "サーバー情報"
|
||||||
toggle: "表示を切り替え"
|
toggle: "表示を切り替え"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "misskey",
|
"name": "misskey",
|
||||||
"author": "syuilo <i@syuilo.com>",
|
"author": "syuilo <i@syuilo.com>",
|
||||||
"version": "2.33.0",
|
"version": "2.34.1",
|
||||||
"clientVersion": "1.0.6292",
|
"clientVersion": "1.0.6318",
|
||||||
"codename": "nighthike",
|
"codename": "nighthike",
|
||||||
"main": "./built/index.js",
|
"main": "./built/index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -152,7 +152,7 @@
|
|||||||
"mkdirp": "0.5.1",
|
"mkdirp": "0.5.1",
|
||||||
"mocha": "5.2.0",
|
"mocha": "5.2.0",
|
||||||
"moji": "0.5.1",
|
"moji": "0.5.1",
|
||||||
"mongodb": "3.0.8",
|
"mongodb": "3.0.10",
|
||||||
"monk": "6.0.6",
|
"monk": "6.0.6",
|
||||||
"ms": "2.1.1",
|
"ms": "2.1.1",
|
||||||
"nan": "2.10.0",
|
"nan": "2.10.0",
|
||||||
@@ -218,6 +218,6 @@
|
|||||||
"webpack-cli": "2.1.4",
|
"webpack-cli": "2.1.4",
|
||||||
"websocket": "1.0.26",
|
"websocket": "1.0.26",
|
||||||
"ws": "5.2.0",
|
"ws": "5.2.0",
|
||||||
"xev": "2.0.0"
|
"xev": "2.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ import StreamManager from './stream-manager';
|
|||||||
import MiOS from '../../../mios';
|
import MiOS from '../../../mios';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server stream connection
|
* Notes stats stream connection
|
||||||
*/
|
*/
|
||||||
export class ServerStream extends Stream {
|
export class NotesStatsStream extends Stream {
|
||||||
constructor(os: MiOS) {
|
constructor(os: MiOS) {
|
||||||
super(os, 'server');
|
super(os, 'notes-stats');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ServerStreamManager extends StreamManager<ServerStream> {
|
export class NotesStatsStreamManager extends StreamManager<NotesStatsStream> {
|
||||||
private os: MiOS;
|
private os: MiOS;
|
||||||
|
|
||||||
constructor(os: MiOS) {
|
constructor(os: MiOS) {
|
||||||
@@ -22,7 +22,7 @@ export class ServerStreamManager extends StreamManager<ServerStream> {
|
|||||||
|
|
||||||
public getConnection() {
|
public getConnection() {
|
||||||
if (this.connection == null) {
|
if (this.connection == null) {
|
||||||
this.connection = new ServerStream(this.os);
|
this.connection = new NotesStatsStream(this.os);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.connection;
|
return this.connection;
|
||||||
30
src/client/app/common/scripts/streaming/server-stats.ts
Normal file
30
src/client/app/common/scripts/streaming/server-stats.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import Stream from './stream';
|
||||||
|
import StreamManager from './stream-manager';
|
||||||
|
import MiOS from '../../../mios';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server stats stream connection
|
||||||
|
*/
|
||||||
|
export class ServerStatsStream extends Stream {
|
||||||
|
constructor(os: MiOS) {
|
||||||
|
super(os, 'server-stats');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ServerStatsStreamManager extends StreamManager<ServerStatsStream> {
|
||||||
|
private os: MiOS;
|
||||||
|
|
||||||
|
constructor(os: MiOS) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.os = os;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getConnection() {
|
||||||
|
if (this.connection == null) {
|
||||||
|
this.connection = new ServerStatsStream(this.os);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.connection;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,7 +75,7 @@ root(isDark)
|
|||||||
align-self center
|
align-self center
|
||||||
margin 0 .5em 0 0
|
margin 0 .5em 0 0
|
||||||
padding 1px 6px
|
padding 1px 6px
|
||||||
font-size 12px
|
font-size 80%
|
||||||
color isDark ? #758188 : #aaa
|
color isDark ? #758188 : #aaa
|
||||||
border solid 1px isDark ? #57616f : #ddd
|
border solid 1px isDark ? #57616f : #ddd
|
||||||
border-radius 3px
|
border-radius 3px
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import wAnalogClock from './analog-clock.vue';
|
|||||||
import wVersion from './version.vue';
|
import wVersion from './version.vue';
|
||||||
import wRss from './rss.vue';
|
import wRss from './rss.vue';
|
||||||
import wServer from './server.vue';
|
import wServer from './server.vue';
|
||||||
|
import wPostsMonitor from './posts-monitor.vue';
|
||||||
import wMemo from './memo.vue';
|
import wMemo from './memo.vue';
|
||||||
import wBroadcast from './broadcast.vue';
|
import wBroadcast from './broadcast.vue';
|
||||||
import wCalendar from './calendar.vue';
|
import wCalendar from './calendar.vue';
|
||||||
@@ -22,6 +23,7 @@ Vue.component('mkw-tips', wTips);
|
|||||||
Vue.component('mkw-donation', wDonation);
|
Vue.component('mkw-donation', wDonation);
|
||||||
Vue.component('mkw-broadcast', wBroadcast);
|
Vue.component('mkw-broadcast', wBroadcast);
|
||||||
Vue.component('mkw-server', wServer);
|
Vue.component('mkw-server', wServer);
|
||||||
|
Vue.component('mkw-posts-monitor', wPostsMonitor);
|
||||||
Vue.component('mkw-memo', wMemo);
|
Vue.component('mkw-memo', wMemo);
|
||||||
Vue.component('mkw-rss', wRss);
|
Vue.component('mkw-rss', wRss);
|
||||||
Vue.component('mkw-version', wVersion);
|
Vue.component('mkw-version', wVersion);
|
||||||
|
|||||||
190
src/client/app/common/views/widgets/posts-monitor.vue
Normal file
190
src/client/app/common/views/widgets/posts-monitor.vue
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mkw-posts-monitor">
|
||||||
|
<mk-widget-container :show-header="props.design == 0" :naked="props.design == 2">
|
||||||
|
<template slot="header">%fa:chart-line%%i18n:@title%</template>
|
||||||
|
<button slot="func" @click="toggle" title="%i18n:@toggle%">%fa:sort%</button>
|
||||||
|
|
||||||
|
<div class="qpdmibaztplkylerhdbllwcokyrfxeyj" :class="{ dual: props.view == 0 }" :data-darkmode="$store.state.device.darkmode">
|
||||||
|
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`" preserveAspectRatio="none" v-show="props.view != 2">
|
||||||
|
<defs>
|
||||||
|
<linearGradient :id="localGradientId" x1="0" x2="0" y1="1" y2="0">
|
||||||
|
<stop offset="0%" stop-color="hsl(200, 80%, 70%)"></stop>
|
||||||
|
<stop offset="100%" stop-color="hsl(90, 80%, 70%)"></stop>
|
||||||
|
</linearGradient>
|
||||||
|
<mask :id="localMaskId" x="0" y="0" :width="viewBoxX" :height="viewBoxY">
|
||||||
|
<polygon
|
||||||
|
:points="localPolygonPoints"
|
||||||
|
fill="#fff"
|
||||||
|
fill-opacity="0.5"/>
|
||||||
|
<polyline
|
||||||
|
:points="localPolylinePoints"
|
||||||
|
fill="none"
|
||||||
|
stroke="#fff"
|
||||||
|
stroke-width="1"/>
|
||||||
|
</mask>
|
||||||
|
</defs>
|
||||||
|
<rect
|
||||||
|
x="-1" y="-1"
|
||||||
|
:width="viewBoxX + 2" :height="viewBoxY + 2"
|
||||||
|
:style="`stroke: none; fill: url(#${ localGradientId }); mask: url(#${ localMaskId })`"/>
|
||||||
|
<text x="1" y="5">Local</text>
|
||||||
|
</svg>
|
||||||
|
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`" preserveAspectRatio="none" v-show="props.view != 1">
|
||||||
|
<defs>
|
||||||
|
<linearGradient :id="fediGradientId" x1="0" x2="0" y1="1" y2="0">
|
||||||
|
<stop offset="0%" stop-color="hsl(200, 80%, 70%)"></stop>
|
||||||
|
<stop offset="100%" stop-color="hsl(90, 80%, 70%)"></stop>
|
||||||
|
</linearGradient>
|
||||||
|
<mask :id="fediMaskId" x="0" y="0" :width="viewBoxX" :height="viewBoxY">
|
||||||
|
<polygon
|
||||||
|
:points="fediPolygonPoints"
|
||||||
|
fill="#fff"
|
||||||
|
fill-opacity="0.5"/>
|
||||||
|
<polyline
|
||||||
|
:points="fediPolylinePoints"
|
||||||
|
fill="none"
|
||||||
|
stroke="#fff"
|
||||||
|
stroke-width="1"/>
|
||||||
|
</mask>
|
||||||
|
</defs>
|
||||||
|
<rect
|
||||||
|
x="-1" y="-1"
|
||||||
|
:width="viewBoxX + 2" :height="viewBoxY + 2"
|
||||||
|
:style="`stroke: none; fill: url(#${ fediGradientId }); mask: url(#${ fediMaskId })`"/>
|
||||||
|
<text x="1" y="5">Fedi</text>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</mk-widget-container>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import define from '../../../common/define-widget';
|
||||||
|
import * as uuid from 'uuid';
|
||||||
|
|
||||||
|
export default define({
|
||||||
|
name: 'server',
|
||||||
|
props: () => ({
|
||||||
|
design: 0,
|
||||||
|
view: 0
|
||||||
|
})
|
||||||
|
}).extend({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
connection: null,
|
||||||
|
connectionId: null,
|
||||||
|
viewBoxY: 30,
|
||||||
|
stats: [],
|
||||||
|
fediGradientId: uuid(),
|
||||||
|
fediMaskId: uuid(),
|
||||||
|
localGradientId: uuid(),
|
||||||
|
localMaskId: uuid(),
|
||||||
|
fediPolylinePoints: '',
|
||||||
|
localPolylinePoints: '',
|
||||||
|
fediPolygonPoints: '',
|
||||||
|
localPolygonPoints: ''
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
viewBoxX(): number {
|
||||||
|
return this.props.view == 0 ? 50 : 100;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
viewBoxX() {
|
||||||
|
this.draw();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.connection = (this as any).os.streams.notesStatsStream.getConnection();
|
||||||
|
this.connectionId = (this as any).os.streams.notesStatsStream.use();
|
||||||
|
|
||||||
|
this.connection.on('stats', this.onStats);
|
||||||
|
this.connection.on('statsLog', this.onStatsLog);
|
||||||
|
this.connection.send({
|
||||||
|
type: 'requestLog',
|
||||||
|
id: Math.random().toString()
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.connection.off('stats', this.onStats);
|
||||||
|
this.connection.off('statsLog', this.onStatsLog);
|
||||||
|
(this as any).os.streams.notesStatsStream.dispose(this.connectionId);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toggle() {
|
||||||
|
if (this.props.view == 2) {
|
||||||
|
this.props.view = 0;
|
||||||
|
} else {
|
||||||
|
this.props.view++;
|
||||||
|
}
|
||||||
|
this.save();
|
||||||
|
},
|
||||||
|
func() {
|
||||||
|
if (this.props.design == 2) {
|
||||||
|
this.props.design = 0;
|
||||||
|
} else {
|
||||||
|
this.props.design++;
|
||||||
|
}
|
||||||
|
this.save();
|
||||||
|
},
|
||||||
|
draw() {
|
||||||
|
const stats = this.props.view == 0 ? this.stats.slice(-50) : this.stats;
|
||||||
|
const fediPeak = Math.max.apply(null, stats.map(x => x.all)) || 1;
|
||||||
|
const localPeak = Math.max.apply(null, stats.map(x => x.local)) || 1;
|
||||||
|
|
||||||
|
this.fediPolylinePoints = stats.map((s, i) => `${this.viewBoxX - ((stats.length - 1) - i)},${(1 - (s.all / fediPeak)) * this.viewBoxY}`).join(' ');
|
||||||
|
this.localPolylinePoints = stats.map((s, i) => `${this.viewBoxX - ((stats.length - 1) - i)},${(1 - (s.local / localPeak)) * this.viewBoxY}`).join(' ');
|
||||||
|
|
||||||
|
this.fediPolygonPoints = `${this.viewBoxX - (stats.length - 1)},${ this.viewBoxY } ${ this.fediPolylinePoints } ${ this.viewBoxX },${ this.viewBoxY }`;
|
||||||
|
this.localPolygonPoints = `${this.viewBoxX - (stats.length - 1)},${ this.viewBoxY } ${ this.localPolylinePoints } ${ this.viewBoxX },${ this.viewBoxY }`;
|
||||||
|
},
|
||||||
|
onStats(stats) {
|
||||||
|
this.stats.push(stats);
|
||||||
|
if (this.stats.length > 100) this.stats.shift();
|
||||||
|
this.draw();
|
||||||
|
},
|
||||||
|
onStatsLog(statsLog) {
|
||||||
|
statsLog.forEach(stats => this.onStats(stats));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="stylus" scoped>
|
||||||
|
root(isDark)
|
||||||
|
&.dual
|
||||||
|
> svg
|
||||||
|
width 50%
|
||||||
|
float left
|
||||||
|
|
||||||
|
&:first-child
|
||||||
|
padding-right 5px
|
||||||
|
|
||||||
|
&:last-child
|
||||||
|
padding-left 5px
|
||||||
|
|
||||||
|
> svg
|
||||||
|
display block
|
||||||
|
padding 10px
|
||||||
|
width 100%
|
||||||
|
|
||||||
|
> text
|
||||||
|
font-size 5px
|
||||||
|
fill isDark ? rgba(#fff, 0.55) : rgba(#000, 0.55)
|
||||||
|
|
||||||
|
> tspan
|
||||||
|
opacity 0.5
|
||||||
|
|
||||||
|
&:after
|
||||||
|
content ""
|
||||||
|
display block
|
||||||
|
clear both
|
||||||
|
|
||||||
|
.qpdmibaztplkylerhdbllwcokyrfxeyj[data-darkmode]
|
||||||
|
root(true)
|
||||||
|
|
||||||
|
.qpdmibaztplkylerhdbllwcokyrfxeyj:not([data-darkmode])
|
||||||
|
root(false)
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -76,9 +76,15 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.connection.on('stats', this.onStats);
|
this.connection.on('stats', this.onStats);
|
||||||
|
this.connection.on('statsLog', this.onStatsLog);
|
||||||
|
this.connection.send({
|
||||||
|
type: 'requestLog',
|
||||||
|
id: Math.random().toString()
|
||||||
|
});
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.connection.off('stats', this.onStats);
|
this.connection.off('stats', this.onStats);
|
||||||
|
this.connection.off('statsLog', this.onStatsLog);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onStats(stats) {
|
onStats(stats) {
|
||||||
@@ -94,6 +100,9 @@ export default Vue.extend({
|
|||||||
|
|
||||||
this.cpuP = (stats.cpu_usage * 100).toFixed(0);
|
this.cpuP = (stats.cpu_usage * 100).toFixed(0);
|
||||||
this.memP = (stats.mem.used / stats.mem.total * 100).toFixed(0);
|
this.memP = (stats.mem.used / stats.mem.total * 100).toFixed(0);
|
||||||
|
},
|
||||||
|
onStatsLog(statsLog) {
|
||||||
|
statsLog.forEach(stats => this.onStats(stats));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -55,11 +55,11 @@ export default define({
|
|||||||
this.fetching = false;
|
this.fetching = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.connection = (this as any).os.streams.serverStream.getConnection();
|
this.connection = (this as any).os.streams.serverStatsStream.getConnection();
|
||||||
this.connectionId = (this as any).os.streams.serverStream.use();
|
this.connectionId = (this as any).os.streams.serverStatsStream.use();
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
(this as any).os.streams.serverStream.dispose(this.connectionId);
|
(this as any).os.streams.serverStatsStream.dispose(this.connectionId);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggle() {
|
toggle() {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<option value="post-form">%i18n:common.widgets.post-form%</option>
|
<option value="post-form">%i18n:common.widgets.post-form%</option>
|
||||||
<option value="messaging">%i18n:common.widgets.messaging%</option>
|
<option value="messaging">%i18n:common.widgets.messaging%</option>
|
||||||
<option value="memo">%i18n:common.widgets.memo%</option>
|
<option value="memo">%i18n:common.widgets.memo%</option>
|
||||||
|
<option value="posts-monitor">%i18n:common.widgets.posts-monitor%</option>
|
||||||
<option value="server">%i18n:common.widgets.server%</option>
|
<option value="server">%i18n:common.widgets.server%</option>
|
||||||
<option value="donation">%i18n:common.widgets.donation%</option>
|
<option value="donation">%i18n:common.widgets.donation%</option>
|
||||||
<option value="nav">%i18n:common.widgets.nav%</option>
|
<option value="nav">%i18n:common.widgets.nav%</option>
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ root(isDark)
|
|||||||
> .renote
|
> .renote
|
||||||
display flex
|
display flex
|
||||||
align-items center
|
align-items center
|
||||||
padding 8px 16px
|
padding 8px 16px 0 16px
|
||||||
line-height 28px
|
line-height 28px
|
||||||
white-space pre
|
white-space pre
|
||||||
color #9dbb00
|
color #9dbb00
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ export default Vue.extend({
|
|||||||
fetchMoreNotifications() {
|
fetchMoreNotifications() {
|
||||||
this.fetchingMoreNotifications = true;
|
this.fetchingMoreNotifications = true;
|
||||||
|
|
||||||
const max = 30;
|
const max = 20;
|
||||||
|
|
||||||
(this as any).api('i/notifications', {
|
(this as any).api('i/notifications', {
|
||||||
limit: max + 1,
|
limit: max + 1,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<option value="post-form">%i18n:common.widgets.post-form%</option>
|
<option value="post-form">%i18n:common.widgets.post-form%</option>
|
||||||
<option value="messaging">%i18n:common.widgets.messaging%</option>
|
<option value="messaging">%i18n:common.widgets.messaging%</option>
|
||||||
<option value="memo">%i18n:common.widgets.memo%</option>
|
<option value="memo">%i18n:common.widgets.memo%</option>
|
||||||
|
<option value="posts-monitor">%i18n:common.widgets.posts-monitor%</option>
|
||||||
<option value="server">%i18n:common.widgets.server%</option>
|
<option value="server">%i18n:common.widgets.server%</option>
|
||||||
<option value="donation">%i18n:common.widgets.donation%</option>
|
<option value="donation">%i18n:common.widgets.donation%</option>
|
||||||
<option value="nav">%i18n:common.widgets.nav%</option>
|
<option value="nav">%i18n:common.widgets.nav%</option>
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import Progress from './common/scripts/loading';
|
|||||||
import Connection from './common/scripts/streaming/stream';
|
import Connection from './common/scripts/streaming/stream';
|
||||||
import { HomeStreamManager } from './common/scripts/streaming/home';
|
import { HomeStreamManager } from './common/scripts/streaming/home';
|
||||||
import { DriveStreamManager } from './common/scripts/streaming/drive';
|
import { DriveStreamManager } from './common/scripts/streaming/drive';
|
||||||
import { ServerStreamManager } from './common/scripts/streaming/server';
|
import { ServerStatsStreamManager } from './common/scripts/streaming/server-stats';
|
||||||
|
import { NotesStatsStreamManager } from './common/scripts/streaming/notes-stats';
|
||||||
import { MessagingIndexStreamManager } from './common/scripts/streaming/messaging-index';
|
import { MessagingIndexStreamManager } from './common/scripts/streaming/messaging-index';
|
||||||
import { OthelloStreamManager } from './common/scripts/streaming/othello';
|
import { OthelloStreamManager } from './common/scripts/streaming/othello';
|
||||||
|
|
||||||
@@ -104,14 +105,16 @@ export default class MiOS extends EventEmitter {
|
|||||||
localTimelineStream: LocalTimelineStreamManager;
|
localTimelineStream: LocalTimelineStreamManager;
|
||||||
globalTimelineStream: GlobalTimelineStreamManager;
|
globalTimelineStream: GlobalTimelineStreamManager;
|
||||||
driveStream: DriveStreamManager;
|
driveStream: DriveStreamManager;
|
||||||
serverStream: ServerStreamManager;
|
serverStatsStream: ServerStatsStreamManager;
|
||||||
|
notesStatsStream: NotesStatsStreamManager;
|
||||||
messagingIndexStream: MessagingIndexStreamManager;
|
messagingIndexStream: MessagingIndexStreamManager;
|
||||||
othelloStream: OthelloStreamManager;
|
othelloStream: OthelloStreamManager;
|
||||||
} = {
|
} = {
|
||||||
localTimelineStream: null,
|
localTimelineStream: null,
|
||||||
globalTimelineStream: null,
|
globalTimelineStream: null,
|
||||||
driveStream: null,
|
driveStream: null,
|
||||||
serverStream: null,
|
serverStatsStream: null,
|
||||||
|
notesStatsStream: null,
|
||||||
messagingIndexStream: null,
|
messagingIndexStream: null,
|
||||||
othelloStream: null
|
othelloStream: null
|
||||||
};
|
};
|
||||||
@@ -218,7 +221,8 @@ export default class MiOS extends EventEmitter {
|
|||||||
this.store = initStore(this);
|
this.store = initStore(this);
|
||||||
|
|
||||||
//#region Init stream managers
|
//#region Init stream managers
|
||||||
this.streams.serverStream = new ServerStreamManager(this);
|
this.streams.serverStatsStream = new ServerStatsStreamManager(this);
|
||||||
|
this.streams.notesStatsStream = new NotesStatsStreamManager(this);
|
||||||
|
|
||||||
this.once('signedin', () => {
|
this.once('signedin', () => {
|
||||||
// Init home stream manager
|
// Init home stream manager
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
<option value="rss">%i18n:common.widgets.rss%</option>
|
<option value="rss">%i18n:common.widgets.rss%</option>
|
||||||
<option value="photo-stream">%i18n:common.widgets.photo-stream%</option>
|
<option value="photo-stream">%i18n:common.widgets.photo-stream%</option>
|
||||||
<option value="slideshow">%i18n:common.widgets.slideshow%</option>
|
<option value="slideshow">%i18n:common.widgets.slideshow%</option>
|
||||||
|
<option value="posts-monitor">%i18n:common.widgets.posts-monitor%</option>
|
||||||
<option value="version">%i18n:common.widgets.version%</option>
|
<option value="version">%i18n:common.widgets.version%</option>
|
||||||
<option value="server">%i18n:common.widgets.server%</option>
|
<option value="server">%i18n:common.widgets.server%</option>
|
||||||
<option value="memo">%i18n:common.widgets.memo%</option>
|
<option value="memo">%i18n:common.widgets.memo%</option>
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ const uri = u && p
|
|||||||
*/
|
*/
|
||||||
import mongo from 'monk';
|
import mongo from 'monk';
|
||||||
|
|
||||||
const db = mongo(uri);
|
const db = mongo(uri, {
|
||||||
|
poolSize: 16,
|
||||||
|
keepAlive: 1
|
||||||
|
});
|
||||||
|
|
||||||
export default db;
|
export default db;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ import ProgressBar from './utils/cli/progressbar';
|
|||||||
import EnvironmentInfo from './utils/environmentInfo';
|
import EnvironmentInfo from './utils/environmentInfo';
|
||||||
import MachineInfo from './utils/machineInfo';
|
import MachineInfo from './utils/machineInfo';
|
||||||
import DependencyInfo from './utils/dependencyInfo';
|
import DependencyInfo from './utils/dependencyInfo';
|
||||||
import stats from './utils/stats';
|
import serverStats from './server-stats';
|
||||||
|
import notesStats from './notes-stats';
|
||||||
|
|
||||||
import loadConfig from './config/load';
|
import loadConfig from './config/load';
|
||||||
import { Config } from './config/types';
|
import { Config } from './config/types';
|
||||||
@@ -49,7 +50,8 @@ function main() {
|
|||||||
masterMain(opt);
|
masterMain(opt);
|
||||||
|
|
||||||
ev.mount();
|
ev.mount();
|
||||||
stats();
|
serverStats();
|
||||||
|
notesStats();
|
||||||
} else {
|
} else {
|
||||||
workerMain(opt);
|
workerMain(opt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ import Following from './following';
|
|||||||
const Note = db.get<INote>('notes');
|
const Note = db.get<INote>('notes');
|
||||||
Note.createIndex('uri', { sparse: true, unique: true });
|
Note.createIndex('uri', { sparse: true, unique: true });
|
||||||
Note.createIndex('userId');
|
Note.createIndex('userId');
|
||||||
|
Note.createIndex({
|
||||||
|
createdAt: -1
|
||||||
|
});
|
||||||
export default Note;
|
export default Note;
|
||||||
|
|
||||||
export function isValidText(text: string): boolean {
|
export function isValidText(text: string): boolean {
|
||||||
|
|||||||
20
src/notes-stats-child.ts
Normal file
20
src/notes-stats-child.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import Note from './models/note';
|
||||||
|
|
||||||
|
setInterval(async () => {
|
||||||
|
const [all, local] = await Promise.all([Note.count({
|
||||||
|
createdAt: {
|
||||||
|
$gte: new Date(Date.now() - 3000)
|
||||||
|
}
|
||||||
|
}), Note.count({
|
||||||
|
createdAt: {
|
||||||
|
$gte: new Date(Date.now() - 3000)
|
||||||
|
},
|
||||||
|
'_user.host': null
|
||||||
|
})]);
|
||||||
|
|
||||||
|
const stats = {
|
||||||
|
all, local
|
||||||
|
};
|
||||||
|
|
||||||
|
process.send(stats);
|
||||||
|
}, 3000);
|
||||||
20
src/notes-stats.ts
Normal file
20
src/notes-stats.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import * as childProcess from 'child_process';
|
||||||
|
import Xev from 'xev';
|
||||||
|
|
||||||
|
const ev = new Xev();
|
||||||
|
|
||||||
|
export default function() {
|
||||||
|
const log = [];
|
||||||
|
|
||||||
|
const p = childProcess.fork(__dirname + '/notes-stats-child.js');
|
||||||
|
|
||||||
|
p.on('message', stats => {
|
||||||
|
ev.emit('notesStats', stats);
|
||||||
|
log.push(stats);
|
||||||
|
if (log.length > 100) log.shift();
|
||||||
|
});
|
||||||
|
|
||||||
|
ev.on('requestNotesStatsLog', id => {
|
||||||
|
ev.emit('notesStatsLog:' + id, log);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -6,13 +6,19 @@ import Xev from 'xev';
|
|||||||
const ev = new Xev();
|
const ev = new Xev();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report stats regularly
|
* Report server stats regularly
|
||||||
*/
|
*/
|
||||||
export default function() {
|
export default function() {
|
||||||
|
const log = [];
|
||||||
|
|
||||||
|
ev.on('requestServerStatsLog', id => {
|
||||||
|
ev.emit('serverStatsLog:' + id, log);
|
||||||
|
});
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
osUtils.cpuUsage(cpuUsage => {
|
osUtils.cpuUsage(cpuUsage => {
|
||||||
const disk = diskusage.checkSync(os.platform() == 'win32' ? 'c:' : '/');
|
const disk = diskusage.checkSync(os.platform() == 'win32' ? 'c:' : '/');
|
||||||
ev.emit('stats', {
|
const stats = {
|
||||||
cpu_usage: cpuUsage,
|
cpu_usage: cpuUsage,
|
||||||
mem: {
|
mem: {
|
||||||
total: os.totalmem(),
|
total: os.totalmem(),
|
||||||
@@ -21,7 +27,10 @@ export default function() {
|
|||||||
disk,
|
disk,
|
||||||
os_uptime: os.uptime(),
|
os_uptime: os.uptime(),
|
||||||
process_uptime: process.uptime()
|
process_uptime: process.uptime()
|
||||||
});
|
};
|
||||||
|
ev.emit('serverStats', stats);
|
||||||
|
log.push(stats);
|
||||||
|
if (log.length > 50) log.shift();
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res
|
|||||||
}
|
}
|
||||||
|
|
||||||
// テキストが無いかつ添付ファイルが無いかつRenoteも無いかつ投票も無かったらエラー
|
// テキストが無いかつ添付ファイルが無いかつRenoteも無いかつ投票も無かったらエラー
|
||||||
if (text === undefined && files === null && renote === null && poll === undefined) {
|
if ((text === undefined || text === null) && files === null && renote === null && poll === undefined) {
|
||||||
return rej('text, mediaIds, renoteId or poll is required');
|
return rej('text, mediaIds, renoteId or poll is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
35
src/server/api/stream/notes-stats.ts
Normal file
35
src/server/api/stream/notes-stats.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import * as websocket from 'websocket';
|
||||||
|
import Xev from 'xev';
|
||||||
|
|
||||||
|
const ev = new Xev();
|
||||||
|
|
||||||
|
export default function(request: websocket.request, connection: websocket.connection): void {
|
||||||
|
const onStats = stats => {
|
||||||
|
connection.send(JSON.stringify({
|
||||||
|
type: 'stats',
|
||||||
|
body: stats
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
connection.on('message', async data => {
|
||||||
|
const msg = JSON.parse(data.utf8Data);
|
||||||
|
|
||||||
|
switch (msg.type) {
|
||||||
|
case 'requestLog':
|
||||||
|
ev.once('notesStatsLog:' + msg.id, statsLog => {
|
||||||
|
connection.send(JSON.stringify({
|
||||||
|
type: 'statsLog',
|
||||||
|
body: statsLog
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
ev.emit('requestNotesStatsLog', msg.id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ev.addListener('notesStats', onStats);
|
||||||
|
|
||||||
|
connection.on('close', () => {
|
||||||
|
ev.removeListener('notesStats', onStats);
|
||||||
|
});
|
||||||
|
}
|
||||||
35
src/server/api/stream/server-stats.ts
Normal file
35
src/server/api/stream/server-stats.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import * as websocket from 'websocket';
|
||||||
|
import Xev from 'xev';
|
||||||
|
|
||||||
|
const ev = new Xev();
|
||||||
|
|
||||||
|
export default function(request: websocket.request, connection: websocket.connection): void {
|
||||||
|
const onStats = stats => {
|
||||||
|
connection.send(JSON.stringify({
|
||||||
|
type: 'stats',
|
||||||
|
body: stats
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
connection.on('message', async data => {
|
||||||
|
const msg = JSON.parse(data.utf8Data);
|
||||||
|
|
||||||
|
switch (msg.type) {
|
||||||
|
case 'requestLog':
|
||||||
|
ev.once('serverStatsLog:' + msg.id, statsLog => {
|
||||||
|
connection.send(JSON.stringify({
|
||||||
|
type: 'statsLog',
|
||||||
|
body: statsLog
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
ev.emit('requestServerStatsLog', msg.id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ev.addListener('serverStats', onStats);
|
||||||
|
|
||||||
|
connection.on('close', () => {
|
||||||
|
ev.removeListener('serverStats', onStats);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import * as websocket from 'websocket';
|
|
||||||
import Xev from 'xev';
|
|
||||||
|
|
||||||
const ev = new Xev();
|
|
||||||
|
|
||||||
export default function(request: websocket.request, connection: websocket.connection): void {
|
|
||||||
const onStats = stats => {
|
|
||||||
connection.send(JSON.stringify({
|
|
||||||
type: 'stats',
|
|
||||||
body: stats
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
ev.addListener('stats', onStats);
|
|
||||||
|
|
||||||
connection.on('close', () => {
|
|
||||||
ev.removeListener('stats', onStats);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,8 @@ import messagingStream from './stream/messaging';
|
|||||||
import messagingIndexStream from './stream/messaging-index';
|
import messagingIndexStream from './stream/messaging-index';
|
||||||
import othelloGameStream from './stream/othello-game';
|
import othelloGameStream from './stream/othello-game';
|
||||||
import othelloStream from './stream/othello';
|
import othelloStream from './stream/othello';
|
||||||
import serverStream from './stream/server';
|
import serverStatsStream from './stream/server-stats';
|
||||||
|
import notesStatsStream from './stream/notes-stats';
|
||||||
import requestsStream from './stream/requests';
|
import requestsStream from './stream/requests';
|
||||||
import { ParsedUrlQuery } from 'querystring';
|
import { ParsedUrlQuery } from 'querystring';
|
||||||
import authenticate from './authenticate';
|
import authenticate from './authenticate';
|
||||||
@@ -28,8 +29,13 @@ module.exports = (server: http.Server) => {
|
|||||||
ws.on('request', async (request) => {
|
ws.on('request', async (request) => {
|
||||||
const connection = request.accept();
|
const connection = request.accept();
|
||||||
|
|
||||||
if (request.resourceURL.pathname === '/server') {
|
if (request.resourceURL.pathname === '/server-stats') {
|
||||||
serverStream(request, connection);
|
serverStatsStream(request, connection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.resourceURL.pathname === '/notes-stats') {
|
||||||
|
notesStatsStream(request, connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,8 +164,8 @@ export default async function(
|
|||||||
'metadata.deletedAt': { $exists: false }
|
'metadata.deletedAt': { $exists: false }
|
||||||
});
|
});
|
||||||
|
|
||||||
if (much !== null) {
|
if (much) {
|
||||||
log('file with same hash is found');
|
log(`file with same hash is found: ${much._id}`);
|
||||||
return much;
|
return much;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user