Skip to content

Commit

Permalink
githubplugin: implemented plugin installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Morg42 committed Nov 6, 2024
1 parent bfe4d10 commit 9b19be0
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
10 changes: 8 additions & 2 deletions githubplugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,17 @@ def setup_github(self) -> bool:

def fetch_github_forks(self) -> bool:
""" fetch forks from github API """
return self.gh.get_forks()
if self.gh:
return self.gh.get_forks()
else:
return False

def fetch_github_pulls(self) -> bool:
""" fetch PRs from github API """
return self.gh.get_pulls()
if self.gh:
return self.gh.get_pulls()
else:
return False

def fetch_github_branches_from(self, fork=None, owner='', fetch=False) -> dict:
"""
Expand Down
28 changes: 28 additions & 0 deletions githubplugin/webif/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,34 @@ def updatePlugins(self):
if plugins != {}:
return {"operation": "request", "result": "success", "data": plugins}

@cherrypy.expose
@cherrypy.tools.json_out()
@cherrypy.tools.json_in()
def selectPlugin(self):
json = cherrypy.request.json
owner = json.get("owner")
branch = json.get("branch")
plugin = json.get("plugin")
confirm = json.get("confirm")
name = f'{owner}/{branch}'
if (owner is None or owner == '' or
branch is None or branch == '' or
plugin is None or plugin == ''):
msg = f'Fehlerhafte Daten für Repo {owner}/plugins, Branch {branch} oder Plugin {plugin} übergeben.'
return {"operation": "request", "result": "error", "data": msg}

if confirm:
res = self.plugin.create_repo()
msg = f'Fehler beim Erstellen des Repos "{owner}/plugins", Branch {branch}, Plugin {plugin}'
else:
res = self.plugin.init_repo(name, owner, plugin, branch)
msg = f'Fehler beim Initialisieren des Repos "{owner}/plugins", Branch {branch}, Plugin {plugin}'

if res:
return {"operation": "request", "result": "success"}
else:
return {"operation": "request", "result": "error", "data": msg}


# @cherrypy.expose
# @cherrypy.tools.json_out()
Expand Down
22 changes: 22 additions & 0 deletions githubplugin/webif/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,28 @@
}
}

function selectPlugin(selObj) {
var owner = document.getElementById('owner').value;
var branch = document.getElementById('branch').value;
var plugin = document.getElementById('plugin').value;

if (owner != '' && branch != '' && plugin != '') {
$.ajax({
type: "POST",
url: "selectPlugin",
data: JSON.stringify({'owner': owner, 'branch': branch, 'plugin': plugin}),
contentType: 'application/json',
dataType: 'json',
error: function(response) {
alert("Fehler beim Übermitteln der Daten. Bitte shng-Log prüfen!");
},
success: function(response) {
alert(response['data']);
}
})
}
}


</script>

Expand Down

0 comments on commit 9b19be0

Please sign in to comment.