From bc17a0b2cb3e789d79e277ecd64a10ae1ac2e7a5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 20 Feb 2018 07:56:39 +0900 Subject: [PATCH] wip --- src/web/app/common/scripts/bytes-to-size.ts | 6 - .../app/desktop/-tags/home-widgets/server.tag | 533 ------------------ .../components/widgets/server.cpu-memory.vue | 127 +++++ .../views/components/widgets/server.cpu.vue | 68 +++ .../views/components/widgets/server.disk.vue | 76 +++ .../views/components/widgets/server.info.vue | 25 + .../components/widgets/server.memory.vue | 76 +++ .../views/components/widgets/server.pie.vue | 61 ++ .../components/widgets/server.uptimes.vue | 46 ++ .../views/components/widgets/server.vue | 127 +++++ src/web/app/filters/bytes.ts | 8 + src/web/app/filters/index.ts | 1 + src/web/app/init.ts | 3 + 13 files changed, 618 insertions(+), 539 deletions(-) delete mode 100644 src/web/app/common/scripts/bytes-to-size.ts delete mode 100644 src/web/app/desktop/-tags/home-widgets/server.tag create mode 100644 src/web/app/desktop/views/components/widgets/server.cpu-memory.vue create mode 100644 src/web/app/desktop/views/components/widgets/server.cpu.vue create mode 100644 src/web/app/desktop/views/components/widgets/server.disk.vue create mode 100644 src/web/app/desktop/views/components/widgets/server.info.vue create mode 100644 src/web/app/desktop/views/components/widgets/server.memory.vue create mode 100644 src/web/app/desktop/views/components/widgets/server.pie.vue create mode 100644 src/web/app/desktop/views/components/widgets/server.uptimes.vue create mode 100644 src/web/app/desktop/views/components/widgets/server.vue create mode 100644 src/web/app/filters/bytes.ts create mode 100644 src/web/app/filters/index.ts diff --git a/src/web/app/common/scripts/bytes-to-size.ts b/src/web/app/common/scripts/bytes-to-size.ts deleted file mode 100644 index 1d2b1e7ce..000000000 --- a/src/web/app/common/scripts/bytes-to-size.ts +++ /dev/null @@ -1,6 +0,0 @@ -export default (bytes, digits = 0) => { - const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; - if (bytes == 0) return '0Byte'; - const i = Math.floor(Math.log(bytes) / Math.log(1024)); - return (bytes / Math.pow(1024, i)).toFixed(digits).replace(/\.0+$/, '') + sizes[i]; -}; diff --git a/src/web/app/desktop/-tags/home-widgets/server.tag b/src/web/app/desktop/-tags/home-widgets/server.tag deleted file mode 100644 index 992517163..000000000 --- a/src/web/app/desktop/-tags/home-widgets/server.tag +++ /dev/null @@ -1,533 +0,0 @@ - - -

%fa:spinner .pulse .fw%%i18n:common.loading%

- - - - - - - - -
- - - - - - - - - - - - - - - - - CPU { cpuP }% - - - - - - - - - - - - - - - - MEM { memP }% - - - - - - - -
-

%fa:microchip%CPU

-

{ cores } Cores

-

{ model }

-
- - -
- - - -
-

%fa:flask%Memory

-

Total: { bytesToSize(total, 1) }

-

Used: { bytesToSize(used, 1) }

-

Free: { bytesToSize(free, 1) }

-
- - -
- - - -
-

%fa:R hdd%Storage

-

Total: { bytesToSize(total, 1) }

-

Available: { bytesToSize(available, 1) }

-

Used: { bytesToSize(used, 1) }

-
- - -
- - -

Uptimes

-

Process: { process ? process.toFixed(0) : '---' }s

-

OS: { os ? os.toFixed(0) : '---' }s

- - -
- - -

Maintainer: { meta.maintainer }

-

Machine: { meta.machine }

-

Node: { meta.node }

