Browse Source

Patch values instead of replacing charts.js

pull/23/head
Weilbyte 5 years ago
parent
commit
bea1a0aa2e
No known key found for this signature in database GPG Key ID: BB87B2C8A1468388
  1. 7
      PVEDiscordDark.py
  2. 10
      PVEDiscordDark/js/PVEDiscordDark.js
  3. 22013
      PVEDiscordDark/js/charts.js

7
PVEDiscordDark.py

@ -71,7 +71,7 @@ def themeIsInstalled():
tplFile = open('/usr/share/pve-manager/index.html.tpl') tplFile = open('/usr/share/pve-manager/index.html.tpl')
tplLines = tplFile.readlines() tplLines = tplFile.readlines()
for line in tplLines: for line in tplLines:
if "<link rel='stylesheet' type='text/css' href='/pve2/css/dd_style.css'>" in line: if ("<link rel='stylesheet' type='text/css' href='/pve2/css/dd_style.css'>" in line or "<script type='text/javascript' src='/pve2/js/dd_patcher.js'></script>" in line):
tplUsesTheme = True tplUsesTheme = True
if (os.path.isfile('/usr/share/pve-manager/css/dd_style.css') or tplUsesTheme): if (os.path.isfile('/usr/share/pve-manager/css/dd_style.css') or tplUsesTheme):
return True return True
@ -91,11 +91,6 @@ def installTheme():
with open('/usr/share/pve-manager/index.html.tpl', 'a') as tplFile: with open('/usr/share/pve-manager/index.html.tpl', 'a') as tplFile:
tplFile.write("<link rel='stylesheet' type='text/css' href='/pve2/css/dd_style.css'>") tplFile.write("<link rel='stylesheet' type='text/css' href='/pve2/css/dd_style.css'>")
tplFile.write("<script type='text/javascript' src='/pve2/js/dd_patcher.js'></script>") tplFile.write("<script type='text/javascript' src='/pve2/js/dd_patcher.js'></script>")
cprint(colors.NORMAL, 'Replacing charts.js..')
if os.path.exists('/usr/share/javascript/extjs/charts.js'):
shutil.copyfile('/usr/share/javascript/extjs/charts.js', '/usr/share/javascript/extjs/charts.js.bak')
os.remove('/usr/share/javascript/extjs/charts.js')
urllib.request.urlretrieve(f'{baseURL}/PVEDiscordDark/js/charts.js', '/usr/share/javascript/extjs/charts.js')
for index, image in enumerate(images): for index, image in enumerate(images):
cprint(colors.NORMAL, f'Downloading images [{index + 1}/{len(images)}]..\r', False, True) cprint(colors.NORMAL, f'Downloading images [{index + 1}/{len(images)}]..\r', False, True)
urllib.request.urlretrieve(f'{baseURL}/PVEDiscordDark/images/{image}', f'/usr/share/pve-manager/images/{image}') urllib.request.urlretrieve(f'{baseURL}/PVEDiscordDark/images/{image}', f'/usr/share/pve-manager/images/{image}')

10
PVEDiscordDark/js/PVEDiscordDark.js

@ -19,6 +19,15 @@ const swapLogo = async function() {
}; };
}; };
const patchCharts = function() {
Ext.chart.theme.Base.prototype.config.chart.defaults.background = '#23272a';
Ext.chart.theme.Base.prototype.config.axis.defaults.label.color = 'white';
Ext.chart.theme.Base.prototype.config.axis.defaults.title.color = 'white';
Ext.chart.theme.Base.prototype.config.axis.defaults.style.strokeStyle = '#7289DA';
Ext.chart.theme.Base.prototype.config.axis.defaults.grid.strokeStyle = 'rgba(44, 47, 51, 1)';
Ext.chart.theme.Base.prototype.config.sprites.text.color = 'white';
};
function patchGaugeWidget() { function patchGaugeWidget() {
Proxmox.panel.GaugeWidget.prototype.backgroundColor = '#2C2F33'; Proxmox.panel.GaugeWidget.prototype.backgroundColor = '#2C2F33';
Proxmox.panel.GaugeWidget.prototype.criticalColor = '#f04747'; Proxmox.panel.GaugeWidget.prototype.criticalColor = '#f04747';
@ -169,6 +178,7 @@ function patchSubscription() {
} }
swapLogo(); swapLogo();
patchCharts();
patchGaugeWidget(); patchGaugeWidget();
patchBackupConfig(); patchBackupConfig();
patchDiskSmartWindow(); patchDiskSmartWindow();

22013
PVEDiscordDark/js/charts.js

File diff suppressed because it is too large
Loading…
Cancel
Save