From c96d688a9c2fdf6abafcbb5b6ed6c0ae4efc110d Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Thu, 29 Apr 2021 08:12:44 +0000 Subject: [PATCH] add alert if new trmm version available #453 --- api/tacticalrmm/core/views.py | 3 +++ api/tacticalrmm/tacticalrmm/utils.py | 17 +++++++++++++++++ web/src/views/Dashboard.vue | 16 +++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/api/tacticalrmm/core/views.py b/api/tacticalrmm/core/views.py index bae96036..025ec5d7 100644 --- a/api/tacticalrmm/core/views.py +++ b/api/tacticalrmm/core/views.py @@ -62,9 +62,12 @@ def version(request): @api_view() def dashboard_info(request): + from tacticalrmm.utils import get_latest_trmm_ver + return Response( { "trmm_version": settings.TRMM_VERSION, + "latest_trmm_ver": get_latest_trmm_ver(), "dark_mode": request.user.dark_mode, "show_community_scripts": request.user.show_community_scripts, "dbl_click_action": request.user.agent_dblclick_action, diff --git a/api/tacticalrmm/tacticalrmm/utils.py b/api/tacticalrmm/tacticalrmm/utils.py index 72fea20d..c8af6d53 100644 --- a/api/tacticalrmm/tacticalrmm/utils.py +++ b/api/tacticalrmm/tacticalrmm/utils.py @@ -263,3 +263,20 @@ def run_nats_api_cmd(mode: str, ids: list[str], timeout: int = 30) -> None: subprocess.run(cmd, capture_output=True, timeout=timeout) except Exception as e: logger.error(e) + + +def get_latest_trmm_ver() -> str: + url = "https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/api/tacticalrmm/tacticalrmm/settings.py" + try: + r = requests.get(url, timeout=5) + except: + return "error" + + try: + for line in r.text.splitlines(): + if "TRMM_VERSION" in line: + return line.split(" ")[2].strip('"') + except Exception as e: + logger.error(e) + + return "error" diff --git a/web/src/views/Dashboard.vue b/web/src/views/Dashboard.vue index 9c16bf1b..e9b36e93 100644 --- a/web/src/views/Dashboard.vue +++ b/web/src/views/Dashboard.vue @@ -8,7 +8,14 @@ - Tactical RMM   v{{ currentTRMMVersion }} + Tactical RMMv{{ currentTRMMVersion }} + v{{ latestTRMMVersion }} available @@ -411,6 +418,7 @@ export default { filterChecksFailing: false, filterRebootNeeded: false, currentTRMMVersion: null, + latestTRMMVersion: "error", showUserPreferencesModal: false, columns: [ { @@ -719,6 +727,7 @@ export default { this.darkMode = r.data.dark_mode; this.$q.dark.set(this.darkMode); this.currentTRMMVersion = r.data.trmm_version; + this.latestTRMMVersion = r.data.latest_trmm_ver; this.$store.commit("SET_AGENT_DBLCLICK_ACTION", r.data.dbl_click_action); this.$store.commit("setShowCommunityScripts", r.data.show_community_scripts); this.$store.commit("SET_NO_CODE_SIGN", r.data.no_code_sign); @@ -805,6 +814,11 @@ export default { clients: state => state.clients, }), ...mapGetters(["selectedAgentPk", "needRefresh", "clientTreeSplitterModel"]), + latestReleaseURL() { + return this.latestTRMMVersion !== "error" + ? `https://github.com/wh1te909/tacticalrmm/releases/tag/v${this.latestTRMMVersion}` + : ""; + }, wsUrl() { return getBaseUrl().split("://")[1]; },