note description: "Summary description for {ES_CLOUD_HANDLER}." date: "$Date$" revision: "$Revision$" class ES_CLOUD_HANDLER inherit CMS_HANDLER rename make as make_with_cms_api end WSF_URI_TEMPLATE_HANDLER create make feature {NONE} -- Initialization make (a_mod_api: ES_CLOUD_API) do make_with_cms_api (a_mod_api.cms_api) es_cloud_api := a_mod_api end feature -- API es_cloud_api: ES_CLOUD_API feature -- Execution execute (req: WSF_REQUEST; res: WSF_RESPONSE) -- Execute handler for `req' and respond in `res'. do if req.is_get_request_method then get_cloud (req, res) -- elseif req.is_post_request_method then else send_bad_request (req, res) end end get_cloud (req: WSF_REQUEST; res: WSF_RESPONSE) local l_user: ES_CLOUD_USER r: like new_generic_response s: STRING l_plan: detachable ES_CLOUD_PLAN l_org: detachable ES_CLOUD_ORGANIZATION l_session: detachable ES_CLOUD_SESSION l_sessions: detachable LIST [ES_CLOUD_SESSION] inst: ES_CLOUD_INSTALLATION l_display_all: BOOLEAN k: READABLE_STRING_32 ago: DATE_TIME_AGO_CONVERTER l_can_be_deleted, l_user_has_no_license: BOOLEAN do if attached req.query_parameter ("display") as d and then d.is_case_insensitive_equal ("all") then l_display_all := True end r := new_generic_response (req, res) r.add_javascript_url (r.module_name_resource_url ({ES_CLOUD_MODULE}.name, "/files/js/es_cloud.js", Void)) r.add_style (r.module_name_resource_url ({ES_CLOUD_MODULE}.name, "/files/css/es_cloud.css", Void), Void) r.set_title ("EiffelStudio account") s := "" create ago.make if attached api.user as u then create l_user.make (u) s.append ("

User "+ api.html_encoded (api.real_user_display_name (u)) +"

") -- Plan -- Installation ... s.append ("
") if attached es_cloud_api.user_installations (l_user) as l_installations and then not l_installations.is_empty then s.append ("

EiffelStudio is installed on " + l_installations.count.out + " devices: ") if l_display_all then s.append ("only active sessions") else s.append ("include ended or expired") end s.append ("

") else s.append ("

EiffelStudio is not yet installed.

") end s.append ("
") s.append ("
") if attached es_cloud_api.user_organizations (l_user) as l_orgs then across l_orgs as o_ic loop l_org := o_ic.item if es_cloud_api.is_organization_manager (l_user, l_org) then s.append ("

Manager of organization: ") s.append ("") s.append (html_encoded (l_org.title_or_name)) s.append ("

") else s.append ("

Member of organization: ") s.append (html_encoded (l_org.title_or_name)) s.append ("

") end end end s.append ("
") s.append ("
") if attached es_cloud_api.user_licenses (l_user) as lics and then not lics.is_empty then across lics as ic loop if attached ic.item as l_user_lic and then attached l_user_lic.license as lic then l_plan := lic.plan s.append ("

License "+ html_encoded (lic.key) + " for plan ") s.append (html_encoded (l_plan.title_or_name)) s.append ("") s.append ("

") end end else s.append ("Please subscribe to a license ...") l_user_has_no_license := True end s.append ("
") if l_user_has_no_license and then attached es_cloud_api.user_subscription (l_user) as sub then s.append ("
") l_plan := sub.plan s.append ("

You are subscribed to plan: ") s.append (html_encoded (l_plan.title_or_name)) s.append ("") s.append ("

") s.append ("
") end else s.append ("

Please Login or Register...

") end if l_plan = Void then s.append ("
") s.append ("EiffelStudio plans") s.append ("
") end r.set_main_content (s) r.execute end note copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end