Browse Source

Change display of project update day

pull/32/head
Hironsan 6 years ago
parent
commit
1cb09d1c40
5 changed files with 16 additions and 4 deletions
  1. BIN
      app/db.sqlite3
  2. 2
      app/server/serializers.py
  3. 2
      app/server/static/bundle/projects.js
  4. 13
      app/server/static/js/projects.js
  5. 3
      app/server/templates/projects.html

BIN
app/db.sqlite3

2
app/server/serializers.py

@ -22,7 +22,7 @@ class ProjectSerializer(serializers.ModelSerializer):
class Meta:
model = Project
fields = ('id', 'name', 'description', 'guideline', 'users', 'project_type', 'image')
fields = ('id', 'name', 'description', 'guideline', 'users', 'project_type', 'image', 'updated_at')
class ProjectFilteredPrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField):

2
app/server/static/bundle/projects.js

@ -460,7 +460,7 @@ eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn th
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_1__);\n\n\n\naxios__WEBPACK_IMPORTED_MODULE_1___default.a.defaults.xsrfCookieName = 'csrftoken';\naxios__WEBPACK_IMPORTED_MODULE_1___default.a.defaults.xsrfHeaderName = 'X-CSRFToken';\nconst baseUrl = window.location.href.split('/').slice(0, 3).join('/');\n\n\nconst vm = new vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n el: '#projects_root',\n delimiters: ['[[', ']]'],\n data: {\n items: [],\n isActive: false,\n isDelete: false,\n project: null,\n selected: 'All Project',\n },\n\n methods: {\n\n deleteProject() {\n axios__WEBPACK_IMPORTED_MODULE_1___default.a.delete(`${baseUrl}/api/projects/${this.project.id}/`).then((response) => {\n this.isDelete = false;\n const index = this.items.indexOf(this.project);\n this.items.splice(index, 1);\n });\n },\n\n setProject(project) {\n this.project = project;\n this.isDelete = true;\n },\n\n matchType(projectType) {\n if (projectType === 'DocumentClassification') {\n return this.selected === 'Text Classification';\n }\n if (projectType === 'SequenceLabeling') {\n return this.selected === 'Sequence Labeling';\n }\n if (projectType === 'Seq2seq') {\n return this.selected === 'Seq2seq';\n }\n return false;\n },\n },\n\n computed: {\n selectedProjects() {\n const projects = [];\n for (let item of this.items) {\n if ((this.selected === 'All Project') || this.matchType(item.project_type)) {\n projects.push(item);\n }\n }\n return projects;\n },\n },\n\n created() {\n axios__WEBPACK_IMPORTED_MODULE_1___default.a.get(`${baseUrl}/api/projects`).then((response) => {\n this.items = response.data;\n });\n },\n});\n\n\n//# sourceURL=webpack:///./static/js/projects.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_1__);\n\n\n\naxios__WEBPACK_IMPORTED_MODULE_1___default.a.defaults.xsrfCookieName = 'csrftoken';\naxios__WEBPACK_IMPORTED_MODULE_1___default.a.defaults.xsrfHeaderName = 'X-CSRFToken';\nconst baseUrl = window.location.href.split('/').slice(0, 3).join('/');\n\n\nconst vm = new vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n el: '#projects_root',\n delimiters: ['[[', ']]'],\n data: {\n items: [],\n isActive: false,\n isDelete: false,\n project: null,\n selected: 'All Project',\n },\n\n methods: {\n\n deleteProject() {\n axios__WEBPACK_IMPORTED_MODULE_1___default.a.delete(`${baseUrl}/api/projects/${this.project.id}/`).then((response) => {\n this.isDelete = false;\n const index = this.items.indexOf(this.project);\n this.items.splice(index, 1);\n });\n },\n\n setProject(project) {\n this.project = project;\n this.isDelete = true;\n },\n\n matchType(projectType) {\n if (projectType === 'DocumentClassification') {\n return this.selected === 'Text Classification';\n }\n if (projectType === 'SequenceLabeling') {\n return this.selected === 'Sequence Labeling';\n }\n if (projectType === 'Seq2seq') {\n return this.selected === 'Seq2seq';\n }\n return false;\n },\n\n getDaysAgo(dateStr) {\n const updatedAt = new Date(dateStr);\n const currentTm = new Date();\n\n // difference between days(ms)\n const msDiff = currentTm.getTime() - updatedAt.getTime();\n\n // convert daysDiff(ms) to daysDiff(day)\n const daysDiff = Math.floor(msDiff / (1000 * 60 * 60 * 24));\n\n return daysDiff;\n },\n },\n\n computed: {\n selectedProjects() {\n const projects = [];\n for (let item of this.items) {\n if ((this.selected === 'All Project') || this.matchType(item.project_type)) {\n projects.push(item);\n }\n }\n return projects;\n },\n },\n\n created() {\n axios__WEBPACK_IMPORTED_MODULE_1___default.a.get(`${baseUrl}/api/projects`).then((response) => {\n this.items = response.data;\n });\n },\n});\n\n\n//# sourceURL=webpack:///./static/js/projects.js?");
/***/ })

13
app/server/static/js/projects.js

@ -44,6 +44,19 @@ const vm = new Vue({
}
return false;
},
getDaysAgo(dateStr) {
const updatedAt = new Date(dateStr);
const currentTm = new Date();
// difference between days(ms)
const msDiff = currentTm.getTime() - updatedAt.getTime();
// convert daysDiff(ms) to daysDiff(day)
const daysDiff = Math.floor(msDiff / (1000 * 60 * 60 * 24));
return daysDiff;
},
},
computed: {

3
app/server/templates/projects.html

@ -117,8 +117,7 @@
[[ project.description ]]
</div>
<div class="dataset-item__main-info">
<span class="dataset-item__main-update">updated <span title="Sun Nov 04 2018 07:35:07 GMT+0900 (日本標準時)">11
days ago</span></span></div>
<span class="dataset-item__main-update">updated <span>[[ getDaysAgo(project.updated_at) ]] days ago</span></span></div>
</div>
</td>
<td class="is-vertical"><span class="tag is-normal">[[ project.project_type ]]</span></td>

Loading…
Cancel
Save