forked from HospitalRun/hospitalrun-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added capability to load db from file
Also added sample db dump. Resolves HospitalRun#13
- Loading branch information
Showing
12 changed files
with
171 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Ember from 'ember'; | ||
import ModalHelper from 'hospitalrun/mixins/modal-helper'; | ||
import ProgressDialog from 'hospitalrun/mixins/progress-dialog'; | ||
export default Ember.Controller.extend(ModalHelper, ProgressDialog, { | ||
database: Ember.inject.service(), | ||
fileSystem: Ember.inject.service('filesystem'), | ||
progressMessage: 'Please wait while your database is loaded.', | ||
progressTitle: 'Loading Database', | ||
syncResults: null, | ||
|
||
actions: { | ||
loadFile: function() { | ||
var fileSystem = this.get('fileSystem'), | ||
fileToImport = this.get('importFile'); | ||
if (!fileToImport || !fileToImport.type) { | ||
this.displayAlert('Select File To Load', 'Please select file to load.'); | ||
} else { | ||
this.showProgressModal(); | ||
this.set('syncResults'); | ||
fileSystem. fileToString(fileToImport).then((fileAsString) => { | ||
var database = this.get('database'); | ||
this.set('importFile'); | ||
this.set('model.importFileName'); | ||
database.loadDBFromDump(fileAsString).then((results) => { | ||
this.closeProgressModal(); | ||
this.set('syncResults', results); | ||
}).catch((err) => { | ||
this.displayAlert('Error Loading', `The database could not be imported. The error was:${JSON.stringify(err)}`); | ||
}); | ||
}); | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; | ||
import Ember from 'ember'; | ||
import UserSession from 'hospitalrun/mixins/user-session'; | ||
export default AbstractEditRoute.extend(UserSession, { | ||
hideNewButton: true, | ||
editTitle: 'Load DB', | ||
|
||
beforeModel: function() { | ||
if (!this.currentUserCan('load_db')) { | ||
this.transitionTo('application'); | ||
} | ||
}, | ||
|
||
// No model needed for import. | ||
model: function() { | ||
return Ember.RSVP.resolve(Ember.Object.create({})); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<div class="panel panel-primary"> | ||
<div class="panel-body"> | ||
{{#em-form model=model submitButton=false }} | ||
{{file-upload label="File To Load" property="importFileName" selectedFile=importFile }} | ||
<button class="btn btn-default" {{action 'loadFile'}}>Load File</button> | ||
{{/em-form}} | ||
{{#if syncResults}} | ||
<h4>File Load Successful</h4> | ||
<div class="form-group col-xs-3"> | ||
<label>Start Time</label> | ||
<p class="form-control-static">{{date-format syncResults.start_time format="l h:mm A"}}</p> | ||
</div> | ||
<div class="form-group col-xs-3"> | ||
<label>End Time</label> | ||
<p class="form-control-static">{{date-format syncResults.end_time format="l h:mm A"}}</p> | ||
</div> | ||
<div class="form-group col-xs-3"> | ||
<label>Docs Read</label> | ||
<p class="form-control-static">{{syncResults.docs_read}}</p> | ||
</div> | ||
<div class="form-group col-xs-3"> | ||
<label>Docs Written</label> | ||
<p class="form-control-static">{{syncResults.docs_written}}</p> | ||
</div> | ||
{{/if}} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.