Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Commit

Permalink
version bump
Browse files Browse the repository at this point in the history
-Changed port number used
-Moved sample_db.sqlite location to persist after upgrading app
  • Loading branch information
m-murphy committed Aug 18, 2017
1 parent 76754ed commit 2792b93
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ app
run.spec

yarn-error\.log

\.idea/
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
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**
9 changes: 5 additions & 4 deletions src/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/electron/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/sample-db-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sample-db",
"version": "1.0.0",
"version": "1.1.5",
"license": "MIT",
"scripts": {
"build": "webpack",
Expand Down
2 changes: 1 addition & 1 deletion src/sample-db-app/src/app/guards/location-exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class LocationExistsGuard implements CanActivate {
return of(inStore);
}
return this.hasLocationInApi(id);
})
});
}

canActivate(route: ActivatedRouteSnapshot): Observable<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion src/sample-db-app/src/app/services/bulk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
2 changes: 1 addition & 1 deletion src/sample-db-app/src/app/services/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'});

Expand Down
2 changes: 1 addition & 1 deletion src/sample-db-app/src/app/services/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
2 changes: 1 addition & 1 deletion src/sample-db-app/src/app/services/plate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand Down
2 changes: 1 addition & 1 deletion src/sample-db-app/src/app/services/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
2 changes: 1 addition & 1 deletion src/sample-db-app/src/app/services/specimen-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'});

Expand Down
2 changes: 1 addition & 1 deletion src/sample-db-app/src/app/services/study.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'});

Expand Down
8 changes: 4 additions & 4 deletions src/sample-db-app/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/sample-db-py/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
20 changes: 16 additions & 4 deletions src/sample-db-py/sample_db/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/sample-db-py/sample_db/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2792b93

Please sign in to comment.