From 2792b935a1884aa6d1262a34cca8aa05e6fb4e13 Mon Sep 17 00:00:00 2001 From: Max Murphy Date: Fri, 18 Aug 2017 11:09:47 -0700 Subject: [PATCH] version bump -Changed port number used -Moved sample_db.sqlite location to persist after upgrading app --- .gitignore | 2 ++ README.md | 11 +++++++++- src/electron/main.js | 9 +++++---- src/electron/package.json | 2 +- src/sample-db-app/package.json | 2 +- .../src/app/guards/location-exists.ts | 2 +- src/sample-db-app/src/app/services/bulk.ts | 2 +- .../src/app/services/location.ts | 2 +- src/sample-db-app/src/app/services/logging.ts | 2 +- src/sample-db-app/src/app/services/plate.ts | 2 +- src/sample-db-app/src/app/services/search.ts | 2 +- .../src/app/services/specimen-type.ts | 2 +- src/sample-db-app/src/app/services/study.ts | 2 +- src/sample-db-app/src/styles.css | 8 ++++---- src/sample-db-py/run.py | 2 +- src/sample-db-py/sample_db/config.py | 20 +++++++++++++++---- src/sample-db-py/sample_db/utils.py | 2 +- 17 files changed, 49 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 6bedf80..47ce767 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ app run.spec yarn-error\.log + +\.idea/ diff --git a/README.md b/README.md index 382af48..8b4c93c 100644 --- a/README.md +++ b/README.md @@ -56,4 +56,13 @@ A CSV file [(template here)](https://github.com/Greenhouse-Lab/sample_db/blob/ma In the case that tubes or specimens must be deleted from the database, navigate to the **Delete** tab, and upload the indicated files ([Delete by Specimen Template](https://github.com/Greenhouse-Lab/sample_db/blob/master/templates/delete_specimen_template.csv) or [Delete by Barcode Template](https://github.com/Greenhouse-Lab/sample_db/blob/master/templates/delete_barcode_template.csv)). Succesful deletion will result in a message with the number of specimens and tubes that have been deleted from the database. # Backup and Restore Databases -SampleDB will automatically backup the database the first time that it is run every day. Backups are stored in `/path/to/sampledb/Resources/app/db-server/db_backups` and may be restored by overwriting `/path/to/sampledb/Resources/app/db-server/sample_db.sqlite`. **Be sure to close SampleDB after use, otherwise the database will not be backed up daily** \ No newline at end of file +SampleDB will automatically backup the database the first time that it is run every day. Backups are stored at the following locations + +|Platform |Path | +|-|-| +|Windows:|`C:\\User\yourUserName\Local\com.greenhouse.sampledb\{current_version}\db_backups`| +|Mac:|`~/Library/Application Support/com.greenhouse.sampledb/{current_version}/db_backups` | + +Backups may be restored by overwriting the sample_db.sqlite file contained in the application data folder. + + **Be sure to close SampleDB after use, otherwise the database will not be backed up daily** \ No newline at end of file diff --git a/src/electron/main.js b/src/electron/main.js index 622843d..e42f442 100644 --- a/src/electron/main.js +++ b/src/electron/main.js @@ -40,7 +40,8 @@ function createWindow () { // when you should delete the corresponding element. mainWindow = null }) - createWindow = () => {}; + + // createWindow = () => {}; } // This method will be called when Electron has finished @@ -70,15 +71,15 @@ app.on('ready', () => { // Make electron sever local files called from the app. protocol.interceptFileProtocol('file', (request, callback) => { - const url = request.url.substr(7); - callback({ path: path.normalize(`${__dirname}/db-app/${url}`)}) + const item_url = request.url.substr(7); + callback({ path: path.normalize(`${__dirname}/db-app/${item_url}`)}) }, (err) => { if (err) console.error('Failed to register protocol'); }); let p = setInterval(() => { - http.get('http://localhost:5000/status', (response) => { + http.get('http://localhost:17327/status', (response) => { response.on('data', (chunk) => { clearInterval(p); createWindow(); diff --git a/src/electron/package.json b/src/electron/package.json index 401806b..d3042f8 100644 --- a/src/electron/package.json +++ b/src/electron/package.json @@ -1,6 +1,6 @@ { "name": "sample-db", - "version": "1.0.0", + "version": "1.1.5", "description": "Sample Database management application.", "main": "main.js", "repository": "https://github.com/greenhouse-lab/sample_db", diff --git a/src/sample-db-app/package.json b/src/sample-db-app/package.json index b5ab94c..d77f571 100644 --- a/src/sample-db-app/package.json +++ b/src/sample-db-app/package.json @@ -1,6 +1,6 @@ { "name": "sample-db", - "version": "1.0.0", + "version": "1.1.5", "license": "MIT", "scripts": { "build": "webpack", diff --git a/src/sample-db-app/src/app/guards/location-exists.ts b/src/sample-db-app/src/app/guards/location-exists.ts index 55c326e..0f298f8 100644 --- a/src/sample-db-app/src/app/guards/location-exists.ts +++ b/src/sample-db-app/src/app/guards/location-exists.ts @@ -47,7 +47,7 @@ export class LocationExistsGuard implements CanActivate { return of(inStore); } return this.hasLocationInApi(id); - }) + }); } canActivate(route: ActivatedRouteSnapshot): Observable { diff --git a/src/sample-db-app/src/app/services/bulk.ts b/src/sample-db-app/src/app/services/bulk.ts index 12f12f3..60131f1 100644 --- a/src/sample-db-app/src/app/services/bulk.ts +++ b/src/sample-db-app/src/app/services/bulk.ts @@ -10,7 +10,7 @@ export interface DeleteQuery { @Injectable() export class BulkService { - private API_PATH = 'http://localhost:5000'; + private API_PATH = 'http://localhost:17327'; private postFileHeaders = new Headers({'Content-Type': undefined}); constructor(private http: Http) {} diff --git a/src/sample-db-app/src/app/services/location.ts b/src/sample-db-app/src/app/services/location.ts index 2d6aa1f..f972f11 100644 --- a/src/sample-db-app/src/app/services/location.ts +++ b/src/sample-db-app/src/app/services/location.ts @@ -5,7 +5,7 @@ import { Location } from '../models/location'; @Injectable() export class LocationService { - private API_PATH = 'http://localhost:5000'; + private API_PATH = 'http://localhost:17327'; private headers = new Headers({'Content-Type': 'application/json'}); diff --git a/src/sample-db-app/src/app/services/logging.ts b/src/sample-db-app/src/app/services/logging.ts index 88541ce..2536fc1 100644 --- a/src/sample-db-app/src/app/services/logging.ts +++ b/src/sample-db-app/src/app/services/logging.ts @@ -9,7 +9,7 @@ interface LogMessage { } @Injectable() export class LoggingService { - private API_PATH = 'http://localhost:5000'; + private API_PATH = 'http://localhost:17327'; private headers = new Headers({'Content-Type': 'application/json'}); constructor(private http: Http) {} diff --git a/src/sample-db-app/src/app/services/plate.ts b/src/sample-db-app/src/app/services/plate.ts index 8c48773..4eba7e0 100644 --- a/src/sample-db-app/src/app/services/plate.ts +++ b/src/sample-db-app/src/app/services/plate.ts @@ -7,7 +7,7 @@ import * as _ from 'lodash'; @Injectable() export class MatrixPlateService { - private API_PATH = 'http://localhost:5000'; + private API_PATH = 'http://localhost:17327'; private headers = new Headers({'Content-Type': 'application/json'}); private postFileHeaders = new Headers({'Content-Type': undefined}); diff --git a/src/sample-db-app/src/app/services/search.ts b/src/sample-db-app/src/app/services/search.ts index 20fc210..c05844e 100644 --- a/src/sample-db-app/src/app/services/search.ts +++ b/src/sample-db-app/src/app/services/search.ts @@ -5,7 +5,7 @@ import { fromPromise } from 'rxjs/observable/fromPromise'; @Injectable() export class SearchService { - private API_PATH = 'http://localhost:5000'; + private API_PATH = 'http://localhost:17327'; private postFileHeaders = new Headers({'Content-Type': undefined}); constructor(private http: Http) {} diff --git a/src/sample-db-app/src/app/services/specimen-type.ts b/src/sample-db-app/src/app/services/specimen-type.ts index 25b3f21..81362ce 100644 --- a/src/sample-db-app/src/app/services/specimen-type.ts +++ b/src/sample-db-app/src/app/services/specimen-type.ts @@ -5,7 +5,7 @@ import { SpecimenType } from '../models/specimen-type'; @Injectable() export class SpecimenTypeService { - private API_PATH = 'http://localhost:5000'; + private API_PATH = 'http://localhost:17327'; private headers = new Headers({'Content-Type': 'application/json'}); diff --git a/src/sample-db-app/src/app/services/study.ts b/src/sample-db-app/src/app/services/study.ts index 989404d..cea5e87 100644 --- a/src/sample-db-app/src/app/services/study.ts +++ b/src/sample-db-app/src/app/services/study.ts @@ -7,7 +7,7 @@ import { StudySubject, Specimen } from '../models/study-subject'; @Injectable() export class StudyService { - private API_PATH = 'http://localhost:5000'; + private API_PATH = 'http://localhost:17327'; private headers = new Headers({'Content-Type': 'application/json'}); diff --git a/src/sample-db-app/src/styles.css b/src/sample-db-app/src/styles.css index f059d4c..41a11ff 100644 --- a/src/sample-db-app/src/styles.css +++ b/src/sample-db-app/src/styles.css @@ -5,12 +5,12 @@ font-family: 'Material Icons'; font-style: normal; font-weight: 400; - src: url(http://localhost:5000/assets/MaterialIcons-Regular.eot); /* For IE6-8 */ + src: url(http://localhost:17327/assets/MaterialIcons-Regular.eot); /* For IE6-8 */ src: local('Material Icons'), local('MaterialIcons-Regular'), - url(http://localhost:5000/assets/MaterialIcons-Regular.woff2) format('woff2'), - url(http://localhost:5000/assets/MaterialIcons-Regular.woff) format('woff'), - url(http://localhost:5000/assets/MaterialIcons-Regular.ttf) format('truetype'); + url(http://localhost:17327/assets/MaterialIcons-Regular.woff2) format('woff2'), + url(http://localhost:17327/assets/MaterialIcons-Regular.woff) format('woff'), + url(http://localhost:17327/assets/MaterialIcons-Regular.ttf) format('truetype'); } .material-icons { diff --git a/src/sample-db-py/run.py b/src/sample-db-py/run.py index 1a59d28..db54481 100644 --- a/src/sample-db-py/run.py +++ b/src/sample-db-py/run.py @@ -2,7 +2,7 @@ import flask as _ from sample_db import app from gevent.wsgi import WSGIServer -server = WSGIServer(('127.0.0.1', 5000), app) +server = WSGIServer(('127.0.0.1', 17327), app) # app.logger.warning("Starting Server") server.serve_forever() # app.run() diff --git a/src/sample-db-py/sample_db/config.py b/src/sample-db-py/sample_db/config.py index d23cb69..17c5f41 100644 --- a/src/sample-db-py/sample_db/config.py +++ b/src/sample-db-py/sample_db/config.py @@ -19,13 +19,24 @@ basedir = os.path.abspath(os.path.dirname(__file__)) prod_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')) +major_version = 'v1' +version = 'v1.1.5' +app_dir = 'com.greenhouse.sampledb' + +if os.sys.platform == 'darwin': + APPDATA = os.path.join(os.environ.get('HOME'), 'Library', 'Application Support', app_dir, major_version) +elif os.sys.platform == 'win32': + APPDATA = os.path.join(os.environ.get('LOCALAPPDATA'), app_dir, major_version) + +if not os.path.exists(APPDATA): + os.makedirs(APPDATA) class Config: DEBUG = False SQLALCHEMY_COMMIT_ON_TEARDOWN = True SQLALCHEMY_RECORD_QUERIES = True - BACKUP_DATE_FORMAT = "%d-%m-%y" + BACKUP_DATE_FORMAT = "%d-%b-%y" # Logging @@ -45,10 +56,11 @@ class DevelopmentConfig(Config): class ProductionConfig(Config): - SQLALCHEMY_DATABASE_URI = os.environ.get('PROD_DATABASE_URL') or 'sqlite:///' + os.path.join(prod_dir, + SQLALCHEMY_DATABASE_URI = os.environ.get('PROD_DATABASE_URL') or 'sqlite:///' + os.path.join(APPDATA, 'sample_db.sqlite') - DB_PATH = os.path.join(prod_dir, 'sample_db.sqlite') - BACKUP_PATH = os.path.join(prod_dir, 'db_backups') + DB_PATH = os.path.join(APPDATA, 'sample_db.sqlite') + BACKUP_PATH = os.path.join(APPDATA, 'db_backups') + ASSETS_PATH = os.path.join(prod_dir, 'static') LOGGING_LOCATION = os.path.join(prod_dir, 'app.log') LOGGING_LEVEL = logging.ERROR diff --git a/src/sample-db-py/sample_db/utils.py b/src/sample-db-py/sample_db/utils.py index b960d32..8a17e0f 100644 --- a/src/sample-db-py/sample_db/utils.py +++ b/src/sample-db-py/sample_db/utils.py @@ -3,7 +3,7 @@ import shutil -def backup_db(path, backup_dir, date_format="%d-%m-%y"): +def backup_db(path, backup_dir, date_format="%d-%b-%y"): if not os.path.exists(backup_dir): os.mkdir(backup_dir) all_backups = os.listdir(backup_dir)