Exemplo n.º 1
0
 def importLayer(self):
     params = [
         Parameter("layer", "Layer to add", "", VECTOR, ""),
         Parameter("message", "Commit message", "", STRING, "")
     ]
     ret = openParametersDialog(params, "Add layer")
     if ret is not None:
         if ret["layer"] is None:
             return
         if isGeogigLayer(ret["layer"]):
             raise GeogigError("Selected layer is already a Geogig layer")
         if GEOGIGID_FIELD in [
                 f.name().lower() for f in ret["layer"].fields()
         ]:
             raise GeogigError("Selected layer has a 'geogigid' field")
         msg = ret["message"] or "Added layer '{}'".format(
             ret["layer"].name())
         self.server.addLayer(self.user, self.repo, ret["layer"], "master",
                              msg)
         saveStyleFromQgisLayer(ret["layer"], self.server, self.user,
                                self.repo)
         self.refreshContent()
         iface.messageBar().pushMessage("Add layer",
                                        "Layer correctly imported",
                                        level=Qgis.Info,
                                        duration=5)
 def getPassword(self):
     # self.user = "******"
     # self.password = "******"
     if self.user is None or self.password is None:            
         params = [Parameter("username", "Username", "", STRING, ""),
               Parameter("password", "Password", "", PASSWORD, "")]
         ret = openParametersDialog(params, "Geogig server credentials ({})".format(self.url))            
         if ret is not None:
             self.user = ret["username"]
             self.password = ret["password"]
             return True, True
         return False, True
     return True, False
Exemplo n.º 3
0
    def createUser(self):
        stores = self.server.stores()
        params = [
            Parameter("email", "Email", "", STRING, ""),
            Parameter("username", "Username", "", STRING, ""),
            Parameter("password", "Password", "", STRING, ""),
            Parameter("fullname", "Full name", "", STRING, ""),
            Parameter("defaultstore", "Default Store", "", CHOICE, stores)
        ]

        ret = openParametersDialog(params, "New user")
        if ret is not None:
            self.server.createUser(ret["username"], ret["password"],
                                   ret["fullname"], ret["email"],
                                   ret["defaultstore"])
            self.refreshContent()
Exemplo n.º 4
0
    def addNewServer(self):
        params = [
            Parameter("url", "URL", "", STRING, "http://localhost:8181"),
            Parameter("name", "Name", "", STRING, "")
        ]

        urls = []
        for i in range(self.childCount()):
            serverItem = self.child(i)
            urls.append(serverItem.url)
        ret = openParametersDialog(params, "New server")
        if ret is not None:
            url = ret["url"]
            url = url + "/" if not url.endswith("/") else url
            if url in urls:
                raise GeogigError("A server item with that url already exists")
            item = ServerItem(url, ret["name"])
            self.addChild(item)
            servers = _servers()
            servers[ret["name"]] = url
            _saveServers(servers)
Exemplo n.º 5
0
 def createRepo(self):
     #stores = self.server.stores()
     params = [Parameter("reponame", "Repository name", "", STRING, "")]
     ret = openParametersDialog(params, "New repository")
     if ret is not None:
         self.server.createRepo(self.user, ret["reponame"])