/** * API and other application related definitions */ /* API URIs to backend services */ var apiUri = { // API backend baseurl baseurl: "http://clubadmin.ardor.org.ro/clubadminb", // main web services URIs // Resource Management labels: "/services/rm/labels", activity: "/services/rm/activity", activity_users: "/services/um/activity_users", trainings:"/services/rm/trainings", clubs:"/services/rm/clubs", users: "/services/um/users", groups: "/services/rm/groups", // User Management login: "/services/um/login", logout: "/services/um/logout", session: "/services/um/session", reset: "/services/um/reset_password", register: "/services/um/register", activate: "/services/um/activate_account_email", // Stats quickstats: "/services/stats/quickstats", statistics: "/services/stats/statistics" }; /** * A map with all application html pages, indexed by a common name - this is mainly used by redirect mechanism * @type {{home: string, login: string, logout: string}} */ var pageMap = { "home": "index.php", "login": "login.php", "logout": "logout.php", "activity_list": "activity_list.php", "maintenance": "error/maintenance.php" }; var groupPageMap = { "error": { 404: "error/404.php", 500: "error/500.php", 502: "error/502.php", 503: "error/503.php", 504: "error/504.php", "unexpected": "error/unexpected.php", "requirements": "error/requirements.php", "default": "error/unexpected.php" } }; /* View context mapping - the main scripts names */ var viewContextMap = { activate_account: 'cid_activate_account', activity: 'cid_activity', activity_list: 'cid_activity_list', add_activity: 'cid_add_activity', club_management: 'cid_club_management', groups: 'cid_groups', help: 'cid_help', index: 'cid_index', login: 'cid_login', logout: 'cid_logout', reports: 'cid_reports', requirements_error: 'cid_requirements_error', settings: 'cid_settings', trainings: 'cid_trainings', user_management: 'cid_user_management' }; /* Access level for each view context */ var accessLevel = { cid_activate_account: [], cid_activity: [], cid_activity_list: [], cid_add_activity: ['owner', 'trainer'], cid_club_management: ['admin'], cid_groups: ['owner', 'trainer'], cid_help: [], cid_index: [], cid_login: [], cid_logout: [], cid_reports: [], cid_requirements_error: [], cid_settings: [], cid_trainings: [], cid_user_management: [] }; var MAX_SELECT_LIST = 100; var MAX_READ_LIST = 1000; var itemsPerPage = 10; var errorObject = { error: false, code: 0, message: "" }; /** * Application entities */ // User roles var userRole = { all: "all", admin: "admin", owner: "owner", trainer: "trainer", debater: "debater" }; var userRoleHuman = { all: "all", admin: "Administrator", owner: "Club Owner", trainer: "Trainer", debater: "Debater" }; // Club regions var clubRegion = { all: "all" }; var clubRegionHuman = { all: "all" }; var months = { 1: "Ianuarie", 2: "Febrarie", 3: "Martie", 4: "Aprilie", 5: "Mai", 6: "Iunie", 7: "Iulie", 8: "August", 9: "Septembrie", 10: "Octombrie", 11: "Noiembrie", 12: "Decembrie" }; var HTTPServiceCodes = { "unexpected": "Unexpected error occured: http_code (http_text)", "server_error": { 500: {"is_error": true, "http": "Internal Server Error", "error_code": "server_error_001", "text": ""}, 501: {"is_error": true, "http": "Not Implemented", "error_code": "server_error_002", "text": ""}, 502: {"is_error": true, "http": "Bad Gateway", "error_code": "server_error_003", "text": ""}, 503: {"is_error": true, "http": "Service Unavailable", "error_code": "server_error_004", "text": ""}, 504: {"is_error": true, "http": "Gateway Timeout", "error_code": "server_error_005", "text": ""} }, "activity": { "Read": { 200: {"is_error": false, "http": "", "error_code": "activity_read_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "activity_read_002", "text": "Invalid request"} }, "ReadById": { 200: {"is_error": false, "http": "", "error_code": "activity_readbyid_001", "text": "Success"}, 401: {"is_error": true, "http": "", "error_code": "activity_readbyid_002", "text": "Not authorized to read this activity"}, 404: {"is_error": true, "http": "", "error_code": "activity_readbyid_003", "text": "Activity not found"}, 400: {"is_error": true, "http": "", "error_code": "activity_readbyid_004", "text": "Invalid request"} }, "Create": { 201: {"is_error": false, "http": "", "error_code": "activity_create_001", "text": "Activity successfully created"}, 400: {"is_error": true, "http": "", "error_code": "activity_create_002", "text": "Invalid request"} }, "Update": { 202: {"is_error": false, "http": "", "error_code": "activity_update_001", "text": "Activity successfully updated"}, 204: {"is_error": false, "http": "", "error_code": "activity_update_002", "text": "Nothing to do"}, 404: {"is_error": true, "http": "", "error_code": "activity_update_003", "text": "Activity not found"}, 400: {"is_error": true, "http": "", "error_code": "activity_update_004", "text": "Invalid request"} }, "Delete": { 200: {"is_error": false, "http": "", "error_code": "activity_delete_001", "text": "Success"}, 404: {"is_error": true, "http": "", "error_code": "activity_delete_002", "text": "Activity not found"}, 400: {"is_error": true, "http": "", "error_code": "activity_delete_003", "text": "Invalid request"} } }, "activity_users": { "ParticipantsForActivity": { 200: {"is_error": false, "http": "", "error_code": "activity_users_001", "text": "Success"}, 404: {"is_error": true, "http": "", "error_code": "activity_users_002", "text": "Activity not found"}, 400: {"is_error": true, "http": "", "error_code": "activity_users_003", "text": "Invalid request"} } }, "labels": { "Read": { 200: {"is_error": false, "http": "", "error_code": "labels_read_001", "text": "Success"}, 404: {"is_error": true, "http": "", "error_code": "labels_read_002", "text": "Unknown operation"}, 400: {"is_error": true, "http": "", "error_code": "labels_read_003", "text": "Invalid request"} } }, "login": { "Auth": { 200: {"is_error": false, "http": "", "error_code": "login_auth_001", "text": "Success"}, 401: {"is_error": true, "http": "", "error_code": "login_auth_002", "text": "Incorrect username or password"}, 404: {"is_error": true, "http": "", "error_code": "login_auth_003", "text": "Account not exists or might not be activated"}, 400: {"is_error": true, "http": "", "error_code": "login_auth_004", "text": "Invalid request"} } }, "session": { "CheckSession": { 200: {"is_error": false, "http": "", "error_code": "login_checksession_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "login_checksession_002", "text": "Invalid request"} } }, "logout": { "Logout": { 200: {"is_error": false, "http": "", "error_code": "logout_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "logout_002", "text": "Logout failed"} } }, "reset": { "Reset": { 200: {"is_error": false, "http": "", "error_code": "reset_001", "text": "Reset password email was successfully sent"}, 404: {"is_error": true, "http": "", "error_code": "reset_002", "text": "No account with given email was found"}, 406: {"is_error": true, "http": "", "error_code": "reset_003", "text": "Account is not activated"}, 417: {"is_error": true, "http": "", "error_code": "reset_004", "text": "Sending email failed"}, 400: {"is_error": true, "http": "", "error_code": "reset_005", "text": "Logout failed"} } }, "activate": { "Activate": { 201: {"is_error": false, "http": "", "error_code": "activate_001", "text": "The email was successfully sent"}, 304: {"is_error": true, "http": "", "error_code": "activate_002", "text": "The account was already activated"}, 404: {"is_error": true, "http": "", "error_code": "activate_003", "text": "No account exists with given email"}, 417: {"is_error": true, "http": "", "error_code": "activate_004", "text": "Activation link expired"}, 400: {"is_error": true, "http": "", "error_code": "activate_004", "text": "Invalid request"} } }, "register": { "Create": { 200: {"is_error": false, "http": "", "error_code": "register_create_001", "text": "The account was successfully created. An activation link was sent to given email address."}, 201: {"is_error": false, "http": "", "error_code": "register_create_001", "text": "The account was successfully created. An activation link was sent to given email address."}, 404: {"is_error": true, "http": "", "error_code": "register_create_002", "text": "Club does not exist"}, 406: {"is_error": true, "http": "", "error_code": "register_create_003", "text": "Username already exists"}, 408: {"is_error": true, "http": "", "error_code": "register_create_004", "text": "The invitation email cannot be sent"}, 409: {"is_error": true, "http": "", "error_code": "register_create_005", "text": "The two password inputs are not the same"}, 417: {"is_error": true, "http": "", "error_code": "register_create_006", "text": "The invitation email already exists"}, 400: {"is_error": true, "http": "", "error_code": "register_create_007", "text": "Invalid request"} } }, "users": { "Read": { 200: {"is_error": false, "http": "", "error_code": "users_read_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "users_read_002", "text": "Invalid request"} }, "ReadById": { 200: {"is_error": false, "http": "", "error_code": "users_readbyid_001", "text": "Success"}, 404: {"is_error": true, "http": "", "error_code": "users_readbyid_002", "text": "User not found"}, 400: {"is_error": true, "http": "", "error_code": "users_readbyid_003", "text": "Invalid request"} }, "BulkUpdate": { 200: {"is_error": false, "http": "", "error_code": "users_bulkupdate_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "users_bulkupdate_002", "text": "Invalid request"} } }, "clubs": { "Read": { 200: {"is_error": false, "http": "", "error_code": "clubs_read_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "clubs_read_002", "text": "Invalid request"} }, "Create": { 200: {"is_error": false, "http": "", "error_code": "clubs_create_001", "text": "Success"}, 409: {"is_error": true, "http": "", "error_code": "clubs_create_002", "text": "Club name already exists in selected region"}, 400: {"is_error": true, "http": "", "error_code": "clubs_create_003", "text": "Invalid request"} } }, "trainings": { "Read": { 200: {"is_error": false, "http": "", "error_code": "trainings_read_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "trainings_read_002", "text": "Invalid request"} } }, "groups": { "Read": { 200: {"is_error": false, "http": "", "error_code": "groups_read_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "groups_read_002", "text": "Invalid request"} }, "ReadById": { 200: {"is_error": false, "http": "", "error_code": "groups_readbyid_001", "text": "Success"}, 401: {"is_error": true, "http": "", "error_code": "groups_readbyid_002", "text": "Not authorized to read this group"}, 404: {"is_error": true, "http": "", "error_code": "groups_readbyid_003", "text": "Group not found"}, 400: {"is_error": true, "http": "", "error_code": "groups_readbyid_004", "text": "Invalid request"} }, "Create": { 201: {"is_error": false, "http": "", "error_code": "groups_create_001", "text": "Group successfully created"}, 400: {"is_error": true, "http": "", "error_code": "groups_create_002", "text": "Invalid request"} }, "Update": { 202: {"is_error": false, "http": "", "error_code": "groups_update_001", "text": "Group successfully updated"}, 204: {"is_error": false, "http": "", "error_code": "groups_update_002", "text": "Nothing to do"}, 404: {"is_error": true, "http": "", "error_code": "groups_update_003", "text": "Group not found"}, 400: {"is_error": true, "http": "", "error_code": "groups_update_004", "text": "Invalid request"} }, "Delete": { 200: {"is_error": false, "http": "", "error_code": "groups_delete_001", "text": "Success"}, 404: {"is_error": true, "http": "", "error_code": "groups_delete_002", "text": "Group not found"}, 400: {"is_error": true, "http": "", "error_code": "groups_delete_003", "text": "Invalid request"} } }, "quickstats": { "UsersQuickStats": { 200: {"is_error": false, "http": "", "error_code": "quickstats_users_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "quickstats_users_002", "text": "Invalid request"} }, "ActivityQuickStats": { 200: {"is_error": false, "http": "", "error_code": "quickstats_activity_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "quickstats_activity_001", "text": "Invalid request"} } }, "statistics": { "Activityreport": { 200: {"is_error": false, "http": "", "error_code": "statistics_activityreport_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "statistics_activityreport_002", "text": "Invalid request"} }, "Participantsreport": { 200: {"is_error": false, "http": "", "error_code": "statistics_participantsreport_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "statistics_participantsreport_002", "text": "Invalid request"} }, "Activitytypereport": { 200: {"is_error": false, "http": "", "error_code": "statistics_activitytype_001", "text": "Success"}, 400: {"is_error": true, "http": "", "error_code": "statistics_activitytype_002", "text": "Invalid request"} } } };