import { changePassphrase } from "./pages/user/ChangePassphrase";
import { EncryptionServiceFactory } from "../common/service/EncryptionServiceFactory";
import log from "loglevel";
import { AlertifyNotificationService } from "../common/service/AlertifyNotificationService";
import { stats } from "./pages/Home";
import { Credentials } from "../common/global/Credentials";
import { getOtherUsers } from "../common/ajax/Users";
import { viewUsers } from "./pages/user/ViewUsers";

// log.setLevel("TRACE");
const es = EncryptionServiceFactory.getEncryptionService();
const ns = new AlertifyNotificationService();
const authToken = Credentials.authToken;
$("#changePassphraseForm").on("submit", (event) => {
  event.preventDefault();
  changePassphrase(es, ns, authToken);
});

const pathMatcher = (path: string) => window.location.pathname == path;

if (pathMatcher("/admin")) {
  stats();
}
if (pathMatcher("/admin/users")) {
  // $("#usersTableBody").html("");
  viewUsers(authToken);
}
