Skip to content

Commit

Permalink
new draft for repo
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorv7519 committed Nov 11, 2024
1 parent bace3cd commit 7e648b8
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 5 deletions.
24 changes: 24 additions & 0 deletions Mergin/project_limit_hit_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
from qgis.PyQt import uic
from qgis.PyQt.QtWidgets import QDialog
from qgis.PyQt.QtCore import QUrl
from qgis.PyQt.QtGui import QDesktopServices

ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui", "ui_project_limit_hit_dialog.ui")

class ProjectLimitHitDialog(QDialog):
def __init__(self, e, parent=None):
QDialog.__init__(self, parent)
self.ui = uic.loadUi(ui_file, self)

quota = e.server_response.get('projects_quota', 'N/A')
plan = e.server_response.get('plan', 'N/A')
self.planQuota_label.setText(str(quota))
self.planName_label.setText(str(plan))

self.cancel_btn.clicked.connect(self.reject)
self.upgrade_plan_btn.clicked.connect(self.open_upgrade_link)

def open_upgrade_link(self):
QDesktopServices.openUrl(QUrl("https://www.merginmaps.com/pricing"))
self.accept()
10 changes: 5 additions & 5 deletions Mergin/projects_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from .mergin.merginproject import MerginProject
from .project_status_dialog import ProjectStatusDialog

from .project_limit_hit_dialog import ProjectLimitHitDialog

class MerginProjectsManager(object):
"""Class for managing Mergin Maps projects in QGIS."""
Expand Down Expand Up @@ -96,10 +96,10 @@ def create_project(self, project_name, project_dir, is_public, namespace):
if e.http_error == 409:
msg = f'Project named "{project_name}" already exists in the workspace "{namespace}".\nPlease try renaming the project.'
elif e.server_code == ErrorCode.ProjectsLimitHit.value:
msg = (
"Maximum number of projects reached. Please upgrade your subscription to create new projects.\n"
f"Projects quota: {e.server_response['projects_quota']}"
)
print(e.server_response)
dlg = ProjectLimitHitDialog(e)
dlg.exec()
return False
elif e.server_code == ErrorCode.StorageLimitHit.value:
msg = (
f"{e.detail}\nCurrent limit: {bytes_to_human_size(dlg.exception.server_response['storage_limit'])}"
Expand Down
168 changes: 168 additions & 0 deletions Mergin/ui/ui_project_limit_hit_dialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>278</height>
</rect>
</property>
<property name="windowTitle">
<string>Project limit hit</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>You have reached the maximum limit of active monthly contributors for your subscription.</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Upgrade your subscription or wait until next month
for refresh of slots.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Used</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="planQuota_label">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QProgressBar" name="plan_quota_progress_bar">
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Plan</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="planName_label">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="cancel_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="upgrade_plan_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Upgrade</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

0 comments on commit 7e648b8

Please sign in to comment.