Przeglądaj źródła

logout, organizace group

Honza 5 lat temu
rodzic
commit
411a9ea343
4 zmienionych plików z 164 dodań i 14 usunięć
  1. 41 9
      Atlas.py
  2. BIN
      __pycache__/Atlas.cpython-37.pyc
  3. 108 3
      dlg_editMap.ui
  4. 15 2
      dlg_userInfo.ui

+ 41 - 9
Atlas.py

@@ -318,10 +318,13 @@ class Atlas:
     def run_UserInfoDialog(self):
         self.dlg = UserInfoDialog() 
         self.dlg.show()
+        self.dlg.pushButton_logout.setStyleSheet("#pushButton_logout {color: #fff !important;text-transform: uppercase;  text-decoration: none;   background: #72c02c;   padding: 20px;  border-radius: 50px;    display: inline-block; border: none;transition: all 0.4s ease 0s;} #pushButton_logout:hover{background: #66ab27 ;}")
+        self.dlg.setStyleSheet("#DialogBase {background: #f0f0f0 ;}")
         userEndpoint = "http://layman.lesprojekt.cz/rest/current-user"
         r = requests.get(url = userEndpoint,  headers = self.authHeader)
         res = r.text
         res = self.fromByteToJson(r.content)
+        self.dlg.pushButton_logout.clicked.connect(lambda: self.logout())
         print(res['claims'])
         self.dlg.label_layman.setText(res['claims']['preferred_username'])
         self.dlg.label_agrihub.setText(res['claims']['email'])
@@ -343,6 +346,10 @@ class Atlas:
         self.dlg.lineEdit_units.setText(self.compositeList[x]['units'])
         self.dlg.lineEdit_scale.setText(str(self.compositeList[x]['scale']))
         self.dlg.lineEdit_user.setText(self.compositeList[x]['user']['name'])
+        self.dlg.lineEdit_xmin.setText(self.compositeList[x]['extent'][0])
+        self.dlg.lineEdit_xmax.setText(self.compositeList[x]['extent'][2])
+        self.dlg.lineEdit_ymin.setText(self.compositeList[x]['extent'][1])
+        self.dlg.lineEdit_ymax.setText(self.compositeList[x]['extent'][3])
         self.dlg.rejected.connect(lambda: self.afterCloseEditMapDialog()) 
         self.dlg.pushButton_save.clicked.connect(lambda: self.modifyMap(x))
         self.dlg.rejected.connect(lambda: self.afterCloseCompositeDialog())
@@ -706,7 +713,20 @@ class Atlas:
         return loaded 
                    
         
-                   
+    def logout(self):
+        self.menu_saveLocalFile.setEnabled(False)
+        self.menu_loadJson.setEnabled(False)
+        self.menu_ImportLayerDialog.setEnabled(False)
+        self.menu_AddLayerDialog.setEnabled(False) 
+        self.menu_AddMapDialog.setEnabled(False)       
+        self.menu_ImportLayerDialog.setEnabled(False)
+        self.menu_ImportMapDialog.setEnabled(False)    
+        self.menu_UserInfoDialog.setEnabled(False)
+        self.textbox.setText("Layman")
+        self.dlg.close()
+       # self.flaskThread.join()
+       # self.thread1.join() ## ukončujeme vlákno, které se stará o refresh tokenů OAUTH
+
     def enableLoadMapButtons(self, item):
         self.dlg.pushButton_mapWFS.setEnabled(True)
     def enableButtonImport(self, item, column):
@@ -1096,8 +1116,8 @@ class Atlas:
         # disconnects
         self.dockwidget.closingPlugin.disconnect(self.onClosePlugin)
 
-  
-
+        self.flaskThread.terminate() ## killing daemons
+        self.thread1.terminate()
         self.pluginIsActive = False
 
 
@@ -1200,7 +1220,11 @@ class Atlas:
         self.compositeList[x]['name'] = name
         self.compositeList[x]['abstract'] = self.dlg.lineEdit_abstract.text()
         self.compositeList[x]['title'] = self.dlg.lineEdit_title.text()
-
+        self.compositeList[x]['extent'][0] = self.dlg.lineEdit_xmin.text()
+        self.compositeList[x]['extent'][2] = self.dlg.lineEdit_xmax.text()
+        self.compositeList[x]['extent'][1] = self.dlg.lineEdit_ymin.text()
+        self.compositeList[x]['extent'][3] = self.dlg.lineEdit_ymax.text()
+        print(self.compositeList[x]['extent'])
         
         print(self.URI+'/rest/'+self.laymanUsername+'/maps/'+self.compositeList[x]['name'])       
         oldName = self.dlg.lineEdit_name.text()
