-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vue #95
Merged
Merged
Vue #95
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
949715b
Vue
nickvergessen 7aefbc9
WebPack
nickvergessen 57a0387
Makefile
nickvergessen b59df84
.vue files
nickvergessen 007a291
Update README.md with information
nickvergessen 57eacd2
No dev verion in production
nickvergessen 94d4058
Less dependencies
nickvergessen 33f54af
Commit package-lock.json
nickvergessen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
app_name=notifications | ||
|
||
project_dir=$(CURDIR)/../$(app_name) | ||
build_dir=$(CURDIR)/build | ||
source_dir=$(build_dir)/$(app_name) | ||
sign_dir=$(build_dir)/sign | ||
|
||
all: package | ||
|
||
dev-setup: clean npm-update build-js | ||
|
||
npm-update: | ||
rm -rf node_modules | ||
npm update | ||
|
||
build-js: | ||
npm run dev | ||
|
||
build-js-production: | ||
npm run build | ||
|
||
clean: | ||
rm -rf $(build_dir) | ||
|
||
package: clean build-js-production | ||
mkdir -p $(source_dir) | ||
rsync -a \ | ||
--exclude=/build \ | ||
--exclude=/docs \ | ||
--exclude=/js-src \ | ||
--exclude=/l10n/.tx \ | ||
--exclude=/tests \ | ||
--exclude=/.git \ | ||
--exclude=/.github \ | ||
--exclude=/CONTRIBUTING.md \ | ||
--exclude=/issue_template.md \ | ||
--exclude=/README.md \ | ||
--exclude=/.gitignore \ | ||
--exclude=/.scrutinizer.yml \ | ||
--exclude=/.travis.yml \ | ||
--exclude=/.drone.yml \ | ||
--exclude=/node_modules \ | ||
--exclude=/npm-debug.log \ | ||
--exclude=/package.json \ | ||
--exclude=/package-lock.json \ | ||
--exclude=/Makefile \ | ||
$(project_dir)/ $(source_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
* @copyright (c) 2016 Joas Schilling <coding@schilljs.com> | ||
* @copyright (c) 2015 Tom Needham <tom@owncloud.com> | ||
* | ||
* @author Tom Needham <tom@owncloud.com> | ||
* @author Joas Schilling <coding@schilljs.com> | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
*/ | ||
|
||
/* global OC, OCA, $, _, t, define, console */ | ||
|
||
define(function (require) { | ||
"use strict"; | ||
|
||
return { | ||
|
||
/** @type {number} */ | ||
pollInterval: 30000, // milliseconds | ||
|
||
/** @type {number|null} */ | ||
interval: null, | ||
|
||
/** @type {Vue|null} */ | ||
vm: null, | ||
|
||
/** | ||
* Initialise the app | ||
*/ | ||
initialise: function() { | ||
|
||
// Add to the UI | ||
$('form.searchbox').after($('<div>').attr('id', 'notifications')); | ||
|
||
// Setup Vue | ||
var Vue = require('vue'); | ||
this.vm = new Vue(require('./components/root.vue')); | ||
|
||
// Initial call to the notification endpoint | ||
this._fetch(); | ||
|
||
// Setup the background checker | ||
this.interval = setInterval(this._backgroundFetch.bind(this), this.pollInterval); | ||
}, | ||
|
||
/** | ||
* Performs the AJAX request to retrieve the notifications | ||
*/ | ||
_fetch: function() { | ||
var request = $.ajax({ | ||
url: OC.linkToOCS('apps/notifications/api/v2', 2) + 'notifications', | ||
type: 'GET', | ||
beforeSend: function (request) { | ||
request.setRequestHeader('Accept', 'application/json'); | ||
} | ||
}); | ||
|
||
request.done(function(data, statusText, xhr) { | ||
if (xhr.status === 204) { | ||
// 204 No Content - Intercept when no notifiers are there. | ||
this._shutDownNotifications(); | ||
} else if (!_.isUndefined(data) && !_.isUndefined(data.ocs) && !_.isUndefined(data.ocs.data) && _.isArray(data.ocs.data)) { | ||
this.vm.notifications = data.ocs.data; | ||
} else { | ||
console.debug("data.ocs.data is undefined or not an array"); | ||
} | ||
}.bind(this)); | ||
request.fail(function(xhr) { | ||
if (xhr.status === 503) { | ||
// 503 - Maintenance mode | ||
console.debug('Shutting down notifications: instance is in maintenance mode.'); | ||
} else if (xhr.status === 404) { | ||
// 404 - App disabled | ||
console.debug('Shutting down notifications: app is disabled.'); | ||
} else { | ||
console.error('Shutting down notifications: [' + xhr.status + '] ' + xhr.statusText); | ||
} | ||
|
||
this._shutDownNotifications(); | ||
}.bind(this)); | ||
}, | ||
|
||
_backgroundFetch: function() { | ||
this.vm.backgroundFetching = true; | ||
this._fetch(); | ||
}, | ||
|
||
/** | ||
* The app was disabled or has no notifiers, so we can stop polling | ||
* And hide the UI as well | ||
*/ | ||
_shutDownNotifications: function() { | ||
window.clearInterval(this.interval); | ||
this.vm.shutdown = true; | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<template> | ||
<button class="action-button pull-right" :class="{ primary: primary }" | ||
:data-type="type" :data-href="link" @click="onClickActionButton">{{label}}</button> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "action", | ||
props: [ | ||
'label', | ||
'link', | ||
'type', | ||
'primary' | ||
], | ||
methods: { | ||
onClickActionButton: function () { | ||
$.ajax({ | ||
url: this.link, | ||
type: this.type || 'GET', | ||
success: function () { | ||
this.$parent._$el.fadeOut(OC.menuSpeed); | ||
this.$parent.$emit('remove'); | ||
$('body').trigger(new $.Event('OCA.Notification.Action', { | ||
notification: this.$parent, | ||
action: { | ||
url: this.link, | ||
type: this.type || 'GET' | ||
} | ||
})); | ||
}.bind(this), | ||
error: function () { | ||
OC.Notification.showTemporary(t('notifications', 'Failed to perform action')); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
</script> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you're using an up-to-date version of npm, it will generate a
package-lock.json
. You might want to exclude that too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont have that on npm 5.6.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, maybe it's just generated if you use
npm install --save xxx
or similar https://docs.npmjs.com/files/package-lock.jsonThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm let me add this, so everyone is installing the same stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, it locks down the exact version number, just like composer does with
composer.lock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and it speeds up
npm install
as npm doesn't have to build the dependency graph 👍