Skip to content

Commit

Permalink
Usage plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmalloy committed Feb 13, 2024
1 parent cd6e979 commit dcd9ea7
Showing 1 changed file with 149 additions and 0 deletions.
149 changes: 149 additions & 0 deletions src/app/mods/system.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { FormlyFieldConfig } from '@ngx-formly/core';
import { Schema } from 'jtd';
import * as moment from 'moment';
import { Plugin } from '../model/plugin';
import { Mod } from '../model/tag';
Expand All @@ -20,8 +22,155 @@ const systemPlugin: Plugin = {
},
};

const systemUsagePlugin: Plugin = {
tag: '_plugin/system/usage',
name: $localize`📟️ System Usage`,
config: {
mod: $localize`📟️ System`,
generated: 'Generated by jasper-ui ' + moment().toISOString(),
submitChild: $localize`📊️ usage`,
description: $localize`View system usage and limits.`,
// language=CSS
css: `
._plugin-system.ui > .md {
display: inline-block;
padding: 10px;
border-radius: 8px;
background-color: var(--bg-accent);
backdrop-filter: blur(1px);
box-shadow: 0 0 4px 2px rgba(0, 0, 0, 0.1);
}
`,
// language=Handlebars
ui: `
### Usage
| | | Used | Limit |
|--|:--:|--:|--:|
| Ref | <progress value="{{usage.ref}}" max="{{usage.limit.ref}}"></progress> | {{usage.ref}} | {{usage.limit.ref}} |
| Ext | <progress value="{{usage.ext}}" max="{{usage.limit.ext}}"></progress> | {{usage.ext}} | {{usage.limit.ext}} |
| User | <progress value="{{usage.user}}" max="{{usage.limit.user}}"></progress> | {{usage.user}} | {{usage.limit.user}} |
| Plugin | <progress value="{{usage.plugin}}" max="{{usage.limit.plugin}}"></progress> | {{usage.plugin}} | {{usage.limit.plugin}} |
| Template | <progress value="{{usage.template}}" max="{{usage.limit.template}}"></progress> | {{usage.template}} | {{usage.limit.template}} |
### Size
| | | Used | Limit |
|--|:--:|--:|--:|
| Ref | <progress value="{{size.ref}}" max="{{size.limit.ref}}"></progress> | {{size.ref}} | {{size.limit.ref}} |
| Ext | <progress value="{{size.ext}}" max="{{size.limit.ext}}"></progress> | {{size.ext}} | {{size.limit.ext}} |
| User | <progress value="{{size.user}}" max="{{size.limit.user}}"></progress> | {{size.user}} | {{size.limit.user}} |
| Plugin | <progress value="{{size.plugin}}" max="{{size.limit.plugin}}"></progress> | {{size.plugin}} | {{size.limit.plugin}} |
| Template | <progress value="{{size.template}}" max="{{size.limit.template}}"></progress> | {{size.template}} | {{size.limit.template}} |
`,
form: [{
key: 'usage',
props: {
label: $localize`Usage`,
},
fieldGroup: quotaForm(),
}, {
key: 'size',
props: {
label: $localize`Size`,
},
fieldGroup: quotaForm(),
}],
},
schema: {
optionalProperties: {
usage: quotaSchema(),
size: quotaSchema(),
}
}
};

function quotaSchema(): Schema {
return {
optionalProperties: {
ref: {type: 'uint32'},
ext: {type: 'uint32'},
user: {type: 'uint32'},
plugin: {type: 'uint32'},
template: {type: 'uint32'},
limit: {
optionalProperties: {
ref: {type: 'uint32'},
ext: {type: 'uint32'},
user: {type: 'uint32'},
plugin: {type: 'uint32'},
template: {type: 'uint32'},
},
},
},
};
}

function quotaForm(): FormlyFieldConfig[] {
return [{
key: 'ref',
type: 'number',
props: {
label: $localize`Refs:`,
}
}, {
key: 'limit.ref',
type: 'number',
props: {
label: $localize`Limit:`,
}
}, {
key: 'ext',
type: 'number',
props: {
label: $localize`Exts:`,
}
}, {
key: 'limit.ext',
type: 'number',
props: {
label: $localize`Limit:`,
}
}, {
key: 'user',
type: 'number',
props: {
label: $localize`Users:`,
}
}, {
key: 'limit.user',
type: 'number',
props: {
label: $localize`Limit:`,
}
}, {
key: 'plugin',
type: 'number',
props: {
label: $localize`Plugins:`,
}
}, {
key: 'limit.plugin',
type: 'number',
props: {
label: $localize`Limit:`,
}
}, {
key: 'template',
type: 'number',
props: {
label: $localize`Templates:`,
}
}, {
key: 'limit.template',
type: 'number',
props: {
label: $localize`Limit:`,
}
}];
}

export const systemMod: Mod = {
plugins: {
system: systemPlugin,
systemUsagePlugin: systemUsagePlugin,
},
}

0 comments on commit dcd9ea7

Please sign in to comment.