mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-31 12:52:13 +00:00
DSS-5869 Controllers for Flows page and subpage feature
This commit is contained in:
parent
53cdc2d0be
commit
5cd31fd9ee
66
wherehows-web/app/controllers/flows.js
Normal file
66
wherehows-web/app/controllers/flows.js
Normal file
@ -0,0 +1,66 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
currentName: null,
|
||||
urn: null,
|
||||
queryParams: null,
|
||||
previousPage: function () {
|
||||
var model = this.get("model");
|
||||
if (model && model.data && model.data.page) {
|
||||
var currentPage = model.data.page;
|
||||
if (currentPage <= 1) {
|
||||
return currentPage;
|
||||
}
|
||||
else {
|
||||
return currentPage - 1;
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}.property('model.data.page'),
|
||||
nextPage: function () {
|
||||
var model = this.get("model");
|
||||
if (model && model.data && model.data.page) {
|
||||
var currentPage = model.data.page;
|
||||
var totalPages = model.data.totalPages;
|
||||
if (currentPage >= totalPages) {
|
||||
return totalPages;
|
||||
}
|
||||
else {
|
||||
return currentPage + 1;
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}.property('model.data.page'),
|
||||
first: function () {
|
||||
var model = this.get("model");
|
||||
if (model && model.data && model.data.page) {
|
||||
var currentPage = model.data.page;
|
||||
if (currentPage <= 1) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}.property('model.data.page'),
|
||||
last: function () {
|
||||
var model = this.get("model");
|
||||
if (model && model.data && model.data.page) {
|
||||
var currentPage = model.data.page;
|
||||
var totalPages = model.data.totalPages;
|
||||
if (currentPage >= totalPages) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}.property('model.data.page')
|
||||
});
|
124
wherehows-web/app/controllers/flows/flowsname/flow/pagedflow.js
Normal file
124
wherehows-web/app/controllers/flows/flowsname/flow/pagedflow.js
Normal file
@ -0,0 +1,124 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
flowname: 'flowName',
|
||||
queryParams: ['urn'],
|
||||
urn: null,
|
||||
lineageUrl: null,
|
||||
previousPage: function () {
|
||||
var model = this.get("model");
|
||||
if (model && model.data && model.data.page) {
|
||||
var currentPage = model.data.page;
|
||||
if (currentPage <= 1) {
|
||||
return currentPage;
|
||||
}
|
||||
else {
|
||||
return currentPage - 1;
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}.property('model.data.page'),
|
||||
nextPage: function () {
|
||||
var model = this.get("model");
|
||||
if (model && model.data && model.data.page) {
|
||||
var currentPage = model.data.page;
|
||||
var totalPages = model.data.totalPages;
|
||||
if (currentPage >= totalPages) {
|
||||
return totalPages;
|
||||
}
|
||||
else {
|
||||
return currentPage + 1;
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}.property('model.data.page'),
|
||||
first: function () {
|
||||
var model = this.get("model");
|
||||
if (model && model.data && model.data.page) {
|
||||
var currentPage = model.data.page;
|
||||
if (currentPage <= 1) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}.property('model.data.page'),
|
||||
last: function () {
|
||||
var model = this.get("model");
|
||||
if (model && model.data && model.data.page) {
|
||||
var currentPage = model.data.page;
|
||||
var totalPages = model.data.totalPages;
|
||||
if (currentPage >= totalPages) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}.property('model.data.page'),
|
||||
getUrnWatchId: function (urn) {
|
||||
var controller = this;
|
||||
var watcherEndpoint = "/api/v1/urn/watch?urn=" + urn
|
||||
$.get(watcherEndpoint, function (data) {
|
||||
if (data.id && data.id !== 0) {
|
||||
controller.set('urnWatched', true)
|
||||
controller.set('urnWatchedId', data.id)
|
||||
} else {
|
||||
controller.set('urnWatched', false)
|
||||
controller.set('urnWatchedId', 0)
|
||||
}
|
||||
})
|
||||
},
|
||||
actions: {
|
||||
watchUrn: function (urn) {
|
||||
var _this = this
|
||||
var url = "/api/v1/urn/watch"
|
||||
var token = $("#csrfToken").val().replace('/', '')
|
||||
if (!this.get('urnWatched')) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'POST',
|
||||
header: {
|
||||
'Csrf-Token': token
|
||||
},
|
||||
data: {
|
||||
csrfToken: token,
|
||||
urn: urn,
|
||||
type: 'urn',
|
||||
'notification_type': 'WEEKLY'
|
||||
}
|
||||
}).done(function (data, txt, xhr) {
|
||||
Notify.toast('You are now watching: ' + urn, 'Success', 'success')
|
||||
_this.set('urnWatched', true)
|
||||
_this.getUrnWatchId(urn);
|
||||
}).fail(function (xhr, txt, error) {
|
||||
Notify.toast('URN could not be watched', 'Error Watching Urn', 'error')
|
||||
})
|
||||
} else {
|
||||
url += ("/" + this.get('urnWatchedId'))
|
||||
url += "?csrfToken=" + token
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'DELETE',
|
||||
header: {
|
||||
'Csrf-Token': token
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (data, txt, xhr) {
|
||||
_this.set('urnWatched', false)
|
||||
_this.set('urnWatchedId', 0)
|
||||
}).fail(function (xhr, txt, error) {
|
||||
Notify.toast('Could not unwatch urn', 'Error', 'error')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
queryParams: ['urn'],
|
||||
urn: null
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user