{"size": 881, "ext": "js", "max_stars_repo_path": "app/controllers/index.js", "max_stars_repo_name": "adopted-ember-projects/hospitalrun-frontend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/controllers/index.js", "max_issues_repo_name": "adopted-ember-projects/hospitalrun-frontend", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/controllers/index.js", "max_forks_repo_name": "adopted-ember-projects/hospitalrun-frontend", "max_forks_repo_forks_event_min_datetime": "2019-08-07T06:05:57.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-07T06:05:57.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 30.3793103448, "max_line_length": 96, "alphanum_fraction": 0.6424517594}
import { inject as service } from '@ember/service';
import { run } from '@ember/runloop';
import Controller from '@ember/controller';
import { alias } from '@ember/object/computed';
import { get } from '@ember/object';
import UserSession from 'hospitalrun/mixins/user-session';

export default Controller.extend(UserSession, {
  config: service(),
  database: service(),
  standAlone: alias('config.standAlone'),
  needsUserSetup: alias('config.needsUserSetup'),
  // on init, look up the list of users and determine if there's a need for a needsUserSetup msg
  init() {
    if (get(this, 'standAlone')) {
      get(this, 'database.usersDB').allDocs().then((results) => {
        if (results.total_rows <= 1) {
          run(() => this.set('config.needsUserSetup', true));
        }
      });
    }
  },
  actions: {
    newUser() {
      this.send('createNewUser');
    }
  }
});
