Skip to content

Commit

Permalink
feat: resource manager
Browse files Browse the repository at this point in the history
  • Loading branch information
YiqingQu committed Oct 14, 2023
1 parent e3beb28 commit 0aae5fe
Show file tree
Hide file tree
Showing 30 changed files with 643 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ dmypy.json
.DS_Store
.idea

/data/files/
Binary file added data/files/idata_files/AT15-51.dbf
Binary file not shown.
Binary file added data/files/idata_files/AT15-51.shp
Binary file not shown.
Binary file added data/files/idata_files/AT15-51.shx
Binary file not shown.
Binary file added data/files/idata_files/Riv2.sbn
Binary file not shown.
Binary file added data/files/idata_files/Riv2.sbx
Binary file not shown.
Binary file added data/files/idata_files/Riv2.shp
Binary file not shown.
Binary file added data/files/idata_files/Riv2.shx
Binary file not shown.
Binary file added data/files/idata_files/maize_YieldPerHectare.tif
Binary file not shown.
Binary file added data/files/idata_files/wrfinput_d0x.nc
Binary file not shown.
13 changes: 8 additions & 5 deletions myportal/apps.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import os

from django.apps import AppConfig


# from django.contrib.sites.models import Site


class MyportalConfig(AppConfig):
name = 'myportal'

def ready(self):
print("myportal is ready")
# site = Site.objects.get(id=1)
print("myportal is ready!")

# site = Site.objects.first()
# host = os.environ.get("SITE_HOST", default="localhost:8000")
#
# site.domain = host
# site.name = host
# #
# # site.domain = host
# # site.name = host
# site.save()
6 changes: 6 additions & 0 deletions myportal/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import os
from pathlib import Path

GLOBUS_INDEX_NAME = "schema-org-index"

RMQ_NAME = "geoedf-all"
Expand All @@ -6,3 +9,6 @@
# RMQ_HOST = 'some-rabbit'
RMQ_USER = 'guest'
RMQ_PASS = 'guest'

BASE_DIR = Path(__file__).resolve().parent.parent
FILES_ROOT = os.path.join(BASE_DIR, 'data', 'files')
21 changes: 21 additions & 0 deletions myportal/migrations/0005_fileinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.16 on 2023-09-24 23:29

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('myportal', '0004_auto_20230506_2245'),
]

operations = [
migrations.CreateModel(
name='FileInfo',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('path', models.URLField()),
('info', models.CharField(max_length=255)),
],
),
]
8 changes: 8 additions & 0 deletions myportal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ def __str__(self):
return f"Resource {self.uuid}: " \
f"resource_type = {self.resource_type}, filepath = {self.path}, task_id = {self.task_id}, " \
f"created_time = {self.created_time}"


class FileInfo(models.Model):
path = models.URLField()
info = models.CharField(max_length=255)

def __str__(self):
return self.path
17 changes: 10 additions & 7 deletions myportal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import logging
import os
from pathlib import Path
from django.template import context_processors
from myportal import fields
Expand Down Expand Up @@ -57,7 +58,7 @@
# LOGIN_URL = '/login/globus'
ACCOUNT_LOGOUT_REDIRECT_URL = '/accounts/login/'
LOGIN_REDIRECT_URL = '/accounts/profile/'
ACCOUNT_DEFAULT_HTTP_PROTOCOL='https'
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'

# This dictates which scopes will be requested on each user login
SOCIAL_AUTH_GLOBUS_SCOPE = [
Expand Down Expand Up @@ -179,16 +180,16 @@
ACCOUNT_EMAIL_VERIFICATION = 'none'

SWAGGER_SETTINGS = {
'SECURITY_DEFINITIONS': {
'Basic': {
'SECURITY_DEFINITIONS': {
'Basic': {
'type': 'basic'
},
'Bearer': {
},
'Bearer': {
'type': 'apiKey',
'name': 'Authorization',
'in': 'header'
}
}
}
}
}

ROOT_URLCONF = 'myportal.urls'
Expand Down Expand Up @@ -258,6 +259,8 @@
'static/',
]

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

Expand Down
3 changes: 3 additions & 0 deletions myportal/static/css/base.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.navbar-brand {
font-family: Helvetica, sans-serif;
}
22 changes: 22 additions & 0 deletions myportal/static/css/file-manager.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ul li {
list-style-type: none;
}

.dot-separator {
height: 2px;
width: 2px;
background: #000;
border-radius: 50%;
}

.actions span {
cursor: pointer;
width: 1.5em;
display: flex;
justify-content: center;
align-items: center;
}

.modal {
z-index: 99999 !important;
}
22 changes: 17 additions & 5 deletions myportal/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

{# CSS files #}
<link rel="stylesheet" type="text/css" href="{% static 'bootstrap/css/bootstrap.min.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}"/>

{# Custom Fonts #}
<script type="text/javascript" src="{% static 'js/fontawesome-all.min.js' %}"></script>
Expand All @@ -35,11 +36,10 @@
success: function (data) {
console.log(data.domain);
var existingHref = loginLink.attr('href');
var domain = data.domain; // Assuming the API response contains the new URL
// Update the href attribute of the login link
var newHref = existingHref.replace('domain', domain);
if (domain === 'localhost:8000'){
newHref = existingHref.replace('https', 'http');
var newHref = existingHref.replace('domain', data.domain);
if (data.domain === 'localhost:8000') {
newHref = newHref.replace('https', 'http');
console.log('equal');
}
loginLink.attr('href', newHref);
},
Expand All @@ -66,6 +66,15 @@
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto"></ul>
<ul class="navbar-nav my-lg-0">

{% if request.user.is_authenticated %}
<li>
<a id="file-manage" class="nav-link"
href="{% url 'file-manage' %}">My Resources</a>
</li>
{% endif %}
</ul>
<ul class="navbar-nav my-lg-0">

{% if request.user.is_authenticated %}
Expand All @@ -83,6 +92,7 @@
</li>
{% endif %}
</ul>

</div>
</div>
</nav>
Expand All @@ -97,5 +107,7 @@
<script type="text/javascript" src="{% static 'js/jquery.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/popper.min.js' %}"></script>
<script type="text/javascript" src="{% static 'bootstrap/js/bootstrap.min.js' %}"></script>
{% block extrascripts %}
{% endblock %}
</body>
</html>
1 change: 1 addition & 0 deletions myportal/templates/error.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
{% block body %}
<h1 id="error-title">An Error Occurred</h1>
<p id="error-content">Sorry, an error occurred while processing your request. Please try again later.</p>
<p id="error-content">{{ error.msg }}</p>
{% endblock %}
Loading

0 comments on commit 0aae5fe

Please sign in to comment.