Skip to content

Commit

Permalink
Add version compare to disable older Nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSin- committed Aug 31, 2020
1 parent 68887b1 commit afb80d7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"ajv": "^6.12.4",
"angular-svg-round-progressbar": "^4.0.0",
"compare-versions": "^3.6.0",
"electron-store": "^6.0.0",
"got": "^11.5.2",
"lodash": "^4.17.20",
Expand Down
8 changes: 5 additions & 3 deletions src/app/config/no-config/no-config.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

import { ElectronService } from 'ngx-electron';
import compareVersions from 'compare-versions';

import { Config, ConfigService } from '../config.service';

Expand All @@ -22,11 +23,12 @@ export class NoConfigComponent implements OnInit {
public configSaved: string;

public objectvalues = Object.values;
private octoprintMinVers: string = '1.3.5';
public octoprintNodes: any = {
'other': {
'display': 'Other (> 1.4.0)',
'display': 'Other (> ' + this.octoprintMinVers + ')',
'name': 'other',
'version': '1.4.0',
'version': this.octoprintMinVers,
'url': 'other',
'disable': false
}
Expand Down Expand Up @@ -162,7 +164,7 @@ export class NoConfigComponent implements OnInit {
'version': service.txtRecord.version,
'url': service.host.replace(/\.$/, '') + ":" + service.port + service.txtRecord.path.replace(/\/$/, '') + "/api/",
// Compare version to make sure it meets the requirement
'disable': false
'disable': (compareVersions(this.octoprintMinVers, service.txtRecord.version) == -1 ? true : false)
};

this.octoprintNodes[service.host.replace(/\.$/, '').replace('.', '_')] = node;
Expand Down

0 comments on commit afb80d7

Please sign in to comment.