diff --git a/class/core/config_api.py b/class/core/config_api.py index 1872208e6..0b40f4431 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -312,6 +312,8 @@ class config_api: else: data['ssl'] = '' + data['site_count'] = public.M('sites').count() + data['username'] = public.M('users').where( "id=?", (1,)).getField('username') diff --git a/plugins/csvn/index.py b/plugins/csvn/index.py index d6e01a508..103827569 100755 --- a/plugins/csvn/index.py +++ b/plugins/csvn/index.py @@ -640,6 +640,21 @@ def projectScriptDebug(): return public.getJson(data) +def getTotalStatistics(): + st = status() + data = {} + if st == 'start': + svn_path = getServerDir() + '/data/repositories' + data['status'] = True + data['count'] = len(os.listdir(svn_path)) + data['ver'] = public.readFile(getServerDir() + '/version.pl').strip() + return public.returnJson(True, 'ok', data) + else: + data['status'] = False + data['count'] = 0 + return public.returnJson(False, 'fail', data) + + if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -688,5 +703,7 @@ if __name__ == "__main__": print projectScriptEdit() elif func == 'project_script_debug': print projectScriptDebug() + elif func == 'get_total_statistics': + print getTotalStatistics() else: print 'fail' diff --git a/plugins/gogs/index.py b/plugins/gogs/index.py index c46db4ec2..5ee118c39 100755 --- a/plugins/gogs/index.py +++ b/plugins/gogs/index.py @@ -573,6 +573,20 @@ def gogsEdit(): data['commit'] = getPluginDir() + '/hook/commit.tpl' return public.getJson(data) + +def getTotalStatistics(): + st = status() + data = {} + if st == 'start': + data['status'] = True + data['count'] = 1 + data['ver'] = public.readFile(getServerDir() + '/version.pl').strip() + return public.returnJson(True, 'ok', data) + else: + data['status'] = False + data['count'] = 0 + return public.returnJson(False, 'fail', data) + if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -617,5 +631,7 @@ if __name__ == "__main__": print projectScriptDebug() elif func == 'gogs_edit': print gogsEdit() + elif func == 'get_total_statistics': + print getTotalStatistics() else: print 'fail' diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index e5d8f8c93..e14bc3344 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -777,6 +777,7 @@ def getDbAccess(): userStr = ','.join(accs) return public.returnJson(True, userStr) + def toSize(size): d = ('b', 'KB', 'MB', 'GB', 'TB') s = d[0] @@ -786,9 +787,10 @@ def toSize(size): size = size / 1024 s = b _size = round(size, 2) - print size,_size + print size, _size return str(size) + ' ' + b + def setDbAccess(): args = getArgs() data = checkArgs(args, ['username', 'access']) @@ -856,7 +858,7 @@ def getDbInfo(): ret2['type'] = table[0][1] ret2['rows_count'] = table[0][4] ret2['collation'] = table[0][14] - data_size = table[0][6]+table[0][8] + data_size = table[0][6] + table[0][8] ret2['data_byte'] = data_size ret2['data_size'] = public.toSize(data_size) ret2['table_name'] = i[0] @@ -941,6 +943,21 @@ def alterTable(): return public.returnJson(True, "更改成功!") return public.returnJson(False, "更改失败!") + +def getTotalStatistics(): + st = status() + data = {} + if st == 'start': + data['status'] = True + data['count'] = pSqliteDb('databases').count() + data['ver'] = public.readFile(getServerDir() + '/version.pl').strip() + return public.returnJson(True, 'ok', data) + else: + data['status'] = False + data['count'] = 0 + return public.returnJson(False, 'fail', data) + + if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -1005,5 +1022,7 @@ if __name__ == "__main__": print optTable() elif func == 'alter_table': print alterTable() + elif func == 'get_total_statistics': + print getTotalStatistics() else: print 'error' diff --git a/route/static/app/index.js b/route/static/app/index.js index efda0cc39..ac198b35c 100755 --- a/route/static/app/index.js +++ b/route/static/app/index.js @@ -850,3 +850,29 @@ function showDanger(num, port) { }); $(".showDanger td").css("padding", "8px") } + +//加载关键数据总数 +loadKeyDataCount(); +function loadKeyDataCount(){ + var plist = ['mysql', 'csvn', 'gogs']; + for (var i = 0; i < plist.length; i++) { + pname = plist[i]; + function call(pname){ + $.post('/plugins/run', {name:pname, func:'get_total_statistics'}, function(data) { + try { + var rdata = $.parseJSON(data['data']); + } catch(e){ + return; + } + if (!rdata['status']){ + return; + } + var html = '
'+pname+'
\ +