import { logger } from "./shims";

var projectId, apiClient;
var projectName = "(unknown)";
var pubDate, audioFormat, recordingRadius, location, geoListenEnabled;

export class Project {
  constructor(newProjectId,options) {
    projectId = newProjectId;
    apiClient = options.apiClient;
  }

  toString() {
    return `Roundware Project '${projectName}' (#${projectId})`;
  }

  // getRecordingRadius() {
  //   return recordingRadius;
  // }

  connect(sessionId) {
    var path = "/projects/" + projectId + "/";

    var data = {
      session_id: sessionId
    };

    let that = this;

    return apiClient.get(path,data).
      then(function connectionSuccess(data) {
        projectName = data.name;
        pubDate = data.pub_date;
        audioFormat = data.audio_format;
        that.recordingRadius = data.recording_radius;
        return sessionId;
      });
  }

  uiconfig(sessionId) {
    var path = "/projects/" + projectId + "/uiconfig/";

    var data = {
      session_id: sessionId
    };

    return apiClient.get(path,data).
      then(function connectionSuccess(data) {
        // let this._uiConfig = data;
        return data;
      });
  }
}

@@ -830,16 +830,123 @@
 radius;%0A
+        that.location = %7B%22latitude%22: data.latitude,%0A                         %22longitude%22: data.longitude%7D;%0A
         

make project.latitude/longitude available to UI