- - -
- - - - - - { (p * 100).toFixed(0) }% - - - - diff --git a/src/web/app/desktop/views/components/widgets/server.cpu-memory.vue b/src/web/app/desktop/views/components/widgets/server.cpu-memory.vue new file mode 100644 index 000000000..00b3dc3af --- /dev/null +++ b/src/web/app/desktop/views/components/widgets/server.cpu-memory.vue @@ -0,0 +1,127 @@ + + + + + diff --git a/src/web/app/desktop/views/components/widgets/server.cpu.vue b/src/web/app/desktop/views/components/widgets/server.cpu.vue new file mode 100644 index 000000000..337ff62ce --- /dev/null +++ b/src/web/app/desktop/views/components/widgets/server.cpu.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/src/web/app/desktop/views/components/widgets/server.disk.vue b/src/web/app/desktop/views/components/widgets/server.disk.vue new file mode 100644 index 000000000..c21c56290 --- /dev/null +++ b/src/web/app/desktop/views/components/widgets/server.disk.vue @@ -0,0 +1,76 @@ + + + + + diff --git a/src/web/app/desktop/views/components/widgets/server.info.vue b/src/web/app/desktop/views/components/widgets/server.info.vue new file mode 100644 index 000000000..870baf149 --- /dev/null +++ b/src/web/app/desktop/views/components/widgets/server.info.vue @@ -0,0 +1,25 @@ + + + + + diff --git a/src/web/app/desktop/views/components/widgets/server.memory.vue b/src/web/app/desktop/views/components/widgets/server.memory.vue new file mode 100644 index 000000000..2afc627fd --- /dev/null +++ b/src/web/app/desktop/views/components/widgets/server.memory.vue @@ -0,0 +1,76 @@ + + + + + diff --git a/src/web/app/desktop/views/components/widgets/server.pie.vue b/src/web/app/desktop/views/components/widgets/server.pie.vue new file mode 100644 index 000000000..45ca8101b --- /dev/null +++ b/src/web/app/desktop/views/components/widgets/server.pie.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/src/web/app/desktop/views/components/widgets/server.uptimes.vue b/src/web/app/desktop/views/components/widgets/server.uptimes.vue new file mode 100644 index 000000000..06713d83c --- /dev/null +++ b/src/web/app/desktop/views/components/widgets/server.uptimes.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/src/web/app/desktop/views/components/widgets/server.vue b/src/web/app/desktop/views/components/widgets/server.vue new file mode 100644 index 000000000..5aa01fd4e --- /dev/null +++ b/src/web/app/desktop/views/components/widgets/server.vue @@ -0,0 +1,127 @@ + + + + + diff --git a/src/web/app/filters/bytes.ts b/src/web/app/filters/bytes.ts new file mode 100644 index 000000000..3afb11e9a --- /dev/null +++ b/src/web/app/filters/bytes.ts @@ -0,0 +1,8 @@ +import Vue from 'vue'; + +Vue.filter('bytes', (v, digits = 0) => { + const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; + if (v == 0) return '0Byte'; + const i = Math.floor(Math.log(v) / Math.log(1024)); + return (v / Math.pow(1024, i)).toFixed(digits).replace(/\.0+$/, '') + sizes[i]; +}); diff --git a/src/web/app/filters/index.ts b/src/web/app/filters/index.ts new file mode 100644 index 000000000..16ff8c87a --- /dev/null +++ b/src/web/app/filters/index.ts @@ -0,0 +1 @@ +require('./bytes'); diff --git a/src/web/app/init.ts b/src/web/app/init.ts index 8abb7f7aa..c3eede0d3 100644 --- a/src/web/app/init.ts +++ b/src/web/app/init.ts @@ -20,6 +20,9 @@ require('./common/views/directives'); // Register global components require('./common/views/components'); +// Register global filters +require('./filters'); + Vue.mixin({ destroyed(this: any) { if (this.$el.parentNode) {