@@ -1996,10 +2020,18 @@ class Atlas:
         root = QgsProject.instance().layerTreeRoot()
         group = root.findGroup(groupName)
         if not(group):
-            group = root.addGroup(groupName)           
+            group = root.addGroup(groupName)  
+            group = self.reorderToTop(groupName)
         QgsProject.instance().addMapLayer(layer,False)
         group.insertChildNode(1,QgsLayerTreeLayer(layer))         
-
+    def reorderToTop(self, name):
+        root = QgsProject.instance().layerTreeRoot()
+        for ch in root.children():
+            if ch.name() == name:
+                _ch = ch.clone()
+                root.insertChildNode(0, _ch)
+                root.removeChildNode(ch)
+        return _ch
     def convertUrlFromHex(self, url):
         url = url.replace('%3A',':')
         url = url.replace('%2F','/')
@@ -2260,9 +2292,9 @@ class Atlas:
             #################       
      
         print ("##### flask server is starting #####")                     
-        thread = StartFlaskDaemon()
-        thread.daemon = True
-        thread.start()       
+        self.flaskThread = StartFlaskDaemon()
+        self.flaskThread.daemon = True
+        self.flaskThread.start()       
         url = 'https://www.'+self.liferayServer+'/o/oauth2/authorize?response_type=code&client_id='+self.client_id+'&redirect_uri=http%3A%2F%2Flocalhost:3000%2Fclient%2Fauthn%2Foauth2-liferay%2Fcallback&code_challenge='+self.code_challenge ##n4bQgYhMfWWaL-qgxVrQFaO_TxsrC4Is0V1sFbDwCgg'
         webbrowser.open(url, new=2)
 

BIN
__pycache__/Atlas.cpython-37.pyc


+ 108 - 3
dlg_editMap.ui

@@ -9,7 +9,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>350</width>
+    <width>550</width>
     <height>250</height>
    </rect>
   </property>
@@ -21,13 +21,13 @@
   </property>
   <property name="minimumSize">
    <size>
-    <width>350</width>
+    <width>550</width>
     <height>250</height>
    </size>
   </property>
   <property name="maximumSize">
    <size>
-    <width>350</width>
+    <width>550</width>
     <height>250</height>
    </size>
   </property>
@@ -210,6 +210,111 @@
     <bool>true</bool>
    </property>
   </widget>
+  <widget class="QLineEdit" name="lineEdit_xmin">
+   <property name="geometry">
+    <rect>
+     <x>370</x>
+     <y>56</y>
+     <width>130</width>
+     <height>22</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_ymin">
+   <property name="geometry">
+    <rect>
+     <x>370</x>
+     <y>116</y>
+     <width>130</width>
+     <height>22</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_ymax">
+   <property name="geometry">
+    <rect>
+     <x>370</x>
+     <y>146</y>
+     <width>130</width>
+     <height>22</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_8">
+   <property name="geometry">
+    <rect>
+     <x>300</x>
+     <y>149</y>
+     <width>41</width>
+     <height>16</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>YMax:</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_7">
+   <property name="geometry">
+    <rect>
+     <x>300</x>
+     <y>89</y>
+     <width>41</width>
+     <height>16</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>XMax:</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_9">
+   <property name="geometry">
+    <rect>
+     <x>300</x>
+     <y>60</y>
+     <width>41</width>
+     <height>16</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>XMin:</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_10">
+   <property name="geometry">
+    <rect>
+     <x>300</x>
+     <y>29</y>
+     <width>211</width>
+     <height>16</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Extent of canvas:</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_xmax">
+   <property name="geometry">
+    <rect>
+     <x>370</x>
+     <y>86</y>
+     <width>130</width>
+     <height>22</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_11">
+   <property name="geometry">
+    <rect>
+     <x>300</x>
+     <y>120</y>
+     <width>41</width>
+     <height>16</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>YMin:</string>
+   </property>
+  </widget>
  </widget>
  <resources/>
  <connections/>

+ 15 - 2
dlg_userInfo.ui

@@ -9,8 +9,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>400</width>
-    <height>300</height>
+    <width>322</width>
+    <height>216</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -68,6 +68,19 @@
     <string/>
    </property>
   </widget>
+  <widget class="QPushButton" name="pushButton_logout">
+   <property name="geometry">
+    <rect>
+     <x>42</x>
+     <y>140</y>
+     <width>93</width>
+     <height>28</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Logout</string>
+   </property>
+  </widget>
  </widget>
  <resources/>
  <connections/>