Пример #1
0
        protected void TryLogin(string apiPath, string password)
        {
            apiPath = apiPath.Trim();
            if (apiPath[apiPath.Length - 1] == '/')
            {
                apiPath = apiPath.Remove(apiPath.Length - 1);
            }

            var request = UnityWebRequest.Get(apiPath + "/user");

            request.SetRequestHeader("PRIVATE-TOKEN", password);

            var async = request.SendWebRequest();

            async.completed += op =>
            {
                UnityWebRequestAsyncOperation asyncop = op as UnityWebRequestAsyncOperation;
                if (asyncop.webRequest.isHttpError)
                {
                    Debug.Log(asyncop.webRequest.error + " :: " + asyncop.webRequest.downloadHandler.text);
                    GetAuthToken();
                }
                else
                {
                    GitlabUserData user = JsonUtility.FromJson <GitlabUserData>(asyncop.webRequest.downloadHandler.text);

                    _userID = user.id;

                    var setting = BugReporterPlugin.settings.GetBackendSettings(backendName);
                    setting.token   = password;
                    setting.apiPath = apiPath;

                    _apiPath    = apiPath;
                    _token      = password;
                    _isLoggedIn = true;
                    BugReporterPlugin.SaveSettings();

                    Debug.LogFormat("[Gitlab Backend] : Logged in as user " + user.name);

                    // Gitlab have an image uploader setup by default
                    BugReporterPlugin.SetupImageUploader(GitlabImageUploader.imgUploaderName);

                    if (setting.projectPath != "")
                    {
                        SetupProjectInfo();
                    }

                    if (OnPostInit != null)
                    {
                        OnPostInit.Invoke();
                    }
                }
            };
        }
Пример #2
0
        private void OnGUI()
        {
            entry.title = EditorGUILayout.TextField("Title", entry.title);
            EditorGUILayout.LabelField("Description");
            entry.description = EditorGUILayout.TextArea(entry.description, GUILayout.MinHeight((150)));

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Assignees");
            if (EditorGUILayout.DropdownButton(new GUIContent(entry.assigneesString), FocusType.Keyboard))
            {
                GenericMenu menu = new GenericMenu();

                var users = BugReporterPlugin.users;
                foreach (var user in users)
                {
                    menu.AddItem(new GUIContent(user.name), ArrayUtility.Contains(entry.assignees, user), ToggleUserAssignee, user);
                }

                menu.ShowAsContext();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Labels");
            if (EditorGUILayout.DropdownButton(new GUIContent(entry.labelsString), FocusType.Keyboard))
            {
                GenericMenu menu = new GenericMenu();

                var labels = BugReporterPlugin.labels;
                foreach (var label in labels)
                {
                    menu.AddItem(new GUIContent(label), ArrayUtility.Contains(entry.labels, label), ToggleLabel, label);
                }

                menu.ShowAsContext();
            }
            EditorGUILayout.EndHorizontal();

            if (severityMax != 0)
            {
                entry.severity = EditorGUILayout.IntSlider("Severity", entry.severity, 0, severityMax);
            }

            EditorGUILayout.BeginHorizontal();

            logPosition = EditorGUILayout.Toggle("Log Position", logPosition);

            if (BugReporterPlugin.settings.currentImageUploader == "")
            {
                int selected = EditorGUILayout.Popup("Image uploader", -1, BugReporterPlugin.GetImageUploaderName());
                if (selected != -1)
                {
                    BugReporterPlugin.SetupImageUploader(BugReporterPlugin.GetImageUploaderName()[selected]);
                }
            }
            else
            {
                uploadScreenshot = EditorGUILayout.Toggle("Upload Screenshot", uploadScreenshot);
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Send"))
            {
                onWindowClosed(this);
                Close();
            }

            if (GUILayout.Button("Cancel"))
            {
                Close();
            }

            EditorGUILayout.EndHorizontal();
        }